Python PyQt5.QtWidgets.QAction() Examples

The following are code examples for showing how to use PyQt5.QtWidgets.QAction(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: gpvdm   Author: roderickmackenzie   File: ribbon_solar.py    (license) View Source Project 115 votes vote down vote up
def optics(self):
		toolbar = QToolBar()
		toolbar.setToolButtonStyle( Qt.ToolButtonTextUnderIcon)
		toolbar.setIconSize(QSize(42, 42))
		
		self.run = QAction(QIcon_load("media-playback-start"), wrap_text(_("Calculate"),5), self)
		toolbar.addAction(self.run)
		
		self.export = QAction(QIcon_load("document-export"), wrap_text(_("Export spectrum"),5), self)
		#self.export.triggered.connect(self.save_image)
		toolbar.addAction(self.export)

		spacer = QWidget()
		spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
		toolbar.addWidget(spacer)


		self.help = QAction(QIcon_load("help"), _("Help"), self)
		toolbar.addAction(self.help)
		return toolbar 
Example 2
Project: examples   Author: pyqt   File: shapedclock.py    (license) View Source Project 36 votes vote down vote up
def __init__(self, parent=None):
        super(ShapedClock, self).__init__(parent,
                Qt.FramelessWindowHint | Qt.WindowSystemMenuHint)

        timer = QTimer(self)
        timer.timeout.connect(self.update)
        timer.start(1000)

        quitAction = QAction("E&xit", self, shortcut="Ctrl+Q",
                triggered=QApplication.instance().quit)
        self.addAction(quitAction)

        self.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.setToolTip("Drag the clock with the left mouse button.\n"
                "Use the right mouse button to open a context menu.")
        self.setWindowTitle(self.tr("Shaped Analog Clock")) 
Example 3
Project: VIRTUAL-PHONE   Author: SumanKanrar-IEM   File: menu.py    (license) View Source Project 7 votes vote down vote up
def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
 
        mainMenu = self.menuBar() 
        fileMenu = mainMenu.addMenu('File')
        editMenu = mainMenu.addMenu('Edit')
        viewMenu = mainMenu.addMenu('View')
        searchMenu = mainMenu.addMenu('Search')
        toolsMenu = mainMenu.addMenu('Tools')
        helpMenu = mainMenu.addMenu('Help')
 
        exitButton = QAction(QIcon('exit24.png'), 'Exit', self)
        exitButton.setShortcut('Ctrl+Q')
        exitButton.setStatusTip('Exit application')
        exitButton.triggered.connect(self.close)
        fileMenu.addAction(exitButton)
 
        self.show() 
Example 4
Project: binja_dynamics   Author: nccgroup   File: __init__.py    (license) View Source Project 6 votes vote down vote up
def submit_line(self):
        """ Writes the input to the text browser, adds it to the history, and
        adds it to the message queue to be sent to the binary """
        raw = self._textbox.text()
        line = self.decode(raw)
        if line is None:
            return
        if raw not in self.history:
            self.history.append(raw)
            action = QtWidgets.QAction(str(raw), self)
            action.triggered.connect(partial(self.set_text_box_contents, raw))
            self._hist_menu.insertAction(self._hist_menu.actions()[0], action)
        self._messages.put((line, None))
        self._autoscroll()
        # self._textBrowser.setTextColor(usercolor)
        # self._textBrowser.insertPlainText(line + "\n")
        # self._textBrowser.setTextColor(self.palette().color(QPalette.WindowText))
        self._textbox.clear()
        self._autoscroll() 
Example 5
Project: plexdesktop   Author: coryo   File: extra_widgets.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, parent=None):
        super().__init__(parent)
        """style is relying on object names so make sure they are set
           before registering widgets"""
        self.setObjectName('HubSearch')

        search_action = QtWidgets.QAction(self)
        search_action.setObjectName('search_action')
        close_action = QtWidgets.QAction(self)
        close_action.setObjectName('close_action')
        close_action.triggered.connect(self.cancel.emit)
        close_action.triggered.connect(self.clear)

        self.addAction(search_action, QtWidgets.QLineEdit.LeadingPosition)
        self.addAction(close_action, QtWidgets.QLineEdit.TrailingPosition)

        plexdesktop.style.Style.Instance().widget.register(search_action, 'glyphicons-search')
        plexdesktop.style.Style.Instance().widget.register(close_action, 'cancel') 
Example 6
Project: binja_dynamics   Author: ehennenfent   File: __init__.py    (license) View Source Project 6 votes vote down vote up
def submit_line(self):
        """ Writes the input to the text browser, adds it to the history, and
        adds it to the message queue to be sent to the binary """
        raw = self._textbox.text()
        line = self.decode(raw)
        if line is None:
            return
        if raw not in self.history:
            self.history.append(raw)
            action = QtWidgets.QAction(str(raw), self)
            action.triggered.connect(partial(self.set_text_box_contents, raw))
            self._hist_menu.insertAction(self._hist_menu.actions()[0], action)
        self._messages.put((line, None))
        self._autoscroll()
        # self._textBrowser.setTextColor(usercolor)
        # self._textBrowser.insertPlainText(line + "\n")
        # self._textBrowser.setTextColor(self.palette().color(QPalette.WindowText))
        self._textbox.clear()
        self._autoscroll() 
