Ejemplo n.º 1
0
    def __init__(self, callback_remove_tag: Callable = None):
        super().__init__()

        self._callback_remove_tag = callback_remove_tag

        self.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.verticalHeader().setVisible(False)

        model = QStandardItemModel()
        model.setHorizontalHeaderLabels(['Tag', '# Files'])
        self.setModel(model)

        # FIXME: seems hacky
        if self._callback_remove_tag:
            self._remove_action = QAction('Remove tag from image')
            self._remove_action.triggered.connect(self._callback_remove_tag)
Ejemplo n.º 2
0
 def add_main_menu(self, menu):
     menu_action = self.addAction(QIcon(CharIconEngine("\uf0c9")), "")
     menu_action.setMenu(menu)
     menu_button = self.widgetForAction(menu_action)
     menu_button.setPopupMode(menu_button.InstantPopup)
     action = QAction(self)
     action.triggered.connect(menu_button.showMenu)
     keys = [
         QKeySequence(Qt.ALT + Qt.Key_F),
         QKeySequence(Qt.ALT + Qt.Key_E)
     ]
     action.setShortcuts(keys)
     keys_str = ", ".join([key.toString() for key in keys])
     menu_button.setToolTip(
         f"<p>Customize and control Spine DB Editor ({keys_str})</p>")
     return action
Ejemplo n.º 3
0
 def setTabellenAuswahl(self, tables: List[str]) -> None:
     """
     Fügt dem SubMenu "Ganze Tabelle anzeigen" soviele Tabellen-Namen hinzu wie in <tables> enthalten.
     :param tables:
     :return:
     """
     n = len(tables)
     actions = [QAction(self._submenuShowTableContent) for i in range(n)]
     for i in range(n):
         act = actions[i]
         act.setText(tables[i])
         #act.triggered.connect( lambda action=act: self.onShowTableContent(action) ) --> funktioniert nicht
         act.triggered.connect(partial(self.onShowTableContent, act))
         #txt = act.text()
         #act.triggered.connect( lambda table=txt: self.showTableContent.emit( txt ) ) --> funktioniert nicht
         self._submenuShowTableContent.addAction(act)
Ejemplo n.º 4
0
 def initCMenu(self):
     """
     Context menu initialization
     """
     menu = QMenu()
     # menu.addAction('View image in a separate window', self.viewImage)  # too large overload and limited usage: removed
     menu.addAction("Copy Image to Clipboard", self.hCopy)
     menu.addAction(self.actionSub)
     subMenuRating = menu.addMenu('Rating')
     for i in range(6):
         action = QAction(str(i), None)
         subMenuRating.addAction(action)
         action.triggered.connect(
             lambda checked=False, action=action: self.setRating(
                 action))  # named arg checked is sent
     self.cMenu = menu
Ejemplo n.º 5
0
    def makefullscreen(self, request):
        if request.toggleOn():
            self.fullView = QWebEngineView()
            self.exitFSAction = QAction(self.fullView)
            self.exitFSAction.setShortcut(Qt.Key_Escape)
            self.exitFSAction.triggered.connect(
                lambda: self.triggerAction(self.ExitFullScreen))

            self.fullView.addAction(self.exitFSAction)
            self.setView(self.fullView)
            self.fullView.showFullScreen()
            self.fullView.raise_()
        else:
            del self.fullView
            self.setView(self.view)
        request.accept()
Ejemplo n.º 6
0
    def __init__(self, widget):
        QMainWindow.__init__(self)
        self.setWindowTitle("Tutorial")
        self.resize(800, 600)

        # Menu
        self.menu = self.menuBar()
        self.file_menu = self.menu.addMenu("File")

        # Exit QAction
        exit_action = QAction("Exit", self)
        exit_action.setShortcut("Ctrl+Q")
        exit_action.triggered.connect(self.exit_app)

        self.file_menu.addAction(exit_action)
        self.setCentralWidget(widget)
