Ejemplo n.º 1
0
def prefMenuItem_radioButtons(preferenceName,
                              labelList,
                              defaultIndex,
                              menu,
                              command=None,
                              font=None):
    """Adds a set of radio buttons to the menu, who's value selection gets stored as
    a preference"""

    actionGroup = QtGui.QActionGroup(menu)
    actionGroup.setExclusive(True)
    defaultIndex = ka_preference.get(preferenceName, defaultIndex)

    for i, label in enumerate(labelList):
        action = actionGroup.addAction(label)
        action.setCheckable(True)
        if font:
            action.setFont(font)

        if i == defaultIndex:
            action.setChecked(True)

        def cmd(i=i, preferenceName=preferenceName, command=command):
            ka_preference.set(preferenceName, i)
            if command != None:
                command()

        menu.connect(action, QtCore.SIGNAL('triggered()'), cmd)
        menu.addAction(action)

    return actionGroup
Ejemplo n.º 2
0
 def __init__(self):
     loader = QUiLoader()
     filePath = os.path.join(os.path.dirname(__file__), 'bug_426.ui')
     self.widget = loader.load(filePath)
     self.group = QtGui.QActionGroup(self.widget)
     self.widget.show()
     QtCore.QTimer.singleShot(0, self.widget.close)
Ejemplo n.º 3
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.º 4
0
    def __init__(self, *args, **kwargs):
        super(LayerToggleGroup, self).__init__(*args, **kwargs)
        self.actions = {}
        self.actionGroup = QtGui.QActionGroup(self)
        self.actionGroup.setExclusive(False)
        self.options = {}
        for layer in Layer.AllLayers:
            option = LayerToggleOptions.getOption("%s_visible" % layer, bool,
                                                  True)
            self.options[layer] = option

            action = QtGui.QAction(layer, self)
            action.setCheckable(True)
            action.setChecked(option.value())
            log.info("LAYER %s VISIBLE %s", layer, option.value())
            action.layerName = layer
            self.actions[layer] = action
            self.actionGroup.addAction(action)

        self.actionGroup.triggered.connect(self.actionTriggered)

        self.menu = QtGui.QMenu()

        for layer in Layer.AllLayers:
            self.menu.addAction(self.actions[layer])
Ejemplo n.º 5
0
    def ViewMenu(self):
        font = QtGui.QAction(QtGui.QIcon('exit.png'), '&Font', self)
        font.setShortcut('Shift+F')
        font.triggered.connect(self.fontEdit)

        viewmenu = self.menu.addMenu('&View')
        viewmenu.addAction(font)

        syntaxMenu = viewmenu.addMenu('&Syntax Highlighting')
        self.group = QtGui.QActionGroup(self, exclusive=True)
        self.checkdefault = self.group.addAction(
            QtGui.QAction('&None', self, checkable=True))
        self.checkdefault.setChecked(True)
        syntaxMenu.addAction(self.checkdefault)
        self.checkpython = self.group.addAction(
            QtGui.QAction('&Python', self, checkable=True))
        syntaxMenu.addAction(self.checkpython)
        self.checkc = self.group.addAction(
            QtGui.QAction('&C/C++', self, checkable=True))
        syntaxMenu.addAction(self.checkc)
        self.checkhtml = self.group.addAction(
            QtGui.QAction('&HTML', self, checkable=True))
        syntaxMenu.addAction(self.checkhtml)
        self.checkmkd = self.group.addAction(
            QtGui.QAction('&Markdown', self, checkable=True))
        syntaxMenu.addAction(self.checkmkd)
        self.checkc.triggered.connect(self.changeHighlightToC)
        self.checkpython.triggered.connect(self.changeHighlightToPython)
        self.checkhtml.triggered.connect(self.changeHighlightToHtml)
        self.checkmkd.triggered.connect(self.changeHighlightToMkd)
        self.checkdefault.triggered.connect(self.removeHighlight)
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        QtGui.QMainWindow.__init__(self)

        w = QtGui.QWidget()
        self.setCentralWidget(w)
        self.resize(800,600)
        self.setWindowTitle('Simple')

        fileMenu = self.menuBar().addMenu('&File')
        optMenu = self.menuBar().addMenu('&Options')

        self.addToMenu(fileMenu, '&New', lambda: self.new())
        self.addToMenu(fileMenu, '&Open...', lambda: self.openConf())
        self.addToMenu(fileMenu, '&Save', lambda: self.saveConf(True))
        self.addToMenu(fileMenu, 'Save &as...', lambda: self.saveConf(False))
        self.addToMenu(fileMenu, '&Quit', self.close)

        optLevelGroup = QtGui.QActionGroup(optMenu)
        a = self.addToMenu(optMenu, '&Basic',
                           lambda: self.setLevel(0), optLevelGroup)
        self.addToMenu(optMenu, '&Advanced',
                       lambda: self.setLevel(1), optLevelGroup)
        self.addToMenu(optMenu, '&Expert',
                       lambda: self.setLevel(2), optLevelGroup)
        a.setChecked(True)

        self.level = 0
        self.confFileName = None
        if len(args) == 2:
            self.new(args[1])
        else:
            self.new()