Example 7
Project: gpvdm   Author: roderickmackenzie   File: ribbon_database.py    (license) View Source Project 6 votes vote down vote up
def __init__(self):
		QToolBar.__init__(self)

		self.setToolButtonStyle( Qt.ToolButtonTextUnderIcon)
		self.setIconSize(QSize(42, 42))
		
		self.materials = QAction(QIcon_load("organic_material"), _("Materials\ndatabase"), self)
		self.materials.triggered.connect(self.callback_view_materials)
		self.addAction(self.materials)

		self.spectra_file = QAction(QIcon_load("spectra_file"), _("Optical\ndatabase"), self)
		self.spectra_file.triggered.connect(self.callback_view_optical)
		self.addAction(self.spectra_file)

		if enable_betafeatures()==True:
			self.tb_import_pvlighthouse = QAction(QIcon_load("sync"), _("Update materials\nfrom PVLighthouse"), self)
			self.tb_import_pvlighthouse.triggered.connect(self.callback_pvlighthouse)
			self.addAction(self.tb_import_pvlighthouse)

			self.tb_import_refractiveindex = QAction(QIcon_load("sync"), _("Update materials\nfrom refractiveindex.info"), self)
			self.tb_import_refractiveindex.triggered.connect(self.callback_refractiveindex)
			self.addAction(self.tb_import_refractiveindex) 
Example 8
Project: gpvdm   Author: roderickmackenzie   File: ribbon.py    (license) View Source Project 6 votes vote down vote up
def file(self):
		toolbar = QToolBar()
		toolbar.setToolButtonStyle( Qt.ToolButtonTextUnderIcon)
		toolbar.setIconSize(QSize(42, 42))
		
		self.home_new = QAction(QIcon_load("document-new"), _("New simulation").replace(" ","\n"), self)
		#self.home_new.setText(_("New\nsimulation"))
		toolbar.addAction(self.home_new)

		self.home_open = QAction(QIcon_load("document-open"), _("Open\nsimulation"), self)
		toolbar.addAction(self.home_open)

		self.home_export = QAction(QIcon_load("document-export"), _("Export\ndata"), self)
		toolbar.addAction(self.home_export)

		spacer = QWidget()
		spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
		toolbar.addWidget(spacer)

		self.home_help = QAction(QIcon_load("internet-web-browser"), _("Help"), self)
		toolbar.addAction(self.home_help)

		return toolbar 
Example 9
Project: pysport   Author: sportorg   File: main.py    (license) View Source Project 6 votes vote down vote up
def _create_menu(self, parent, actions_list):
        for action_item in actions_list:
            if 'type' in action_item:
                if action_item['type'] == 'separator':
                    parent.addSeparator()
            elif 'action' in action_item:
                action = QtWidgets.QAction(self)
                parent.addAction(action)
                action.setText(action_item['title'])
                action.triggered.connect(action_item['action'])
                if 'shortcut' in action_item:
                    action.setShortcut(action_item['shortcut'])
                if 'icon' in action_item:
                    action.setIcon(QtGui.QIcon(action_item['icon']))
                if 'status_tip' in action_item:
                    action.setStatusTip(action_item['status_tip'])
                if 'property' in action_item:
                    self.menu_property[action_item['property']] = action
            else:
                menu = QtWidgets.QMenu(parent)
                menu.setTitle(action_item['title'])
                self._create_menu(menu, action_item['actions'])
                parent.addAction(menu.menuAction()) 
Example 10
Project: opcua-modeler   Author: FreeOpcUa   File: refnodesets_widget.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, view):
        QObject.__init__(self, view)
        self.view = view
        self.model = QStandardItemModel()
        self.view.setModel(self.model)
        self.nodesets = []
        self.server_mgr = None
        self._nodeset_to_delete = None
        self.view.header().setSectionResizeMode(1)
        
        addNodeSetAction = QAction("Add Reference Node Set", self.model)
        addNodeSetAction.triggered.connect(self.add_nodeset)
        self.removeNodeSetAction = QAction("Remove Reference Node Set", self.model)
        self.removeNodeSetAction.triggered.connect(self.remove_nodeset)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(addNodeSetAction)
        self._contextMenu.addAction(self.removeNodeSetAction) 
Example 11
Project: opcua-modeler   Author: FreeOpcUa   File: namespace_widget.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, view):
        QObject.__init__(self, view)
        self.view = view
        self.model = QStandardItemModel()
        self.view.setModel(self.model)
        delegate = MyDelegate(self.view, self)
        delegate.error.connect(self.error.emit)
        self.view.setItemDelegate(delegate)
        self.node = None
        self.view.header().setSectionResizeMode(1)
        
        self.addNamespaceAction = QAction("Add Namespace", self.model)
        self.addNamespaceAction.triggered.connect(self.add_namespace)
        self.removeNamespaceAction = QAction("Remove Namespace", self.model)
        self.removeNamespaceAction.triggered.connect(self.remove_namespace)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(self.addNamespaceAction)
        self._contextMenu.addAction(self.removeNamespaceAction) 
