Ejemplo n.º 1
0
    def connectActions(self):
        super(PlotMainWindow, self).connectActions()
        self.actionExport.triggered.connect(self.exportData_Callback)
        self.actionExport.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_E)
        self.actionImport.triggered.connect(self.importData_Callback)
        self.actionImport.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_I)

        self.fitTypeActionGroup = QtGui.QActionGroup(self)
        self.fitTypeActionGroup.addAction(self.actionFitTypeLinear)
        self.fitTypeActionGroup.addAction(self.actionFitTypePolynomial2)
        self.fitTypeActionGroup.addAction(self.actionFitTypePolynomial3)
        self.fitTypeActionGroup.addAction(self.actionFitTypePolynomial4)
        self.fitTypeActionGroup.addAction(self.actionFitTypePolynomial5)
        self.fitTypeActionGroup.setExclusive(True)
        self.fitTypeActionGroup.triggered.connect(self.fitTypeChanged_Callback)

        self.unitsActionGroup = QtGui.QActionGroup(self)
        self.unitsActionGroup.addAction(self.actionUnitsUM)
        self.unitsActionGroup.addAction(self.actionUnitsPPM)
        self.unitsActionGroup.addAction(self.actionUnitsPH)
        self.unitsActionGroup.setExclusive(True)
        self.unitsActionGroup.triggered.connect(self.unitsChanged_Callback)

        itemDelegate = DoubleItemDelegate(self.tableWidget)
        self.tableWidget.setItemDelegateForColumn(0, itemDelegate)
Ejemplo n.º 2
0
    def createPopMenu(self):
        #actions
        self.popmenu = QtGui.QMenu(self)
        self.snn_ac_group = QtGui.QActionGroup(self.popmenu)
        self.snn_ac_group.setExclusive(True)

        self.ac_s11 = QtGui.QAction('S11', self.popmenu)
        self.ac_s21 = QtGui.QAction('S21', self.popmenu)
        self.ac_s12 = QtGui.QAction('S12', self.popmenu)
        self.ac_s22 = QtGui.QAction('S22', self.popmenu)
        snn_actions = [self.ac_s11, self.ac_s21, self.ac_s12, self.ac_s22]

        for ac in snn_actions:
            ac.setCheckable(True)
            self.snn_ac_group.addAction(ac)
        self.ac_s11.setChecked(True)
        self.popmenu.addActions(snn_actions)

        self.ac_delay = QtGui.QAction('show delay', self.popmenu)
        self.ac_phase = QtGui.QAction('show phase', self.popmenu)
        self.ac_expanded = QtGui.QAction('show expanded', self.popmenu)
        self.type_ac_group = QtGui.QActionGroup(self.popmenu)
        types_actions = [self.ac_delay, self.ac_phase, self.ac_expanded]
        for ac in types_actions:
            ac.setCheckable(True)
            self.type_ac_group.addAction(ac)
        self.ac_phase.setChecked(True)
        self.popmenu.addActions(types_actions)
        self.setShowPopMenu(True)
Ejemplo n.º 3
0
    def createAction(self):

        self.newAct = QtGui.QAction(QtGui.QIcon(':/images/new.png'),
                                    u"&新規作成...", self)
        self.newAct.setShortcuts(QtGui.QKeySequence.New)
        self.newAct.triggered.connect(self.newFile)

        self.openAct = QtGui.QAction(QtGui.QIcon(':/images/open.png'),
                                     u"&開く...", self)
        self.openAct.setShortcuts(QtGui.QKeySequence.Open)
        self.openAct.triggered.connect(self.open)

        self.saveAct = QtGui.QAction(QtGui.QIcon(':/images/save.png'), u"&保存",
                                     self)
        self.saveAct.setShortcuts(QtGui.QKeySequence.Save)
        self.saveAct.triggered.connect(self.save)

        self.saveAsAct = QtGui.QAction(u"&名前を付けて保存", self)
        self.saveAsAct.setShortcuts(QtGui.QKeySequence.SaveAs)
        self.saveAsAct.triggered.connect(self.saveAs)

        self.savePythonFileAct = QtGui.QAction(u"&Python &File出力", self)
        self.savePythonFileAct.triggered.connect(self.savePythonFile)

        self.saveXMLFileAct = QtGui.QAction(u"&XML &File 出力", self)
        self.saveXMLFileAct.triggered.connect(self.saveXMLFile)

        self.size10Act = QtGui.QAction("&10", self, checkable=True)
        self.size10Act.triggered.connect(self.set10FontSize)
        self.size12Act = QtGui.QAction("&12", self, checkable=True)
        self.size12Act.triggered.connect(self.set12FontSize)
        self.size24Act = QtGui.QAction("&24", self, checkable=True)
        self.size24Act.triggered.connect(self.set24FontSize)
        self.size48Act = QtGui.QAction("&48", self, checkable=True)
        self.size48Act.triggered.connect(self.set48FontSize)

        self.sizeGroup = QtGui.QActionGroup(self)
        self.sizeGroup.addAction(self.size10Act)
        self.sizeGroup.addAction(self.size12Act)
        self.sizeGroup.addAction(self.size24Act)
        self.sizeGroup.addAction(self.size48Act)
        self.size12Act.setChecked(True)

        self.pathAct = QtGui.QAction(u"&Path設定", self)
        self.pathAct.triggered.connect(self.setPath)

        self.moduleAct = QtGui.QAction(u"&インポートモジュール設定", self)
        self.moduleAct.triggered.connect(self.setModule)

        self.execStringAct = QtGui.QAction("&exec", self, checkable=True)
        self.execStringAct.triggered.connect(self.setExecString)

        self.fileMethodAct = QtGui.QAction("&file", self, checkable=True)
        self.fileMethodAct.triggered.connect(self.setFileMethod)

        self.execGroup = QtGui.QActionGroup(self)
        self.execGroup.addAction(self.execStringAct)
        self.execGroup.addAction(self.fileMethodAct)
        self.execStringAct.setChecked(True)