Ejemplo n.º 7
0
    def __init__(self, session=None, parent=None):
        '''Main window that holds all GUI pieces.'''
        super(MainWindow, self).__init__(parent)

        # -- Functional members --
        self.session = session
        self.regActionGroup = QtGui.QActionGroup(self) # Registration actions 
        self.fitAtStart = True # Fit image to window at start (or not)

        # -- Widget members --
        self.imageViewer = imageviewer.ImageViewer(self, fit=self.fitAtStart)
        self.imhist = histogram.HistogramEditor() # If parent=self, it will be non-window child
        
        # -- Intialize graphical interface --
        self.init_ui()

        # -- If session already has images, show them --
        if session.loaded:
            # FIXME: initialization should be automatic inside imageViewer
            #        maybe by checking a flag (reset when loading data)
            self.imageViewer.initialize(self.session.get_current_image())
            self.set_image()

        # -- Connect signals --
        self.imhist.sliders.sliderMoved.connect(self.change_levels)
Ejemplo n.º 8
0
    def create_connections(self):

        # Define group to action fit items and load fit of settings file
        self.ui.action_group_view = QtGui.QActionGroup(self)

        self.ui.action_group_view.addAction(self.ui.action_original_fit)
        self.ui.action_group_view.addAction(self.ui.action_vertical_fit)
        self.ui.action_group_view.addAction(self.ui.action_horizontal_fit)
        self.ui.action_group_view.addAction(self.ui.action_best_fit)

        view_adjust = self.model.load_view_adjust(
            self.ui.action_group_view.checkedAction().objectName())

        # Define that action fit is checked
        for act in self.ui.action_group_view.actions():
            if act.objectName() == view_adjust:
                act.setChecked(True)
                self.model.fit_type = act.objectName()

        # Connect recent file menu
        for act in self.ui.menu_recent_files.actions():
            act.triggered.connect(self.open_recent_file)

        # Connect recent bookmark menu
        for act in self.ui.menu_recent_bookmarks.actions():
            act.triggered.connect(self.open_recent_bookmark)

        # update recent bookmark menu when mouse hover
        self.ui.menu_recent_bookmarks.aboutToShow.connect(
            self.update_recent_bookmarks_menu)
Ejemplo n.º 9
0
    def __init__(self):
        """
            Create toolbar and invoke pressing of first tab.
        """
        super().__init__()

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        # create tool bar
        toolbar = QtGui.QToolBar()
        action_group = QtGui.QActionGroup(toolbar)

        toolbar.addAction(g.create_action(t.load_ui_icon('icon.lobby.single.new.png'), 'Start new single player scenario', action_group, toggle_connection=self.toggled_single_player_scenario_selection, checkable=True))
        toolbar.addAction(g.create_action(t.load_ui_icon('icon.lobby.single.load.png'), 'Continue saved single player scenario', action_group, toggle_connection=self.toggled_single_player_load_scenario, checkable=True))

        toolbar.addSeparator()

        toolbar.addAction(g.create_action(t.load_ui_icon('icon.lobby.network.png'), 'Show server lobby', action_group, toggle_connection=self.toggled_server_lobby, checkable=True))
        toolbar.addAction(g.create_action(t.load_ui_icon('icon.lobby.multiplayer-game.png'), 'Start or continue multiplayer scenario', action_group, toggle_connection=self.toggled_multiplayer_scenario_selection, checkable=True))

        layout.addWidget(toolbar)

        content = QtGui.QWidget()
        self.content_layout = QtGui.QVBoxLayout(content)
        self.content_layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(content)
Ejemplo n.º 10
0
    def setupGUI(self):
        pg.setConfigOption('background', (255, 255, 255))
        pg.setConfigOption('foreground', (0, 0, 0))
        self.layout = QtGui.QVBoxLayout()
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.layout)
        # menu
        self.menuBar = QtGui.QMenuBar()
        self.layout.setMenuBar(self.menuBar)
        # menu actions
        self.viewMenu = self.menuBar.addMenu('View')
        self.parMenu = self.viewMenu.addMenu('Parameter')
        self.plotVsMenu = self.viewMenu.addMenu('Plot versus')
        self.plotVsXAction = QtGui.QAction('x', self, checkable=True)
        self.plotVsYAction = QtGui.QAction('y', self, checkable=True)
        self.plotVsGroup = QtGui.QActionGroup(self)
        self.plotVsXAction.setActionGroup(self.plotVsGroup)
        self.plotVsYAction.setActionGroup(self.plotVsGroup)
        self.plotVsMenu.addAction(self.plotVsXAction)
        self.plotVsMenu.addAction(self.plotVsYAction)
        self.plotVsXAction.setChecked(True)
        self.autoScaleAction = QtGui.QAction('Auto scale',
                                             self,
                                             checkable=True)
        self.autoScaleAction.setChecked(True)
        self.viewMenu.addAction(self.autoScaleAction)
        self.parameterGroup = QtGui.QActionGroup(self)
        # widgets
        splitter = QtGui.QSplitter()
        splitter.setOrientation(QtCore.Qt.Horizontal)
        self.tree = CParameterTree(name='Elastic moduli')

        self.sublayout = pg.GraphicsLayoutWidget()
        #
        self.layout.addWidget(splitter)
        splitter.addWidget(self.tree)
        splitter.addWidget(self.sublayout)
        self.plt = self.sublayout.addPlot()
        setupPlot.setup_plot(self.plt)
        #
        self.tree.setGeometry(0, 0, 200, 15)
        splitter.setSizes([
            int(self.width() * 0.4),
            int(self.width() * 0.6),
        ])
        splitter.setStretchFactor(0, 0)
        splitter.setStretchFactor(1, 1)
