Ejemplo n.º 1
0
 def paintEvent(self, event):
     if hasattr(self, "_update_dpi") and self._update_dpi():
         return  # matplotlib#19123 (<3.4).
     # We always repaint the full canvas (doing otherwise would require an
     # additional copy of the buffer into a contiguous block, so it's not
     # clear it would be faster).
     buf = _util.cairo_to_premultiplied_argb32(
         self.get_renderer()._get_buffer())
     height, width, _ = buf.shape
     # The image buffer is not necessarily contiguous, but the padding
     # in the ARGB32 case (each scanline is 32-bit aligned) happens to
     # match what QImage requires; in the RGBA128F case the documented Qt
     # requirement does not seem necessary?
     if QtGui.__name__.startswith("PyQt6"):
         from PyQt6 import sip
         ptr = sip.voidptr(buf)
     else:
         ptr = buf
     qimage = QtGui.QImage(ptr, width, height,
                           QtGui.QImage.Format(6))  # ARGB32_Premultiplied
     getattr(qimage, "setDevicePixelRatio",
             lambda _: None)(self.device_pixel_ratio)
     # https://bugreports.qt.io/browse/PYSIDE-140
     if (QtCore.__name__.startswith("PySide") and QtCore.__version_info__ <
         (5, 12)):
         ctypes.c_long.from_address(id(buf)).value -= 1
     painter = QtGui.QPainter(self)
     painter.eraseRect(self.rect())
     painter.drawImage(0, 0, qimage)
     self._draw_rect_callback(painter)
     painter.end()
Ejemplo n.º 2
0
 def _icon(name):
     direct = os.path.dirname(__file__)
     name = os.path.join(direct, name)
     pm = QtGui.QPixmap(name)
     if hasattr(pm, 'setDevicePixelRatio'):
         pm.setDevicePixelRatio(fig.canvas._dpi_ratio)
     return QtGui.QIcon(pm)
Ejemplo n.º 3
0
    def __init__(self, canvas, parent, plot_win, prj, coordinates=True):

        self.plot_win = plot_win
        self.prj = prj
        self.grid_action = None
        self.flagged_action = None
        self.flag_action = None
        self.unflag_action = None
        self.insert_action = None
        self.insert_sample = None
        self.mon_label = None

        self._ids_flag = None
        self._flag_mode = None
        self._flag_start = None
        self._flag_end = None

        # custom  cursors
        pan_px = QtGui.QPixmap(os.path.join(self.media, 'pan_cursor.png'))
        pan_px.setMask(pan_px.mask())
        self.pan_cursor = QtGui.QCursor(pan_px)
        grab_px = QtGui.QPixmap(os.path.join(self.media, 'grab_cursor.png'))
        grab_px.setMask(grab_px.mask())
        self.grab_cursor = QtGui.QCursor(grab_px)

        NavigationToolbar2QT.__init__(self,
                                      canvas=canvas,
                                      parent=parent,
                                      coordinates=coordinates)
        self.setIconSize(QtCore.QSize(24, 24))

        self.canvas.mpl_connect('button_press_event', self.press)
        self.canvas.mpl_connect('button_release_event', self.release)
Ejemplo n.º 4
0
def build_menubar(fig, actions):
    root = fig.canvas.manager.window

    # File menu items
    saveact = QtGui.QAction('Save', root)
    saveact.triggered.connect(actions['save'])
    exitact = QtGui.QAction('Exit', root)
    exitact.triggered.connect(actions['exit'])

    # Help menu items
    helpact = QtGui.QAction('Help', root)
    helpact.triggered.connect(actions['help'])
    aboutact = QtGui.QAction('About', root)
    aboutact.triggered.connect(actions['about'])

    # Menubar creation
    mb = root.menuBar()
    # The File menubar item
    filemenu = mb.addMenu('File')
    filemenu.addAction(saveact)
    filemenu.addAction(exitact)
    # The Help menubar item
    helpmenu = mb.addMenu('Help')
    helpmenu.addAction(helpact)
    helpmenu.addAction(aboutact)

    return mb
 def set_color(self, color):
     if color != self._color:
         self._color = color
         self.colorChanged.emit(self._color)
         pixmap = QtGui.QPixmap(self.iconSize())
         pixmap.fill(color)
         self.setIcon(QtGui.QIcon(pixmap))
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle("application main window")

        self.file_menu = QtGui.QMenu('&File', self)
        self.file_menu.addAction('&Quit', self.fileQuit,
                                 QtCore.Qt.CTRL + QtCore.Qt.Key_Q)
        self.menuBar().addMenu(self.file_menu)

        self.help_menu = QtGui.QMenu('&Help', self)
        self.menuBar().addSeparator()
        self.menuBar().addMenu(self.help_menu)

        self.help_menu.addAction('&About', self.about)

        self.main_widget = QtGui.QWidget(self)

        l = QtGui.QVBoxLayout(self.main_widget)
        sc = MyStaticMplCanvas(self.main_widget, width=5, height=4, dpi=100)
        dc = MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=100)
        l.addWidget(sc)
        l.addWidget(dc)

        self.main_widget.setFocus()
        self.setCentralWidget(self.main_widget)

        self.statusBar().showMessage("All hail matplotlib!", 2000)
