예제 #1
0
 def __init__(self, parent=None):
     super(ValveButton, self).__init__(parent)
     self.setCheckable(True)
     self.setAttribute(Qt.WA_NoSystemBackground)
     self._rendererOn = QtSvg.QSvgRenderer(self)
     self._rendererOff = QtSvg.QSvgRenderer(self)
     self._rendererOn.load(":/img/valve_green.svg")
     self._rendererOff.load(":/img/valve_red.svg")
예제 #2
0
    def on_applyButton_clicked(self):
        """ Apply settings for a node
        """

        current = self.treeWidgetSymbols.currentItem()
        if current:
            name = current.text(0)
            normal_renderer = QtSvg.QSvgRenderer(':/symbols/' + name +
                                                 '.normal.svg')
            select_renderer = QtSvg.QSvgRenderer(':/symbols/' + name +
                                                 '.selected.svg')
            for item in self.items:
                item.setRenderers(normal_renderer, select_renderer)
                item.default_symbol = False
                item.type = name
예제 #3
0
def svg2jpg(svgString):
    svgMatch = re.match(
        '.*viewBox.*viewBox=\"[ \t]*([0-9]+\.?[0-9]*)[ \t]+([0-9]+\.?[0-9]*)[ \t]+([0-9]+\.?[0-9]*)[ \t]+([0-9]+\.?[0-9]*)[ \t]*\".*$',
        svgString, re.DOTALL)
    if svgMatch:
        svgWidth = float(svgMatch.group(3))
        svgHeight = float(svgMatch.group(4))
    else:
        print 'makeSvgs: no match for width/height.'
        exit()

    #svgWidth = 200
    #svgHeight = 166
    #svgWidth = 100
    #svgHeight = 83

    #rect = QtCore.QRect(0,0,svgWidth,svgHeight)

    svgSize = QtCore.QSize(svgWidth, svgHeight)
    myXmlStreamReader = QtCore.QXmlStreamReader(svgString)
    myRenderer = QtSvg.QSvgRenderer(myXmlStreamReader)

    myImage = QtGui.QImage(svgSize, QtGui.QImage.Format_ARGB32)
    myTempPainter = QtGui.QPainter(myImage)
    myTempPainter.fillRect(myImage.rect(), QtCore.Qt.white)
    myRenderer.render(myTempPainter)
    myTempPainter.end()

    buf = QtCore.QBuffer()
    buf.open(QtCore.QIODevice.ReadWrite)
    myImage.save(buf, "JPG")

    buf.seek(0)
    jpg = buf.readAll()
    return jpg
 def reset(self):
     self.posicion2xy()
     bm = self.bloqueDatos
     self.pixmap = QtSvg.QSvgRenderer(QtCore.QByteArray(bm.xml))
     self.setOpacity(bm.opacidad)
     self.setZValue(bm.posicion.orden)
     self.update()
예제 #5
0
파일: Qt.py 프로젝트: msnoigrs/svgplotlib
    def SaveFile(self):
        dlg = QtGui.QFileDialog.getSaveFileName
        filename = dlg(self, "Save", '',
                       "svg file ( *.svg ) ;; image file ( *.png )")

        if filename:
            filename = unicode(filename)

            if filename.endswith('.svg'):
                fh = open(filename, 'wb')
                self.svg.write(fh)
                fh.close()
            else:
                fh = io.BytesIO()
                self.svg.write(fh)
                content = QtCore.QByteArray(fh.getvalue())

                image = QtGui.QImage(self.width, self.height,
                                     QtGui.QImage.Format_ARGB32_Premultiplied)

                painter = QtGui.QPainter(image)
                painter.setViewport(0, 0, self.width, self.height)
                painter.eraseRect(0, 0, self.width, self.height)
                render = QtSvg.QSvgRenderer(content)
                render.render(painter)
                painter.end()

                image.save(filename)
예제 #6
0
    def intrinsicSize(self, doc, posInDocument, format):
        renderer = QtSvg.QSvgRenderer(format.property(Window.SvgData))
        size = renderer.defaultSize()

        if size.height() > 25:
            size *= 25.0 / size.height()

        return QtCore.QSizeF(size)