Example 12
Project: Mac-Python-3.X   Author: L1nwatch   File: shapedclock.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, parent=None):
        super(ShapedClock, self).__init__(parent,
                Qt.FramelessWindowHint | Qt.WindowSystemMenuHint)

        timer = QTimer(self)
        timer.timeout.connect(self.update)
        timer.start(1000)

        quitAction = QAction("E&xit", self, shortcut="Ctrl+Q",
                triggered=QApplication.instance().quit)
        self.addAction(quitAction)

        self.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.setToolTip("Drag the clock with the left mouse button.\n"
                "Use the right mouse button to open a context menu.")
        self.setWindowTitle(self.tr("Shaped Analog Clock")) 
Example 13
Project: Worksets   Author: DozyDolphin   File: trayindicator.py    (license) View Source Project 6 votes vote down vote up
def build_menu(self, workset_names = None):
        self.menu.clear()
        worksets = self.controller.get_worksets()
        for workset in worksets:
            action = QAction(workset.name, self)
            action.setCheckable(True)

            if workset_names is not None:
                if action.text() in workset_names:
                    action.setChecked(True)
            self.menu.addAction(action)
            action.triggered.connect(functools.partial(
                self.handle_workset,
                action))

        self.menu.addSeparator()

        create_action = self.menu.addAction(_("Manage worksets"))
        create_action.triggered.connect(self.manage_worksets)

        settings_action = self.menu.addAction(_("Settings"))
        settings_action.triggered.connect(self.settings)

        exit_action = self.menu.addAction(_("Quit"))
        exit_action.triggered.connect(self.close) 
Example 14
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1020.py    (license) View Source Project 6 votes vote down vote up
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name == '_':
                    self.uiList[menu_str].addSeparator()
                else:
                    if atn_name not in self.uiList.keys():
                        self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                        if atn_hotkey != '':
                            self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                    self.uiList[menu_str].addAction(self.uiList[atn_name]) 
Example 15
Project: universal_tool_template.py   Author: shiningdesign   File: UITranslator.py    (license) View Source Project 6 votes vote down vote up
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name] 
Example 16
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_0904.py    (license) View Source Project 6 votes vote down vote up
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name] 
Example 17
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_0803.py    (license) View Source Project 6 votes vote down vote up
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name] 
Example 18
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_v8.1.py    (license) View Source Project 6 votes vote down vote up
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name] 
Example 19
Project: Laborejo   Author: hilbrichtsoftware   File: graphs.py    (license) View Source Project 6 votes vote down vote up
def contextMenuEvent(self, event):
        menu = QtWidgets.QMenu()

        listOfLabelsAndFunctions = [
            ("interpolation Type", self.changeInterpolationType),
            ("CC Value", self.changeCCValue),
            ("delete", self.delete), #deletes the last hover item which is of course the current one.
            ]

        for text, function in listOfLabelsAndFunctions:
            if text == "separator":
                self.addSeparator()
            else:
                a = QtWidgets.QAction(text, menu)
                menu.addAction(a)
                a.triggered.connect(function)

        pos = QtGui.QCursor.pos()
        pos.setY(pos.y() + 5)
        self.ungrabMouse() #if we don't ungrab and the user clicks the context menu "away" by clicking in an empty area this will still get registered as mouseclick belonging to the current item and change the value to some insane amount, breaking the point.
        menu.exec_(pos) 
Example 20
Project: Laborejo   Author: hilbrichtsoftware   File: timeline.py    (license) View Source Project 6 votes vote down vote up
def contextMenuEvent(self, event):
        menu = QtWidgets.QMenu()

        listOfLabelsAndFunctions = [
            ("interpolation type", self.changeInterpolationType),
            ("units per minute", self.changeTempoUnits),
            ("reference note", self.changeTempoReference),
            ]
        if not self.staticExportItem["positionInBlock"] == 0:
            listOfLabelsAndFunctions.append(("delete", lambda: api.removeTempoItem(self.staticExportItem["id"])))

        for text, function in listOfLabelsAndFunctions:
            if text == "separator":
                self.addSeparator()
            else:
                a = QtWidgets.QAction(text, menu)
                menu.addAction(a)
                a.triggered.connect(function)

        pos = QtGui.QCursor.pos()
        pos.setY(pos.y() + 5)
        self.ungrabMouse() #if we don't ungrab and the user clicks the context menu "away" by clicking in an empty area this will still get registered as mouseclick belonging to the current item
        menu.exec_(pos) 
Example 21
Project: Laborejo   Author: hilbrichtsoftware   File: timeline.py    (license) View Source Project 6 votes vote down vote up
def deactivate_contextMenuEvent(self, event):
        menu = QtWidgets.QMenu()

        listOfLabelsAndFunctions = [
            ("restore to full duration ", self.contextRestore),
            ]

        for text, function in listOfLabelsAndFunctions:
            if text == "separator":
                self.addSeparator()
            else:
                a = QtWidgets.QAction(text, menu)
                menu.addAction(a)
                a.triggered.connect(function)

        pos = QtGui.QCursor.pos()
        pos.setY(pos.y() + 5)
        self.ungrabMouse() #if we don't ungrab and the user clicks the context menu "away" by clicking in an empty area this will still get registered as mouseclick belonging to the current item
        menu.exec_(pos) 