Ejemplo n.º 11
0
 def create_action(self,i):
     amp_group = QtGui.QActionGroup(self)
     five = QtGui.QAction(amp_group, checkable=True)
     five.setText('500')
     ten = QtGui.QAction(amp_group, checkable=True, checked=True)
     ten.setText('1000')
     amp_group.triggered.connect(lambda button: self.change_amp(button, i))
     return amp_group, five, ten
Ejemplo n.º 12
0
    def __initUI__(self):
        self.ui = Ui_mapcreater()
        self.ui.setupUi(self)

        g1 = QtGui.QActionGroup(self)
        g1.addAction(self.ui.actionDrawMap)
        g1.addAction(self.ui.actionDrawRoute)

        g2 = QtGui.QActionGroup(self)
        g2.addAction(self.ui.actionEraser)
        g2.addAction(self.ui.actionPen)

        self.sa = QtGui.QScrollArea()
        self.sa.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.sa.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.sa.setWidgetResizable(False)

        self.mc = MapCanvas(self.sa)
        self.sa.setWidget(self.mc)

        self.setCentralWidget(self.sa)
        self.centralWidget().setAlignment(QtCore.Qt.AlignCenter)
 def _setQActionGroup(self,menu,enum):
      #Set Menu Saves Config File Chackable
     indexes = menu.actions()
     menu.clear()
     print len(indexes)
     group = QtGui.QActionGroup(self.ui)
     mapper = QtCore.QSignalMapper()  
     group.setExclusive(True)
     
     for item in enum.names.items():
         index = QtGui.QAction(item[0],group)            
         index.setCheckable(True)
         index.triggered.connect(mapper.map)
         mapper.setMapping(index,item[1])            
         group.addAction(index) 
     return group,mapper
Ejemplo n.º 14
0
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        self.currentPath = ""

        self.area = SvgWindow()

        fileMenu = QtGui.QMenu(self.tr("&File"), self)
        self.openAction = fileMenu.addAction(self.tr("&Open..."))
        self.openAction.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+O")))
        self.quitAction = fileMenu.addAction(self.tr("E&xit"))
        self.quitAction.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+Q")))

        self.menuBar().addMenu(fileMenu)

        rendererMenu = QtGui.QMenu(self.tr("&Renderer"), self)
        self.nativeAction = rendererMenu.addAction(self.tr("&Native"))
        self.nativeAction.setCheckable(True)

        if QtOpenGL.QGLFormat.hasOpenGL():
            self.glAction = rendererMenu.addAction(self.tr("&OpenGL"))
            self.glAction.setCheckable(True)

        self.imageAction = rendererMenu.addAction(self.tr("&Image"))
        self.imageAction.setCheckable(True)
        self.imageAction.setChecked(True)

        rendererGroup = QtGui.QActionGroup(self)
        rendererGroup.addAction(self.nativeAction)

        if QtOpenGL.QGLFormat.hasOpenGL():
            rendererGroup.addAction(self.glAction)

        rendererGroup.addAction(self.imageAction)

        self.menuBar().addMenu(rendererMenu)

        self.connect(self.openAction, QtCore.SIGNAL("triggered()"),
                     self.openFile)
        self.connect(self.quitAction, QtCore.SIGNAL("triggered()"), QtGui.qApp,
                     QtCore.SLOT("quit()"))
        self.connect(rendererGroup, QtCore.SIGNAL("triggered(QAction *)"),
                     self.setRenderer)

        self.setCentralWidget(self.area)
        self.setWindowTitle(self.tr("SVG Viewer"))
Ejemplo n.º 15
0
def init_draft_statusbar_scale():
    """
    this function initializes draft statusbar scale widget
    """
    param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")

    mw = Gui.getMainWindow()
    if mw:
        sb = mw.statusBar()
        if sb is None:
            return
    else:
        return

    scale_widget = QtGui.QToolBar()
    scale_widget.setObjectName("draft_status_scale_widget")

    # get scales list according to system units
    draft_scales = get_scales()

    # get draft annotation scale
    draft_annotation_scale = param.GetFloat("DraftAnnotationScale", 1.0)

    # initializes scale widget
    scale_widget.draft_scales = draft_scales
    scaleLabel = QtGui.QPushButton("Scale")
    scaleLabel.setObjectName("ScaleLabel")
    scaleLabel.setFlat(True)
    menu = QtGui.QMenu(scaleLabel)
    gUnits = QtGui.QActionGroup(menu)
    for u in draft_scales:
        a = QtGui.QAction(gUnits)
        a.setText(u)
        menu.addAction(a)
    scaleLabel.setMenu(menu)
    gUnits.triggered.connect(_set_scale)
    scale_label = scale_to_label(draft_annotation_scale)
    scaleLabel.setText(scale_label)
    tooltip = "Set the scale used by draft annotation tools"
    scaleLabel.setToolTip(QT_TRANSLATE_NOOP("draft", tooltip))
    scale_widget.addWidget(scaleLabel)
    scale_widget.scaleLabel = scaleLabel

    # add scale widget to the statusbar
    sb.insertPermanentWidget(3, scale_widget)
    scale_widget.show()