예제 #7
0
    def __init__(self, parent):
        QtGui.QGraphicsView.__init__(self, parent)

        self.renderer = QtSvg.QSvgRenderer('electrodes.svg')
        # self.pixmap = QtGui.QPixmap(900,900)
        #        self.pixmap.fill(QtCore.Qt.transparent)
        self.scene = QtGui.QGraphicsScene()
        self.setScene(self.scene)
예제 #8
0
파일: SVGView.py 프로젝트: dio4/vista_1
    def print_(self, docName, printer):
        size = self.getPageRectSizeF()
        if size:
            printer.setPaperSize(size, 0)

#        if size:
#            if printer.outputFileName():
#                printer.setPaperSize(size,0)
#            else:
#                w = size.width()
#                h = size.height()
#                if w < h:
#                    size.transpose()
#                    printer.setOrientation(QtGui.QPrinter.Landscape)
#                else:
#                    printer.setOrientation(QtGui.QPrinter.Portrait)
#                printer.setPaperSize(size,0)
#        else:
#            printer.setPaperSize(QtGui.QPrinter.A4)
#            printer.setOrientation(QtGui.QPrinter.Portrait)

        printer.setFullPage(True)
        printer.setPageMargins(0, 0, 0, 0, 0)
        printer.setCreator('vista-med')
        printer.setDocName(docName)
        printer.setFontEmbeddingEnabled(True)
        painter = QtGui.QPainter()

        renderer = QtSvg.QSvgRenderer()
        painter.begin(printer)
        #        if printer.orientation() == QtGui.QPrinter.Landscape:
        #            painterRect = painter.viewport()
        #            painter.translate(0, painterRect.height())
        #            painter.rotate(270)

        pageIdList = self.findPages()
        if pageIdList:
            fromPage = printer.fromPage()
            toPage = printer.fromPage()
            if fromPage and toPage:
                pageIdList = pageIdList[fromPage - 1:toPage]
            if printer.pageOrder == QtGui.QPrinter.LastPageFirst:
                pageIdList.reverse()
            firstPage = True
            for pageId in pageIdList:
                self.hideAllPagesExceptOne(pageId)
                renderer.load(self.toByteArray(0))
                if not firstPage:
                    printer.newPage()
                renderer.render(painter)
                firstPage = False
        else:
            renderer.load(self.toByteArray())
            renderer.render(painter)


#        del renderer
        painter.end()
예제 #9
0
    def __init__(self, view, data):
        QtSvg.QGraphicsSvgItem.__init__(self)
        # The renderer must be preserved for the lifetime of the image
        self.renderer = QtSvg.QSvgRenderer(QtCore.QByteArray(data))

        #print "IH", self.renderer.defaultSize().height()

        self.setSharedRenderer(self.renderer)
        view.gScene.addItem(self)
        self.uscale = 1.0
예제 #10
0
def svg2pm(svg, tam):
    pm = QtGui.QPixmap(tam, tam)
    pm.fill(QtCore.Qt.transparent)
    qb = QtCore.QByteArray(svg)
    render = QtSvg.QSvgRenderer(qb)
    painter = QtGui.QPainter()
    painter.begin(pm)
    render.render(painter)
    painter.end()
    return pm
예제 #11
0
    def intrinsicSize(self, doc, posInDocument, format):
        renderer = QtSvg.QSvgRenderer(format.property(self.SvgData))
        view_box = renderer.viewBox()
        size = QtCore.QSize(view_box.width(), view_box.height())
        side = max(doc.pageSize().height(), doc.pageSize().width())

        ratio = side / max(size.width(), size.height())

        size *= ratio / (3 + 1e-9)

        return QtCore.QSizeF(size)
예제 #12
0
    def draw_svg(self, painter):
        if not self.is_rightside:
            painter.scale(-1, 1)
            offset = 2 * self.rect.topLeft().x() + self.rect.width()
            painter.translate(-offset, 0)

        if self.svg:
            QtSvg.QSvgRenderer(self.svg).render(painter, self.rect_f)
        else:
            painter.setOpacity(self.opacity)
            self.svg_renderer.render(painter, self.rect_f)