Ejemplo n.º 4
0
    def generateContextMenu(self):
        self.popMenu = QtGui.QMenu(self)
        self.acSetAutoScale = QtGui.QAction('Autoscale', self)
        self.acSetAutoScale.setCheckable(True)
        self.acSetAutoScale.setChecked(True)
        self.popMenu.addAction(self.acSetAutoScale)

        self.acSetAutoScale.toggled.connect(self.setAutoscale)

        self.acSet3D = QtGui.QAction('3D', self)
        self.acSet3D.setCheckable(True)
        self.acSet3D.setChecked(False)
        self.popMenu.addAction(self.acSet3D)

        self.acgCM = QtGui.QActionGroup(self)

        self.CMmenu = QtGui.QMenu(self)
        self.CMmenu.setTitle('Colormaps')

        for cm in ("gray|red|green|blue|red white|green white|blue white|" +
                   "cyan|magenta|cyan white|jet|" +
                   "magenta white|hot|cyan hot|afmhot|bmg").split("|"):
            ac = QtGui.QAction(cm, self.acgCM)
            ac.triggered.connect(functools.partial(self.setCM, cm))
            ac.setCheckable(True)
            if cm == self.cm:
                ac.setChecked(True)
        ip_methods = [
            'none', 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36',
            'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom',
            'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos'
        ]

        self.acgIP = QtGui.QActionGroup(self)
        for ip in ip_methods:
            ac = QtGui.QAction(ip, self.acgIP)
            ac.triggered.connect(functools.partial(self.setIP, ip))
            ac.setCheckable(True)

            self.acgIP.addAction(ac)

        self.IPmenu = QtGui.QMenu(self)
        self.IPmenu.setTitle('Interpolation')
        self.IPmenu.addActions(self.acgIP.actions())

        self.CMmenu.addActions(self.acgCM.actions())

        self.popMenu.addSeparator()
        self.popMenu.addMenu(self.CMmenu)
        self.popMenu.addSeparator()
        self.popMenu.addMenu(self.IPmenu)

        self.acAsNewScan = QtGui.QAction("Use selection as new scan",
                                         self.popMenu)
        self.acAsNewScan.triggered.connect(self.onAsNewScan)
        self.acAsNewScan.setEnabled(False)
        self.popMenu.addSeparator()
        self.popMenu.addAction(self.acAsNewScan)
Ejemplo n.º 5
0
    def connectActions(self):
        self.samplesLineEdit.editingFinished.connect(
            self.samplesChanged_Callback)
        self.samplesValidator = QtGui.QIntValidator(0, 2**16 - 1,
                                                    self.samplesLineEdit)
        self.samplesLineEdit.setValidator(self.samplesValidator)
        self.portLineEdit.editingFinished.connect(self.portChanged_Callback)
        self.connectPushButton.pressed.connect(self.connectPressed_Callback)
        self.connectPushButton.clicked.connect(self.connectClicked_Callback)
        self.calibratePushButton.pressed.connect(
            self.calibratePressed_Callback)
        self.calibratePushButton.clicked.connect(
            self.calibrateClicked_Callback)
        self.measurePushButton.clicked.connect(self.measureClicked_Callback)
        self.measurePushButton.pressed.connect(self.measurePressed_Callback)
        self.actionSave.triggered.connect(self.saveFile_Callback)
        self.actionSave.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_S)
        self.actionAbout.triggered.connect(self.about_Callback)
        self.actionSave.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_A)

        self.modeActionGroup = QtGui.QActionGroup(self)
        self.modeActionGroup.addAction(self.actionStandardRGBLED)
        self.modeActionGroup.addAction(self.actionCustomLEDVerB)
        self.modeActionGroup.addAction(self.actionCustomLEDVerC)
        self.modeActionGroup.setExclusive(True)
        self.actionStandardRGBLED.setChecked(True)

        standardRgbLED_Callback = functools.partial(self.sensorMode_Callback,
                                                    'StandardRGBLED')
        self.actionStandardRGBLED.triggered.connect(standardRgbLED_Callback)
        customVerB_Callback = functools.partial(self.sensorMode_Callback,
                                                'CustomLEDVerB')
        self.actionCustomLEDVerB.triggered.connect(customVerB_Callback)
        customVerC_Callback = functools.partial(self.sensorMode_Callback,
                                                'CustomLEDVerC')
        self.actionCustomLEDVerC.triggered.connect(customVerC_Callback)

        self.significantDigitActionGroup = QtGui.QActionGroup(self)
        self.significantDigitActionGroup.setExclusive(True)
        self.significantDigitAction2Value = {}

        for i in constants.SIGNIFICANT_DIGITS_LIST:
            actionName = 'actionSignificantDigits{0}'.format(i)
            action = QtGui.QAction(self.menuSignificantDigits)
            action.setCheckable(True)
            action.setText('{0}'.format(i))
            self.menuSignificantDigits.addAction(action)
            self.significantDigitActionGroup.addAction(action)
            if i == constants.DEFAULT_SIGNIFICANT_DIGIT_INDEX:
                action.setChecked(True)
            self.significantDigitAction2Value[action] = i
Ejemplo n.º 6
0
    def updateWindowMenu(self):
        """
        Update the `Window` menu.

        The `Window` menu is dynamic because its content is determined
        by the currently open views. Because the number of these views or
        its contents may vary at any moment we must update the `Window`
        menu every time it is open. For simplicity we don't keep track
        of changes in the menu content. Instead, we clean and create it
        from scratch every time it is about to show.
        """

        # Clear the menu and rebuild it from scratch
        wmenu = self.window_menu
        wmenu.clear()
        window_actions = [
            'windowCascade', 'windowTile', 'windowRestoreAll',
            'windowMinimizeAll', 'windowClose', 'windowCloseAll',
            'windowSeparator'
        ]
        vitables.utils.addActions(wmenu, window_actions, self.gui_actions)

        windows_list = self.workspace.subWindowList()
        if not windows_list:
            return

        # Create actions for the existing views
        action_group = QtGui.QActionGroup(wmenu)
        wmenu.action_group = action_group
        counter = 1
        for window in windows_list:
            title = window.windowTitle()
            if counter < 10:
                action = wmenu.addAction(u"&{0:d} {1}".format(counter, title))
                wmenu.action_group.addAction(action)
            elif counter == 10:
                wmenu.addSeparator()
                submenu = wmenu.addMenu(
                    translate('VTGUI', "&More...", 'A Windows submenu'))
                action_subgroup = QtGui.QActionGroup(submenu)
            elif counter < 36:
                atext = u"&{0} {1}".format(chr(counter + ord("@") - 10), title)
                action = submenu.addAction(atext)
                action_subgroup.addAction(action)

            self.window_mapper.setMapping(action, window)
            action.triggered.connect(self.window_mapper.map)
            action.setCheckable(True)
            if self.workspace.activeSubWindow() == window:
                action.setChecked(True)
            counter = counter + 1