Ejemplo n.º 16
0
 def makePlotMenu(self, name, plots, style_fn):
   if not len(plots):
     return
   menu = QtGui.QMenu(name, self.lineStyleMenu)
   group = QtGui.QActionGroup(act)
   action = QtGui.QAction("All", group)
   action.triggered.connect(lambda: AllLineStyleDialog(self, name, self.getCanvas(), plots, style_fn).exec_())
   group.addAction(action)
   sep = QtGui.QAction(group)
   sep.setSeparator(True)
   group.addAction(sep)
   for y in plots:
     style = style_fn(y)
     action = QtGui.QAction(style.label, group)
     action.triggered.connect(lambda yin=y,stylein=style: LineStyleDialog(self, yin, self.getCanvas(), stylein, style_fn).exec_())
     group.addAction(action)
   menu.addActions(group.actions())
   self.lineStyleMenu.addMenu(menu)
Ejemplo n.º 17
0
    def init_ui(self):
        self.resize(800, 700)
        self.setContentsMargins(10, 10, 10, 10)
        self.setWindowTitle('Mine Bash')

        filemenu = self.menuBar().addMenu('File')
        self.open = filemenu.addAction('Open')
        self.save = filemenu.addAction('Save')

        self.tabs = QtGui.QTabWidget(self)
        self.setCentralWidget(self.tabs)

        self.tools = QtGui.QToolBar(self)
        self.addToolBar(self.tools)

        # selection tools

        self.seltools = QtGui.QActionGroup(self.tools)

        self.brush = self.tools.addAction('Brush')
        self.brush.setCheckable(1)
        self.seltools.addAction(self.brush)

        self.box = self.tools.addAction('Box')
        self.box.setCheckable(1)
        self.seltools.addAction(self.box)

        # clipboard tools

        self.tools.addSeparator()

        self.copybtn = self.tools.addAction('Copy')
        self.pastebtn = self.tools.addAction('Paste')
        self.mergebtn = self.tools.addAction('Merge')
        self.cancelbtn = self.tools.addAction('Cancel Merge')

        # status bar

        self.status = self.statusBar()
        self.status.setSizeGripEnabled(0)
        self.status.setContentsMargins(10, 0, 10, 0)

        self.copylabel = QtGui.QLabel('')
        self.status.addWidget(self.copylabel)
Ejemplo n.º 18
0
    def __init__(self, parent=None):
        super(TexManagerUI, self).__init__(parent=parent)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.coordinator = CoordinatorMayaUI()
        self.clipboard = None

        uiAGR_selectionBehaviour = QtGui.QActionGroup(self)
        self.ui.uiACT_selectNothing.setActionGroup(uiAGR_selectionBehaviour)
        self.ui.uiACT_selectTextureNode.setActionGroup(
            uiAGR_selectionBehaviour)
        self.ui.uiACT_selectAssigned.setActionGroup(uiAGR_selectionBehaviour)

        self.searchReplaceDlg = SearchReplaceDialog(self)
        self.retargetDlg = RetargetDialog(self)
        self.copyMoveDlg = CopyMoveDialog(self)
        self.logDlg = LogDialog(self)

        self.createContextMenu()

        self.ui_initSettings()

        self.setUpdatesAllowed(False)
        self.ui_loadSettings(self.ui.uiACT_collapseRepetitions)
        self.setUpdatesAllowed(True)

        self.harvester = MayaSceneHarvester()

        self.setTableDelegates()
        self.initModels()
        self.fillTable()

        self.ui_loadSettings()

        self.connect(
            self.ui.uiTBL_textures.selectionModel(),
            QtCore.SIGNAL('selectionChanged(QItemSelection, QItemSelection)'),
            self.onTableSelectionChanged)

        self.displayStatusBarInfo()
        self.updateUiStates()