예제 #13
0
    def drawShape(self, painter, rect):
        """Draw image."""
        s = self.settings
        logging.debug('drawShape')
        # draw border and fill
        painter.drawRect(rect)

        # check to see whether image needs reloading
        image = None
        if s.embeddedDataset != s.dataset or s.embeddedTarget != s.target:
            self.actionEmbed()
            image = self.cacheimage

        # or needs recreating from embedded data
        elif s.embeddedImageData != '':
            if s.embeddedImageData is not self.cacheembeddata:
                self.updateCachedEmbedded()
                self.updateCachedImage()
            image = self.cacheimage

        # if no image, then use default image
        if (not image or image.isNull() or image.width() == 0
                or image.height() == 0):
            # empty image
            r = QtSvg.QSvgRenderer()

            r.render(painter, rect)

        else:
            # image rectangle
            irect = QtCore.QRectF(image.rect())

            # preserve aspect ratio
            if s.aspect:
                xr = rect.width() / irect.width()
                yr = rect.height() / irect.height()

                if xr > yr:
                    rect = QtCore.QRectF(
                        rect.left() +
                        (rect.width() - irect.width() * yr) * 0.5, rect.top(),
                        irect.width() * yr, rect.height())
                else:
                    rect = QtCore.QRectF(
                        rect.left(),
                        rect.top() +
                        (rect.height() - irect.height() * xr) * 0.5,
                        rect.width(),
                        irect.height() * xr)

            # finally draw image
            rect.setWidth(rect.width() - 1)
            rect.setLeft(rect.left() + 1)
            painter.drawImage(rect, image, irect)
예제 #14
0
def generaPM(piezas):
    dicPM["V"] = Iconos.pmComentario()
    dicPM["R"] = Iconos.pmApertura()
    dicPM["M"] = Iconos.pmComentarioMas()
    dicPM["S"] = Iconos.pmAperturaComentario()
    for k in "KQRNBkqrnb":
        dicPZ[k] = piezas.render(k)

    carpNAGs = "./IntFiles/NAGs"
    for f in os.listdir(carpNAGs):
        if f.endswith(".svg") and f.startswith("$") and len(f) > 5:
            nag = f[1:-4]
            if nag.isdigit():
                fsvg = carpNAGs + "/" + f
                dicNG[nag] = QtSvg.QSvgRenderer(fsvg)
예제 #15
0
    def __init__(self):
        super(MPLPlot, self).__init__()

        figure = Figure()
        axes = figure.gca()
        axes.set_title("Use the mouse wheel to zoom")
        axes.plot(np.random.rand(5))
        canvas = FigureCanvas(figure)
        canvas.setGeometry(0, 0, 500, 500)

        imgdata = StringIO.StringIO()
        figure.savefig(imgdata, format='svg')
        imgdata.seek(0)
        xmlreader = QtCore.QXmlStreamReader(imgdata.getvalue())
        self.renderer = QtSvg.QSvgRenderer(xmlreader)
예제 #16
0
 def icono(self, pieza, nombre):
     fich = os.path.join(
         "Pieces", nombre,
         "%s%s.svg" % ("w" if pieza.isupper() else "b", pieza.lower()))
     f = codecs.open(fich, "r", 'utf-8', 'ignore')
     qb = QtCore.QByteArray(f.read())
     f.close()
     pm = QtGui.QPixmap(32, 32)
     pm.fill(QtCore.Qt.transparent)
     render = QtSvg.QSvgRenderer(qb)
     painter = QtGui.QPainter()
     painter.begin(pm)
     render.render(painter)
     painter.end()
     icon = QtGui.QIcon(pm)
     return icon
예제 #17
0
 def saveAllPNG(self, nombre, px):
     for pieza in "pnbrqk":
         for color in "wb":
             fich = os.path.join("Pieces", nombre,
                                 "%s%s.svg" % (color, pieza))
             f = codecs.open(fich, "r", 'utf-8', 'ignore')
             qb = QtCore.QByteArray(f.read())
             f.close()
             pm = QtGui.QPixmap(px, px)
             pm.fill(QtCore.Qt.transparent)
             render = QtSvg.QSvgRenderer(qb)
             painter = QtGui.QPainter()
             painter.begin(pm)
             render.render(painter)
             painter.end()
             pm.save("IntFiles/Figs/%s%s.png" % (color, pieza), "PNG")