Ejemplo n.º 7
0
 def makePopupMenu(self, bookid):
     menu = QtGui.QMenu()
     if bookid:
         filename = self._db.getFilenameByBookId(bookid)
         group = QtGui.QActionGroup(menu)
         group.triggered.connect(self.on_group1_triggered)
         for program in self.programSettings.getPrograms():
             if not program[1].isEmpty():
                 if program[0].isEmpty():
                     a = menu.addAction(program[1])
                 else:
                     a = menu.addAction(program[0])
                 args = [
                     x.decode('utf8') for x in shlex.split(
                         unicode(program[1]).encode('utf8'))
                 ]
                 program = args.pop(0)
                 args = [arg.replace('%p', filename) for arg in args]
                 a.program = program
                 a.args = args
                 group.addAction(a)
         groups = self._db.getGroupsBookNotIn(bookid)
         if groups:
             if not menu.isEmpty():
                 menu.addSeparator()
             menu2 = QtGui.QMenu(self.tr("Add to group"), menu)
             group2 = QtGui.QActionGroup(menu2)
             group2.triggered.connect(self.on_group2_triggered)
             for group in groups:
                 a = menu2.addAction(group[1])
                 a.bookid = bookid
                 a.groupid = group[0]
                 group2.addAction(a)
             menu.addMenu(menu2)
         groups = self._db.getGroupsBookIn(bookid)
         if groups:
             if not menu.isEmpty():
                 menu.addSeparator()
             menu3 = QtGui.QMenu(self.tr("Remove from group"), menu)
             group3 = QtGui.QActionGroup(menu3)
             group3.triggered.connect(self.on_group3_triggered)
             for group in groups:
                 a = menu3.addAction(group[1])
                 a.bookid = bookid
                 a.groupid = group[0]
                 group3.addAction(a)
             menu.addMenu(menu3)
     return menu
Ejemplo n.º 8
0
def create_menu_items_from_view(menu, items):
    # TODO: images & radio groups, for now only basic representation
    for item in items:
        if item.type is MenuItemView.COMMAND:
            it = QtGui.QAction(item.label, menu)
            QtCore.QObject.connect(it, QtCore.SIGNAL("triggered()"),
                                   item.command)
            menu.addAction(it)
        elif item.type is MenuItemView.CASCADE_MENU:
            men = QtGui.QMenu(item.label, menu)
            create_menu_items_from_view(men, item.items)
            menu.addMenu(men)
        elif item.type is MenuItemView.SEPARATOR:
            menu.addSeparator()
        elif item.type is MenuItemView.CHECKBUTTON:
            it = QtGui.QAction(item.label, menu)
            it.setCheckable(True)
            if item.checkbox:  #TODO : isn't it checkbox_value instead of checkbox ? By the way the MenuItemView constructor doesn't store the checkbox_value passed to it
                it.setChecked(True)
            QtCore.QObject.connect(it, QtCore.SIGNAL("triggered()"),
                                   item.command)
            menu.addAction(it)
        elif item.type is MenuItemView.RADIOBUTTON:
            it = QtGui.QAction(item.label, menu)
            it.setCheckable(True)
            if item.checkbox:
                it.setChecked(True)
            QtCore.QObject.connect(it, QtCore.SIGNAL("triggered()"),
                                   item.command)
        elif item.type is MenuItemView.RADIOBUTTONGROUP:
            group = QtGui.QActionGroup(menu)
            create_menu_items_from_view(group, item.items)
            menu.addActions(group)
Ejemplo n.º 9
0
    def loadFavourites(self):
        self.favouritesMenu.clear()
        self.favouritesListWidget.clear()
        if len(self.favouritesList) > 0:
            self.favouritesActionGroup = QtGui.QActionGroup(self)
            self.favouritesActionGroup.triggered.connect(
                self.favouriteActivated)
            for i in self.favouritesList:
                action = QtGui.QAction(
                    QtGui.QIcon(os.path.join("Resources", "images", "star")),
                    i, self)
                self.favouritesActionGroup.addAction(action)
                self.favouritesMenu.addAction(action)

                item = QtGui.QListWidgetItem(i.strip())
                item.setToolTip(i)
                item.setSizeHint(QtCore.QSize(20, 20))
                self.favouritesListWidget.addItem(item)

            self.favouritesMenu.addSeparator()
            self.favouritesMenu.addAction(self.manageFavAct)
            self.removeButton.setDisabled(False)
        else:
            action = QtGui.QAction("No Favourites", self)
            self.favouritesMenu.addAction(action)
            self.favouritesMenu.addAction(action)
            self.removeButton.setDisabled(True)
Ejemplo n.º 10
0
    def __createContextMenu(self, widget):
        self.contextMenu = QtWidgets.QMenu(widget)

        self.propertyAction = self.contextMenu.addAction("Properties")
        # self.propertyAction.setEnabled(False)

        menu = self.contextMenu.addMenu("Class labels")

        group = QtWidgets.QActionGroup(widget, exclusive=True)
        self.classActions = list()
        for i in range(Parameters.NUMBER_SUPPORTED_CLASSES):
            action = group.addAction(
                QtWidgets.QAction("Class {0}".format(i + 1),
                                  widget,
                                  checkable=True))
            self.classActions.append(action)
            menu.addAction(action)

        self.classActions[self.__classId].setChecked(True)

        self.contextMenu.addMenu(menu)
        self.contextMenu.addSeparator()
        self.excludeAction = self.contextMenu.addAction("Exclude Gaussian")
        self.convertAction = self.contextMenu.addAction("Convert to samples")
        self.deleteAction = self.contextMenu.addAction("Delete Gaussian")