Example 22
Project: PointlessMaker   Author: aboood40091   File: main.py    (license) View Source Project 6 votes vote down vote up
def CreateAction(self, shortname, function, icon, text, statustext, shortcut, toggle=False):
        """
        Helper function to create an action
        From Miyamoto
        """

        if icon is not None:
            act = QtWidgets.QAction(icon, text, self)
        else:
            act = QtWidgets.QAction(text, self)

        if shortcut is not None: act.setShortcut(shortcut)
        if statustext is not None: act.setStatusTip(statustext)
        if toggle:
            act.setCheckable(True)
        if function is not None: act.triggered.connect(function)

        self.actions[shortname] = act 
Example 23
Project: py301   Author: PFLC   File: prac9.py    (license) View Source Project 6 votes vote down vote up
def initUI(self):               
        
        exitAction = QAction(QIcon('exit.png'), '&Exit', self)        
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(qApp.quit)

        self.statusBar()

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(exitAction)
        
        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle('Menubar')    
        self.show() 
Example 24
Project: py301   Author: PFLC   File: prac11.py    (license) View Source Project 6 votes vote down vote up
def initUI(self):               
        
        textEdit = QTextEdit()
        self.setCentralWidget(textEdit)

        exitAction = QAction(QIcon('exit24.png'), '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)

        toolbar = self.addToolBar('Exit')
        toolbar.addAction(exitAction)
        
        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('Main window')    
        self.show() 
Example 25
Project: opcua-widgets   Author: FreeOpcUa   File: tree_widget.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, view):
        QObject.__init__(self, view)
        self.view = view
        self.model = TreeViewModel()
        self.model.clear()  # FIXME: do we need this?
        self.model.error.connect(self.error)
        self.view.setModel(self.model)

        #self.view.setUniformRowHeights(True)
        self.model.setHorizontalHeaderLabels(['DisplayName', "BrowseName", 'NodeId'])
        self.view.header().setSectionResizeMode(0)
        self.view.header().setStretchLastSection(True)
        self.view.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.settings = QSettings()
        state = self.settings.value("tree_widget_state", None)
        if state is not None:
            self.view.header().restoreState(state)

        self.actionReload = QAction("Reload", self)
        self.actionReload.triggered.connect(self.reload_current) 
Example 26
Project: urh   Author: jopohl   File: GeneratorListWidget.py    (license) View Source Project 6 votes vote down vote up
def contextMenuEvent(self, event: QContextMenuEvent):
        menu = QMenu()
        sel_indexes = [index.row() for index in self.selectedIndexes()]
        edit_action = QAction("Edit", self)
        if len(sel_indexes) == 0:
            edit_action.setEnabled(False)

        menu.addAction(edit_action)

        if self.count() > 0:
            edit_all_action = QAction("Edit all", self)
            edit_all_action.triggered.connect(self.on_edit_all_action_triggered)
            menu.addAction(edit_all_action)

        action = menu.exec_(self.mapToGlobal(event.pos()))
        if action == edit_action:
            selected_indx = sel_indexes[0]
            self.item_edit_clicked.emit(selected_indx) 
Example 27
Project: urh   Author: jopohl   File: ProtocolTableView.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, parent=None):
        super().__init__(parent)

        self.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)
        self.horizontalHeader().setSectionResizeMode(QHeaderView.Fixed)

        self.ref_message_action = QAction(self.tr("Mark as reference message"), self)
        self.ref_message_action.setShortcut(QKeySequence("R"))
        self.ref_message_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.ref_message_action.triggered.connect(self.set_ref_message)

        self.hide_row_action = QAction("Hide selected rows", self)
        self.hide_row_action.setShortcut(QKeySequence("H"))
        self.hide_row_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.hide_row_action.triggered.connect(self.hide_row)

        self.addAction(self.ref_message_action)
        self.addAction(self.hide_row_action) 
Example 28
Project: urh   Author: jopohl   File: MessageBreakPlugin.py    (license) View Source Project 6 votes vote down vote up
def get_action(self, parent, undo_stack: QUndoStack, sel_range, protocol: ProtocolAnalyzer, view: int):
        """
        :type parent: QTableView
        :type undo_stack: QUndoStack
        :type protocol_analyzers: list of ProtocolAnalyzer
        """
        min_row, max_row, start, end = sel_range
        if min_row == -1 or max_row == -1 or start == -1 or end == -1:
            return None

        if max_row != min_row:
            QMessageBox.critical(parent, self.tr("Error in MessageBreak"),
                                 self.tr("You can only break one line per action."))
            return None

        end = protocol.convert_index(end, view, 0, True, message_indx=min_row)[0]
        # factor = 1 if view == 0 else 4 if view == 1 else 8

        self.command = MessageBreakAction(protocol, max_row, end)
        action = QAction(self.command.text(), parent)
        action.triggered.connect(self.action_triggered)
        self.undo_stack = undo_stack
        return action 