예제 #18
0
    def __init__(self, tooth_id, model):
        teeth.ChartTooth.__init__(self, tooth_id, model)

        #: a boolean so that it's clear this is a ChartRoot,
        #: not the parent class ChartTooth
        self.is_root = True

        #: this variable determines the opacity of any painting
        self.opacity = 0.2

        shortname = self.short_name
        if not self.is_rightside:
            shortname = "%s%s%s" % (shortname[0], "r", shortname[2:])

        #: a reference to a QtSvg.QSvgRenderer with the correct svg
        self.svg_renderer = QtSvg.QSvgRenderer(":teeth/%s.svg" % shortname)
예제 #19
0
    def getrend(self, filepath=None):
        '''return a handle to the shared SVG renderer
            for the given svg file.

        If no filepath is given, return the renderer for
            the default svg file.

        '''

        from PyQt4 import QtCore, QtSvg

        if filepath is None:
            datadir = 'data'
            filename = 'robot.svg'
            filepath = os.path.join(datadir, 'images', filename)
        fp = QtCore.QString(filepath)
        rend = QtSvg.QSvgRenderer(fp, self.app)
        return rend
예제 #20
0
    def __init__(self, escena, bloqueMarker, rutinaPulsada=None, siEditando=False):
        super(MarkerSC, self).__init__(escena, bloqueMarker)

        self.rutinaPulsada = rutinaPulsada
        self.rutinaPulsadaCarga = None

        self.distBordes = 0.20 * bloqueMarker.anchoCasilla

        self.pixmap = QtSvg.QSvgRenderer(QtCore.QByteArray(bloqueMarker.xml))

        self.posicion2xy()

        self.siMove = False
        self.tpSize = None

        self.siEditando = siEditando

        self.siRecuadro = False
        if siEditando:
            self.setAcceptsHoverEvents(True)
예제 #21
0
    def clear_board(self):
        """Clear and prepare board for animation"""

        scene = self.scene()
        scene.clear()
        self.resetTransform()

        self.xml_stream_reader = QtCore.QXmlStreamReader()
        if self.frame_template:
            self.xml_stream_reader = QtCore.QXmlStreamReader(
                self.frame_template)

        self.svg_renderer = QtSvg.QSvgRenderer(self.xml_stream_reader)
        self.svg_item = QtSvg.QGraphicsSvgItem()
        self.svg_item.setSharedRenderer(self.svg_renderer)
        self.svg_item.setFlags(QtGui.QGraphicsItem.ItemClipsToShape)
        self.svg_item.setCacheMode(QtGui.QGraphicsItem.NoCache)
        self.svg_item.setZValue(0)

        scene.addItem(self.svg_item)

        scene.setSceneRect(self.svg_item.boundingRect().adjusted(
            -10, -10, 10, 10))
예제 #22
0
                def __init__(self,
                             image_filename,
                             width=0,
                             heigth=0,
                             parent=None):
                    QtGui.QWidget.__init__(self, parent)

                    self.setWindowTitle('Conan Graph Viewer')
                    self.resize(width, height)

                    if image_filename[-3:] == 'svg':
                        svg_renderer = QtSvg.QSvgRenderer(image_filename)

                        if svg_renderer.isValid():
                            self.pixmap = QtGui.QPixmap(width, height)
                            painter = QtGui.QPainter(self.pixmap)
                            svg_renderer.render(painter)
                        else:
                            self.statusBar().showMessage('Svg invalid')

                    else:
                        self.pixmap = QtGui.QPixmap(image_filename)

                    self.label = QtGui.QLabel(self)
                    self.label.setPixmap(self.pixmap)
                    self.setCentralWidget(self.label)

                    self.exit = QtGui.QAction(
                        QtGui.QIcon(
                            '/usr/share/icons/oxygen/22x22/actions/application-exit.png'
                        ), 'Exit', self)
                    self.exit.setShortcut('Ctrl+Q')
                    self.connect(self.exit, QtCore.SIGNAL('triggered()'),
                                 QtCore.SLOT('close()'))

                    self.toolbar = self.addToolBar('Main')
                    self.toolbar.addAction(self.exit)