Ejemplo n.º 19
0
    def __init__(self, parent=None, f=QtCore.Qt.WindowFlags()):
        """ SpreadsheetWindow(parent: QWidget, f: WindowFlags)
                              -> SpreadsheetWindow
        Layout menu, status bar and tab widget

        """
        QtGui.QMainWindow.__init__(self, parent, f)
        self.setWindowTitle('UV-CDAT - Untitled')
        self.shownConfig = False  #flag to control the window setup code is done only once
        # The stack of current spreadsheets
        self.stackedCentralWidget = QtGui.QStackedWidget(self)
        # The controller that handles the spreadsheets
        self.tabControllerStack = TabControllerStack(self.stackedCentralWidget)
        # FIXME: Temprary create view for now
        self.tabControllerStack.add_view('Default')
        self.stackedCentralWidget.addWidget(self.tabControllerStack)
        # Do we need fullscreen?
        self.fullScreenStackedWidget = QtGui.QStackedWidget(
            self.stackedCentralWidget)
        self.stackedCentralWidget.addWidget(self.fullScreenStackedWidget)
        self.setCentralWidget(self.stackedCentralWidget)
        self.setStatusBar(QtGui.QStatusBar(self))
        self.modeActionGroup = QtGui.QActionGroup(self)

        self.App = QtCore.QCoreApplication.instance()
        self.App.installEventFilter(self)

        self.setupMenu()

        self.tabControllerStack.needChangeTitle.connect(self.setWindowTitle)

        self.quitAction = QtGui.QAction('&Quit Spreadsheet', self)
        self.addAction(self.quitAction)
        self.quitAction.setShortcut('Ctrl+Q')
        self.quitAction.triggered.connect(self.quitActionTriggered)

        # if the spreadsheet has one row and 2 columns
        # this will cause the spreadsheet to have each cell
        # 550 x 450 size in the server
        #self.resize(1156, 599)

        # FIXME: remove test
        self.testPlot()
Ejemplo n.º 20
0
 def __init__(self):
     QtCore.QObject.__init__(self)
     elements = utils.loadUi(self._MAIN_WINDOW_UI)
     self.window = elements["MainWindow"]
     # Binding Window's custom event handlers
     self.window.closeEvent = self.closeEvent
     self.centralWidget = elements["centralWidget"]
     # Menus
     self.menuFile = elements["menuFile"]
     elements["actionQuit"].triggered.connect(self.window.close)
     self._actionQuit = elements["actionQuit"]
     self.menuEdit = elements["menuEdit"]
     self._actionDevices = elements["actionDevices"]
     self.menuView = elements["menuView"]
     # Tool bars
     self.toolBarMain = elements["toolBarMain"]
     self.toolBarSwitch = elements["toolBarSwitch"]
     self.toolBarView = elements["toolBarView"]
     # Dialogs
     self.about = about.About()
     elements["actionAbout"].triggered.connect(self.about.run)
     self.devices = devices.DevicesDialog()
     elements["actionDevices"].triggered.connect(self.devices.run)
     self.settings = settings.SettingsDialog()
     elements["actionSettings"].triggered.connect(self.settings.run)
     # Views
     self._viewGroup = QtGui.QActionGroup(self.window)
     self._views = view.all(self)
     for i, obj in enumerate(self._views):
         self._viewGroup.addAction(obj.action)
         self.menuView.addAction(obj.action)
         self.toolBarSwitch.addAction(obj.action)
         obj.action.setShortcut("ALT+%d" % (i+1))
     # Uniform width of ToolBar buttons
     self._buttonWidth = QtGui.QFontMetrics(self.window.font()).width(
                                         'a' * self._TOOLBAR_BUTTON_LETTERS)
     for toolBar in (self.toolBarMain, self.toolBarSwitch):
         for action in toolBar.actions():
             if action.isSeparator():
                 continue
             toolBar.widgetForAction(action).setFixedWidth(self._buttonWidth)
     # Settings
     self._loadState()
Ejemplo n.º 21
0
    def aboutShowMenu(self):
        self.menu.clear()

        self.ag = QtGui.QActionGroup(self.menu)
        self.ag.setExclusive(True)

        for n, vp in enumerate(self.project.stackup.via_pairs):
            l1, l2 = vp.layers
            a1 = QtGui.QAction("%d-%d" % (l1.order, l2.order), self.menu)
            a1.setCheckable(True)
            a1.setChecked(vp is self.model.current_layer_pair)

            def closure(vp):
                def fn():
                    self.__changed_selected_viapair(vp)
                return fn

            a1.triggered.connect(closure(vp))

            self.menu.addAction(a1)
            self.ag.addAction(a1)
Ejemplo n.º 22
0
    def setupToolButtonExtra(self):
        self.menu = QtGui.QMenu()
        self.ag = QtGui.QActionGroup(self.menu)

        for n in valid_select:
            a1 = QtGui.QAction(select_names[n], self.menu)

            def closure(n):
                def fn():
                    self.__set_version(n)
                    self.toolButton.click()

                return fn

            a1.triggered.connect(closure(n))

            self.menu.addAction(a1)
            self.ag.addAction(a1)

        self.toolButton.setMenu(self.menu)
        self.__update_icon()
Ejemplo n.º 23
0
def init_draft_statusbar(sb):
    """
    this function initializes draft statusbar
    """

    statuswidget = QtGui.QToolBar()
    statuswidget.setObjectName("draft_status_widget")

    # SCALE TOOL -------------------------------------------------------------

    # get scales list according to system units
    draft_scales = get_scales()

    # get draft annotation scale
    param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft")
    draft_annotation_scale = param.GetFloat("DraftAnnotationScale", 1.0)

    # initializes scale widget
    statuswidget.draft_scales = draft_scales
    scaleLabel = QtGui.QPushButton("Scale")
    scaleLabel.setObjectName("ScaleLabel")
    scaleLabel.setFlat(True)
    menu = QtGui.QMenu(scaleLabel)
    gUnits = QtGui.QActionGroup(menu)
    for u in draft_scales:
        a = QtGui.QAction(gUnits)
        a.setText(u)
        menu.addAction(a)
    scaleLabel.setMenu(menu)
    gUnits.triggered.connect(_set_scale)
    scale_label = scale_to_label(draft_annotation_scale)
    scaleLabel.setText(scale_label)
    tooltip = "Set the scale used by draft annotation tools"
    scaleLabel.setToolTip(QT_TRANSLATE_NOOP("draft", tooltip))
    statuswidget.addWidget(scaleLabel)
    statuswidget.scaleLabel = scaleLabel

    # ADD TOOLS TO STATUS BAR ------------------------------------------------
    sb.addPermanentWidget(statuswidget)
    statuswidget.show()