Ejemplo n.º 11
0
 def __init__(self, parent=None, script=None):
     super(MainWindow, self).__init__(parent)
     self.setWindowTitle("Pyctools graph editor")
     self.script_file = os.getcwd()
     ## file menu
     file_menu = self.menuBar().addMenu('File')
     file_menu.addAction('Load script', self.load_script, 'Ctrl+O')
     file_menu.addAction('Save script', self.save_script, 'Ctrl+S')
     file_menu.addSeparator()
     quit_action = QtGui.QAction('Quit', self)
     quit_action.setShortcuts(['Ctrl+Q', 'Ctrl+W'])
     quit_action.triggered.connect(
         QtGui.QApplication.instance().closeAllWindows)
     file_menu.addAction(quit_action)
     ## zoom menu
     zoom_menu = self.menuBar().addMenu('Zoom')
     zoom_menu.addAction('Zoom in', self.zoom_in, 'Ctrl++')
     zoom_menu.addAction('Zoom out', self.zoom_out, 'Ctrl+-')
     zoom_menu.addSeparator()
     self.zoom_group = QtGui.QActionGroup(self)
     for zoom in (25, 35, 50, 70, 100, 141, 200):
         action = QtGui.QAction('%d%%' % zoom, self)
         action.setCheckable(True)
         if zoom == 100:
             action.setChecked(True)
         action.setData(zoom)
         zoom_menu.addAction(action)
         self.zoom_group.addAction(action)
     self.zoom_group.triggered.connect(self.set_zoom)
     ## main application area
     self.setCentralWidget(QtGui.QWidget())
     grid = QtGui.QGridLayout()
     grid.setColumnStretch(0, 1)
     self.centralWidget().setLayout(grid)
     # component list and network drawing area
     splitter = QtGui.QSplitter(self)
     splitter.setChildrenCollapsible(False)
     self.component_list = ComponentList(self)
     splitter.addWidget(self.component_list)
     self.network_area = NetworkArea(self)
     self.view = QtGui.QGraphicsView(self.network_area)
     self.view.setAcceptDrops(True)
     self.view.setDragMode(QtGui.QGraphicsView.RubberBandDrag)
     self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
     self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
     splitter.addWidget(self.view)
     splitter.setStretchFactor(1, 1)
     grid.addWidget(splitter, 0, 0, 1, 5)
     # buttons
     run_button = QtGui.QPushButton('run graph')
     run_button.clicked.connect(self.network_area.run_graph)
     grid.addWidget(run_button, 1, 3)
     stop_button = QtGui.QPushButton('stop graph')
     stop_button.clicked.connect(self.network_area.stop_graph)
     grid.addWidget(stop_button, 1, 4)
     # load initial script
     if script:
         script = os.path.abspath(script)
         self.set_window_title(script)
         self.network_area.load_script(script)
Ejemplo n.º 12
0
    def __init__(self, param_info, widget_list, parent=None):
        """ QParameterEditorSelector(param_info: ParameterInfo,
        widget_list: list of widgets that conform to the parameter
        exploration widget interface.
        """
        QtGui.QToolButton.__init__(self, parent)
        self._param_info = param_info
        self.type = param_info.spec.descriptor.name
        self.setAutoRaise(True)
        self.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly)
        self.setPopupMode(QtGui.QToolButton.InstantPopup)

        self.setText(unichr(0x25bc))  # Down triangle

        self.actionGroup = QtGui.QActionGroup(self)

        self._actions = []
        for widget in widget_list:
            action = QtGui.QAction(widget.exploration_name, self.actionGroup)
            self._actions.append(action)

        aId = 0
        for action in self.actionGroup.actions():
            action.setCheckable(True)
            action.setData(aId)
            aId += 1

        menu = QtGui.QMenu(self)
        menu.addActions(self.actionGroup.actions())
        self.setMenu(menu)
Ejemplo n.º 13
0
    def setupMenuTheme(self):
        # unfortunately Qt Designer doesn't support QActionGroup, we have to code it up
        actionTitleShortcuts = set()

        def actionTitle(title):
            shortcutFound = False
            ret = ''
            for c in title:
                l = c.lower()
                if not shortcutFound and l in 'abcdefghijklmnopqrstuvwxy' and l not in actionTitleShortcuts:
                    ret += '&'
                    actionTitleShortcuts.add(l)
                    shortcutFound = True
                ret += c
            return ret

        self.uiMenuThemeGroup = QtGui.QActionGroup(self.uiThemeMenu, exclusive=True)
        self.uiDarkThemeAct = QtGui.QAction(actionTitle("Dark Orange"), self)
        self.uiDarkThemeAct.setCheckable(True)
        self.uiDarkThemeAct.toggled.connect(ColorTheme.setDarkTheme)
        self.uiThemeMenu.addAction(self.uiMenuThemeGroup.addAction(self.uiDarkThemeAct))
        for k in QtGui.QStyleFactory.keys():
            act = QtGui.QAction(actionTitle(k), self)
            act.setCheckable(True)
            act.toggled.connect(self.setStyleCallback(k))
            self.uiThemeMenu.addAction(self.uiMenuThemeGroup.addAction(act))
            cleanname = self.buildInStyleToActionName(k)
            setattr(self, cleanname, act)
        self.uiCustomQssFileAct = QtGui.QAction(actionTitle("Custom Qss stylesheet"), self)
        self.uiCustomQssFileAct.triggered.connect(self.setCustomQss)
        self.uiThemeMenu.addAction(self.uiCustomQssFileAct)
