class Actions(actioncollection.ActionCollection): name = "docbrowser" def title(self): return _("Documentation Browser") def createActions(self, parent=None): self.help_back = QAction(parent) self.help_forward = QAction(parent) self.help_home = QAction(parent) self.help_print = QAction(parent) self.help_lilypond_doc= QAction(parent) self.help_lilypond_context = QAction(parent) self.help_back.setIcon(icons.get("go-previous")) self.help_forward.setIcon(icons.get("go-next")) self.help_home.setIcon(icons.get("go-home")) self.help_lilypond_doc.setIcon(icons.get("lilypond-run")) self.help_print.setIcon(icons.get("document-print")) self.help_lilypond_doc.setShortcut(QKeySequence("F9")) self.help_lilypond_context.setShortcut(QKeySequence("Shift+F9")) def translateUI(self): self.help_back.setText(_("Back")) self.help_forward.setText(_("Forward")) # L10N: Home page of the LilyPond manual self.help_home.setText(_("Home")) self.help_print.setText(_("Print...")) self.help_lilypond_doc.setText(_("&LilyPond Documentation")) self.help_lilypond_context.setText(_("&Contextual LilyPond Help"))
def createAction(self, text="", slot=None, shortcut=None, icon=None, tip=None, checkable=False, signal="triggered()"): """Create action out of keyword arguments. Return action. Keyword arguments: text -- User visible text (default "") slot -- function to call (default None) shortcut -- Key sequence (default None) icon -- Name of icon file (default None) tip -- Tooltip (default None) checkable -- Should action be checkable (default None) signal -- Signal to emit (default "triggered()") """ action = QAction(text, self) if icon is not None: action.setIcon(QIcon(":/resource/{0}.png".format(icon))) if shortcut is not None: action.setShortcut(shortcut) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if slot is not None: self.connect(action, SIGNAL(signal), slot) if checkable: action.setCheckable(True) return action
class Actions(actioncollection.ActionCollection): name = "documentactions" def createActions(self, parent): self.file_open_file_at_cursor = QAction(parent) self.edit_cut_assign = QAction(parent) self.view_highlighting = QAction(parent) self.view_highlighting.setCheckable(True) self.tools_indent_auto = QAction(parent) self.tools_indent_auto.setCheckable(True) self.tools_indent_indent = QAction(parent) self.tools_reformat = QAction(parent) self.tools_convert_ly = QAction(parent) self.edit_cut_assign.setIcon(icons.get('edit-cut')) self.file_open_file_at_cursor.setShortcut(QKeySequence("Alt+Ctrl+O")) self.edit_cut_assign.setShortcut(QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_X)) def translateUI(self): self.file_open_file_at_cursor.setText(_("Open File at C&ursor")) self.edit_cut_assign.setText(_("Cut and Assign...")) self.view_highlighting.setText(_("Syntax &Highlighting")) self.tools_indent_auto.setText(_("&Automatic Indent")) self.tools_indent_indent.setText(_("Re-&Indent")) self.tools_reformat.setText(_("&Format")) self.tools_convert_ly.setText(_("&Update with convert-ly..."))
def __init__(self): super(MainWindow, self).__init__() # The tabs, one per counter self.tabs = QTabWidget() #self.tabs.currentChanged.connect(self.currentTabChanged) #self.current_tab = 0 self.setupTabs() self.setCentralWidget(self.tabs) self.statusBar() exitAction = QAction(QIcon('exit.png'), '&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(qApp.quit) registerAction = QAction('Register', self) registerAction.setShortcut('Ctrl+R') registerAction.setStatusTip('Register new counter entry') registerAction.triggered.connect(self.register) menuBar = self.menuBar() fileMenu = menuBar.addMenu("&File") fileMenu.addAction(registerAction) fileMenu.addAction(exitAction) self.setWindowTitle("Monepy - v %s" % version)
def __init__(self): QObject.__init__(self) self._createdActions = [] self._createdMenus = [] self._currentDocument = core.workspace().currentDocument() # probably None model = core.actionManager() for menu in _MENUS: if menu[2]: menuObj = model.addMenu(menu[0], menu[1], QIcon(':/enkiicons/' + menu[2])) else: menuObj = model.addMenu(menu[0], menu[1]) menuObj.setEnabled(False) self._createdMenus.append(menuObj) for command, path, text, shortcut, icon in _ACTIONS: actObject = QAction(text, self) if shortcut: actObject.setShortcut(shortcut) if icon: actObject.setIcon(QIcon(':/enkiicons/' + icon)) actObject.setData(command) actObject.setEnabled(False) actObject.triggered.connect(self.onAction) model.addAction(path, actObject) self._createdActions.append(actObject) core.workspace().currentDocumentChanged.connect(self.onCurrentDocumentChanged)
def create_action(parent, text, shortcut=None, icon=None, tip=None, toggled=None, triggered=None, data=None, context=Qt.WindowShortcut): """Create a QAction""" action = QAction(text, parent) if triggered is not None: parent.connect(action, SIGNAL("triggered()"), triggered) if toggled is not None: parent.connect(action, SIGNAL("toggled(bool)"), toggled) action.setCheckable(True) if icon is not None: if isinstance(icon, (str, unicode)): icon = get_icon(icon) action.setIcon( icon ) if shortcut is not None: action.setShortcut(shortcut) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if data is not None: action.setData(QVariant(data)) #TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut # (this will avoid calling shortcuts from another dockwidget # since the context thing doesn't work quite well with these widgets) action.setShortcutContext(context) return action
def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) backAction = QAction(QIcon(":/back.png"), "&Back", self) backAction.setShortcut(QKeySequence.Back) homeAction = QAction(QIcon(":/home.png"), "&Home", self) homeAction.setShortcut("Home") self.pageLabel = QLabel() toolBar = QToolBar() toolBar.addAction(backAction) toolBar.addAction(homeAction) toolBar.addWidget(self.pageLabel) self.textBrowser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) self.connect(backAction, SIGNAL("triggered()"), self.textBrowser, SLOT("backward()")) self.connect(homeAction, SIGNAL("triggered()"), self.textBrowser, SLOT("home()")) self.connect(self.textBrowser, SIGNAL("sourceChanged(QUrl)"), self.updatePageTitle) self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(page)) self.resize(400, 600) self.setWindowTitle("{0} Help".format( QApplication.applicationName()))
def __init__(self, Ui_MainWindow, timeout=1000): super(FellesGui, self).__init__() self.setAttribute(Qt.WA_DeleteOnClose) exitAction = QAction('Quit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Quit application') print("Push 'Ctrl+Q' to quit the application") exitAction.triggered.connect(self.close) # Create Widget for the purpose of updating the widgets periodically #self.timer = QTimer() #self.timer.timeout.connect(self.paintEvent) #self.timer.start(timeout) # --> Instantiate UI !!! This is where the widgets are initiated !!! self.buildUi(Ui_MainWindow) # --> Setup the Menu Bar fileMenu = self.menuBar().addMenu('&File') fileMenu.addAction(exitAction) # --> Order widgets to connect to their slaves self.initialiseSlaves.emit() # --> Initialise "Threads" performing the sampling ports = QFellesWidgetBaseClass.___ports___.keys() self.sampling_threads = [ FellesThread(port) for port in ports ] #self.statusBar().showMessage.connect(FellesThread.sample_failed) self.statusBar().showMessage('Idling...')
class Actions(actioncollection.ActionCollection): name = "docbrowser" def title(self): return _("Documentation Browser") def createActions(self, parent=None): self.help_back = QAction(parent) self.help_forward = QAction(parent) self.help_home = QAction(parent) self.help_print = QAction(parent) self.help_lilypond_doc = QAction(parent) self.help_lilypond_context = QAction(parent) self.help_back.setIcon(icons.get("go-previous")) self.help_forward.setIcon(icons.get("go-next")) self.help_home.setIcon(icons.get("go-home")) self.help_lilypond_doc.setIcon(icons.get("lilypond-run")) self.help_print.setIcon(icons.get("document-print")) self.help_lilypond_doc.setShortcut(QKeySequence("F9")) self.help_lilypond_context.setShortcut(QKeySequence("Shift+F9")) def translateUI(self): self.help_back.setText(_("Back")) self.help_forward.setText(_("Forward")) # L10N: Home page of the LilyPond manual self.help_home.setText(_("Home")) self.help_print.setText(_("Print...")) self.help_lilypond_doc.setText(_("&LilyPond Documentation")) self.help_lilypond_context.setText(_("&Contextual LilyPond Help"))
def __init__(self, parent=None, admin=False, *args, **kwargs): FMenuBar.__init__(self, parent=parent, *args, **kwargs) self.setWindowIcon(QIcon(QPixmap("{}".format(Config.APP_LOGO)))) self.parent = parent menu = [ {"name": u"Tableau de Bord", "icon": 'dashboard', "admin": False, "shortcut": "Ctrl+T", "goto": DashbordViewWidget}, {"name": u"Ajout demande", "icon": 'demande', "admin": False, "shortcut": "Alt+D", "goto": RegistrationViewWidget}, {"name": u"Gestion demande", "icon": 'gestion_dmd', "admin": False, "shortcut": "Ctrl+D", "goto": ResgistrationManagerWidget}, {"name": u"Cooperatives", "icon": 'scoop', "admin": False, "shortcut": "Ctrl+C", "goto": CooperativeSocietyViewWidget}, ] # Menu aller à goto_ = self.addMenu(u"&Aller a") for m in menu: el_menu = QAction( QIcon("{}{}.png".format(Config.img_media, m.get('icon'))), m.get('name'), self) el_menu.setShortcut(m.get("shortcut")) self.connect( el_menu, SIGNAL("triggered()"), lambda m=m: self.goto(m.get('goto'))) goto_.addSeparator() goto_.addAction(el_menu) # Menu Aide help_ = self.addMenu(u"Aide") help_.addAction(QIcon("{}help.png".format(Config.img_cmedia)), "Aide", self.goto_help) help_.addAction(QIcon("{}info.png".format(Config.img_cmedia)), u"À propos", self.goto_about)
def create_action(self, name, shortcut, status_tip, callback, enabled=True): action = QAction(name, self) action.setShortcut(shortcut) action.setStatusTip(status_tip) action.triggered.connect(callback) action.setEnabled(enabled) return action
def addAction(self, path, action, icon=QIcon(), shortcut=None): """Add new action to the menu Returns created QAction object """ subPath = self._parentPath(path) parentAction = self.action(subPath) if parentAction is None: assert False, "Menu path not found: " + subPath if isinstance(action, basestring): action = QAction( icon, action, parentAction ) else: action.setParent( parentAction ) if shortcut is not None: action.setShortcut(shortcut) parentAction.menu().addAction( action ) self._pathToAction[ path ] = action action.path = path action.changed.connect(self._onActionChanged) self.actionInserted.emit( action ) return action
def addAction(self, _path, action, icon=QIcon(), shortcut=None): """Add new action to the menu """ path = self._cleanPath( _path ) subPath = '/'.join(path.split('/')[0: -1]) parentAction = self.action(subPath) if parentAction is None: print >> sys.stderr, "Menu path not found", subPath assert False if isinstance(action, basestring): action = QAction( icon, action, parentAction ) else: action.setParent( parentAction ) if shortcut is not None: action.setShortcut(shortcut) parentAction.menu().addAction( action ) self._pathToAction[ path ] = action action.path = path action.changed.connect(self._onActionChanged) self.actionInserted.emit( action ) return action
class ViewActions(actioncollection.ActionCollection): name = "view" def createActions(self, parent=None): self.window_split_horizontal = QAction(parent) self.window_split_vertical = QAction(parent) self.window_close_view = QAction(parent) self.window_close_others = QAction(parent) self.window_next_view = QAction(parent) self.window_previous_view = QAction(parent) # icons self.window_split_horizontal.setIcon(icons.get('view-split-top-bottom')) self.window_split_vertical.setIcon(icons.get('view-split-left-right')) self.window_close_view.setIcon(icons.get('view-close')) self.window_next_view.setIcon(icons.get('go-next-view')) self.window_previous_view.setIcon(icons.get('go-previous-view')) # shortcuts self.window_close_view.setShortcut(Qt.CTRL + Qt.SHIFT + Qt.Key_W) self.window_next_view.setShortcuts(QKeySequence.NextChild) qutil.removeShortcut(self.window_next_view, "Ctrl+,") self.window_previous_view.setShortcuts(QKeySequence.PreviousChild) qutil.removeShortcut(self.window_previous_view, "Ctrl+.") def translateUI(self): self.window_split_horizontal.setText(_("Split &Horizontally")) self.window_split_vertical.setText(_("Split &Vertically")) self.window_close_view.setText(_("&Close Current View")) self.window_close_others.setText(_("Close &Other Views")) self.window_next_view.setText(_("&Next View")) self.window_previous_view.setText(_("&Previous View"))
def __init__(self): QObject.__init__(self) self._createdActions = [] self._createdSeparators = [] self._createdMenus = [] self._currentDocument = core.workspace().currentDocument() # probably None for menu in _MENUS: if menu[2]: menuObj = core.actionManager().addMenu(menu[0], menu[1], QIcon(':/enkiicons/' + menu[2])) else: menuObj = core.actionManager().addMenu(menu[0], menu[1]) menuObj.setEnabled(False) self._createdMenus.append(menuObj) for item in _ACTIONS: if isinstance(item, tuple): # action command, path, text, shortcut, icon = item actObject = QAction(text, self) if shortcut: actObject.setShortcut(shortcut) if icon: actObject.setIcon(QIcon(':/enkiicons/' + icon)) actObject.setData(command) actObject.setEnabled(False) actObject.triggered.connect(self.onAction) core.actionManager().addAction(path, actObject) self._createdActions.append(actObject) else: # separator menuPath = item menu = core.actionManager().menu(menuPath) self._createdSeparators.append(menu.addSeparator()) core.workspace().currentDocumentChanged.connect(self.onCurrentDocumentChanged)
class CToolBar(QToolBar): def __init__(self, parent=None): super(CToolBar, self).__init__() self.setMovable(False) self.dir = QAction(self.style().standardIcon(QStyle.SP_DirHomeIcon), 'Change directory', self) self.dir.setShortcut('Ctrl+D') self.tab = QAction(self.style().standardIcon(QStyle.SP_ToolBarHorizontalExtensionButton), 'Add tab', self) self.tab.setShortcut('Ctrl+T') self.addAction(self.dir) self.addAction(self.tab) self.connect(self.dir, SIGNAL('triggered()'), self.addPath) self.connect(self.tab, SIGNAL('triggered()'), self.addTab) def addPath(self): dialog = AddPathDialog() dialog.exec() if dialog.lineEdit.text(): self.parent().centralWidget().files = listFiles(dialog.lineEdit.text()) self.parent().centralWidget().refreshTables() def addTab(self): dialog = AddTabDialog() dialog.exec() if dialog.lineEdit.text() and dialog.lineEdit_2.text(): self.parent().centralWidget().addTab(dialog.lineEdit.text(), ('Filename', 'Filesize', 'Path'), dialog.lineEdit_2.text())
class FellesGui(QMainWindow): """ """ startSampling = pyqtSignal() pauseSampling = pyqtSignal() stopSampling = pyqtSignal() terminateThreads = pyqtSignal() def __init__(self, Ui_MainWindow, timeout=1000): super(FellesGui, self).__init__() self.setAttribute(Qt.WA_DeleteOnClose) self.exitAction = QAction('Quit', self) self.exitAction.setShortcut('Ctrl+Q') self.exitAction.setStatusTip('Quit application') print("Push 'Ctrl+Q' to quit the application") self.exitAction.triggered.connect(self.close) # Create Widget for the purpose of updating the widgets periodically #self.timer = QTimer() #self.timer.timeout.connect(self.paintEvent) #self.timer.start(timeout) # --> Instantiate UI !!! This is where the widgets are initiated !!! self.buildUi(Ui_MainWindow) # --> Setup the Menu Bar self.fileMenu = self.menuBar().addMenu('&File') self.fileMenu.addAction(self.exitAction) # --> Order widgets to connect to their slaves #self.initialiseSlaves.emit() # --> Initialise "Threads" performing the sampling ports = QFellesWidgetBaseClass.___ports___.keys() self.threads = [FellesThread(port) for port in ports] for thread in self.threads: self.terminateThreads.connect(thread.quit) self.statusBar().showMessage('Idling...') def buildUi(self, Ui_MainWindow): self.statusBar().showMessage('Initialising Modules') self.ui = Ui_MainWindow() self.ui.setupUi(self) def closeEvent(self, event): """ Method executed when application is closed """ txt = "Are you sure to quit?" reply = QMessageBox.question(self, 'Message', txt, QMessageBox.Yes, QMessageBox.No) if reply == QMessageBox.Yes: self.terminateThreads.emit() event.accept() else: event.ignore()
def _init_ui(self): """Create and populate the menu bar. """ # Exit Application exit_action = QAction(self._exit_icon, '&Exit', self) exit_action.setShortcut('Ctrl+Q') exit_action.setStatusTip('Exit application') exit_action.triggered.connect(self._cleanup) exit_action.triggered.connect(qApp.quit) # Open options dialog options_action = QAction(self._config_icon, '&Config', self) options_action.setShortcut('Ctrl+O') options_action.setStatusTip('Open Options Dialog') options_action.triggered.connect(self._on_options_action_clicked) # Show version number about_action = QAction(self._about_icon, "About", self) about_action.triggered.connect(self._on_about_action_clicked) # Create menu bar file_menu = self._mainMenu.addMenu('&File') file_menu.addAction(exit_action) option_menu = self._mainMenu.addMenu('&Options') option_menu.addAction(options_action) help_menu = self._mainMenu.addMenu('?') help_menu.addAction(about_action)
def initUI(self): closeAction = QAction('Close', self) closeAction.setShortcut('Ctrl+Q') closeAction.setStatusTip('Close Application') closeAction.triggered.connect(lambda: sys.exit(0)) loadAction = QAction('Load Protocol', self) loadAction.setStatusTip('Load the Default Protocol') loadAction.triggered.connect(self.find_pcl_file) menubar = self.menuBar() file_menu = menubar.addMenu('&File') file_menu.addAction(closeAction) load_menu = menubar.addMenu('&Load') load_menu.addAction(loadAction) self.toolbar = self.addToolBar('Exit') self.toolbar.addAction(closeAction) load_menu.addSeparator() for idx, recent_pcl in enumerate(self.recent_pcls): new_action = QAction("%d %s" % (idx + 1, recent_pcl['name']), self) new_action.triggered.connect(self.open_recent_pcl) new_action.setData(QVariant(recent_pcl['filename'])) load_menu.addAction(new_action) self.setWindowTitle('fealines') self.show_empty_screen() self.showMaximized()
def create_action(parent, text, shortcut=None, icon=None, tip=None, toggled=None, triggered=None, data=None, menurole=None, context=Qt.WindowShortcut): """Create a QAction""" action = QAction(text, parent) if triggered is not None: parent.connect(action, SIGNAL("triggered()"), triggered) if toggled is not None: parent.connect(action, SIGNAL("toggled(bool)"), toggled) action.setCheckable(True) if icon is not None: if is_text_string(icon): icon = get_icon(icon) action.setIcon(icon) if shortcut is not None: action.setShortcut(shortcut) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if data is not None: action.setData(data) if menurole is not None: action.setMenuRole(menurole) #TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut # (this will avoid calling shortcuts from another dockwidget # since the context thing doesn't work quite well with these widgets) action.setShortcutContext(context) return action
def onSetupEditorButtons(self): """Add IO button to Editor""" if isinstance(self.parentWindow, AddCards): btn = self._addButton("new_occlusion", lambda o=self: onImgOccButton(self, "add"), _("Alt+a"), _("Add Image Occlusion (Alt+A/Alt+O)"), canDisable=False) elif isinstance(self.parentWindow, EditCurrent): btn = self._addButton( "edit_occlusion", lambda o=self: onImgOccButton(self, "editcurrent"), _("Alt+a"), _("Edit Image Occlusion (Alt+A/Alt+O)"), canDisable=False) else: btn = self._addButton("edit_occlusion", lambda o=self: onImgOccButton(self, "browser"), _("Alt+a"), _("Edit Image Occlusion (Alt+A/Alt+O)"), canDisable=False) # secondary hotkey: press_action = QAction(self.parentWindow, triggered=btn.animateClick) press_action.setShortcut(QKeySequence(_("Alt+o"))) btn.addAction(press_action)
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.loadTranslations() self.settings = QSettings("LVK Inc", "DataCenters") self.resourcesGraphEditor = ResourcesGraphEditor() self.demandGraphEditor = DemandGraphEditor() self.randomDialog = RandomDemandDialog() self.Vis = Vis() self.graphvis = GraphVis(self) self.demands = {} self.project = Project() # TODO: Captain, we have a problem! # For some reason, in Python 2.7 QSettings converts dicts to QVariant # So the ini file is undecypherable # This works fine in Python 3.2 by the way #if self.settings.value("vis"): #self.Vis.canvas.settings = self.settings.value("vis") #self.graphvis.settings = self.settings.value("graphVis") self.settingsDialog = SettingsDialog(self.Vis.canvas.settings, self.graphvis.settings) self.settingsDialog.ui.backup.setChecked( self.settings.value("backup").toBool()) self.settingsDialog.ui.autosave.setChecked( self.settings.value("autosave").toBool()) self.settingsDialog.ui.interval.setValue( self.settings.value("interval").toInt()[0]) i = 0 for s in self.languages: self.settingsDialog.ui.languages.addItem(s) if s == str(self.settings.value("language").toString()): self.settingsDialog.ui.languages.setCurrentIndex(i) i += 1 self.resourcesGraphEditor.setData(self.project.resources) for i in range(self.MaxRecentFiles): a = QAction(self) a.setVisible(False) a.setEnabled(False) if i <= 9: a.setShortcut(QKeySequence(self.tr("Alt+") + str(i + 1))) QObject.connect(a, SIGNAL("triggered()"), self.OpenRecentFile) self.ui.menuFile.insertAction(self.ui.actionExit, a) self.recentFileActions.append(a) self.UpdateRecentFileActions() self.basename = self.windowTitle() self.demandGraphEditor.demand_changed.connect(self.demandChanged) self.backupTimer = QTimer() self.backupTimer.setInterval(60000) self.backupTimer.setSingleShot(False) QObject.connect(self.backupTimer, SIGNAL("timeout()"), self.Backup) self.autosaveTimer = QTimer() self.autosaveTimer.setInterval(60000) self.autosaveTimer.setSingleShot(False) QObject.connect(self.autosaveTimer, SIGNAL("timeout()"), self.Autosave) self.Translate( str(self.settings.value("language", "English").toString())) self.projFilter = self.tr("Data centers projects (*.dcxml)") self.setWindowTitle(self.tr("Untitled") + " - " + self.basename) self.loadPlugins()
def init(): action = QAction("Open audio in Audacity", mw) action.setShortcut('Ctrl+Shift+A') action.setEnabled(True) mw.connect(action, SIGNAL('triggered()'), open_in_audacity) mw.form.menuTools.addAction(action)
def create_action(parent, text, shortcut=None, icon=None, tip=None, toggled=None, triggered=None, data=None, window_context=True): """Create a QAction""" action = QAction(text, parent) if triggered is not None: parent.connect(action, SIGNAL("triggered()"), triggered) if toggled is not None: parent.connect(action, SIGNAL("toggled(bool)"), toggled) action.setCheckable(True) if icon is not None: if isinstance(icon, (str, unicode)): icon = get_icon(icon) action.setIcon(icon) if shortcut is not None: action.setShortcut(shortcut) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if data is not None: action.setData(QVariant(data)) if window_context: action.setShortcutContext(Qt.WindowShortcut) else: #TODO: Hard-code all shortcuts and choose window_context=False # (this will avoid calling shortcuts from another dockwidget # since the context thing doesn't work quite well with these) action.setShortcutContext(Qt.WidgetShortcut) return action
def create_action(self, text, slot=None, shortcut=None, icon=None, tip=None, checkable=False, signal="triggered()"): u""" :param text: :param slot: :param shortcut: :param icon: :param tip: :param checkable: :param signal: :return: """ action = QAction(text, self) if slot is not None: self.connect(action, SIGNAL(signal), slot) if shortcut is not None: action.setShortcut(shortcut) if icon is not None: action.setIcon(icon) if tip is not None: action.setToolTip(tip) if checkable is not None: action.setCheckable(checkable) return action
def __init__(self, bind_address: str, port: int, filesToRead: [str]): """ :param bind_address: address to bind to when listening for live connections. :param port: port to bind to when listening for live connections. :param filesToRead: replay files to open. """ QMainWindow.__init__(self) self.liveWindow = LivePlayerWindow(bind_address, port) self.replayWindow = ReplayWindow() self.tabManager = QTabWidget() self.tabManager.addTab(self.replayWindow, "Replays") self.tabManager.addTab(self.liveWindow, "Live connections") self.setCentralWidget(self.tabManager) openAction = QAction("Open...", self) openAction.setShortcut("Ctrl+O") openAction.setStatusTip("Open a replay file") openAction.triggered.connect(self.onOpenFile) menuBar = self.menuBar() fileMenu = menuBar.addMenu("File") fileMenu.addAction(openAction) for fileName in filesToRead: self.replayWindow.openFile(fileName)
class Kipcalc(kdeui.KMainWindow): def __init__ (self): super(Kipcalc, self).__init__() self.resize(640, 480) self.create_actions() self.create_menus() self.setCentralWidget(IPWidget(self)) def print_(self): pass def create_actions(self): self.action_quit = QAction('&Quit', self) self.action_quit.setIcon(kdeui.KIcon('exit')) self.action_quit.setShortcut(self.tr('Ctrl+Q')) self.connect(self.action_quit, SIGNAL('triggered()'), self.close) self.action_print = QAction('&Print', self) #self.action_print.setIcon(kdeui.KIcon('print')) self.connect(self.action_quit, SIGNAL('triggered()'), self.print_) def create_menus(self): self.file_menu = self.menuBar().addMenu("&File") self.file_menu.addAction(self.action_quit) self.file_menu.addAction(self.action_print)
def __init__(self, app = None, filename='.'): super(mainWindow, self).__init__() self.resize(1800,900) self.centralWidget = QWidget() self.layout = QHBoxLayout() self.centralWidget.setLayout(self.layout) self.tab = QTabWidget() self.astraPlot = astraHDFPlotWidget(filename) self.layout.addWidget(self.astraPlot) self.setCentralWidget(self.centralWidget) self.setWindowTitle("ASTRA Data Plotter") menubar = self.menuBar() fileMenu = menubar.addMenu('&File') # reloadSettingsAction = QAction('Reload Settings', self) # reloadSettingsAction.setStatusTip('Reload Settings YAML File') # reloadSettingsAction.triggered.connect(self.picklePlot.reloadSettings) # fileMenu.addAction(reloadSettingsAction) exitAction = QAction('&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(app.quit) fileMenu.addAction(exitAction)
def contextMenuEvent(self, event): def correctWord(cursor, word): # From QTextCursor doc: # if there is a selection, the selection is deleted and replaced return lambda: cursor.insertText(word) popup_menu = self.createStandardContextMenu() paste_action = popup_menu.actions()[6] paste_formatted_action = QAction(self.tr("Paste raw HTML"), popup_menu) paste_formatted_action.triggered.connect(self.insertFromRawHtml) paste_formatted_action.setShortcut(QKeySequence("Ctrl+Shift+V")) popup_menu.insertAction(paste_action, paste_formatted_action) # Spellcheck the word under mouse cursor, not self.textCursor cursor = self.cursorForPosition(event.pos()) cursor.select(QTextCursor.WordUnderCursor) text = cursor.selectedText() if self.speller and text: if not self.speller.check(text): lastAction = popup_menu.actions()[0] for word in self.speller.suggest(text)[:10]: action = QAction(word, popup_menu) action.triggered.connect(correctWord(cursor, word)) action.setFont(QFont(None, weight=QFont.Bold)) popup_menu.insertAction(lastAction, action) popup_menu.insertSeparator(lastAction) popup_menu.exec_(event.globalPos())
def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) backAction = QAction(QIcon(":/back.png"), "&Back", self) backAction.setShortcut(QKeySequence.Back) homeAction = QAction(QIcon(":/home.png"), "&Home", self) homeAction.setShortcut("Home") self.pageLabel = QLabel() toolBar = QToolBar() toolBar.addAction(backAction) toolBar.addAction(homeAction) toolBar.addWidget(self.pageLabel) self.textBrowser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) self.connect(backAction, SIGNAL("triggered()"), self.textBrowser, SLOT("backward()")) self.connect(homeAction, SIGNAL("triggered()"), self.textBrowser, SLOT("home()")) self.connect(self.textBrowser, SIGNAL("sourceChanged(QUrl)"), self.updatePageTitle) self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(page)) self.resize(400, 600) self.setWindowTitle("{0} Help".format(QApplication.applicationName()))
def addAction(self, path, action, icon=QIcon(), shortcut=None): """Add new action to the menu. Returns created QAction object. ``action`` might be string text or QAction instance. """ subPath = self._parentPath(path) parentAction = self.action(subPath) if parentAction is None: assert False, "Menu path not found: " + subPath if isinstance(action, basestring): action = QAction( icon, action, parentAction ) else: action.setParent( parentAction ) if shortcut is not None: action.setShortcut(shortcut) parentAction.menu().addAction( action ) self._pathToAction[ path ] = action action.path = path action.changed.connect(self._onActionChanged) self.actionInserted.emit( action ) return action
def initUI(self): self.textEdit = QTextEdit() self.textEdit.setReadOnly(True) self.setCentralWidget(self.textEdit) self.statusBar() icon_open = QIcon.fromTheme("document-open", QIcon(":/open.png")) icon_save = QIcon.fromTheme("document-save-as") icon_copy = QIcon.fromTheme("edit-copy") icon_clear = QIcon.fromTheme("edit-clear") openFile = QAction(QIcon(icon_open), 'Open', self) openFile.setShortcut('Ctrl+O') openFile.setStatusTip('Open new File') openFile.triggered.connect(self.showLoadDialog) self.saveFile = QAction(QIcon(icon_save), 'Save', self) self.saveFile.setShortcut('Ctrl+S') self.saveFile.setStatusTip('Save data to File') self.saveFile.triggered.connect(self.showSaveDialog) self.saveFile.setDisabled(True) self.clearData = QAction(QIcon(icon_clear), 'Clear', self) self.clearData.setShortcut('Ctrl+D') self.clearData.setStatusTip('Clear data') self.clearData.triggered.connect(self.clear_event) self.clearData.setDisabled(True) self.copyData = QAction(QIcon(icon_copy), 'Copy', self) self.copyData.setShortcut('Ctrl+C') self.copyData.setStatusTip('Copy data to clipboard') self.copyData.triggered.connect(self.copy_event) self.copyData.setDisabled(True) exitAction = QAction(QIcon(), 'Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.triggered.connect(qApp.quit) menubar = self.menuBar() fileMenu = menubar.addMenu('&File') fileMenu.addAction(openFile) fileMenu.addAction(self.saveFile) fileMenu.addAction(self.copyData) fileMenu.addAction(self.clearData) fileMenu.addSeparator() fileMenu.addAction(exitAction) fileToolBar = self.addToolBar("Load and Save") fileToolBar.setIconSize(QSize(22, 22)) fileToolBar.addAction(openFile) fileToolBar.addAction(self.saveFile) fileToolBar.addAction(self.copyData) fileToolBar.addAction(self.clearData) self.setGeometry(300, 300, 400, 600) self.setWindowTitle('File dialog') self.show()
class Actions(actioncollection.ActionCollection): name = "musicview" def createActions(self, panel): self.music_document_select = DocumentChooserAction(panel) self.music_print = QAction(panel) self.music_zoom_in = QAction(panel) self.music_zoom_out = QAction(panel) self.music_zoom_original = QAction(panel) self.music_zoom_combo = ZoomerAction(panel) self.music_fit_width = QAction(panel, checkable=True) self.music_fit_height = QAction(panel, checkable=True) self.music_fit_both = QAction(panel, checkable=True) self.music_maximize = QAction(panel) self.music_jump_to_cursor = QAction(panel) self.music_sync_cursor = QAction(panel, checkable=True) self.music_copy_image = QAction(panel) self.music_pager = PagerAction(panel) self.music_next_page = QAction(panel) self.music_prev_page = QAction(panel) self.music_print.setIcon(icons.get('document-print')) self.music_zoom_in.setIcon(icons.get('zoom-in')) self.music_zoom_out.setIcon(icons.get('zoom-out')) self.music_zoom_original.setIcon(icons.get('zoom-original')) self.music_fit_width.setIcon(icons.get('zoom-fit-width')) self.music_fit_height.setIcon(icons.get('zoom-fit-height')) self.music_fit_both.setIcon(icons.get('zoom-fit-best')) self.music_maximize.setIcon(icons.get('view-fullscreen')) self.music_jump_to_cursor.setIcon(icons.get('go-jump')) self.music_copy_image.setIcon(icons.get('edit-copy')) self.music_next_page.setIcon(icons.get('go-next')) self.music_prev_page.setIcon(icons.get('go-previous')) self.music_document_select.setShortcut(QKeySequence(Qt.SHIFT | Qt.CTRL | Qt.Key_O)) self.music_print.setShortcuts(QKeySequence.Print) self.music_zoom_in.setShortcuts(QKeySequence.ZoomIn) self.music_zoom_out.setShortcuts(QKeySequence.ZoomOut) self.music_jump_to_cursor.setShortcut(QKeySequence(Qt.CTRL | Qt.Key_J)) self.music_copy_image.setShortcut(QKeySequence(Qt.SHIFT | Qt.CTRL | Qt.Key_C)) def translateUI(self): self.music_document_select.setText(_("Select Music View Document")) self.music_print.setText(_("&Print Music...")) self.music_zoom_in.setText(_("Zoom &In")) self.music_zoom_out.setText(_("Zoom &Out")) self.music_zoom_original.setText(_("Original &Size")) self.music_zoom_combo.setText(_("Zoom Music")) self.music_fit_width.setText(_("Fit &Width")) self.music_fit_height.setText(_("Fit &Height")) self.music_fit_both.setText(_("Fit &Page")) self.music_maximize.setText(_("&Maximize")) self.music_jump_to_cursor.setText(_("&Jump to Cursor Position")) self.music_sync_cursor.setText(_("S&ynchronize with Cursor Position")) self.music_copy_image.setText(_("Copy to &Image...")) self.music_next_page.setText(_("Next Page")) self.music_next_page.setIconText(_("Next")) self.music_prev_page.setText(_("Previous Page")) self.music_prev_page.setIconText(_("Previous"))
def createAction( parent, label, callback=None, icon = None, tip = None, shortcut = None, data = None, toggled = False, tooltip=None, cb_arg=None, iconText=None, checkable=None): """ Create a QAction @param parent: @type parent: @param label: @type label: @param callback: @type callback: @param icon: @type icon: @param tip: @type tip: @param shortcut: @type shortcut: @param data: @type data: @param toggled: @type toggled: @return: @rtype: """ action = QAction(label, parent) if toggled: if callback is not None: action.toggled.connect(callback) action.setCheckable(True) else: if callback is not None: if cb_arg is None: action.triggered.connect(callback) else: action.triggered.connect(lambda: callback(cb_arg) ) if icon: action.setIcon(icon) if shortcut: action.setShortcut(shortcut) if tip: action.setStatusTip(tip) if tooltip: action.setToolTip(tooltip) if data is not None: action.setData( QVariant(data) ) if iconText is not None: action.setIconText(iconText) if checkable is not None: action.setCheckable(checkable) return action
class Actions(actioncollection.ActionCollection): name = 'scorewiz' def createActions(self, parent=None): self.scorewiz = QAction(parent) self.scorewiz.setIcon(icons.get("tools-score-wizard")) self.scorewiz.setShortcut(QKeySequence("Ctrl+Shift+N")) def translateUI(self): self.scorewiz.setText(_("Setup New Score..."))
def act(name, parent, tip='', icon=None, shortcut=None): """ Factory for making a new action """ a = QAction(name, parent) a.setToolTip(tip) if icon: a.setIcon(QIcon(':icons/%s' % icon)) if shortcut: a.setShortcut(shortcut) return a
class Actions(actioncollection.ActionCollection): name = 'autocomplete' def createActions(self, parent): self.autocomplete = QAction(parent, checkable=True) self.popup_completions = QAction(parent) self.popup_completions.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Space)) def translateUI(self): self.autocomplete.setText(_("Automatic &Completion")) self.popup_completions.setText(_("Show C&ompletions Popup"))
def setupMenubar(self): self.menubar = self.parent.menuBar() newFileAction = QAction("&New file", self.parent) newFileAction.triggered.connect(self.parent.newFile) self.parent.newFileAction = newFileAction newDirectoryAction = QAction("New &directory", self.parent) newDirectoryAction.triggered.connect(self.parent.newDirectory) self.parent.newDirectoryAction = newDirectoryAction saveAction = QAction("&Save", self.parent) saveAction.triggered.connect(self.parent.saveDocument) saveAction.setShortcut(Qt.CTRL + Qt.Key_S) saveAllAction = QAction("S&ave all", self.parent) saveAllAction.triggered.connect(self.parent.saveAllDocuments) saveAllAction.setShortcut(Qt.CTRL + Qt.SHIFT + Qt.Key_S) exitAction = QAction(QIcon("icons/exit.png"), "E&xit", self.parent) exitAction.triggered.connect(self.parent.close) fileMenu = self.menubar.addMenu("&File") newMenu = fileMenu.addMenu("New") fileMenu.addAction(saveAction) fileMenu.addAction(saveAllAction) fileMenu.addAction(exitAction) newMenu.addAction(newFileAction) newMenu.addAction(newDirectoryAction) closeTabAction = QAction("Close tab", self.parent) closeTabAction.triggered.connect(self.parent.closeTab) closeTabAction.setShortcut(Qt.CTRL + Qt.Key_W) closeTabAction.setShortcutContext(Qt.ApplicationShortcut) closeOtherTabsAction = QAction("Close other tabs", self.parent) closeOtherTabsAction.triggered.connect(self.parent.closeOtherTabs) closeOtherTabsAction.setShortcut(Qt.CTRL + Qt.Key_Q) closeOtherTabsAction.setShortcutContext(Qt.ApplicationShortcut) closeAllTabsAction = QAction("Close all tabs", self.parent) closeAllTabsAction.triggered.connect(self.parent.closeAllTabs) closeAllTabsAction.setShortcut(Qt.CTRL + Qt.SHIFT + Qt.Key_W) closeAllTabsAction.setShortcutContext(Qt.ApplicationShortcut) viewMenu = self.menubar.addMenu("&View") tabsMenu = viewMenu.addMenu("Tabs") tabsMenu.addAction(closeTabAction) tabsMenu.addAction(closeOtherTabsAction) tabsMenu.addAction(closeAllTabsAction) viewMenu.addAction(self.filesDock.toggleViewAction())
def __init__(self): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.loadTranslations() self.settings = QSettings("LVK Inc", "DataCenters") self.resourcesGraphEditor = ResourcesGraphEditor() self.demandGraphEditor = DemandGraphEditor() self.randomDialog = RandomDemandDialog() self.Vis = Vis() self.graphvis = GraphVis(self) self.demands = {} self.project = Project() # TODO: Captain, we have a problem! # For some reason, in Python 2.7 QSettings converts dicts to QVariant # So the ini file is undecypherable # This works fine in Python 3.2 by the way #if self.settings.value("vis"): #self.Vis.canvas.settings = self.settings.value("vis") #self.graphvis.settings = self.settings.value("graphVis") self.settingsDialog = SettingsDialog(self.Vis.canvas.settings, self.graphvis.settings) self.settingsDialog.ui.backup.setChecked(self.settings.value("backup").toBool()) self.settingsDialog.ui.autosave.setChecked(self.settings.value("autosave").toBool()) self.settingsDialog.ui.interval.setValue(self.settings.value("interval").toInt()[0]) i = 0 for s in self.languages: self.settingsDialog.ui.languages.addItem(s) if s == str(self.settings.value("language").toString()): self.settingsDialog.ui.languages.setCurrentIndex(i) i += 1 self.resourcesGraphEditor.setData(self.project.resources) for i in range(self.MaxRecentFiles): a = QAction(self) a.setVisible(False) a.setEnabled(False) if i <= 9: a.setShortcut(QKeySequence(self.tr("Alt+") + str(i + 1))) QObject.connect(a, SIGNAL("triggered()"), self.OpenRecentFile); self.ui.menuFile.insertAction(self.ui.actionExit, a) self.recentFileActions.append(a) self.UpdateRecentFileActions() self.basename = self.windowTitle() self.demandGraphEditor.demand_changed.connect(self.demandChanged) self.backupTimer = QTimer() self.backupTimer.setInterval(60000) self.backupTimer.setSingleShot(False) QObject.connect(self.backupTimer, SIGNAL("timeout()"), self.Backup) self.autosaveTimer = QTimer() self.autosaveTimer.setInterval(60000) self.autosaveTimer.setSingleShot(False) QObject.connect(self.autosaveTimer, SIGNAL("timeout()"), self.Autosave) self.Translate(str(self.settings.value("language", "English").toString())) self.projFilter = self.tr("Data centers projects (*.dcxml)") self.setWindowTitle(self.tr("Untitled") + " - " + self.basename) self.loadPlugins()
def addCloseAction(widget): """ Adds a close action and connects it to the widget close slot. @param widget any QWidget instance @return new QAction instance """ action = QAction("Close", widget) action.setShortcut("Ctrl+W") widget.addAction(action) widget.connect(action, Signals.triggered, widget.close) return action
def addCloseAction(widget): """ Adds a close action and connects it to the widget close slot. @param widget any QWidget instance @return new QAction instance """ action = QAction('Close', widget) action.setShortcut('Ctrl+W') widget.addAction(action) widget.connect(action, Signals.triggered, widget.close) return action
def __init__(self, config): # Initialize the object as a QWidget and # set its title and minimum width QWidget.__init__(self) self.config = config self.peerList = config.peerList self.setWindowTitle('BlastShare') self.setMinimumSize(320, 480) self.setMaximumWidth(320) self.prefw = None # connects the signals! self.connect(self.peerList, SIGNAL("initTransfer"), self.sendFileToPeer) ''' Will add feature in future version ''' ''' shareFilesAction = QAction(QIcon('exit.png'), '&Share File(s)', self) shareFilesAction.setShortcut('Ctrl+O') shareFilesAction.setStatusTip('Share File(s)') shareFilesAction.triggered.connect(quitApp) ''' preferencesAction = QAction(QIcon('exit.png'), '&Preferences', self) preferencesAction.setShortcut('Ctrl+P') preferencesAction.setStatusTip('Preferences') preferencesAction.triggered.connect(self.editPreferences) exitAction = QAction(QIcon('exit.png'), '&Exit', self) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip('Exit application') exitAction.triggered.connect(quitApp) menubar = QMenuBar() fileMenu = menubar.addMenu('&File') ''' Will enable in future versions ''' # fileMenu.addAction(shareFilesAction) fileMenu.addAction(preferencesAction) fileMenu.addAction(exitAction) layout = QVBoxLayout() layout.setContentsMargins(QMargins(0, 0, 0, 0)) self.setLayout(layout) statusBar = QStatusBar() statusBar.showMessage('Ready') layout.addWidget(menubar) layout.addWidget(self.peerList) layout.addWidget(statusBar)
def createActions(actions, target): # actions = [(name, shortcut, icon, desc, func)] for name, shortcut, icon, desc, func in actions: action = QAction(target) if icon: action.setIcon(QIcon(QPixmap(':/' + icon))) if shortcut: action.setShortcut(shortcut) action.setText(desc) action.triggered.connect(func) setattr(target, name, action)
class Actions(actioncollection.ActionCollection): name = 'scorewiz' def createActions(self, parent=None): self.scorewiz = QAction(parent) self.scorewiz.setIcon(icons.get("tools-score-wizard")) self.scorewiz.setShortcut(QKeySequence("Ctrl+Shift+N")) self.scorewiz.setMenuRole(QAction.NoRole) def translateUI(self): self.scorewiz.setText(_("Score &Wizard..."))
def create_menu_bar(self): filemenu = self.menuBar().addMenu('&File') close = QAction('&Quit', self) close.setShortcut('Ctrl+W') self.connect(close, SIGNAL('triggered()'), self.close) filemenu.addAction(close) helpmenu = self.menuBar().addMenu('&Help') about = QAction('&About', self) about.setShortcut('F1') self.connect(about, SIGNAL('triggered()'), self.about) helpmenu.addAction(about)
def __createAction(self, icon, text, shortcut, statustip): if isinstance(icon, QStyle.StandardPixmap): icon = QApplication.style().standardIcon(icon) else: icon = QIcon(icon) newAction = QAction(icon, text, self) if shortcut is not None: newAction.setShortcut(shortcut) return newAction
class Actions(actioncollection.ActionCollection): name = "logtool" def createActions(self, parent=None): self.log_next_error = QAction(parent) self.log_previous_error = QAction(parent) self.log_next_error.setShortcut(QKeySequence("Ctrl+E")) self.log_previous_error.setShortcut(QKeySequence("Ctrl+Shift+E")) def translateUI(self): self.log_next_error.setText(_("Next Error Message")) self.log_previous_error.setText(_("Previous Error Message"))
def _createAction(self, widget, iconFileName, text, shortcut, slot): """Create QAction with given parameters and add to the widget """ icon = QIcon(qutepart.getIconPath(iconFileName)) action = QAction(icon, text, widget) action.setShortcut(QKeySequence(shortcut)) action.setShortcutContext(Qt.WidgetShortcut) action.triggered.connect(slot) widget.addAction(action) return action
def __init__(self, parent = None): QMainWindow.__init__(self, parent) self.setIconSize(QSize(48, 48)) self.widtab = QTabWidget() #widtab.addTab(QLabel("Tab1"), "Tab 1") self._bba = {} #self._bba_plot_data = [] self._canvas_wid = [] # self.setCentralWidget(self.widtab) # # file menu # self.fileMenu = self.menuBar().addMenu("&File") fileQuitAction = QAction(QIcon(":/file_quit.png"), "&Quit", self) fileQuitAction.setShortcut("Ctrl+Q") fileQuitAction.setToolTip("Quit the application") fileQuitAction.setStatusTip("Quit the application") self.connect(fileQuitAction, SIGNAL("triggered()"), self.close) fileConfigAction = QAction("&Config", self) # fileOpenAction = QAction(QIcon(":file_quit.png"), "&Open...", self) fileOpenAction.setToolTip("Open an existing data file") self.connect(fileOpenAction, SIGNAL("triggered()"), self.fileOpen) self.fileMenu.addAction(fileOpenAction) self.fileMenu.addAction(fileQuitAction) self.fileMenu.addAction(fileConfigAction) self.controlMenu = self.menuBar().addMenu("&Control") controlGoAction = QAction(QIcon(":/control_play.png"), "&Go", self) controlGoAction.setShortcut("Ctrl+G") #fileQuitAction.setToolTip("Quit the application") #fileQuitAction.setStatusTip("Quit the application") #fileQuitAction.setIcon(Qt.QIcon(":/filequit.png")) self.controlMenu.addAction(controlGoAction) self.connect(controlGoAction, SIGNAL("triggered()"), self.align) # help self.helpMenu = self.menuBar().addMenu("&Help") #toolbar = QToolBar(self) #self.addToolBar(toolbar) fileToolBar = self.addToolBar("File") fileToolBar.setObjectName("FileToolBar") fileToolBar.addAction(fileQuitAction) fileToolBar.addAction(controlGoAction)
class Actions(actioncollection.ActionCollection): name = "documentactions" def createActions(self, parent): self.edit_cut_assign = QAction(parent) self.view_highlighting = QAction(parent) self.view_highlighting.setCheckable(True) self.view_goto_file_or_definition = QAction(parent) self.tools_indent_auto = QAction(parent) self.tools_indent_auto.setCheckable(True) self.tools_indent_indent = QAction(parent) self.tools_reformat = QAction(parent) self.tools_remove_trailing_whitespace = QAction(parent) self.tools_convert_ly = QAction(parent) self.tools_quick_remove_comments = QAction(parent) self.tools_quick_remove_articulations = QAction(parent) self.tools_quick_remove_ornaments = QAction(parent) self.tools_quick_remove_instrument_scripts = QAction(parent) self.tools_quick_remove_slurs = QAction(parent) self.tools_quick_remove_dynamics = QAction(parent) self.tools_quick_remove_fingerings = QAction(parent) self.tools_quick_remove_markup = QAction(parent) self.edit_cut_assign.setIcon(icons.get('edit-cut')) self.view_goto_file_or_definition.setShortcut( QKeySequence(Qt.ALT + Qt.Key_Return)) self.edit_cut_assign.setShortcut( QKeySequence(Qt.SHIFT + Qt.CTRL + Qt.Key_X)) def translateUI(self): self.edit_cut_assign.setText(_("Cut and Assign...")) self.view_highlighting.setText(_("Syntax &Highlighting")) self.view_goto_file_or_definition.setText( _("View File or Definition at &Cursor")) self.tools_indent_auto.setText(_("&Automatic Indent")) self.tools_indent_indent.setText(_("Re-&Indent")) self.tools_reformat.setText(_("&Format")) self.tools_remove_trailing_whitespace.setText( _("Remove Trailing &Whitespace")) self.tools_convert_ly.setText(_("&Update with convert-ly...")) self.tools_quick_remove_comments.setText(_("Remove &Comments")) self.tools_quick_remove_articulations.setText( _("Remove &Articulations")) self.tools_quick_remove_ornaments.setText(_("Remove &Ornaments")) self.tools_quick_remove_instrument_scripts.setText( _("Remove &Instrument Scripts")) self.tools_quick_remove_slurs.setText(_("Remove &Slurs")) self.tools_quick_remove_dynamics.setText(_("Remove &Dynamics")) self.tools_quick_remove_fingerings.setText(_("Remove &Fingerings")) self.tools_quick_remove_markup.setText( _("Remove Text &Markup (from music)"))
def __init__(self, parent=None, *args, **kwargs): FMenuBar.__init__(self, parent=parent, *args, **kwargs) self.parent = parent # Menu aller à goto_ = self.addMenu(u"&Aller a") # Address Book # > Add contact # > Find contact # > Delete contact addressbook = QAction( QIcon("{}archive_add.png".format(Config.img_media)), u"Carnet d'adresse", self) addressbook.setShortcut("Ctrl+C") self.connect(addressbook, SIGNAL("triggered()"), self.goto_addressbook) goto_.addAction(addressbook) addcontact = QAction( QIcon("{}addcontact.png".format(Config.img_media)), u"Nouvel contact", self) addcontact.setShortcut("Ctrl+N") self.connect(addcontact, SIGNAL("triggered()"), self.goto_add_contact) goto_.addAction(addcontact) dashboard = QAction(QIcon("{}dashboard.png".format(Config.img_media)), u"Tableau de bord", self) dashboard.setShortcut("Ctrl+T") self.connect(dashboard, SIGNAL("triggered()"), self.dashboard) goto_.addAction(dashboard) # adressbook.addAction(QIcon('images/help.png'), # "Recherher contact", self.goto_search_contact) # Menu Options menu_settings = self.addMenu(u"Options") solde = QAction(QIcon("{}solde.png".format(Config.img_media)), u"Solde du compte", self) solde.setShortcut("Ctrl+S") self.connect(solde, SIGNAL("triggered()"), self.show_solde) menu_settings.addAction(solde) config = QAction(QIcon("{}config.png".format(Config.img_media)), u"Préference", self) config.setShortcut("Ctrl+I") self.connect(config, SIGNAL("triggered()"), self.show_config) menu_settings.addAction(config) # Help menu_help = self.addMenu(u"Aide") menu_help.addAction(QIcon('images/help.png'), "Aide", self.goto_help)
class Actions(actioncollection.ActionCollection): name = "miditool" def createActions(self, parent=None): self.midi_pause = QAction(parent) self.midi_play = QAction(parent) self.midi_stop = QAction(parent) self.midi_restart = QAction(parent) try: self.midi_pause.setShortcut(QKeySequence(Qt.Key_MediaPause)) except AttributeError: pass # No Qt.Key_MediaPause in some PyQt4 versions self.midi_play.setShortcut(QKeySequence(Qt.Key_MediaPlay)) self.midi_stop.setShortcut(QKeySequence(Qt.Key_MediaStop)) self.midi_restart.setShortcut(QKeySequence(Qt.Key_MediaPrevious)) self.midi_pause.setIcon(icons.get('media-playback-pause')) self.midi_play.setIcon(icons.get('media-playback-start')) self.midi_stop.setIcon(icons.get('media-playback-stop')) self.midi_restart.setIcon(icons.get('media-skip-backward')) def translateUI(self): self.midi_pause.setText(_("midi player", "Pause")) self.midi_play.setText(_("midi player", "Play")) self.midi_stop.setText(_("midi player", "Stop")) self.midi_restart.setText(_("midi player", "Restart"))
def createAction(self, text, slot=None, shortcut=None, icon=None, tip=None, checkable=False): action = QAction(text, self) if slot is not None: action.triggered.connect(slot) if shortcut is not None: action.setShortcut(shortcut) if icon is not None: action.setIcon(QIcon(":/{}.png".format(icon))) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if checkable: action.setCheckable(True) return action