예제 #23
0
def svg_to_image(string, size=None):
    """ Convert a SVG document to a QImage.

    Parameters:
    -----------
    string : str
        A Python string or QString containing a SVG document.

    size : QSize, optional
        The size of the image that is produced. If not specified, the SVG
        document's default size is used.
    
    Raises:
    -------
    ValueError
        If an invalid SVG string is provided.

    Returns:
    --------
    A QImage of format QImage.Format_ARGB32.
    """
    if isinstance(string, basestring):
        bytes = QtCore.QByteArray.fromRawData(string)  # shallow copy
    else:
        bytes = string.toAscii()

    renderer = QtSvg.QSvgRenderer(bytes)
    if not renderer.isValid():
        raise ValueError('Invalid SVG data.')

    if size is None:
        size = renderer.defaultSize()
    image = QtGui.QImage(size, QtGui.QImage.Format_ARGB32)
    painter = QtGui.QPainter(image)
    renderer.render(painter)
    return image
예제 #24
0
파일: test.py 프로젝트: jgaztelu/pyVhdl2Sch
    def draw_sch_svg(
            self
    ):  #Ne fonctionne pas car la lib QtSvg ne supporte que TinySVG !
        self.options.format = "svg"
        self.options.filename = "%s." % self.reader.entity.name + "%s" % self.options.format
        print self.options.filename
        self.drawer = PdfDrawer(
            "%s." % self.reader.entity.name + "%s" % self.options.format,
            self.reader.entity, self.options)
        del self.drawer
        # self.ui.graphicsView.set
        w_vue, h_vue = self.ui.graphicsView.width(
        ), self.ui.graphicsView.height()

        # renderer = QtSvg.QSvgRenderer(QtCore.QString("InputGate.svg"))
        renderer = QtSvg.QSvgRenderer(QtCore.QString(self.options.filename))
        if not renderer.isValid():
            raise ValueError('Invalid SVG data.')

        size = renderer.defaultSize()
        image = QtGui.QImage(size, QtGui.QImage.Format_ARGB32)
        painter = QtGui.QPainter(image)
        renderer.render(painter)

        self.current_image = image

        self.fondPlan = QtGui.QPixmap.fromImage(
            self.current_image.scaled(w_vue, h_vue, QtCore.Qt.KeepAspectRatio,
                                      QtCore.Qt.SmoothTransformation))

        w_pix, h_pix = self.fondPlan.width(), self.fondPlan.height()
        self.scene = QtGui.QGraphicsScene()
        self.scene.setSceneRect(0, 0, w_pix, h_pix)
        self.scene.addPixmap(self.fondPlan)

        self.ui.graphicsView.setScene(self.scene)
예제 #25
0
    def load(self, images, positionedImages={}):
        self._scene.clear()
        self._pixmaps = {}

        from PyQt4 import QtSvg
        standardPixmapsvg = QtSvg.QSvgRenderer(self)
        standardPixmapsvg.setViewBox(
            QtCore.QRect(0, 0, self._width, self._height))
        standardPixmapsvg.load(
            "/usr/share/icons/gnome-human/scalable/status/image-loading.svg")
        self.standardPixmap = QtGui.QPixmap(self._width, self._height)

        painter = QtGui.QPainter(self.standardPixmap)
        painter.fillRect(
            QtCore.QRect(0, 0, self._width, self._height),
            QtGui.QBrush(self.palette().color(self.backgroundRole())))
        standardPixmapsvg.render(painter)

        imagesToLoad = images
        if positionedImages:
            imagesToLoad = positionedImages.keys()

        maxX = maxY = minX = minY = 0

        total = len(imagesToLoad)
        current = 0
        row = 0
        for path in images:
            dirname = os.path.dirname(path)
            basename = os.path.basename(path)
            if os.path.isdir(path) or os.path.basename(path).startswith('.'):
                continue

            cachePath = os.path.join(dirname, ".thumbnails/" + basename)
            if os.path.exists(
                    cachePath) and os.stat(cachePath).st_mtime > os.stat(path):
                print 'cache hit'
                imagePath = cachePath

            current += 1
            item = QdGraphicsPixmapItem(
                path, QtCore.QSize(self._width, self._height))
            if positionedImages and path in positionedImages:
                x, y = positionedImages[path]
            else:
                modresult = current % self.imagesPerRow()
                y = self._height * row
                padding = 5
                if modresult == 0:
                    row += 1
                    x = padding
                else:
                    x = padding + modresult * (self._width + padding)

            minX = min(minX, x)
            minY = min(minY, y)
            maxX = max(maxX, x)
            maxY = max(maxY, y)

            item.setPos(x, y)
            item.setPixmap(self.standardPixmap)

            self._pixmaps[path] = item
            self._scene.addItem(item)

        self._progressTotal = current
        self._progressCurrent = 0

        paths = self._pixmaps.keys()
        paths.sort()

        # load in background thread(s)
        self._loader.load(paths)
        self.setScene(self._scene)