Ejemplo n.º 14
0
    def createMenu(self):
        self.actionDateiOeffnen = QtGui.QAction(self.tr(u"Datei öffnen..."),
                                                self)
        self.actionDateiSpeichern = QtGui.QAction(self.tr(u"Speichern"), self)
        self.actionBeenden = QtGui.QAction(self.tr(u"Beenden"), self)
        self.actionBeenden.setMenuRole(QtGui.QAction.QuitRole)

        menuDatei = self.menuBar().addMenu(self.tr(u"Datei"))
        menuDatei.addAction(self.actionDateiOeffnen)
        menuDatei.addAction(self.actionDateiSpeichern)

        actiongroupAnsichten = QtGui.QActionGroup(self)
        #self.actionLinksAusrichten = QtGui.QAction(self.tr(u"Links Ausrichten"), self)
        self.actionLinksAusrichten = QtGui.QAction(
            self.tr(u"Links Ausrichten"), actiongroupAnsichten)
        self.actionLinksAusrichten.setCheckable(True)
        self.actionLinksAusrichten.setChecked(True)
        #self.actionRechtsAusrichten = QtGui.QAction(self.tr(u"Rechts Ausrichten"), self)
        self.actionRechtsAusrichten = QtGui.QAction(
            self.tr(u"Rechts Ausrichten"), actiongroupAnsichten)
        self.actionRechtsAusrichten.setCheckable(True)
        actiongroupAnsichten.setExclusive(False)

        menuAnsicht = menuDatei.addMenu(self.tr(u"Ansicht"))
        menuAnsicht.addAction(self.actionLinksAusrichten)
        menuAnsicht.addAction(self.actionRechtsAusrichten)

        menuDatei.addSeparator()
        menuDatei.addAction(self.actionBeenden)

        self.actionUeber = QtGui.QAction(self.tr(u"Über Hallo Welt..."), self)
        menuUeber = self.menuBar().addMenu(self.tr(u"Hilfe"))
        menuUeber.addAction(self.actionUeber)
Ejemplo n.º 15
0
 def setupMenuBar(self):
     self.fileMenu = self.menuBar().addMenu(self.tr("&File"))
     self.dateFormatMenu = self.fileMenu.addMenu(self.tr("&Date format"))
     self.dateFormatGroup = QtGui.QActionGroup(self)
     for f in self.dateFormats:
         action = QtGui.QAction(f, self, checkable = True, triggered = self.changeDateFormat)
         self.dateFormatGroup.addAction(action)
         self.dateFormatMenu.addAction(action)
         if f == self.currentDateFormat:
             action.setChecked(True)
             
     self.fileMenu.addAction(self.printAction)
     self.fileMenu.addAction(self.exitAction)
     self.cellMenu = self.menuBar().addMenu(self.tr("&Cell"))
     self.cellMenu.addAction(self.cell_addAction)
     self.cellMenu.addAction(self.cell_subAction)
     self.cellMenu.addAction(self.cell_mulAction)
     self.cellMenu.addAction(self.cell_divAction)
     self.cellMenu.addAction(self.cell_sumAction)
     self.cellMenu.addSeparator()
     self.cellMenu.addAction(self.colorAction)
     self.cellMenu.addAction(self.fontAction)
     self.menuBar().addSeparator()
     self.aboutMenu = self.menuBar().addMenu(self.tr("&Help"))
     self.aboutMenu.addAction(self.aboutSpreadSheet)
Ejemplo n.º 16
0
    def __init__(self,
                 initial_tab_width=None,
                 label_text=None,
                 onChanged=None,
                 *args):
        """Create tab width menu.
        @param label_text: text for label.
        @param onChanged: callback to processing tab width change.
        """
        QtGui.QMenu.__init__(self, *args)
        self.onChanged = onChanged
        if onChanged is None:
            self.onChanged = lambda settabwidth: None

        self.setTitle(label_text)

        self.action_group = QtGui.QActionGroup(self)

        self.tabwidth_actions = {}
        for tabwidth in range(MIN_TAB_WIDTH, MAX_TAB_WIDTH + 1):
            action = QtGui.QAction(str(tabwidth), self.action_group)
            action.setCheckable(True)
            action.setData(QtCore.QVariant(tabwidth))
            self.addAction(action)
            self.tabwidth_actions[tabwidth] = action

        self._tabwidth = None
        self._has_separator = False
        self.connect(self, QtCore.SIGNAL("triggered(QAction *)"),
                     self.triggered)

        if initial_tab_width is not None:
            self.setTabWidth(initial_tab_width)
            self.triggered(self.tabwidth_actions[initial_tab_width])
Ejemplo n.º 17
0
    def createActions(self):
        self.addImagesAct = QtGui.QAction("&Add Images...",
                                          self,
                                          shortcut="Ctrl+A",
                                          triggered=self.addImage)

        self.removeAllImagesAct = QtGui.QAction("&Remove All Images",
                                                self,
                                                shortcut="Ctrl+R",
                                                triggered=self.removeAllImages)

        self.exitAct = QtGui.QAction("&Quit",
                                     self,
                                     shortcut="Ctrl+Q",
                                     triggered=self.close)

        self.styleActionGroup = QtGui.QActionGroup(self)
        for styleName in QtGui.QStyleFactory.keys():
            action = QtGui.QAction(self.styleActionGroup,
                                   text="%s Style" % styleName,
                                   checkable=True,
                                   triggered=self.changeStyle)
            action.setData(styleName)

        self.guessModeStateAct = QtGui.QAction("&Guess Image Mode/State",
                                               self,
                                               checkable=True,
                                               checked=True)

        self.aboutAct = QtGui.QAction("&About", self, triggered=self.about)

        self.aboutQtAct = QtGui.QAction("About &Qt",
                                        self,
                                        triggered=QtGui.qApp.aboutQt)
Ejemplo n.º 18
0
    def createMenu(self):
        self.actionDateiOeffnen = QtGui.QAction(self.tr("Open File..."), self)
        self.actionDateiSpeichern = QtGui.QAction(self.tr("Save"), self)
        self.actionBeenden = QtGui.QAction(self.tr("Quit"), self)
        self.actionBeenden.setMenuRole(QtGui.QAction.QuitRole)

        menuDatei = self.menuBar().addMenu(self.tr("File"))
        menuDatei.addAction(self.actionDateiOeffnen)
        menuDatei.addAction(self.actionDateiSpeichern)

        actiongroupAnsichten = QtGui.QActionGroup(self)
        #self.actionLinksAusrichten = QtGui.QAction(self.tr("Align Left"), self)
        self.actionLinksAusrichten = QtGui.QAction(self.tr("Align Left"),
                                                   actiongroupAnsichten)
        self.actionLinksAusrichten.setCheckable(True)
        self.actionLinksAusrichten.setChecked(True)
        #self.actionRechtsAusrichten = QtGui.QAction(self.tr("Align Right"), self)
        self.actionRechtsAusrichten = QtGui.QAction(self.tr("Align Right"),
                                                    actiongroupAnsichten)
        self.actionRechtsAusrichten.setCheckable(True)
        actiongroupAnsichten.setExclusive(True)

        menuAnsicht = menuDatei.addMenu(self.tr("View"))
        menuAnsicht.addAction(self.actionLinksAusrichten)
        menuAnsicht.addAction(self.actionRechtsAusrichten)

        menuDatei.addSeparator()
        menuDatei.addAction(self.actionBeenden)

        self.actionUeber = QtGui.QAction(self.tr(u"About Hello World..."),
                                         self)
        menuUeber = self.menuBar().addMenu(self.tr(u"Help"))
        menuUeber.addAction(self.actionUeber)