Example 29
Project: FIRST-plugin-ida   Author: vrtadmin   File: first.py    (license) View Source Project 6 votes vote down vote up
def applied_custom_menu(self, point):
        index = self.applied_tree_view.indexAt(point)
        address = index.data(FIRSTUI.ROLE_ADDRESS)
        if not address:
            return

        menu = QtWidgets.QMenu(self.applied_tree_view)
        goto_action = QtWidgets.QAction('&Go to Function', self.applied_tree_view)
        goto_action.triggered.connect(lambda:IDAW.Jump(address))
        menu.addAction(goto_action)

        metadata_id = index.data(FIRSTUI.ROLE_ID)
        if metadata_id:
            history_action = QtWidgets.QAction('View &History', self.applied_tree_view)
            history_action.triggered.connect(lambda:self._metadata_history(metadata_id))
            menu.addAction(history_action)

        menu.exec_(QtGui.QCursor.pos()) 
Example 30
Project: FIRST-plugin-ida   Author: vrtadmin   File: first.py    (license) View Source Project 6 votes vote down vote up
def custom_menu(self, point):
            index = self.tree_view.indexAt(point)
            address = index.data(FIRSTUI.ROLE_ADDRESS)
            if not address:
                return

            menu = QtWidgets.QMenu(self.tree_view)
            goto_action = QtWidgets.QAction('&Go to Function', self.tree_view)
            goto_action.triggered.connect(lambda:IDAW.Jump(address))
            menu.addAction(goto_action)

            metadata_id = index.data(FIRSTUI.ROLE_ID)
            if metadata_id:
                history_action = QtWidgets.QAction('View &History', self.tree_view)
                history_action.triggered.connect(lambda:self.metadata_history(metadata_id))
                menu.addAction(history_action)

            menu.exec_(QtGui.QCursor.pos()) 
Example 31
Project: pyqt5-example   Author: guinslym   File: shapedclock.py    (license) View Source Project 6 votes vote down vote up
def __init__(self, parent=None):
        super(ShapedClock, self).__init__(parent,
                Qt.FramelessWindowHint | Qt.WindowSystemMenuHint)

        timer = QTimer(self)
        timer.timeout.connect(self.update)
        timer.start(1000)

        quitAction = QAction("E&xit", self, shortcut="Ctrl+Q",
                triggered=QApplication.instance().quit)
        self.addAction(quitAction)

        self.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.setToolTip("Drag the clock with the left mouse button.\n"
                "Use the right mouse button to open a context menu.")
        self.setWindowTitle(self.tr("Shaped Analog Clock")) 
Example 32
Project: shadowsocks-pyqt   Author: falseen   File: main.py    (license) View Source Project 6 votes vote down vote up
def Tray_init(self):
        self.tray = QSystemTrayIcon()
        self.icon = self.windowIcon()
        self.tray.setIcon(self.icon)
        self.tray.activated[QSystemTrayIcon.ActivationReason].connect(
            self.TrayEvent)
        self.tray_menu = QtWidgets.QMenu(QtWidgets.QApplication.desktop())
        self.ShowAction = QtWidgets.QAction(
            u'?? ', self, triggered=self.re_build)
        self.ShowLog = QtWidgets.QAction(
            u'???? ', self, triggered=self.logwindow.showlog)
        self.QuitAction = QtWidgets.QAction(
            u'?? ', self, triggered=self.app_quit)
        self.tray_menu.addAction(self.ShowLog)
        self.tray_menu.addAction(self.ShowAction)
        self.tray_menu.addAction(self.QuitAction)
        self.tray.setContextMenu(self.tray_menu)  # ????????
        self.tray.show()
        self.showMessage(u"shadowsocks-pyqt ?????") 
Example 33
Project: RRPam-WDS   Author: asselapathirana   File: dialogs.py    (license) View Source Project 6 votes vote down vote up
def setMenu(self):
        bar = self.menuBar()
        bar.setNativeMenuBar(False)  # disable different treatment in Mac OS
        file = bar.addMenu(self.menuitems.file)
        file.addAction(self.menuitems.new_project)
        self.saveaction = file.addAction(self.menuitems.save_project)
        self.saveasaction = file.addAction(self.menuitems.save_project_as)
        file.addAction(self.menuitems.open_project)
        file.addAction(self.menuitems.new_wlc)
        file.addAction(self.menuitems.show_log)
        self.closeaction = file.addAction(self.menuitems.close_project)
        file.triggered[QAction].connect(self.windowaction)
        file2 = bar.addMenu(self.menuitems.view)
        file2.addAction(self.menuitems.cascade)
        file2.addAction(self.menuitems.tiled)
        file2.triggered[QAction].connect(self.windowaction)
        file3 = bar.addMenu(self.menuitems.help)
        self.aboutaction = file3.addAction(self.menuitems.about)
        self.guideaction = file3.addAction(self.menuitems.guide)
        file3.triggered[QAction].connect(self.windowaction) 
Example 34
Project: notepad   Author: lfsando   File: notepad.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def preferences_menu(self):
        
        settings_action = QtWidgets.QAction(QtGui.QIcon('assets/icons/config.png'), '&Settings', self)
        settings_action.setStatusTip('Open Settings')
        settings_action.setShortcut('Ctrl+Shift+P')

        preferences_menu = self.menu_bar.addMenu('Prefere&nces')
        preferences_menu.addAction(settings_action) 