예제 #26
0
 def drawCustomWidget(self, painter):
     renderer = QtSvg.QSvgRenderer()
     renderer.load(self.colors[self.color])
     renderer.render(painter)
예제 #27
0
    def initUI(self):
        namesBox = gui.widgetBox(self.controlArea, "Names")

        gui.lineEdit(namesBox,
                     self,
                     "attr1",
                     "Variable X ",
                     controlWidth=80,
                     orientation="horizontal",
                     enterPlaceholder=True,
                     callback=self.commitIf)
        gui.lineEdit(namesBox,
                     self,
                     "attr2",
                     "Variable Y ",
                     controlWidth=80,
                     orientation="horizontal",
                     enterPlaceholder=True,
                     callback=self.commitIf)
        gui.separator(namesBox)

        gui.widgetLabel(namesBox, "Class labels")
        self.classValuesView = listView = QtGui.QListView()
        listView.setSelectionMode(QtGui.QListView.SingleSelection)
        listView.setSizePolicy(QtGui.QSizePolicy.Ignored,
                               QtGui.QSizePolicy.Maximum)
        listView.setModel(self.classValuesModel)
        listView.selectionModel().select(
            self.classValuesModel.index(0),
            QtGui.QItemSelectionModel.ClearAndSelect)
        listView.setFixedHeight(80)
        listView.clicked.connect(self.updateCursor)
        namesBox.layout().addWidget(listView)

        addClassLabel = QtGui.QAction("+", self)
        addClassLabel.pyqtConfigure(toolTip="Add class label")
        addClassLabel.triggered.connect(self.addNewClassLabel)
        self.removeClassLabel = QtGui.QAction("-", self)
        self.removeClassLabel.pyqtConfigure(toolTip="Remove class label")
        self.removeClassLabel.triggered.connect(self.removeSelectedClassLabel)
        actionsWidget = itemmodels.ModelActionsWidget(
            [addClassLabel, self.removeClassLabel], self)
        actionsWidget.layout().addStretch(10)
        actionsWidget.layout().setSpacing(1)
        namesBox.layout().addWidget(actionsWidget)

        tBox = gui.widgetBox(self.controlArea, "Tools", addSpace=True)
        buttonBox = gui.widgetBox(tBox, orientation="horizontal")
        toolsBox = gui.widgetBox(buttonBox, orientation=QtGui.QGridLayout())

        self.toolActions = QtGui.QActionGroup(self)
        self.toolActions.setExclusive(True)

        for i, (name, tooltip, tool, icon) in enumerate(self.TOOLS):
            action = QtGui.QAction(name, self)
            action.setToolTip(tooltip)
            action.setCheckable(True)
            action.setIcon(QtGui.QIcon(icon))
            # using the old connect here due to problems with overloading
            self.connect(action,
                         QtCore.SIGNAL("triggered()"),
                         lambda tool=tool: self.setCurrentTool(tool))
            button = QtGui.QToolButton()
            button.setDefaultAction(action)
            button.setIconSize(QtCore.QSize(24, 24))
            button.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
            button.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                                 QtGui.QSizePolicy.Fixed)
            toolsBox.layout().addWidget(button, i / 3, i % 3)
            self.toolActions.addAction(action)

            if name in ("Jitter", "Magnet"):
                picture = QtSvg.QSvgRenderer(icon)
                pixmap = QtGui.QPixmap(24, 24)
                pixmap.fill(QtCore.Qt.transparent)
                painter = QtGui.QPainter()
                painter.begin(pixmap)
                painter.setRenderHints(painter.Antialiasing)
                picture.render(painter)
                painter.end()
                tool.cursor = QtGui.QCursor(pixmap)

        for column in range(3):
            toolsBox.layout().setColumnMinimumWidth(column, 10)
            toolsBox.layout().setColumnStretch(column, 1)

        smallButtons = gui.widgetBox(buttonBox)

        #        undoRedoBox = gui.widgetBox(smallButtons, "", addSpace=True)
        icon_undo = _i("Dlg_undo.png", "../icons")
        undo = QtGui.QAction(QtGui.QIcon(icon_undo), "", self)
        undo.pyqtConfigure(toolTip="Undo Action (Ctrl+Z)")
        undo.setShortcut("Ctrl+Z")
        undo.triggered.connect(self.undoStack.undo)
        icon_redo = _i("Dlg_redo.png", "../icons")
        redo = QtGui.QAction(QtGui.QIcon(icon_redo), "", self)
        redo.pyqtConfigure(toolTip="Redo Action (Ctrl+Shift+Z)")
        redo.setShortcut("Ctrl+Shift+Z")
        redo.triggered.connect(self.undoStack.redo)
        undoRedoActionsWidget = itemmodels.ModelActionsWidget(
            [undo, redo], self, direction=QtGui.QBoxLayout.TopToBottom)
        undoRedoActionsWidget.layout().addStretch(10)
        undoRedoActionsWidget.layout().setSpacing(1)
        smallButtons.layout().addWidget(undoRedoActionsWidget)

        gui.separator(tBox)
        indBox = gui.indentedBox(tBox, sep=8)
        self.radiusSlider = gui.hSlider(indBox,
                                        self,
                                        "brushRadius",
                                        None,
                                        50,
                                        100,
                                        label="Radius",
                                        createLabel=None)
        self.densitySlider = gui.hSlider(indBox,
                                         self,
                                         "density",
                                         None,
                                         3,
                                         10,
                                         label="Density",
                                         createLabel=None)

        gui.rubber(self.controlArea)
        commitBox = gui.widgetBox(self.controlArea, "Commit")
        gui.checkBox(commitBox,
                     self,
                     "commit_on_change",
                     "Commit on change",
                     tooltip="Send the data on any change.")
        gui.button(commitBox, self, "Commit", callback=self.sendData)

        QtGui.QShortcut("Delete", self).activated.connect(self.deleteSelected)

        # enable brush tool
        self.toolActions.actions()[0].setChecked(True)
        self.setCurrentTool(self.TOOLS[0][2])
        # main area GUI
        self.mainArea.layout().addWidget(self.plot)