Ejemplo n.º 7
0
    def initUI(self):
        self.textEdit = QTextEdit()
        self.setCentralWidget(self.textEdit)
        self.statusBar()

        # openFile = QAction(QIcon('open.png'), 'Open', self)
        openFile = QAction('開く', self)

        openFile.setShortcut('Ctrl+O')

        openFile.setStatusTip('新しいファイルを開く')
        openFile.triggered.connect(self.showDialog)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('ファイル(&F)')
        fileMenu.addAction(openFile)
Ejemplo n.º 8
0
    def __init__(self):
        super().__init__()

        menu = self.menuBar()
        file_menu = menu.addMenu("&File")

        self.quit = QAction("&Quit")
        self.quit.triggered.connect(app.quit)
        file_menu.addAction(self.quit)

        self.editor = QTextEdit()
        self.load()  # Load up the text from file.

        self.setCentralWidget(self.editor)

        self.setWindowTitle("PenguinNotes")
Ejemplo n.º 9
0
    def __init__(self, mainWin=None):
        """

        @param mainWin: should be the app main window
        @type mainWin:  QMainWindow
        """
        self.mainWin = mainWin
        # init form
        self.initWins()
        actionSub = QAction('Show SubFolders', None)
        actionSub.setCheckable(True)
        actionSub.setChecked(False)
        actionSub.triggered.connect(lambda checked=False, action=actionSub: self.hSubfolders(action))  # named arg checked is always sent
        self.actionSub = actionSub
        # init context menu
        self.initCMenu()