Example 35
Project: notepad   Author: lfsando   File: notepad.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
def format_menu(self):
        """ Add Format Menu """

        font_action = QtWidgets.QAction(QtGui.QIcon('assets/icons/font.png'), '&Font', self)
        font_action.setStatusTip('Change the document font')
        font_action.triggered.connect(self.font_dialog)

        date_action = QtWidgets.QAction(QtGui.QIcon('assets/icons/date.png'), '&Append Date', self)
        date_action.setStatusTip('Insert date and time at cursor location')
        date_action.setShortcut('F5')
        date_action.triggered.connect(self.insert_date)

        self.default_syntax = QtWidgets.QAction('&Default', self)
        self.default_syntax.setStatusTip('Turn off syntax highlighting')

        self.python_syntax = QtWidgets.QAction('&Python', self)
        self.python_syntax.setStatusTip('Turn on syntax highlighting for Python language')

        self.default_syntax.triggered.connect(self.assign_syntax_def)
        self.python_syntax.triggered.connect(self.assign_syntax_py)

        format_menu = self.menu_bar.addMenu('Forma&t')

        syntax_menu = format_menu.addMenu(QtGui.QIcon('assets/icons/synthax.png'), '&Syntax')

        syntax_menu.addAction(self.default_syntax)
        syntax_menu.addAction(self.python_syntax)

        format_menu.addSeparator()
        format_menu.addAction(font_action)
        format_menu.addAction(date_action)

    # Text Finder 
Example 36
Project: activity-browser   Author: LCA-ActivityBrowser   File: toolbar.py    (license) View Source Project 5 votes vote down vote up
def set_project_label(self):
        name = projects.current
        self.project_name_label.setText('Project: {}'.format(name))
        self.project_read_only.setText('')
        if projects.read_only:
            self.project_read_only.setText('Read Only Project')
            self.window.warning("Read Only Project", """Read Only Project.\nAnother Python process is working with this project, no writes are allowed.\nCheck to make sure no other Python interpreters are running, and then re-select this project.""")

    # def get_search_box(self):
    #     search_box = QtWidgets.QLineEdit()
    #     search_box.setMaximumSize(QtCore.QSize(150, 25))

    #     # Search
    #     search_action = QtWidgets.QAction(
    #         QtGui.QIcon(icons.search),
    #         'Search activites (see help for search syntax)',
    #         self.window
    #     )
    #     return search_box

    # def get_key_search(self):
    #     key_search_action = QtWidgets.QAction(
    #         QtGui.QIcon(icons.key),
    #         'Search by key',
    #         self.window
    #     )
    #     # key_search_action.triggered.connect(self.search_by_key)
    #     return key_search_action 
Example 37
Project: activity-browser   Author: LCA-ActivityBrowser   File: inventory.py    (license) View Source Project 5 votes vote down vote up
def setup_context_menu(self):
        # delete database
        self.delete_database_action = QtWidgets.QAction(
            QtGui.QIcon(icons.delete), "Delete database", None
        )
        self.addAction(self.delete_database_action)
        self.delete_database_action.triggered.connect(
            lambda x: signals.delete_database.emit(
                self.currentItem().db_name
            )
        )

        # copy database
        self.copy_database_action = QtWidgets.QAction(
            QtGui.QIcon(icons.duplicate), "Copy database", None
        )
        self.addAction(self.copy_database_action)
        self.copy_database_action.triggered.connect(
            lambda x: signals.copy_database.emit(
                self.currentItem().db_name
            )
        )
        # add activity (important for empty databases, where the activities table will not show up)
        self.add_activity_action = QtWidgets.QAction(
            QtGui.QIcon(icons.add), "Add new activity", None
        )
        self.addAction(self.add_activity_action)
        self.add_activity_action.triggered.connect(
            lambda x: signals.new_activity.emit(
                self.currentItem().db_name
            )
        ) 
Example 38
Project: activity-browser   Author: LCA-ActivityBrowser   File: inventory.py    (license) View Source Project 5 votes vote down vote up
def setup_context_menu(self):
        self.add_activity_action = QtWidgets.QAction(
            QtGui.QIcon(icons.add), "Add new activity", None
        )
        self.copy_activity_action = QtWidgets.QAction(
            QtGui.QIcon(icons.copy), "Copy activity", None
        )
        self.delete_activity_action = QtWidgets.QAction(
            QtGui.QIcon(icons.delete), "Delete activity", None
        )
        self.open_left_tab_action = QtWidgets.QAction(
            QtGui.QIcon(icons.left), "Open in new tab", None
        )
        self.addAction(self.add_activity_action)
        self.addAction(self.copy_activity_action)
        self.addAction(self.delete_activity_action)
        self.addAction(self.open_left_tab_action)
        self.add_activity_action.triggered.connect(
            lambda: signals.new_activity.emit(self.database.name)
        )
        self.copy_activity_action.triggered.connect(
            lambda x: signals.copy_activity.emit(self.currentItem().key)
        )
        self.delete_activity_action.triggered.connect(
            lambda x: signals.delete_activity.emit(self.currentItem().key)
        )
        self.open_left_tab_action.triggered.connect(
            lambda x: signals.open_activity_tab.emit("activities", self.currentItem().key)
        ) 