예제 #28
0
 def drawObject(self, painter, rect, doc, posInDocument, format):
     renderer = QtSvg.QSvgRenderer(format.property(self.SvgData))
     renderer.render(painter, rect)
예제 #29
0
 def openFileSVG(self, svg_file):
     if not svg_file.exists():
         return
     r = QtSvg.QSvgRenderer()
     r.load(svg_file.fileName())
     self.svgItem.setSharedRenderer(r)
예제 #30
0
파일: home.py 프로젝트: sergiolsp/adekzpy
    print 'abrindo Pekz...'
    url = "http://master.adekz.com:8888/web/adekzpekz"
    webbrowser.open(url)


def teste():
    print 'teste!'


m.addAction('Pekz', openUrl)
m.addAction('Quit', quitCB)

QtCore.QObject.connect(m, QtCore.SIGNAL('aboutToShow()'), aboutToShowCB)
i.setContextMenu(m)

svg = QtSvg.QSvgRenderer('anvil.svg')
if not svg.isValid():
    raise RuntimeError('bad SVG')

pm = QtGui.QPixmap(16, 16)
painter = QtGui.QPainter(pm)
svg.render(painter)
icon = QtGui.QIcon(pm)
i.setIcon(icon)
i.show()

app.exec_()

del painter, pm, svg  # avoid the paint device getting
del i, icon  # deleted before the painter
del app