Ejemplo n.º 10
0
    def __init__(self, parent):
        super(ManageSettings, self).__init__(parent)
        self.setWindowTitle("Paraméterek kezelése")
        widget = QWidget()
        main_layout = QHBoxLayout()
        widget.setLayout(main_layout)

        self.setCentralWidget(widget)
        self.table_view = QTableView()
        main_layout.addWidget(self.table_view)

        self.model = QSqlTableModel(db=db)
        self.model.setTable("settings")
        self.model.select()
        self.model.setEditStrategy(QSqlTableModel.OnManualSubmit)
        self.model.setHeaderData(1, Qt.Horizontal, "Paraméter")
        self.model.setHeaderData(2, Qt.Horizontal, "Érték")

        self.table_view.setModel(self.model)
        self.table_view.setSortingEnabled(True)
        self.table_view.hideColumn(0)
        self.table_view.resizeColumnsToContents()

        self.model.dataChanged.connect(self.valtozott)
        gomb_layout = QVBoxLayout()
        main_layout.addLayout(gomb_layout)

        self.apply_button = QPushButton("Módosítások alkalmazása")
        self.cancel_button = QPushButton("Módosítások elvetése")

        gomb_layout.addWidget(self.apply_button)
        gomb_layout.addWidget(self.cancel_button)

        self.space = QSpacerItem(0, 0, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        gomb_layout.addItem(self.space)

        self.setFixedSize(400, 600)
        tb = self.addToolBar("File")

        exit = QAction(QIcon("images/door--arrow.png"), "Kilépés", self)
        tb.addAction(exit)

        tb.actionTriggered[QAction].connect(self.toolbarpressed)

        self.apply_button.clicked.connect(self.valtozas_mentese)
        self.cancel_button.clicked.connect(self.valtozas_elvetese)
Ejemplo n.º 11
0
def start(_exit: bool = False) -> None:
    app = QApplication(sys.argv)

    logo = QIcon(LOGO)
    main_window = MainWindow()
    ui = main_window.ui
    main_window.setWindowIcon(logo)
    tray = QSystemTrayIcon(logo, app)
    tray.activated.connect(main_window.systray_clicked)

    menu = QMenu()
    action_exit = QAction("Exit")
    action_exit.triggered.connect(app.exit)
    menu.addAction(action_exit)

    tray.setContextMenu(menu)

    ui.text.textChanged.connect(partial(queue_text_change, ui))
    ui.command.textChanged.connect(partial(update_button_command, ui))
    ui.keys.textChanged.connect(partial(update_button_keys, ui))
    ui.write.textChanged.connect(partial(update_button_write, ui))
    ui.change_brightness.valueChanged.connect(partial(update_change_brightness, ui))
    ui.switch_page.valueChanged.connect(partial(update_switch_page, ui))
    ui.imageButton.clicked.connect(partial(select_image, main_window))
    ui.brightness.valueChanged.connect(partial(set_brightness, ui))
    for deck_id, deck in api.open_decks().items():
        ui.device_list.addItem(f"{deck['type']} - {deck_id}", userData=deck_id)

    build_device(ui)
    ui.device_list.currentIndexChanged.connect(partial(build_device, ui))

    ui.pages.currentChanged.connect(partial(change_page, ui))

    ui.actionExport.triggered.connect(partial(export_config, main_window))
    ui.actionImport.triggered.connect(partial(import_config, main_window))

    timer = QTimer()
    timer.timeout.connect(partial(sync, ui))
    timer.start(1000)

    api.render()
    tray.show()
    main_window.show()
    if exit:
        return
    else:
        sys.exit(app.exec_())
def demo_docking_widgets():
    """
    Demonstrates how to create a QWidget with PySide2 and attach it to the 3dsmax main window.
    Creates two types of dockable widgets, a QDockWidget and a QToolbar
    """
    # Retrieve 3ds Max Main Window QWdiget
    main_window = GetQMaxMainWindow()

    # QAction reused by both dockable widgets.
    cylinder_icon_path = os.path.dirname(os.path.realpath(__file__)) + "\\cylinder_icon_48.png"
    cylinder_icon = QtGui.QIcon(cylinder_icon_path)
    create_cyl_action = QAction(cylinder_icon, u"Create Cylinder", main_window)
    create_cyl_action.triggered.connect(create_cylinder)

    # QDockWidget construction and placement over the main window
    dock_widget = QDockWidget(main_window)

    # Set for position persistence
    dock_widget.setObjectName("Creators")
    # Set to see dock widget name in toolbar customize popup
    dock_widget.setWindowTitle("Creators")
    dock_tool_button = QToolButton()
    dock_tool_button.setAutoRaise(True)
    dock_tool_button.setDefaultAction(create_cyl_action)
    dock_tool_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly)
    dock_widget.setWidget(dock_tool_button)

    main_window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dock_widget)
    dock_widget.setFloating(True)
    dock_widget.show()

    # QToolBar construction and attachement to main window
    toolbar_widget = QToolBar(main_window)

    # Set for position persistence
    toolbar_widget.setObjectName("Creators TB")
    # Set to see dock widget name in toolbar customize popup
    toolbar_widget.setWindowTitle("Creators TB")
    toolbar_widget.setFloatable(True)
    toolbar_widget.addAction(create_cyl_action)

    main_window.addToolBar(QtCore.Qt.BottomToolBarArea, toolbar_widget)
    toolbar_widget.show()

    toolbar_position = get_pos_to_dock_toolbar(dock_widget)
    make_toolbar_floating(toolbar_widget, toolbar_position)
Ejemplo n.º 13
0
    def __init__(self, layout):
        QMainWindow.__init__(self)
        self.setWindowTitle("Lissajous Application")

        # Menu
        self.menu = self.menuBar()
        self.file_menu = self.menu.addMenu("File")

        # Exit QAction
        exit_action = QAction("Exit", self)
        exit_action.setShortcut("Ctrl+Q")
        exit_action.triggered.connect(self.exit_app)

        self.file_menu.addAction(exit_action)
        widget = QWidget()
        widget.setLayout(layout)
        self.setCentralWidget(widget)
Ejemplo n.º 14
0
    def __init__(self):
        super().__init__()

        self.setWindowTitle("My App")

        label = QLabel("Hello!")
        label.setAlignment(Qt.AlignCenter)

        self.setCentralWidget(label)

        toolbar = QToolBar("My main toolbar")
        self.addToolBar(toolbar)

        button_action = QAction("Your button", self)
        button_action.setStatusTip("This is your button")
        button_action.triggered.connect(self.onMyToolBarButtonClick)
        toolbar.addAction(button_action)