Example 39
Project: activity-browser   Author: LCA-ActivityBrowser   File: history.py    (license) View Source Project 5 votes vote down vote up
def setup_context_menu(self):
        self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
        self.open_left_tab_action = QtWidgets.QAction(
            QtGui.QIcon(icons.left), "Open in new tab", None
        )
        self.addAction(self.open_left_tab_action)
        self.open_left_tab_action.triggered.connect(
            lambda x: signals.open_activity_tab.emit(
                "activities", self.currentItem().key
            )
        ) 
Example 40
Project: activity-browser   Author: LCA-ActivityBrowser   File: calculation_setups.py    (license) View Source Project 5 votes vote down vote up
def setup_context_menu(self):
        self.delete_row_action = QtWidgets.QAction(
            QtGui.QIcon(icons.delete), "Remove row", None
        )
        self.addAction(self.delete_row_action)
        self.delete_row_action.triggered.connect(self.delete_rows) 
Example 41
Project: activity-browser   Author: LCA-ActivityBrowser   File: activity.py    (license) View Source Project 5 votes vote down vote up
def setup_context_menu(self):
        self.delete_exchange_action = QtWidgets.QAction(
            QtGui.QIcon(icons.delete), "Delete exchange(s)", None
        )
        self.addAction(self.delete_exchange_action)
        self.delete_exchange_action.triggered.connect(self.delete_exchanges) 
Example 42
Project: activity-browser   Author: LCA-ActivityBrowser   File: menu_bar.py    (license) View Source Project 5 votes vote down vote up
def setup_file_menu(self):
        menu = QtWidgets.QMenu('&File', self.window)
        # Switch BW2 directory
        # switch_bw2_dir = QtWidgets.QAction(QtGui.QIcon('exit.png'), '&Database directory...', self.window)
        # # switch_bw2_dir.setShortcut('Ctrl+Q')
        # switch_bw2_dir.setStatusTip('Change database directory')
        # switch_bw2_dir.triggered.connect(signals.switch_bw2_dir_path.emit)
        # menu.addAction(switch_bw2_dir)
        menu.addAction(
            '&Database directory...',
            signals.switch_bw2_dir_path.emit
        )
        menu.addAction(
            '&Import database...',
            signals.import_database.emit
        )
        return menu

    # def setup_extensions_menu(self):
    #     extensions_menu = QtWidgets.QMenu('&Extensions', self.window)
    #     # extensions_menu.addAction(
    #     #     self.add_metaprocess_menu_item()
    #     # )
    #     return extensions_menu 
Example 43
Project: uPyLoader   Author: BetaRavener   File: transfer_tree_view.py    (license) View Source Project 5 votes vote down vote up
def _add_menu_action(self, title, handler):
        action = QAction(title, self.context_menu)
        action.triggered.connect(handler)
        self.context_menu.addAction(action)
        return action 
Example 44
Project: git-annex-metadata-gui   Author: alpernebbi   File: main_window.py    (license) View Source Project 5 votes vote down vote up
def create_header_menu_action(self, header):
        actions = self.menu_headers.actions()
        headers = [act.text() for act in actions]

        if header in headers:
            return
        idx = bisect.bisect(headers, header)

        action = QtWidgets.QAction(self)
        action.setText(header)
        action.setCheckable(True)
        action.setChecked(True)

        def set_visibility(visible):
            self.view_keys.show_header(header, visible)
            self.view_head.show_header(header, visible)

        action.triggered.connect(set_visibility)

        def visibility_set(header_, visible):
            if header_ == header:
                action.setChecked(visible)

        for view in (self.view_keys, self.view_head):
            view.header_visibility_changed.connect(visibility_set)

        if idx < len(actions):
            before_action = actions[idx]
            self.menu_headers.insertAction(before_action, action)
        else:
            self.menu_headers.addAction(action)

        empty = len(self.menu_headers.actions()) == 0
        self.menu_headers.setDisabled(empty) 
Example 45
Project: Dragonfly   Author: duaneloh   File: frameviewer.py    (license) View Source Project 5 votes vote down vote up
def init_UI(self):
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle('Dragonfly Frame Viewer')
        window = QtWidgets.QWidget()

        self.hbox = QtWidgets.QHBoxLayout()
        self.frame_panel = frame_panel.Frame_panel(self, powder=self.do_powder, compare=self.do_compare)
        self.hbox.addWidget(self.frame_panel)

        # Menu items
        menubar = self.menuBar()
        menubar.setNativeMenuBar(False)
        # Theme picker
        thememenu = menubar.addMenu('&Theme')
        self.theme = QtWidgets.QActionGroup(self, exclusive=True)
        for i, s in enumerate(map(str, list(QtWidgets.QStyleFactory.keys()))):
            a = self.theme.addAction(QtWidgets.QAction(s, self, checkable=True))
            if i == 0:
                a.setChecked(True)
            a.triggered.connect(self.theme_changed)
            thememenu.addAction(a)
        # Color map picker
        cmapmenu = menubar.addMenu('&Color Map')
        self.color_map = QtWidgets.QActionGroup(self, exclusive=True)
        for i, s in enumerate(['cubehelix', 'CMRmap', 'gray', 'gray_r', 'jet']):
            a = self.color_map.addAction(QtWidgets.QAction(s, self, checkable=True))
            if i == 0:
                a.setChecked(True)
            a.triggered.connect(self.cmap_changed)
            cmapmenu.addAction(a)

        window.setLayout(self.hbox)
        self.setCentralWidget(window)
        self.show() 