Ejemplo n.º 7
0
def build_progress_bar(fig, lastframe, height):
    vbox = QtWidgets.QVBoxLayout()
    fig.canvas.setLayout(vbox)
    width = int(fig.bbox.height * height)

    bar = QtGui.QSlider(QtCore.Qt.Horizontal)
    bar.setRange(0, lastframe)
    bar.setSingleStep(1)
    bar.setMinimumSize(QtCore.QSize(0, width))

    # Add an auto-updating label for the slider
    value = QtWidgets.QLabel('0 of %d' % lastframe)
    value.setMinimumSize(QtCore.QSize(0, width))
    value.connect(bar, QtCore.SIGNAL('valueChanged(int)'),
                  lambda frame: value.setText("%d of %d" % (frame, lastframe)))

    hbox = QtWidgets.QHBoxLayout()
    hbox.addWidget(bar)
    hbox.addWidget(value)

    # This spacer will help force the slider down to the bottom of the canvas
    vspace = QtGui.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding,
                               QtWidgets.QSizePolicy.Expanding)

    vbox.addItem(vspace)
    vbox.addLayout(hbox)
    return bar
Ejemplo n.º 8
0
 def _icon(self, name):
     if is_pyqt5():
         name = name.replace('.png', '_large.png')
     pm = QtGui.QPixmap(os.path.join(self.basedir, name))
     if hasattr(pm, 'setDevicePixelRatio'):
         pm.setDevicePixelRatio(self.canvas._dpi_ratio)
     return QtGui.QIcon(pm)
Ejemplo n.º 9
0
    def draw_input_image(self, idx1=None, idx2=None, new_image=False):
        """
        Draws input image, with additional box visualizations if a node is selected
        - idx1: idx of object1 (subject)
        - idx2: idx of object2 (object)
        """
        image = np.copy(self.image)

        if idx1 is not None and idx2 is None:
            # its an object node
            image = eval_utils.draw_image_box(image,
                                              self.boxes[idx1].cpu().numpy())

        if idx1 is not None and idx2 is not None:
            # its a predicate node
            image = eval_utils.draw_image_edge(image,
                                               self.boxes[idx1].cpu().numpy(),
                                               self.boxes[idx2].cpu().numpy())
            image = eval_utils.draw_image_box(image,
                                              self.boxes[idx1].cpu().numpy())
            image = eval_utils.draw_image_box(image,
                                              self.boxes[idx2].cpu().numpy())

        image = QtGui.QImage(image, image.shape[1], \
                             image.shape[0], QtGui.QImage.Format_RGB888)

        self.pixmap = QtGui.QPixmap(image)
        self.imb.setPixmap(self.pixmap.scaled(200, 200))

        if new_image:
            self.ima.setVisible(0)
            self.imLoadCounter += 1
Ejemplo n.º 10
0
 def generateLegendMenu(self):
     self.menuLegend = QtGui.QMenu(self.menubar)
     self.menuLegend.setTitle('Legend')
     self.actionGenerateLegend = QtGui.QAction(self)
     self.actionGenerateLegend.setText('Generate Draggable Legend')
     self.menuLegend.addAction(self.actionGenerateLegend)
     self.menubar.addAction(self.menuLegend.menuAction())
     self.connect(self.actionGenerateLegend, QtCore.SIGNAL('triggered()'),
                  self.generateLegend)
 def _icon(self, name, color=None):
     if is_pyqt5():
         name = name.replace('.png', '_large.png')
     pm = QtGui.QPixmap(os.path.join(self.basedir, name))
     if hasattr(pm, 'setDevicePixelRatio'):
         pm.setDevicePixelRatio(self.canvas._dpi_ratio)
     if color is not None:
         mask = pm.createMaskFromColor(QtGui.QColor('black'),
                                       QtCore.Qt.MaskOutColor)
         pm.fill(color)
         pm.setMask(mask)
     return QtGui.QIcon(pm)