Ejemplo n.º 15
0
 def _add_db_map_tag_actions(self, db_map, parameter_tags):
     action_texts = [a.text() for a in self.actions]
     for parameter_tag in parameter_tags:
         if parameter_tag["tag"] in action_texts:
             # Already a tag named after that, add db_map id information
             i = action_texts.index(parameter_tag["tag"])
             self.db_map_ids[i].append((db_map, parameter_tag["id"]))
         else:
             action = QAction(parameter_tag["tag"])
             self.insertAction(self.empty_action, action)
             action.setCheckable(True)
             button = self.widgetForAction(action)
             self.tag_button_group.addButton(button,
                                             id=len(self.db_map_ids))
             self.actions.append(action)
             self.db_map_ids.append([(db_map, parameter_tag["id"])])
             action_texts.append(action.text())
Ejemplo n.º 16
0
    def init_output_edit(self):
        """
        初始化输出框
        :return: 无
        """
        self.ui.output_edit.setReadOnly(True)  # 禁止编辑

        #
        # 添加右键菜单
        #
        self.ui.output_edit.setContextMenuPolicy(
            Qt.ActionsContextMenu)  # 允许右键菜单
        send_option = QAction(self.ui.output_edit)  # 具体菜单项
        send_option.setText("清除内容")
        send_option.triggered.connect(
            self.ui.output_edit.clear)  # 点击菜单中的具体选项执行的函数
        self.ui.output_edit.addAction(send_option)
Ejemplo n.º 17
0
    def __init__(self):
        super().__init__()
        self.ok_action = self.default_ok
        self.back_action = self.default_back

        self.ui = Ui_EmotionInstructions()
        self.ui.setupUi(self)

        self.ui.okButton.clicked.connect(self.ok)
        self.ui.backButton.clicked.connect(self.back)

        self.okAction = QAction("OK", self)
        self.okAction.setShortcut(QKeySequence("Shift+Return"))
        self.okAction.triggered.connect(self.ok_action)
        self.addAction(self.okAction)

        self.text = None
Ejemplo n.º 18
0
    def __add_project_to_menu(self, project: "Project"):
        """Creates a new entry for the passed project. Clicking on the project will make
        it the active project on the project manager."""
        project_action = QAction(project.name, self)
        project_action.setCheckable(True)

        index = self.__project_manager.projects.index(project)

        project_action.triggered.connect(
            lambda _=False, index=index: self.__project_manager.
            set_active_project(index))

        self.__projects_actions_group.addAction(project_action)
        self.addAction(project_action)

        LOGGER.debug("Created ProjectMenu Action (Index %s): %s", index,
                     project_action)
Ejemplo n.º 19
0
    def initUI(self):
        # exitAction = QAction(QIcon('exit.png'), '&Exit', self)
        exitAction = QAction('Exit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit Application')
        exitAction.triggered.connect(self.close)

        self.statusBar()

        menubar = self.menuBar()
        fileMenu = menubar.addMenu("&File")
        fileMenu.addAction(exitAction)

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('MenuBar')
        self.statusBar().showMessage("Ready")
        self.show()
Ejemplo n.º 20
0
    def initUI(self):
        self.textEdit = QTextEdit()
        self.setCentralWidget(self.textEdit)
        self.statusBar()

        openFile = QAction(QIcon('icon.png'), 'Open', self)
        openFile.setShortcut('Ctrl+O')
        openFile.setStatusTip('Open new File')
        openFile.triggered.connect(self.showDialog)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('File')
        fileMenu.addAction(openFile)

        self.setGeometry(300, 300, 550, 450)
        self.setWindowTitle('File dialog')
        self.show()