Ejemplo n.º 19
0
    def _update_fft_frame_menu(self):
        """
        Initializes the menu that selects the frame to show in the fft filter
        panel.
        """
        self.fft_frame_menu.clear()
        fft_frames = QtGui.QActionGroup(self)

        selections = [-2, -1] + list(self.image.valid_frames_id)

        #if the default frame is no more present set the average as preselected
        if self.defaults.fft_frame_n in selections:
            active = self.defaults.fft_frame_n
        else:
            active = -1

        for frame_n in selections:
            #"no frame" and "average frame" are codified in the ImageLab class,
            #other frames are codified by their id
            if frame_n == -2:
                name = "None"
            elif frame_n == -1:
                name = "Average"
            else:
                name = str(frame_n)
            act = QtGui.QAction(name, self)
            act.triggered.connect(partial(self._select_fft_frame, frame_n))
            act.setCheckable(True)
            if frame_n == active:
                act.setChecked(True)
            fft_frames.addAction(act)

        self.fft_frame_menu.addActions(fft_frames.actions())
Ejemplo n.º 20
0
    def __init__(self,
                 initial_encoding=None,
                 label_text=None,
                 onChanged=None,
                 *args):
        """Create widget: label + combobox.
        @param initial_encoding: initially selected encoding (default: utf-8).
        @param label_text: text for label (default: "Encoding:").
        @param onChanged: callback to processing encoding change.
        @param args: additional arguments to initialize QWidget.
        """
        QtGui.QMenu.__init__(self, *args)
        self.init_encodings(initial_encoding)
        self.onChanged = onChanged
        if onChanged is None:
            self.onChanged = lambda encoding: None

        self.setTitle(label_text)

        self.action_group = QtGui.QActionGroup(self)

        self.encoding_actions = {}
        for encoding in self.encodings:
            action = QtGui.QAction(encoding, self.action_group)
            action.setCheckable(True)
            action.setData(QtCore.QVariant(encoding))
            self.addAction(action)
            self.encoding_actions[encoding] = action

        self._setEncoding(self.encoding)
        self.connect(self, QtCore.SIGNAL("triggered(QAction *)"),
                     self.triggered)
Ejemplo n.º 21
0
    def __init__(self, parent):
        QtGui.QWidget.__init__(self)
        self.tray = QtGui.QSystemTrayIcon(self)
        self.trayMenu = QtGui.QMenu()
        self.optionsMenu = QtGui.QMenu()
        self.optionsGroup = QtGui.QActionGroup(self)
        self.appWindow = parent

        self.action_quit = QtGui.QAction(
            QtGui.QIcon("../../data/gtk-quit.png"), u'Çık', self)
        self.action_options = QtGui.QAction(
            QtGui.QIcon("../../data/options.png"), u'Seçenekler', self)
        self.action_alwaysJoin = QtGui.QAction(u'Her Zaman', self)
        self.action_alwaysJoin.setCheckable(True)
        self.action_askToJoin = QtGui.QAction(u'Katılmadan Sor', self)
        self.action_askToJoin.setCheckable(True)
        self.action_rejectJoin = QtGui.QAction(u'Katılma', self)
        self.action_rejectJoin.setCheckable(True)

        self.trayMenu.addAction(self.action_options)
        self.trayMenu.addAction(self.action_quit)

        self.action_options.setMenu(self.optionsMenu)
        self.optionsGroup.addAction(self.action_alwaysJoin)
        self.optionsGroup.addAction(self.action_askToJoin)
        self.optionsGroup.addAction(self.action_rejectJoin)
        self.optionsMenu.addAction(self.action_alwaysJoin)
        self.optionsMenu.addAction(self.action_askToJoin)
        self.optionsMenu.addAction(self.action_rejectJoin)

        self.connect(self.action_quit, QtCore.SIGNAL("triggered()"), self.quit)
        self.connect(self.action_options, QtCore.SIGNAL("triggered()"),
                     self.setActions)

        self.setDefaultOptions()

        self.connect(self.action_alwaysJoin, SIGNAL("triggered()"),
                     self.setGlobalParticipation)
        self.connect(self.action_askToJoin, SIGNAL("triggered()"),
                     self.setGlobalParticipation)
        self.connect(self.action_rejectJoin, SIGNAL("triggered()"),
                     self.setGlobalParticipation)

        self.defaultIcon = QtGui.QIcon("../data/user_study.png")
        self.countIcon = QtGui.QIcon("")
        self.lastIcon = self.defaultIcon
        self.tray.setIcon(self.defaultIcon)
        self.tray.setContextMenu(self.trayMenu)
        self.tray.show()

        self.unread = 0  #number of updates

        self.tray.showMessage(u"User Study",
                              u"There's a problem that I could not solve",
                              QtGui.QSystemTrayIcon.Information, 8000)

        self.checkUpdates()

        self.tray.activated.connect(self.__activated)