Ejemplo n.º 12
0
 def trigger(self, *args):
     image = os.path.join(matplotlib.rcParams['datapath'], 'images',
                          'matplotlib.png')
     parent = self.canvas.manager.window
     dia = SubplotToolQt(self.figure, parent)
     dia.setWindowIcon(QtGui.QIcon(image))
     dia.exec_()
Ejemplo n.º 13
0
 def set_large_image(self, index):
     self.thumbnails[self.current_thumbnail].setFrameShape(0)
     self.current_thumbnail = index
     pixmap = QtGui.QPixmap(self.entries[self.current_entry].thumbnails[
         self.current_thumbnail])
     self.image_display.setPixmap(pixmap)
     self.thumbnails[self.current_thumbnail].setFrameShape(1)
Ejemplo n.º 14
0
 def __init__(self):
     super(Model, self).__init__()
     self.items = []
     self.item_model = QtGui.QStandardItemModel(self)
     self.current_label = None
     self.xaxis_unit = None  # Default value, will be set upon first data
     self.total_items_ever_added = 0
Ejemplo n.º 15
0
    def __init__(self, figure):
        _create_qApp()
        super(FigureCanvasQT, self).__init__(figure=figure)

        self.figure = figure
        # We don't want to scale up the figure DPI more than once.
        # Note, we don't handle a signal for changing DPI yet.
        figure._original_dpi = figure.dpi
        self._update_figure_dpi()
        # In cases with mixed resolution displays, we need to be careful if the
        # dpi_ratio changes - in this case we need to resize the canvas
        # accordingly. We could watch for screenChanged events from Qt, but
        # the issue is that we can't guarantee this will be emitted *before*
        # the first paintEvent for the canvas, so instead we keep track of the
        # dpi_ratio value here and in paintEvent we resize the canvas if
        # needed.
        self._dpi_ratio_prev = None

        self._draw_pending = False
        self._is_drawing = False
        self._draw_rect_callback = lambda painter: None

        self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
        self.setMouseTracking(True)
        self.resize(*self.get_width_height())
        # Key auto-repeat enabled by default
        self._keyautorepeat = True

        palette = QtGui.QPalette(QtCore.Qt.white)
        self.setPalette(palette)
Ejemplo n.º 16
0
    def __init__(self, parent=None):
        super(Page3, self).__init__(parent)
        integerValidator = QtGui.QIntValidator(0, 10, self)

        coordLabel = QtWidgets.QLabel('Coordinate File:')
        self.coordLine = QtWidgets.QLineEdit()
        coordBtn = QtWidgets.QPushButton('File', self)
        coordBtn.clicked.connect(self.getCoordfile)
        self.registerField('coordFile*', self.coordLine)

        popLabel = QtWidgets.QLabel('Population File:')
        self.popLine = QtWidgets.QLineEdit()
        popBtn = QtWidgets.QPushButton('File', self)
        popBtn.clicked.connect(self.getPopfile)
        self.registerField('popFile*', self.popLine)

        grid = QtWidgets.QGridLayout()
        grid.setSpacing(10)
        grid.addWidget(coordLabel, 1, 0)
        grid.addWidget(self.coordLine, 1, 1)
        grid.addWidget(coordBtn, 1, 2)
        grid.addWidget(popLabel, 2, 0)
        grid.addWidget(self.popLine, 2, 1)
        grid.addWidget(popBtn, 2, 2)
        self.setLayout(grid)
Ejemplo n.º 17
0
    def __init__(self, parent: Optional[Any] = None) -> None:
        """ TODO: Write documentation.
        """
        # Initialize Qt widget
        super(QtWidgets.QWidget, self).__init__(parent=parent)

        # Initialize Panda3D app
        super(Panda3dViewer, self).__init__(window_type='offscreen')

        # Only accept focus by clicking on widget
        self.setFocusPolicy(Qt.ClickFocus)

        # Enable mouse control
        self.setMouseTracking(True)
        self._app.getMousePos = self.getMousePos
        self._app.taskMgr.add(self._app.move_orbital_camera_task,
                              "move_camera_task",
                              sort=2)

        # Create painter to render "screenshot" from panda3d
        self.paint_surface = QtGui.QPainter()

        # Start event loop
        self.clock = QtCore.QTimer()
        self.clock.setInterval(1000.0 / FRAMERATE)
        self.clock.timeout.connect(self.update)
        self.clock.start()