Ejemplo n.º 21
0
    def initUI(self):

        self.setGeometry(200, 200, 200, 200)

        exitAction = QAction('&Exit', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(QApplication.quit)

        self.statusBar()

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(exitAction)

        self.setWindowTitle('PyQt5 Basic Menubar')
        self.show()
Ejemplo n.º 22
0
 def createWorkbenchPopupMenu(self, index: QModelIndex) -> None:
     # Create a popup menu when workbench is right-clicked over a valid frame name
     # Menu display delete and remove options
     frameName: str = index.data(Qt.DisplayRole)
     pMenu = QMenu(self)
     # Reuse MainWindow actions
     csvAction = self.parentWidget().aWriteCsv
     pickleAction = self.parentWidget().aWritePickle
     # Set correct args for the clicked row
     csvAction.setOperationArgs(w=self.workbenchModel, frameName=frameName)
     pickleAction.setOperationArgs(w=self.workbenchModel,
                                   frameName=frameName)
     deleteAction = QAction('Remove', pMenu)
     deleteAction.triggered.connect(
         lambda: self.workbenchModel.removeRow(index.row()))
     pMenu.addActions([csvAction, pickleAction, deleteAction])
     pMenu.popup(QtGui.QCursor.pos())
Ejemplo n.º 23
0
    def contextMenuVerticalHeader(self, pos):
        """
        Creates a context menu for the vertical header.
        """
        index = self.indexAt(pos)

        # Label
        actionLabelLetter = QAction('Letter', self)
        actionLabelLetter.setStatusTip('Change label to a capital letter')
        actionLabelLetter.setToolTip('Change label to a capital letter')
        actionLabelLetter.triggered.connect( lambda: self.onActionLabelVerticalTriggered(index.row(), Preferences.HeaderLabel.Letter) )

        actionLabelNumber = QAction('Number', self)
        actionLabelNumber.setStatusTip('Change label to a decimal number')
        actionLabelNumber.setToolTip('Change label to a decimal number')
        actionLabelNumber.triggered.connect( lambda: self.onActionLabelVerticalTriggered(index.row(), Preferences.HeaderLabel.Decimal) )

        actionLabelCustom = QAction('Custom…', self)
        actionLabelCustom.setStatusTip('Change label to a user-defined text')
        actionLabelCustom.setToolTip('Change label to a user-defined text')
        actionLabelCustom.triggered.connect( lambda: self.onActionLabelVerticalTriggered(index.row(), Preferences.HeaderLabel.Custom) )

        actionLabelLetters = QAction('Letters', self)
        actionLabelLetters.setStatusTip('Change all labels to capital letters')
        actionLabelLetters.setToolTip('Change all labels to capital letters')
        actionLabelLetters.triggered.connect( lambda: self.onActionLabelAllVerticalTriggered(Preferences.HeaderLabel.Letter) )

        actionLabelNumbers = QAction('Numbers', self)
        actionLabelNumbers.setStatusTip('Change all labels to decimal numbers')
        actionLabelNumbers.setToolTip('Change all labels to decimal numbers')
        actionLabelNumbers.triggered.connect( lambda: self.onActionLabelAllVerticalTriggered(Preferences.HeaderLabel.Decimal) )

        actionLabelCustoms = QAction('Custom…', self)
        actionLabelCustoms.setStatusTip('Change all labels to user-defined texts')
        actionLabelCustoms.setToolTip('Change all labels to user-defined texts')
        actionLabelCustoms.triggered.connect( lambda: self.onActionLabelAllVerticalTriggered(Preferences.HeaderLabel.Custom) )

        # Context menu
        menuLabel = QMenu('Label', self)
        menuLabel.setIcon(QIcon.fromTheme('tag', QIcon(':/icons/actions/16/tag.svg')))
        menuLabel.setStatusTip('Change label')
        menuLabel.setToolTip('Change label')
        menuLabel.addAction(actionLabelLetter)
        menuLabel.addAction(actionLabelNumber)
        menuLabel.addAction(actionLabelCustom)
        menuLabel.addSeparator()
        menuLabel.addAction(actionLabelLetters)
        menuLabel.addAction(actionLabelNumbers)
        menuLabel.addAction(actionLabelCustoms)

        contextMenu = QMenu(self)
        contextMenu.addMenu(menuLabel)
        contextMenu.exec_(self.mapToGlobal(pos))
Ejemplo n.º 24
0
    def addActions(self):
        """Generate all actions"""
        self.openAction = openAction = QAction("&Open", self)
        openAction.setShortcut(QKeySequence.Open)
        self.saveAction = saveAction = QAction("&Save", self)
        saveAction.setShortcut(QKeySequence.Save)
        self.saveAsAction = saveAsAction = QAction("Save &As...", self)
        saveAsAction.setShortcut(QKeySequence.SaveAs)
        self.closeAction = closeAction = QAction("&Close", self)
        closeAction.setShortcut(QKeySequence.Close)
        self.fileMenu.addActions([
            openAction,
            saveAction,
            saveAsAction,
            closeAction,
        ])

        self.recentFileActions = []
        for _ in range(self._maxNumRecentFiles):
            recentFileAction = QAction(self)
            recentFileAction.setVisible(False)
            self.recentFileActions.append(recentFileAction)
        self.recentFilesMenu.addActions(self.recentFileActions)

        self.darkAction = darkAction = QAction("Dark", self)
        self.lightAction = lightAction = QAction("Light", self)
        self.themeMenu.addActions([
            darkAction,
            lightAction,
        ])

        self.aboutAction = aboutAction = QAction("&About", self)
        aboutAction.setShortcut(QKeySequence.WhatsThis)
        self.aboutQtAction = aboutQtAction = QAction("About &Qt", self)
        self.helpMenu.addActions([
            aboutAction,
            aboutQtAction,
        ])
Ejemplo n.º 25
0
 def __init__(self):
     super(MainWindow, self).__init__()
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     tool_menu = QMenu()
     tool_menu.addSeparator()
     tool_menu.addAction(QAction("Default empty group", self))
     tool_menu.addAction(QAction("Default empty group", self))
     tool_menu.addAction(QAction("Default empty group", self))
     tool_menu.addAction(QAction("Default empty group", self))
     tool_menu.addSeparator()
     tool_menu.addAction(QAction("Default empty group", self))
     tool_menu.addAction(QAction("Default empty group", self))
     tool_menu.addAction(QAction("Default empty group", self))
     tool_menu.addSeparator()
     tool_menu.addAction(QAction("Default empty group", self))
     tool_menu.setToolTipsVisible(True)
     self.ui.toolButton.setMenu(tool_menu)
     self.ui.toolButton.clicked.connect(self.on_toolButton)
Ejemplo n.º 26
0
    def createActions(self):
        self.newLetterAct = QAction(QIcon.fromTheme('document-new',
                                                    QIcon(':/images/new.png')),
                                    "&New Letter",
                                    self,
                                    shortcut=QKeySequence.New,
                                    statusTip="Create a new form letter",
                                    triggered=self.newLetter)

        self.saveAct = QAction(QIcon.fromTheme('document-save',
                                               QIcon(':/images/save.png')),
                               "&Save...",
                               self,
                               shortcut=QKeySequence.Save,
                               statusTip="Save the current form letter",
                               triggered=self.save)

        self.printAct = QAction(QIcon.fromTheme('document-print',
                                                QIcon(':/images/print.png')),
                                "&Print...",
                                self,
                                shortcut=QKeySequence.Print,
                                statusTip="Print the current form letter",
                                triggered=self.print_)

        self.undoAct = QAction(QIcon.fromTheme('edit-undo',
                                               QIcon(':/images/undo.png')),
                               "&Undo",
                               self,
                               shortcut=QKeySequence.Undo,
                               statusTip="Undo the last editing action",
                               triggered=self.undo)

        self.quitAct = QAction("&Quit",
                               self,
                               shortcut="Ctrl+Q",
                               statusTip="Quit the application",
                               triggered=self.close)

        self.aboutAct = QAction("&About",
                                self,
                                statusTip="Show the application's About box",
                                triggered=self.about)

        self.aboutQtAct = QAction("About &Qt",
                                  self,
                                  statusTip="Show the Qt library's About box",
                                  triggered=QApplication.instance().aboutQt)
Ejemplo n.º 27
0
    def _init_menu(self):
        self._menu = QMenu()
        pos = self._jump_history.pos
        if pos < 0:
            pos += len(self._jump_history.history)

        actions = []
        for i, point in enumerate(self._jump_history.history):
            a = QAction(f'{i}: {point:x}', self)
            a.setData(i)
            a.setCheckable(True)
            a.setChecked(pos == i)
            a.triggered.connect(self._on_menu_action_activated)
            actions.append(a)

        actions.reverse()
        self._menu.addActions(actions)
        self.setMenu(self._menu)
Ejemplo n.º 28
0
    def make_display_rule_action(display_rule,
                                 group: Optional[QActionGroup] = None
                                 ) -> QAction:
        def make_check_closure():
            def closure():
                display_rule.value = action.isChecked()

            return closure

        action = QAction(f"&{display_rule.menu_text}", group)

        if display_rule.menu_text in CONST.ICONS.keys():
            action.setIcon(CONST.ICONS[display_rule.menu_text])

        action.setCheckable(True)
        action.setChecked(display_rule.value)
        action.toggled.connect(make_check_closure())
        return action
Ejemplo n.º 29
0
    def initActions(self):
        self.newGameAction = QAction("&New Game", self)
        self.newGameAction.setIcon(QIcon(CONST.ICONS["New"]))
        self.newGameAction.triggered.connect(self.newGame)
        self.newGameAction.setShortcut("CTRL+N")

        self.openAction = QAction("&Open", self)
        self.openAction.setIcon(QIcon(CONST.ICONS["Open"]))
        self.openAction.triggered.connect(self.openFile)
        self.openAction.setShortcut("CTRL+O")

        self.saveGameAction = QAction("&Save", self)
        self.saveGameAction.setIcon(QIcon(CONST.ICONS["Save"]))
        self.saveGameAction.triggered.connect(self.saveGame)
        self.saveGameAction.setShortcut("CTRL+S")

        self.saveAsAction = QAction("Save &As", self)
        self.saveAsAction.setIcon(QIcon(CONST.ICONS["Save"]))
        self.saveAsAction.triggered.connect(self.saveGameAs)
        self.saveAsAction.setShortcut("CTRL+A")

        self.showAboutDialogAction = QAction("&About DCS Liberation", self)
        self.showAboutDialogAction.setIcon(QIcon.fromTheme("help-about"))
        self.showAboutDialogAction.triggered.connect(self.showAboutDialog)

        self.showLiberationPrefDialogAction = QAction("&Preferences", self)
        self.showLiberationPrefDialogAction.setIcon(
            QIcon.fromTheme("help-about"))
        self.showLiberationPrefDialogAction.triggered.connect(
            self.showLiberationDialog)

        self.openDiscordAction = QAction("&Discord Server", self)
        self.openDiscordAction.setIcon(CONST.ICONS["Discord"])
        self.openDiscordAction.triggered.connect(
            lambda: webbrowser.open_new_tab("https://" + "discord.gg" + "/" +
                                            "bKrt" + "rkJ"))

        self.openGithubAction = QAction("&Github Repo", self)
        self.openGithubAction.setIcon(CONST.ICONS["Github"])
        self.openGithubAction.triggered.connect(
            lambda: webbrowser.open_new_tab(
                "https://github.com/khopa/dcs_liberation"))
Ejemplo n.º 30
0
    def _createSqlMenu(self):
        # Menü "ImmoCenter"
        menu = QtWidgets.QMenu(self._menubar, title="SQL")
        self._menubar.addMenu(menu)

        # Menüpunkt "Neue Abfrage
        action = QAction(self, text="Neue Datenbankabfrage")
        action.setShortcut(QKeySequence("Ctrl+n"))
        icon = QtGui.QIcon("../images/sql.xpm")
        action.setIcon(icon)
        action.triggered.connect(self.onNewSql)
        menu.addAction(action)
        #self._toolBar.addAction( action )

        #Menüpunkt "Ganze Tabelle anzeigen"
        self._submenuShowTableContent = QtWidgets.QMenu(
            menu, title="Ganze Tabelle anzeigen")
        menu.addMenu(self._submenuShowTableContent)