Ejemplo n.º 22
0
    def __init__(self, pType, parent=None):
        """ QParameterEditorSelector(pType: str, parent: QWidget)
                                     -> QParameterEditorSelector
        Put a stacked widget and a popup button
        
        """
        QtGui.QToolButton.__init__(self, parent)
        self.type = pType
        self.setAutoRaise(True)
        self.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly)
        menu = QtGui.QMenu(self)

        self.setPopupMode(QtGui.QToolButton.InstantPopup)

        if pType == 'String':
            self.setText(QtCore.QString(QtCore.QChar(0x25bc)))  # Down triangle
            self.operationActionGroup = QtGui.QActionGroup(self)
            self.containAction = self.operationActionGroup.addAction('Contain')
            self.containAction.setCheckable(True)

            self.exactAction = self.operationActionGroup.addAction('Exact')
            self.exactAction.setCheckable(True)

            self.regAction = self.operationActionGroup.addAction('Reg Exp')
            self.regAction.setCheckable(True)
            menu.addActions(self.operationActionGroup.actions())
            menu.addSeparator()

            self.caseActionGroup = QtGui.QActionGroup(self)
            self.sensitiveAction = self.caseActionGroup.addAction(
                'Case Sensitive')
            self.sensitiveAction.setCheckable(True)

            self.insensitiveAction = self.caseActionGroup.addAction(
                'Case Insensitive')
            self.insensitiveAction.setCheckable(True)
            menu.addActions(self.caseActionGroup.actions())

        else:
            self.setText('')  # Down triangle
            self.operationActionGroup = QtGui.QActionGroup(self)
            self.expAction = self.operationActionGroup.addAction('Expression')
            self.expAction.setCheckable(True)
            self.setEnabled(False)

        self.setMenu(menu)
Ejemplo n.º 23
0
    def onImageSceneContext(self, imageScene, pos):
        menu = QtGui.QMenu('Labeling menu', self)
       
        labelList = []
        
        volumeLabel = self.volumeEditor.labelWidget.volumeLabelDescriptions

        act = menu.addAction("Labels")
        act.setEnabled(False)
        font = QtGui.QFont( "Helvetica", 10, QtGui.QFont.Bold, True)
        act.setFont(font)
        
        for index, item in enumerate(volumeLabel):
            labelColor = QtGui.QColor.fromRgb(long(item.color))
            labelIndex = item.number
            labelName = item.name
            pixmap = QtGui.QPixmap(16, 16)
            pixmap.fill(labelColor)
            icon = QtGui.QIcon(pixmap)
            
            act = QtGui.QAction(icon, labelName, menu)
            i = imageScene.volumeEditor.labelWidget.listWidget.model().index(labelIndex-1,0)
            # print self.volumeEditor.labelView.selectionModel()
            imageScene.connect(act, QtCore.SIGNAL("triggered()"), lambda i=i: imageScene.onContextSetLabel(i))
            labelList.append(menu.addAction(act))
            
        if imageScene.drawManager.erasing is False:
            eraseAct = QtGui.QAction("Enable eraser", menu)
            menu.addAction(eraseAct)
            imageScene.connect(eraseAct, QtCore.SIGNAL("triggered()"), lambda: imageScene.drawManager.toggleErase())
        else:
            eraseAct = QtGui.QAction("Disable eraser", menu)
            menu.addAction(eraseAct)
            imageScene.connect(eraseAct, QtCore.SIGNAL("triggered()"), lambda: imageScene.drawManager.toggleErase())
            
        menu.addSeparator()
        # brushM = labeling.addMenu("Brush size")
        brushGroup = QtGui.QActionGroup(self)

        act = menu.addAction("Brush Sizes")
        act.setEnabled(False)
        font = QtGui.QFont( "Helvetica", 10, QtGui.QFont.Bold, True)
        act.setFont(font)
        menu.addSeparator()
        
        defaultBrushSizes = [(1, ""), (3, " Tiny"),(5, " Small"),(7, " Medium"),(11, " Large"),(23, " Huge"),(31, " Megahuge"),(61, " Gigahuge")]
        brush = []
        for ind, bSizes in enumerate(defaultBrushSizes):
            b = bSizes[0]
            desc = bSizes[1]
            act = QtGui.QAction("  " + str(b) + desc, brushGroup)
            act.setCheckable(True)
            imageScene.connect(act, QtCore.SIGNAL("triggered()"), lambda b=b: imageScene.drawManager.setBrushSize(b))
            if b == imageScene.drawManager.getBrushSize():
                act.setChecked(True)
            brush.append(menu.addAction(act))
        
        action = menu.exec_(QtGui.QCursor.pos())
Ejemplo n.º 24
0
    def __init__(self, parent=None, standardActions=DefaultActions, **kwargs):
        super().__init__(parent, **kwargs)
        self.__standardActions = standardActions
        self.__actions = {}
        self.__tools = {}
        self.__viewBox = None
        self.__currentTool = None
        self.__toolgroup = QtGui.QActionGroup(self, exclusive=True)

        def on_toolaction(action):
            tool = action.property("tool")
            if self.__currentTool is not None:
                self.__currentTool.setViewBox(None)
            self.__currentTool = tool
            if tool is not None:
                tool.setViewBox(self.__viewBox)
                self.__viewBox.setCursor(tool.cursor)

        self.__toolgroup.triggered[QtGui.QAction].connect(on_toolaction)

        def icon(name):
            path = "icons/Dlg_{}.png".format(name)
            path = pkg_resources.resource_filename(widget.__name__, path)
            return QtGui.QIcon(path)

        isfirsttool = True
        for flag in PlotToolBox.StandardActions:
            if standardActions & flag:
                _text, _iconname, _keyseq = self.ActionData[flag]

                action = QtGui.QAction(
                    _text, self, icon=icon(_iconname),
                    shortcut=QtGui.QKeySequence(_keyseq)
                )

                self.__actions[flag] = action

                if flag & PlotToolBox.ExclusiveMask:
                    action.setCheckable(True)
                    self.__toolgroup.addAction(action)

                    if flag == self.SelectTool:
                        tool = linproj.PlotSelectionTool(self)
                        tool.cursor = Qt.ArrowCursor
                    elif flag == self.ZoomTool:
                        tool = linproj.PlotZoomTool(self)
                        tool.cursor = Qt.ArrowCursor
                    elif flag == self.PanTool:
                        tool = linproj.PlotPanTool(self)
                        tool.cursor = Qt.OpenHandCursor

                    self.__tools[flag] = tool
                    action.setProperty("tool", tool)

                    if isfirsttool:
                        action.setChecked(True)
                        self.__currentTool = tool
                        isfirsttool = False