Ejemplo n.º 18
0
    def __init__(self, wib_server='127.0.0.1', cli=False):
        super().__init__()

        self.cli = cli

        self.wib = WIB(wib_server)

        self.setAutoFillBackground(True)
        p = self.palette()
        p.setColor(self.backgroundRole(), QtGui.QColor(*colors[0]))
        self.setPalette(p)

        self._main = QtWidgets.QWidget()
        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        self.wib_pane = WIBPane(self)
        self.femb_panes = [FEMBPane(self, idx) for idx in range(4)]

        layout.addWidget(self.wib_pane)
        fembs = QtWidgets.QWidget(self._main)
        fembs_layout = QtWidgets.QGridLayout(fembs)
        for idx, f in enumerate(self.femb_panes):
            fembs_layout.addWidget(f, idx // 2, idx % 2)
        layout.addWidget(fembs)

        if self.cli:
            self.get_sensors()
        else:
            QtCore.QTimer.singleShot(500, self.get_sensors)
Ejemplo n.º 19
0
    def __init__(self, cesta_projekt):
        super().__init__()
        self.setWindowIcon(QtGui.QIcon('foto.jpg'))
        _translate = QtCore.QCoreApplication.translate
        self.setWindowTitle(_translate("Dialog", "Grafika"))
        self._main = QtWidgets.QWidget()
        self.cesta = cesta_projekt

        self.setCentralWidget(self._main)
        layout = QtWidgets.QVBoxLayout(self._main)

        static_canvas = FigureCanvas(Figure(figsize=(20, 20)))
        layout.addWidget(static_canvas)
        self.addToolBar(NavigationToolbar(static_canvas, self))

        self._static_ax = static_canvas.figure.subplots()

        query = "select Y, X, CB from gps_sour"
        sour = Databaze.sql_query(self.cesta, query)

        y = []
        x = []
        for i in range(0, len(sour)):
            Y = -sour[i][0]
            X = -sour[i][1]
            CB = sour[i][2]
            y.append(Y)
            x.append(X)
            self._static_ax.text(Y, X, CB)

        self._static_ax.plot(y, x, "+")
        self._static_ax.axis('equal')

        self.show()
Ejemplo n.º 20
0
 def run(self):  
     print('running thread')
     self.infLabel.emit('Video loaded. Analyzing...')
     vidcap = cv2.VideoCapture(self.file)
     success,image = vidcap.read()
    
     while success:
         output = image.copy()
         output = imutils.resize(output, width=400)
         
         truePFR,trueFT = self.model.classify(image)
         print(truePFR,trueFT)
         truePFR,trueFT = self.rollAverage(truePFR,trueFT)
         
         
         pfrtext = "PFR : {pfr}".format(pfr =truePFR)
         fttext =  "Fuel Type : {ft}".format(ft=trueFT)
         
         cv2.putText(output, pfrtext, (3, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5,(0, 255, 0), 2)
         cv2.putText(output, fttext, (3, 40), cv2.FONT_HERSHEY_SIMPLEX, 0.5,(0, 255, 0), 2)
         #h, w, ch = output.shape
         #bytesPerLine = ch * w
         #p = QImage(image, w, h, bytesPerLine, QImage.Format_RGB888)
         output = QtGui.QImage(output.data, output.shape[1], output.shape[0], QtGui.QImage.Format_RGB888).rgbSwapped()
         #p = convertToQtFormat.scaled(640, 480, Qt.KeepAspectRatio)
         self.changePixmap.emit(output)
         self.trgLabel.emit(pfrtext+'\n'+fttext)
         self.infLabel.emit('Running pedictions on each frame ...')
         success,image = vidcap.read()
     print('Done')
     self.infLabel.emit('Finished! Click "Load File" to analyze again.')
Ejemplo n.º 21
0
 def set_marking_label(self, label):
     logging.debug('Setting marking label to %s %s', self, label)
     color = QtGui.QColor(LABEL_COLOR_MAP.get(label, 'white'))
     color.setAlphaF(SPAN_ALPHA)
     self.marking_label.setStyleSheet(
         "background-color: rgba{};".format(tuple(color.getRgb()))
     )
     self.marking_label.setText('Current label-mode: {}'.format(label))
     self.model.set_current_label(label)
Ejemplo n.º 22
0
    def create_main_frame(self):
        self.main_frame = QtGui.QWidget()

        self.fig = Figure((5.0, 4.0), dpi=100)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.main_frame)
        self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.canvas.setFocus()

        self.mpl_toolbar = NavigationToolbar(self.canvas, self.main_frame)

        self.canvas.mpl_connect('key_press_event', self.on_key_press)

        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.canvas)  # the matplotlib canvas
        vbox.addWidget(self.mpl_toolbar)
        self.main_frame.setLayout(vbox)
        self.setCentralWidget(self.main_frame)