Ejemplo n.º 24
0
 def add_menubar_items(self, items, parent, level):
     if not items:
         return
     for item in items:
         itype = item.get('type', None)
         if itype == 'separator':
             parent.addSeparator()
             continue
         if itype == 'menu':
             menu = parent.addMenu(item['text'])
             if 'items' in item:
                 self.add_menubar_items(item['items'], menu, level + 1)
             continue
         if itype == 'radio':
             radio = QtWidgets.QActionGroup(self.main, exclusive=True)
             for item in item['items']:
                 action = self.add_action(item, parent)
                 action.setCheckable(True)
                 action.setChecked(item['checked'])
                 radio.addAction(action)
             continue
         self.add_action(item, parent)
Ejemplo n.º 25
0
    def initMenu(self):
        self.clear()

        d = self.depthCameraStreamController.getDepthCamera()
        if not d:
            return

        names = sorted(
            d.getCameraProfileNames().items(),
            key=lambda x:
            (d.configFile.getCameraProfile(x[0]).getLocation() << 16) + x[0],
            reverse=True)

        if len(names) == 0:
            return

        cameraProfilesGroup = QtGui.QActionGroup(self, exclusive=True)

        for id, n in names:
            profile = d.configFile.getCameraProfile(id)

            if profile:
                if profile.getLocation() == Voxel.ConfigurationFile.IN_CAMERA:
                    n += " (HW)"
                a = QtGui.QAction(n, self)
                a.triggered.connect(
                    partial(self.setCameraProfile, name=n, id=id))
                a.setCheckable(True)
                self.addAction(a)

                if d.getCurrentCameraProfileID() == id:
                    a.setChecked(True)
                a.setActionGroup(cameraProfilesGroup)

        self.addSeparator()

        self.addAction(a)
Ejemplo n.º 26
0
	def initUI(self):
		grid = QtGui.QGridLayout()
		#Create actions dictionary and group dictionary
		self.atomActionGroup = QtGui.QActionGroup(self, exclusive=True)
		self.atomActions = {}								   
		#for atomname in self.editor.atomtypes.keys(): Gives unsorted list
		for key in self.ptable.keys():
			atomname = self.ptable[key]["Symbol"]
			action = QtGui.QAction( '%s'%atomname,
								   self, 
								   statusTip="Set atomtype to %s"%atomname,
								   triggered=self.atomtypePush, objectName=atomname,
								   checkable=True)
			self.atomActionGroup.addAction(action)
			self.atomActions[atomname] = action
			if action.objectName() == "C":
				action.setChecked(True)		
		
			button = QtGui.QToolButton()
			button.setDefaultAction(action)
			button.setFocusPolicy(QtCore.Qt.NoFocus)
			button.setMaximumWidth(40)
			
			if self.ptable[key]["Group"] != None:
				grid.addWidget(button, self.ptable[key]["Period"], self.ptable[key]["Group"])
			else:
				if key <72:
					grid.addWidget(button, 9, key-54)
				else:
					grid.addWidget(button, 10, key-86)
		#Ensure spacing between main table and actinides/lathanides			
		grid.addWidget(QtGui.QLabel(''), 8,1)

		self.setLayout(grid)   
		
		self.move(300, 150)
		self.setWindowTitle('Periodic Table')
Ejemplo n.º 27
0
    def __init__(self, *args, **kwargs):
        super(ShapeWidget, self).__init__(*args, **kwargs)
        buttons = self.buttons = []
        layout = flowlayout.FlowLayout()
        actionGroup = QtGui.QActionGroup(self)
        actionGroup.setExclusive(True)
        iconBase = resourcePath("mcedit2/assets/mcedit2/icons")
        actions = {}
        for shape in Shapes.allShapes:
            filename = os.path.join(iconBase, shape.icon)
            assert os.path.exists(filename), "%r does not exist" % filename
            icon = QtGui.QIcon(filename)
            if icon is None:
                raise ValueError("Failed to read shape icon file %s" % filename)
            def _handler(shape):
                def handler():
                    self.currentShape = shape
                    BrushShapeSetting.setValue(shape.ID)
                    self.shapeChanged.emit()
                return handler
            action = QtGui.QAction(icon, shape.ID, self, triggered=_handler(shape))
            button = QtGui.QToolButton()
            action.setCheckable(True)
            button.setDefaultAction(action)
            button.setIconSize(QtCore.QSize(32, 32))
            buttons.append(button)
            layout.addWidget(button)
            actionGroup.addAction(action)
            actions[shape.ID] = action

        self.setLayout(layout)
        currentID = BrushShapeSetting.value(Shapes.allShapes[0].ID)
        shapesByID = {shape.ID:shape for shape in Shapes.allShapes}
        actions[currentID].setChecked(True)

        self.currentShape = shapesByID.get(currentID, Shapes.allShapes[0])