Example 46
Project: bitmask-dev   Author: leapcode   File: systray.py    (license) View Source Project 5 votes vote down vote up
def _createActions(self):
        self.quitAction = QAction(
            "&Quit", self,
            triggered=self.closeFromSystray) 
Example 47
Project: VIRTUAL-PHONE   Author: SumanKanrar-IEM   File: Menu_Bars.py    (license) View Source Project 5 votes vote down vote up
def __init__(self):
        super().__init__()

        # Create Menu Bar
        bar = self.menuBar()

        # Create Root Menus
        file = bar.addMenu('File')
        edit = bar.addMenu('Edit')

        # Create Actions for menus
        save_action = QAction('Save', self)
        save_action.setShortcut('Ctrl+S')

        new_action = QAction('New', self)
        new_action.setShortcut('Ctrl+N')

        quit_action = QAction('&Quit', self)
        quit_action.setShortcut('Ctrl+Q')

        find_action = QAction('Find...', self)

        replace_action = QAction('Replace...', self)

        # Add actions to Menus
        file.addAction(new_action)
        file.addAction(save_action)
        file.addAction(quit_action)
        find_menu = edit.addMenu('Find')
        find_menu.addAction(find_action)
        find_menu.addAction(replace_action)

        # Events
        quit_action.triggered.connect(self.quit_trigger)
        file.triggered.connect(self.selected)

        self.setWindowTitle("My Menus")
        self.resize(600, 400)

        self.show() 
Example 48
Project: VIRTUAL-PHONE   Author: SumanKanrar-IEM   File: Notepad_menubar.py    (license) View Source Project 5 votes vote down vote up
def init_ui(self):
        bar = self.menuBar()
        file = bar.addMenu('File')
        edit = bar.addMenu('Edit')

        new_action = QAction('New', self)
        new_action.setShortcut('Ctrl+N')

        save_action = QAction('&Save', self)
        save_action.setShortcut('Ctrl+S')

        open_action = QAction('&Open', self)

        quit_action = QAction('&Quit', self)

        font_action = QAction('&Font', self)

        file.addAction(new_action)
        file.addAction(save_action)
        file.addAction(open_action)
        file.addAction(quit_action)
        edit.addAction(font_action)

        quit_action.triggered.connect(self.quit_trigger)
        file.triggered.connect(self.respond)
        font_action.triggered.connect(self.font_changer1)
        self.setWindowTitle("Notepad")
        self.show() 
Example 49
Project: VIRTUAL-PHONE   Author: SumanKanrar-IEM   File: Writing_CSV.py    (license) View Source Project 5 votes vote down vote up
def __init__(self):
        super().__init__()

        self.form_widget = MyTable(10, 5)
        self.setCentralWidget(self.form_widget)
        col_headers = ['Name', 'Phone No.', 'Email', 'Address', 'DOB']
        self.form_widget.setHorizontalHeaderLabels(col_headers)

        # Set up menu
        bar = self.menuBar()
        file = bar.addMenu('File')

        save_action = QAction('&Save', self)
        save_action.setShortcut('Ctrl+S')

        open_action = QAction('&Open', self)

        quit_action = QAction('&Quit', self)

        file.addAction(save_action)
        file.addAction(open_action)
        file.addAction(quit_action)

        quit_action.triggered.connect(self.quit_app)
        save_action.triggered.connect(self.form_widget.save_sheet)
        open_action.triggered.connect(self.form_widget.open_sheet)
        self.show() 
Example 50
Project: VIRTUAL-PHONE   Author: SumanKanrar-IEM   File: Notepad.py    (license) View Source Project 5 votes vote down vote up
def init_ui(self):
        bar = self.menuBar()
        file = bar.addMenu('File')
        edit = bar.addMenu('Edit')

        new_action = QAction('New', self)
        new_action.setShortcut('Ctrl+N')

        save_action = QAction('&Save', self)
        save_action.setShortcut('Ctrl+S')

        open_action = QAction('&Open', self)

        quit_action = QAction('&Quit', self)

        font_action = QAction('&Font', self)

        file.addAction(new_action)
        file.addAction(save_action)
        file.addAction(open_action)
        file.addAction(quit_action)
        edit.addAction(font_action)

        quit_action.triggered.connect(self.quit_trigger)
        file.triggered.connect(self.respond)
        font_action.triggered.connect(self.font_changer1)
        self.setWindowTitle("Notepad")
        self.setWindowIcon(QIcon('notepad.png'))
        self.show()