Ejemplo n.º 23
0
 def __controls(self):
     #Quit Button
     self.btnQuit = QtWidgets.QPushButton('Quit', self)
     self.btnQuit.setToolTip('Quit from PyTrack')
     self.btnQuit.clicked.connect(self.parent.close)
     #Label stupida
     self.lblinfo = QtWidgets.QLabel(' ',self)
     self.lblinfo.setToolTip('http://esss.se')
     self.lblinfo.setPixmap(QtGui.QPixmap('ESS_Logo.png'))
     #Take a measurement
     self.btnStart = QtWidgets.QPushButton('Start',self)
     self.btnStart.clicked.connect(self.Start)
     self.btnStop = QtWidgets.QPushButton('Stop',self)
     self.btnStop.clicked.connect(self.Stop)
     #Label for Messages
     self.lblMessages=QtWidgets.QLabel('Press button to start',self)
     self.lblAuthors=QtWidgets.QLabel('MuYuan 2019\nSRF Section\nLinac Group\nAcceleration Division')
     self.lblAuthors.setAlignment(QtCore.Qt.AlignCenter)
     self.lblAuthors.setFont(QtGui.QFont('',10))
     #puts a canvas object here
     self.PSensorPlot=PSensorCanvas(self, width=5, height=3.5, dpi=144)
     self.PSensorPlot.setToolTip('IOC Measurement')
     #time message
     self.lblTimeMessages=QtWidgets.QLabel(time.strftime("%d-%m-%Y %H:%M:%S",time.localtime(time.time())),self)
     #other controls
     self.lblOperator=QtWidgets.QLabel('Operator',self)
     self.txtOperator=QtWidgets.QLineEdit(self)
     self.txtOperator.setText('SRF Team')
     self.txtOperator.setFixedWidth(100)
     self.lblLocation=QtWidgets.QLabel('Location',self)
     self.txtLocation=QtWidgets.QLineEdit(self)
     self.txtLocation.setText('SRF Laboratory')
     self.lblComments=QtWidgets.QLabel('Comments',self)
     self.txtComments=QtWidgets.QLineEdit(self)
     self.txtComments.setText('IOC waveform measurement')
     self.txtComments.setFixedWidth(300)
     self.lblScanInterval=QtWidgets.QLabel('Interval:',self)
     self.txtScanInterval=QtWidgets.QLineEdit(self)
     self.txtScanInterval.setText('1')
     self.txtScanInterval.setFixedWidth(40)
     self.lblUnit=QtWidgets.QLabel('s',self)
     self.btnInterval=QtWidgets.QPushButton('Apply',self)
     self.btnInterval.setEnabled(True)
     self.btnInterval.clicked.connect(self.setInterval)
Ejemplo n.º 24
0
    def __init__(self, l, r, u, d, parent=None):
        """"""
        QtWidgets.QDialog.__init__(self, parent)
        self.setWindowTitle('Set Heatmap Domain')
        self.setWindowIcon(QtGui.QIcon('kiwi.png'))
        self.setMinimumWidth(400)

        self.header = QtWidgets.QLabel("All distances are relative to the array center.")

        self.leftLabel = QtWidgets.QLabel("Left/West:")
        self.lledit = QtWidgets.QLineEdit(self)
        self.lledit.setText(str(l))

        self.rightLabel = QtWidgets.QLabel("Right/East:")
        self.rledit = QtWidgets.QLineEdit(self)
        self.rledit.setText(str(r))

        self.upLabel = QtWidgets.QLabel("Up/North:")
        self.uledit = QtWidgets.QLineEdit(self)
        self.uledit.setText(str(u))

        self.downLabel = QtWidgets.QLabel("Down/South:")
        self.dledit = QtWidgets.QLineEdit(self)
        self.dledit.setText(str(d))

        self.activate = QtWidgets.QPushButton("Set")

        Box = QtWidgets.QVBoxLayout()

        Box.addWidget(self.header)

        left = QtWidgets.QHBoxLayout()
        left.addWidget(self.leftLabel)
        left.addWidget(self.lledit)

        right = QtWidgets.QHBoxLayout()
        right.addWidget(self.rightLabel)
        right.addWidget(self.rledit)

        up = QtWidgets.QHBoxLayout()
        up.addWidget(self.upLabel)
        up.addWidget(self.uledit)

        down = QtWidgets.QHBoxLayout()
        down.addWidget(self.downLabel)
        down.addWidget(self.dledit)

        Box.addLayout(left)
        Box.addLayout(right)
        Box.addLayout(up)
        Box.addLayout(down)

        Box.addWidget(self.activate)

        # Now put everything into the frame
        self.setLayout(Box)