Ejemplo n.º 28
0
    def __init__(self):
        """
            Create and add all tabs
        """
        super().__init__()

        toolbar = QtGui.QToolBar()
        toolbar.setIconSize(QtCore.QSize(32, 32))
        action_group = QtGui.QActionGroup(toolbar)

        action_preferences_general = g.create_action(t.load_ui_icon('icon.preferences.general.png'), 'Show general preferences', action_group, toggle_connection=self.toggled_general, checkable=True)
        toolbar.addAction(action_preferences_general)
        toolbar.addAction(g.create_action(t.load_ui_icon('icon.preferences.network.png'), 'Show network preferences', action_group, toggle_connection=self.toggled_network, checkable=True))
        toolbar.addAction(g.create_action(t.load_ui_icon('icon.preferences.graphics.png'), 'Show graphics preferences', action_group, toggle_connection=self.toggled_graphics, checkable=True))
        toolbar.addAction(g.create_action(t.load_ui_icon('icon.preferences.music.png'), 'Show music preferences', action_group, toggle_connection=self.toggled_music, checkable=True))


        self.stacked_layout = QtGui.QStackedLayout()

        layout = QtGui.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(toolbar)
        layout.addLayout(self.stacked_layout)

        # empty lists
        self.checkboxes = []
        self.lineedits = []

        # add tabs
        self.create_options_widget_general()
        self.create_options_widget_graphics()
        self.create_options_widget_music()
        self.create_options_widget_network()

        # show general preferences
        action_preferences_general.setChecked(True)
Ejemplo n.º 29
0
    def __init__(self, path=None):

        self.imageshape = (1475, 1709)

        if path is None:  # If not loading an exeriment from file
            # Build an empty experiment tree
            config = [
                {
                    'name': 'Name',
                    'type': 'str',
                    'value': 'New Experiment'
                },
                {
                    'name': 'Detector',
                    'type': 'list',
                    'values': detectors.ALL_DETECTORS
                },
                {
                    'name': 'Pixel Size X',
                    'type': 'float',
                    'value': 172.e-6,
                    'siPrefix': True,
                    'suffix': 'm',
                    'step': 1e-6
                },
                {
                    'name': 'Pixel Size Y',
                    'type': 'float',
                    'value': 172.e-6,
                    'siPrefix': True,
                    'suffix': 'm',
                    'step': 1e-6
                },
                {
                    'name': 'Center X',
                    'type': 'float',
                    'value': 0,
                    'suffix': ' px'
                },
                {
                    'name': 'Center Y',
                    'type': 'float',
                    'value': 0,
                    'suffix': ' px'
                },
                {
                    'name': 'Detector Distance',
                    'type': 'float',
                    'value': 1,
                    'siPrefix': True,
                    'suffix': 'm',
                    'step': 1e-3
                },
                {
                    'name': 'Detector Tilt',
                    'type': 'float',
                    'value': 0,
                    'siPrefix': False,
                    'suffix': u'°',
                    'step': 1e-1
                },
                {
                    'name': 'Detector Rotation',
                    'type': 'float',
                    'value': 0,
                    'siPrefix': False,
                    'suffix': u'°',
                    'step': 1e-1
                },
                {
                    'name': 'Energy',
                    'type': 'float',
                    'value': 10000,
                    'siPrefix': True,
                    'suffix': 'eV'
                },
                {
                    'name': 'Wavelength',
                    'type': 'float',
                    'value': 1,
                    'siPrefix': True,
                    'suffix': 'm'
                },
                # {'name': 'View Mask', 'type': 'action'},
                {
                    'name': 'Incidence Angle (GIXS)',
                    'type': 'float',
                    'value': 0.1,
                    'suffix': u'°'
                },
                {
                    'name': 'Notes',
                    'type': 'text',
                    'value': ''
                }
            ]
            super(experiment, self).__init__(name='Experiment Properties',
                                             type='group',
                                             children=config)

            # Wire up the energy and wavelength parameters to fire events on change (so they always match)
            self.param('Energy').sigValueChanged.connect(self.EnergyChanged)
            self.param('Wavelength').sigValueChanged.connect(
                self.WavelengthChanged)
            self.param('Detector').sigValueChanged.connect(
                self.DetectorChanged)

            # Add tilt style dialog
            self.tiltStyleMenu = QtGui.QMenu()
            grp = QtGui.QActionGroup(self)
            self.fit2dstyle = QtGui.QAction('Use Fit2D style rot/tilt',
                                            self.tiltStyleMenu)
            self.wxdiffstyle = QtGui.QAction('Use WxDiff style rot/tilt',
                                             self.tiltStyleMenu)
            self.fit2dstyle.setCheckable(True)
            self.wxdiffstyle.setCheckable(True)
            self.fit2dstyle.setActionGroup(grp)
            self.wxdiffstyle.setActionGroup(grp)
            self.fit2dstyle.setChecked(True)
            self.fit2dstyle.triggered.connect(self.resetUnits)
            self.wxdiffstyle.triggered.connect(self.resetUnits)

            self.tiltStyleMenu.addActions([self.fit2dstyle, self.wxdiffstyle])

            # Start with a null mask
            self._mask = None

            self.EnergyChanged()
        else:
            # Load the experiment from file
            with open(path, 'r') as f:
                self.config = pickle.load(f)

        self.headermap = {
            'Beam Energy': 'Beam Energy',
            'Sample Alpha Stage': 'Sample Alpha Stage',
            'Detector Vertical': 'Detector Vertical',
            'Detector Horizontal': 'Detector Horizontal',
            'I1 AI': 'I1 AI',
            'Timeline Axis': None
        }