Ejemplo n.º 25
0
    def _create_actions(self):
        tabGroup = QtGui.QActionGroup(self)

        self.overviewAction = QtGui.QAction(QtGui.QIcon(':icons/overview.png'),
                                            _("&Overview"), self)
        self.overviewAction.setStatusTip(_("Show general overview of wallet"))
        self.overviewAction.setToolTip(self.overviewAction.statusTip())
        self.overviewAction.setCheckable(True)
        self.overviewAction.setChecked(True)
        self.overviewAction.triggered.connect(self.show_normal_if_minimized)
        self.overviewAction.triggered.connect(
            lambda: self.centralWidget().setCurrentWidget(self.overviewpage))
        tabGroup.addAction(self.overviewAction)

        self.sendAction = QtGui.QAction(QtGui.QIcon(':icons/send.png'),
                                        _("&Send"), self)
        self.sendAction.setStatusTip(_("Send coins to another address"))
        self.sendAction.setToolTip(self.sendAction.statusTip())
        self.sendAction.setCheckable(True)
        self.sendAction.triggered.connect(self.show_normal_if_minimized)
        self.sendAction.triggered.connect(
            lambda: self.centralWidget().setCurrentWidget(self.sendpage))
        tabGroup.addAction(self.sendAction)

        self.chatAction = QtGui.QAction(QtGui.QIcon(':icons/chat.png'),
                                        _("&Chat"), self)
        self.chatAction.setStatusTip(_("Show chromaclub chat"))
        self.chatAction.setToolTip(self.chatAction.statusTip())
        self.chatAction.setCheckable(True)
        self.chatAction.triggered.connect(self.show_normal_if_minimized)
        self.chatAction.triggered.connect(
            lambda: self.centralWidget().setCurrentWidget(self.chatpage))
        tabGroup.addAction(self.chatAction)

        self.openChromaWalletAction = QtGui.QAction(
            QtGui.QIcon(':icons/chromawallet.png'),
            _("Open current wallet in ChromaWallet"), self)
        self.openChromaWalletAction.setStatusTip(
            _("Open current wallet in ChromaWallet"))
        self.openChromaWalletAction.setToolTip(
            self.openChromaWalletAction.statusTip())
        self.openChromaWalletAction.triggered.connect(self._open_chromawallet)

        self.quitAction = QtGui.QAction(QtGui.QIcon(':icons/exit.png'),
                                        _("E&xit"), self)
        self.quitAction.setStatusTip(_("Quit application"))
        self.quitAction.setToolTip(self.quitAction.statusTip())
        self.quitAction.setShortcut(
            QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Q))
        self.quitAction.setMenuRole(QtGui.QAction.QuitRole)
        self.quitAction.triggered.connect(self._app.quit)

        self.toggleHideAction = QtGui.QAction(
            QtGui.QIcon(':icons/chromaclub.png'), _("&Show / Hide"), self)
        self.toggleHideAction.setStatusTip(_("Show or hide the main Window"))
        self.toggleHideAction.triggered.connect(
            lambda *args: self.show_normal_if_minimized(*
                                                        (list(args) + [True])))
Ejemplo n.º 26
0
    def createActions(self):
        ''' Создание действий к кнопкам '''

        self.setingsAct = QtGui.QAction(u"&Настройки",
                                        self,
                                        shortcut="Ctrl+P",
                                        statusTip=u"Настройки приложения",
                                        triggered=self.configWindow)

        self.exitAct = QtGui.QAction(u"&Выход",
                                     self,
                                     shortcut="Ctrl+Q",
                                     statusTip=u"Выход из приложения",
                                     triggered=self.close)

        self.aboutAct = QtGui.QAction(
            u"&О программе",
            self,
            shortcut="F1",
            statusTip=u"Показать информацию о программе",
            triggered=self.about)

        self.aboutQtAct = QtGui.QAction(
            u"О &PyQt4",
            self,
            statusTip=u"Показать информацию о библиотеке Qt4",
            triggered=QtGui.qApp.aboutQt)

        self.chatAct = QtGui.QAction(u"Рассылка в &чат",
                                     self,
                                     checkable=True,
                                     shortcut="Ctrl+1",
                                     statusTip=u"Запуск рассылки в чат",
                                     triggered=self.menuModeSelected)

        self.admAct = QtGui.QAction(u"Рассылка &поклонникам",
                                    self,
                                    checkable=True,
                                    shortcut="Ctrl+2",
                                    statusTip=u"Запуск рассылки поклонникам",
                                    triggered=self.menuModeSelected)

        self.runAct = QtGui.QAction(u"&Старт",
                                    self,
                                    shortcut="Ctrl+Enter",
                                    statusTip=u"Запуск рассылки",
                                    triggered=self.on_start)

        self.stopAct = QtGui.QAction(u"&Стоп",
                                     self,
                                     shortcut="Escape",
                                     statusTip=u"Остановка рассылки",
                                     triggered=self.on_stop)

        self.actionGroup = QtGui.QActionGroup(self)
        self.actionGroup.addAction(self.chatAct)
        self.actionGroup.addAction(self.admAct)
        self.admAct.setChecked(True)
Ejemplo n.º 27
0
 def viewActionGroup(self):
     """ viewActionGroup() -> None        
     A group for all view actions in order to have only one
     selected at a time
     
     """
     if not hasattr(self, '_viewActionGroup'):
         self._viewActionGroup = QtGui.QActionGroup(self)
     return self._viewActionGroup
Ejemplo n.º 28
0
 def initActions(self, actions):
     for key, actiondef in actions.items():
         if isinstance(actiondef, dict):
             self.actions[key] = QtGui.QActionGroup(self)
             for gkey, gactiondef in actiondef.items():
                 self.initAction(gkey, gactiondef, self.actions[key])
                 self.actions[gkey].setCheckable(True)
         else:
             self.initAction(key, actiondef, self)
Ejemplo n.º 29
0
 def cursorActionGroup(self):
     """ cursorActionGroup() -> None        
     A group for all cursor actions in order to have only one
     selected at a time
     
     """
     if not hasattr(self, '_cursorActionGroup'):
         self._cursorActionGroup = QtGui.QActionGroup(self)
     return self._cursorActionGroup
Ejemplo n.º 30
0
def _menu_for_measurement(a_measurement, parent):
    m = QtGui.QMenu(a_measurement.name, parent)
    g = QtGui.QActionGroup(m)

    for u in a_measurement.units:
        a = _action_for_unit(u, m)
        g.addAction(a)
        m.addAction(a)

    return m