def to_qcolor(color):
    """Create a QColor from a matplotlib color"""
    qcolor = QtGui.QColor()
    try:
        rgba = mcolors.to_rgba(color)
    except ValueError:
        cbook._warn_external('Ignoring invalid color %r' % color)
        return qcolor  # return invalid QColor
    qcolor.setRgbF(*rgba)
    return qcolor
Ejemplo n.º 26
0
 def set_large_image(self, index):
     self.thumbnails[self.current_thumbnail].setFrameShape(
         _enum('QtWidgets.QFrame.Shape').NoFrame)
     self.current_thumbnail = index
     pixmap = QtGui.QPixmap(
         os.fspath(self.entries[self.current_entry].thumbnails[
             self.current_thumbnail]))
     self.image_display.setPixmap(pixmap)
     self.thumbnails[self.current_thumbnail].setFrameShape(
         _enum('QtWidgets.QFrame.Shape').Box)
Ejemplo n.º 27
0
def to_qcolor(color):
    """Create a QColor from a matplotlib color"""
    qcolor = QtGui.QColor()
    try:
        rgba = mcolors.to_rgba(color)
    except ValueError:
        warnings.warn('Ignoring invalid color %r' % color, stacklevel=2)
        return qcolor  # return invalid QColor
    qcolor.setRgbF(*rgba)
    return qcolor
Ejemplo n.º 28
0
def to_qcolor(color):
    """Create a QColor from a matplotlib color"""
    qcolor = QtGui.QColor()
    color = str(color)
    try:
        color = col2hex(color)
    except ValueError:
        #print('WARNING: ignoring invalid color %r' % color)
        return qcolor  # return invalid QColor
    qcolor.setNamedColor(color)  # set using hex color
    return qcolor  # return valid QColor
Ejemplo n.º 29
0
    def _init_toolbar(self):
        #self.basedir = os.path.join(matplotlib.rcParams['datapath'], 'images')
        iconDir = os.path.join(os.path.dirname(os.path.abspath(__file__)),'icons', '')
        for text, tooltip_text, image_file, callback in self.toolitems:
            if text is None:
                self.addSeparator()
            else:
                # a = self.addAction(self._icon(iconDir + image_file + '.png'),
                #                          text, getattr(self, callback))
                a = self.addAction(QtGui.QIcon(iconDir + image_file + '.png'),
                                         text, getattr(self, callback))
                self._actions[callback] = a
                if callback in ['zoom', 'pan', 'cursorcluster', 'radiomode', 'shapemode', 'selectedmode']:
                    a.setCheckable(True)
                if tooltip_text is not None:
                    a.setToolTip(tooltip_text)

        if figureoptions is not None:
            # a = self.addAction(self._icon("qt4_editor_options.png"),
            #                    'Customize', self.edit_parameters)
            a = self.addAction(QtGui.QIcon("qt4_editor_options.png"),
                               'Customize', self.edit_parameters)
            a.setToolTip('Edit curves line and axes parameters')

        self.buttons = {}

        # Add the x,y location widget at the right side of the toolbar
        # The stretch factor is 1 which means any resizing of the toolbar
        # will resize this label instead of the buttons.
        if self.coordinates:
            self.locLabel = QtWidgets.QLabel("", self)
            self.locLabel.setAlignment(
                    QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
            self.locLabel.setSizePolicy(
                QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Ignored))
            labelAction = self.addWidget(self.locLabel)
            labelAction.setVisible(True)

        # reference holder for subplots_adjust window
        self.adj_window = None
Ejemplo n.º 30
0
 def populate_from_menu(menu):
     for act in menu.actions():
         if hasattr(act, 'short'):
             shortcut_text = act.short.key().toString()
         else:
             shortcut_text = ''
         text = '{:s}\t{:s}: {:s}'.format(
             shortcut_text,
             menu.title().replace('&',''),
             act.text().replace('&',''),
         )
         self.help_item_model.appendRow(QtGui.QStandardItem(text))