Ejemplo n.º 30
0
 def __init__(self, parent=None):
     # Initialise the UI
     self.display = None
     super(MainWindow, self).__init__(parent)
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     # Current file
     self._filename = None
     self._filetype = None
     self._last_file_handler = None
     # Importers / Exporters
     self._file_handlers = []
     # Update our window caption
     self._caption = "Zoxel"
     # Our global state + user plugins
     if platform.system() == "Windows":
         appdata = os.path.expandvars("%APPDATA%")
     elif platform.system() == "Darwin":
         appdata = os.path.expanduser("~/Library/Application Support")
     else:
         appdata = os.path.expanduser("~/.local/share")
     self.user_plugins_path = os.path.join(appdata, "Zoxel", "plugins")
     if not os.path.isdir(self.user_plugins_path):
         os.makedirs(self.user_plugins_path, 16877)
     QtCore.QCoreApplication.setOrganizationName("Zoxel")
     QtCore.QCoreApplication.setApplicationName("Zoxel")
     QtCore.QSettings.setDefaultFormat(QtCore.QSettings.IniFormat)
     QtCore.QSettings.setPath(QtCore.QSettings.IniFormat, QtCore.QSettings.UserScope, appdata)
     self.settings = QtCore.QSettings()
     self.state = {}
     # Our animation timer
     self._timer = QtCore.QTimer(self)
     self.connect(self._timer, QtCore.SIGNAL("timeout()"), self.on_animation_tick)
     self._anim_speed = 200
     # Load our state if possible
     self.load_state()
     # Create our GL Widget
     try:
         glw = GLWidget(self.ui.glparent)
         self.ui.glparent.layout().addWidget(glw)
         self.display = glw
     except Exception as E:
         QtGui.QMessageBox.warning(self, "Initialisation Failed", str(E))
         exit(1)
     # Load default model dimensions
     width = self.get_setting("default_model_width")
     height = self.get_setting("default_model_height")
     depth = self.get_setting("default_model_depth")
     if width:
         self.resize_voxels(width, height, depth)
         # Resize is detected as a change, discard changes
         self.display.voxels.saved()
     # Create our palette widget
     voxels = PaletteWidget(self.ui.palette, RGBvalue=self.ui.paletteRGBvalue)
     self.ui.palette.layout().addWidget(voxels)
     self.color_palette = voxels
     # More UI state
     value = self.get_setting("display_axis_grids")
     if value is not None:
         self.ui.action_axis_grids.setChecked(value)
         self.display.axis_grids = value
     value = self.get_setting("background_color")
     if value is not None:
         self.display.background = QtGui.QColor.fromRgb(*value)
     value = self.get_setting("voxel_edges")
     if value is not None:
         self.display.voxel_edges = value
         self.ui.action_voxel_edges.setChecked(value)
     else:
         self.ui.action_voxel_edges.setChecked(self.display.voxel_edges)
     value = self.get_setting("occlusion")
     if value is None:
         value = True
     self.display.voxels.occlusion = value
     self.ui.action_occlusion.setChecked(value)
     # Connect some signals
     if self.display:
         self.display.voxels.notify = self.on_data_changed
         self.display.mouse_click_event.connect(self.on_tool_mouse_click)
         self.display.start_drag_event.connect(self.on_tool_drag_start)
         self.display.end_drag_event.connect(self.on_tool_drag_end)
         self.display.drag_event.connect(self.on_tool_drag)
     if self.color_palette:
         self.color_palette.changed.connect(self.on_color_changed)
     # Initialise our tools
     self._tool_group = QtGui.QActionGroup(self.ui.toolbar_drawing)
     self._tools = []
     self._tools_priorities = {}
     # Setup window
     self.update_caption()
     self.refresh_actions()
     self.display.ready = True
     # Update Check
     try:
         latest_tag = urllib.urlopen("https://github.com/chrmoritz/zoxel/releases/latest").geturl()
         if not latest_tag.endswith(ZOXEL_TAG):
             responce = QtGui.QMessageBox.question(self, "Outdated Zoxel version",
                                                   "A new version of Zoxel is available! Do you want to update now?",
                                                   buttons=(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
                                                   defaultButton=QtGui.QMessageBox.Yes)
             if responce == QtGui.QMessageBox.Yes:
                 webbrowser.open(latest_tag, 2)
                 sys.exit(0)
     except IOError:
         pass