本文整理汇总了Python中PySide.QtGui.QMenu.addSeparator方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.addSeparator方法的具体用法?Python QMenu.addSeparator怎么用?Python QMenu.addSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QMenu
的用法示例。
在下文中一共展示了QMenu.addSeparator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def main():
setStyle()
app = QApplication(sys.argv)
settings = SettingsWindow()
image_output = TestImageOutput(settings)
ir_board = ir.IrBoard(image_output)
print u"Версия библиотеки инфракрасная ручка ",ir_board.getVersion()
win = MainWindow(settings)
win.show()
tray_menu = QMenu()
tray_menu.addAction(QIcon(':/main/restore.png'), u"Восстановить", win.show)
tray_menu.addAction(QIcon(':/main/calibrate.png'), u"Калибровка", win.calibrate)
tray_menu.addAction(QIcon(':/main/cogwheel.png'), u"Настройка", win.settings_window.show)
tray_menu.addSeparator()
tray_menu.addAction(QIcon(':/main/close.png'), u"Выход", app.quit)
tray = QSystemTrayIcon()
tray.setIcon(QIcon(':/main/webcam.png'))
tray.setContextMenu(tray_menu)
tray.show()
return app.exec_()
示例2: create
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def create(self, window: QtGui.QMainWindow, parent_menu: QtGui.QMenu):
if self.disabled:
return
if callable(self.method_name):
method = self.method_name
else:
method = getattr(window, self.method_name)
if self.sep:
parent_menu.addSeparator()
if self.submenu:
menu = QtGui.QMenu(self.verbose_name, p(parent_menu))
if self.icon:
action = parent_menu.addMenu(get_icon(self.icon), menu)
else:
action = parent_menu.addMenu(menu)
action.hovered.connect(functools.partial(self.fill_submenu, window, menu, method))
else:
if self.icon:
action = QtGui.QAction(get_icon(self.icon), self.verbose_name, p(parent_menu))
else:
action = QtGui.QAction(self.verbose_name, p(parent_menu))
# noinspection PyUnresolvedReferences
action.triggered.connect(method)
parent_menu.addAction(action)
if self.shortcut:
action.setShortcut(self.shortcut)
if self.help_text:
action.setStatusTip(self.help_text)
示例3: _create_theme_menu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def _create_theme_menu(self):
theme_menu = QMenu(self)
theme_menu.setTitle('Buttons Theme')
theme_menu.setTearOffEnabled(True)
theme_menu.setWindowTitle(TAG)
theme_actions = QActionGroup(self)
theme_actions.setExclusive(True)
# create ordered theme list
custom_order_theme = sorted(THEMES.iterkeys())
custom_order_theme.remove('Maya Theme')
custom_order_theme.insert(0, 'Maya Theme')
default_item = True
for theme in custom_order_theme:
current_theme_action = QAction(theme, theme_actions)
current_theme_action.setCheckable(True)
current_theme_action.setChecked(
MTTSettings.value('theme', 'Maya Theme') == theme)
current_theme_action.triggered.connect(self.on_change_theme)
theme_menu.addAction(current_theme_action)
if default_item:
theme_menu.addSeparator()
default_item = False
return theme_menu
示例4: _handle_context_menu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def _handle_context_menu(self, pos):
index = self.ui.tree_view.indexAt(pos)
if index.isValid():
pos = self.ui.tree_view.viewport().mapToGlobal(pos)
menu = QMenu()
menu.addAction(self.ui.action_mark_watched)
menu.addAction(self.ui.action_mark_unwatched)
menu.addSeparator()
menu.addAction(self.ui.action_remove)
menu.exec_(pos)
示例5: contextMenuEvent
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def contextMenuEvent(self, event):
"""
Handles the ``contextMenuEvent`` event for :class:`CmdPromptInput`.
:param `event`: a `QContextMenuEvent` event to be processed.
"""
menu = QMenu(self)
menu.addSeparator()
# TODO: Extra stuff
menu.addAction(QAction("TODO: Add Extra stuff", self))
menu.exec_(event.globalPos())
示例6: __setup_stream_menu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def __setup_stream_menu(self):
""" Setup the actions in the context menu. """
m = QMenu(self.parent)
watch_action = QAction("Watch", self, triggered=self.watch)
videos_action = QAction("Videos", self, triggered=self.videos)
web_action = QAction("View on Twitch", self, triggered=self.www_view)
remove_action = QAction("Remove", self, triggered=self.remove)
m.addAction(watch_action)
m.addAction(videos_action)
m.addSeparator()
m.addAction(web_action)
m.addAction(remove_action)
return m
示例7: __init__
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def __init__(self, parent=None):
icon = self.loadIcon()
QSystemTrayIcon.__init__(self, icon, parent)
menu = QMenu(parent)
VBoxMenu.build(menu)
menu.addSeparator()
menu.addAction("Exit", lambda: sys.exit(0))
self.connect(menu, SIGNAL("aboutToShow()"), VBoxMenu.check_state)
self.setContextMenu(menu)
self.setToolTip("VBoxTrayIco")
traySignal = "activated(QSystemTrayIcon::ActivationReason)"
QObject.connect(self, SIGNAL(traySignal), self.showMenu)
示例8: contextMenuEvent
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def contextMenuEvent(self, event):
"""
Handles the ``contextMenuEvent`` event for :class:`MDISubWindow_TextEdit`.
:param `event`: a `QContextMenuEvent` event to be processed.
"""
menu = QMenu(self)
menu.addAction(self.action_Edit_Undo)
menu.addAction(self.action_Edit_Redo)
menu.addSeparator()
menu.addAction(self.action_Edit_Cut)
menu.addAction(self.action_Edit_Copy)
menu.addAction(self.action_Edit_Paste)
menu.addAction(self.action_Edit_Delete)
menu.addSeparator()
menu.addAction(self.action_Edit_SelectAll)
menu.popup(self.mapToGlobal(event.pos()))
# menu.exec_(self.mapToGlobal(event.pos()))
event.accept()
print("MDISubWindow_TextEdit contextMenuEvent")
示例9: SysTray
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
class SysTray(QWidget):
# instdir = '/'.join(realpath(__file__).split('/')[:-1])
def __init__(self, display, parent=None):
super(SysTray, self).__init__(parent)
self.m = managerui.uiManager()
self.s = searchui.uiSearch(display)
self.menuActions()
self.trayIconAndMenu()
self.trayIcon.show()
# def mycloseEvent(self):
# if self.manProc:
# self.manProc.kill()
# if self.seaProc:
# self.seaProc.kill()
def trayIconAndMenu(self):
self.trayMenu = QMenu(self)
self.trayMenu.addAction(self.openSearch)
self.trayMenu.addAction(self.openManager)
self.trayMenu.addSeparator()
self.trayMenu.addAction(self.quitAction)
self.trayIcon = QSystemTrayIcon(self)
self.icon = QIcon(":/res/ooo-base.png")
self.trayIcon.setIcon(self.icon)
self.trayIcon.setToolTip("Tag Manager Menu")
self.trayIcon.setContextMenu(self.trayMenu)
def iconActivated(self, reason):
pass
def menuActions(self):
self.openSearch = QAction("S&earch", self,
triggered=self.initSearch)
self.openManager = QAction("M&anage Files", self,
triggered=self.initManager)
self.quitAction = QAction("&Quit", self,
triggered=qApp.quit)
# These halt the system tray icons execution
# will have to thread these calls
@Slot()
def initSearch(self):
self.s.show()
# self.seaProc = Popen(["python",
# self.instdir + "/searchui.py"])
def initManager(self):
self.m.show()
示例10: MenuNode
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
class MenuNode(object):
_currentMenuContext = None
"""docstring for MenuNode"""
def __init__(self, option, parent, menubar = None):
if isinstance(option ,(str,unicode)):
blobs = option.split('|')
_option={
'label':blobs[0]
}
l = len(blobs)
if l>1: _option['shortcut'] = blobs[1]
if l>2: _option['help'] = blobs[2]
option = _option
self.qtmenubar = menubar
self.qtaction = None
self.qtmenu = None
# self.qtaction = None
self.owner = None
self.parent = parent
signal = option.get( 'signal', None )
self.setSignal(signal)
self.mgr = parent and parent.mgr
self.owner = parent and parent.owner
self.children = []
self.label = option.get('label', 'UNNAMED')
self.name = option.get('name',self.label.replace('&','').replace(' ','_'))
self.name = self.name.lower()
self.shortcut = option.get( 'shortcut', False )
self.help = option.get( 'help', '' )
self.priority = option.get( 'priority', 0 )
self.itemType = option.get( 'type', False )
self.onClick = option.get( 'on_click', None )
self.cmd = option.get( 'command', None )
self.cmdArgs = option.get( 'command_args', None )
self.link = None
self.menuType = self.qtmenubar and 'menubar' or 'item'
children = option.get( 'children', None )
link = option.get( 'link', None )
if children or self.itemType == 'menu':
if self.menuType != 'menubar':
self.menuType = 'menu'
self.itemType = False
elif link:
self.link = link
if self.menuType != 'menubar':
self.menuType = 'link'
elif parent and parent.menuType == 'menubar':
self.menuType = 'menu'
if self.menuType == 'menu' :
self.qtmenu = QMenu(self.label)
if not parent or parent.menuType == 'root': return
parent.addChildControl(self)
if self.itemType == 'check':
checked = option.get('checked',False)
self.setValue(checked or False)
if children:
for data in children:
self.addChild(data)
# self.mgr.addNodeIndex(self)
def getFullName(self):
if parent:
return parent.getFullName()+'/'+self.name
return self.name
def addChild( self, option, owner = None ):
if option=='----':
if self.qtmenu:
self.qtmenu.addSeparator()
elif isinstance(option, list):
output=[]
for data in option:
n = self.addChild(data)
if n :
output.append(n)
if owner: n.owner = owner
return output
else:
node = MenuNode(option, self)
if owner: node.owner = owner
self.children.append(node)
return node
def addChildControl(self, child):
#.........这里部分代码省略.........
示例11: showIndividualContextMenu
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def showIndividualContextMenu(self, person):
actionLookup = {}
m = QMenu()
actionLookup['Show Details'] = m.addAction('Show Details')
# TODO: Add to / remove from path targets
m.addSeparator()
a = m.addMenu('Set A as')
b = m.addMenu('Set B as')
for label1 in AppState.ADDITION_ITERATOR_ORDER:
a2 = a.addMenu(label1)
b2 = b.addMenu(label1)
for label2 in AppState.LEVEL_OPTION_ORDER:
actionLookup[('Set A as',
self.additionIterators[label1],
AppState.LEVEL_OPTIONS[label2])] = a2.addAction(label2)
actionLookup[('Set B as',
self.additionIterators[label1],
AppState.LEVEL_OPTIONS[label2])] = b2.addAction(label2)
m.addSeparator()
actionLookup['Trim Parents'] = m.addAction('Trim Parents')
actionLookup['Trim Spouses'] = m.addAction('Trim Spouses')
actionLookup['Trim Children'] = m.addAction('Trim Children')
if not person in self.aSet and not person in self.bSet:
actionLookup['Trim Parents'].setDisabled(True)
actionLookup['Trim Spouses'].setDisabled(True)
actionLookup['Trim Children'].setDisabled(True)
m.addSeparator()
for label1 in AppState.ADDITION_ITERATOR_ORDER:
temp = m.addMenu('Expand '+label1)
for label2 in AppState.LEVEL_OPTION_ORDER:
actionLookup[('Expand',
self.additionIterators[label1],
AppState.LEVEL_OPTIONS[label2])] = temp.addAction(label2)
choice = m.exec_(QCursor.pos())
if choice != None:
for menus,action in actionLookup.iteritems():
if action == choice:
if menus == 'Show Details':
self.showIndividualDetails(person)
elif menus == 'Trim Parents':
self.snip(person, [self.ped.CHILD_TO_PARENT])
elif menus == 'Trim Spouses':
self.snip(person, [self.ped.HUSBAND_TO_WIFE,
self.ped.WIFE_TO_HUSBAND])
elif menus == 'Trim Children':
self.snip(person, [self.ped.PARENT_TO_CHILD])
else:
assert isinstance(menus,tuple)
newSet = set(menus[1](person,level=menus[2]))
if menus[0] == 'Set A as':
historyID = self.addPedigree(newSet)
self.changePedigreeA(historyID)
elif menus[0] == 'Set B as':
historyID = self.addPedigree(newSet)
self.changePedigreeB(historyID)
elif menus[0] == 'Expand':
self.expand(person, newSet)
break
示例12: handleEvents
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def handleEvents(self, event, signals):
att = self.axisOrder[self.findAxisIndex(event.x)]
# context menu
if event.contextRequested:
contextMenu = QMenu(self)
contextMenu.addAction(u'Select all')
contextMenu.addAction(u'Select none')
contextMenu.addSeparator()
act = QAction(u'Hide Axis', self)
contextMenu.addAction(act)
if len(self.axisOrder) <= 1:
act.setEnabled(False)
axesMenu = QMenu(u'Show/Hide Axes', self)
axesActions = QActionGroup(self)
for a in self.axisOrder:
act = QAction(a,self,checkable=True)
if self.axes[a].visible:
act.toggle()
if len(self.axisOrder) <= 1:
act.setEnabled(False)
axesActions.addAction(act)
for act in axesActions.actions():
axesMenu.addAction(act)
contextMenu.addMenu(axesMenu)
contextMenu.addSeparator()
contextMenu.addAction(u'Use as X axis')
contextMenu.addAction(u'Use as Y axis')
resultAction = contextMenu.exec_(QCursor.pos())
if resultAction != None and resultAction != 0:
# Select all
if resultAction.text() == u'Select all':
self.app.intMan.newOperation(operation.ALL,att=att.dataAxis)
# Select none
if resultAction.text() == u'Select none':
self.app.intMan.newOperation(operation.NONE,att=att.dataAxis)
# Hide axis
if resultAction.text() == u'Hide Axis':
self.toggleVisible(att)
# Toggle axis
if resultAction.actionGroup() == axesActions:
self.toggleVisible(resultAction.text())
# X axis
if resultAction.text() == u'Use as X axis':
if self.app.currentYattribute != self.app.currentXattribute:
self.axes[self.app.currentXattribute].visAxis.handle.background.setAttribute('fill',self.normalHandleColor)
self.axes[self.app.currentXattribute].visAxis.handle.originalBackgroundColor = self.normalHandleColor
self.axes[att].visAxis.handle.background.setAttribute('fill',self.activeHandleColor)
self.axes[att].visAxis.handle.originalBackgroundColor = self.activeHandleColor
self.app.notifyAxisChange(att,xAxis=True)
# Y axis
if resultAction.text() == u'Use as Y axis':
if self.app.currentXattribute != self.app.currentYattribute:
self.axes[self.app.currentYattribute].visAxis.handle.background.setAttribute('fill',self.normalHandleColor)
self.axes[self.app.currentYattribute].visAxis.handle.originalBackgroundColor = self.normalHandleColor
self.axes[att].visAxis.handle.background.setAttribute('fill',self.activeHandleColor)
self.axes[att].visAxis.handle.originalBackgroundColor = self.activeHandleColor
self.app.notifyAxisChange(att,xAxis=False)
#if linesMoved:
# self.highlightedLayer.refreshLines(self.app.highlightedRsNumbers)
return signals
示例13: Indicator
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
class Indicator(QSystemTrayIcon):
def __init__(self, app, *args, **kwargs):
QSystemTrayIcon.__init__(self, *args, **kwargs)
self.app = app
self.menu = QMenu()
self.setContextMenu(self.menu)
self.menu.aboutToShow.connect(self.update)
self.opened_notes = {}
self.activated.connect(self._activated)
def _activated(self, reason):
if reason == QSystemTrayIcon.Trigger:
self.menu.popup(QCursor().pos())
def _add_note(self, struct):
note = Note.from_tuple(struct)
title = note.title[:40].replace('&', '&&')
self.menu.addAction(title, Slot()(
partial(self.open, note=note)
))
@Slot()
def kill_all(self):
try:
self.app.provider.kill()
except dbus.exceptions.DBusException:
pass
os.system('everpad --replace')
@Slot()
def update(self):
self.menu.clear()
try:
version = self.app.provider.get_api_version()
except ( # dbus raise some magic
dbus.exceptions.UnknownMethodException,
dbus.exceptions.DBusException,
):
version = -1
if version != API_VERSION:
action = self.menu.addAction(
self.tr('API version missmatch, please restart'),
)
action.setEnabled(False)
self.menu.addAction(
self.tr('Restart everpad'), self.kill_all,
)
return
if get_auth_token():
pin_notes = self.app.provider.find_notes(
'', dbus.Array([], signature='i'),
dbus.Array([], signature='i'), 0,
20, Note.ORDER_UPDATED_DESC, 1,
)
notes = self.app.provider.find_notes(
'', dbus.Array([], signature='i'),
dbus.Array([], signature='i'), 0,
20 - len(pin_notes), Note.ORDER_UPDATED_DESC, 0,
)
if len(notes) + len(pin_notes) or self.app.provider.is_first_synced():
self.menu.addAction(self.tr('All Notes'), self.show_all_notes)
self.menu.addSeparator()
if len(pin_notes):
for struct in pin_notes:
self._add_note(struct)
self.menu.addSeparator()
for struct in notes:
self._add_note(struct)
self.menu.addSeparator()
self.menu.addAction(self.tr('Create Note'), self.create)
first_sync = False
else:
first_sync = True
if self.app.provider.get_status() == STATUS_SYNC:
action = self.menu.addAction(
self.tr('Wait, first sync in progress') if first_sync
else self.tr('Sync in progress')
)
action.setEnabled(False)
else:
if first_sync:
label = self.tr('Please perform first sync')
else:
label = self.tr('Last sync: %s') % self.app.provider.get_last_sync()
self.menu.addAction(label, Slot()(self.app.provider.sync))
self.menu.addAction(self.tr('Settings and Management'), self.show_management)
self.menu.addSeparator()
self.menu.addAction(self.tr('Exit'), self.exit)
def open(self, note, search_term=''):
old_note_window = self.opened_notes.get(note.id, None)
if old_note_window and not getattr(old_note_window, 'closed', True):
editor = self.opened_notes[note.id]
editor.activateWindow()
else:
editor = Editor(self.app, note)
editor.show()
self.opened_notes[note.id] = editor
if search_term:
editor.findbar.set_search_term(search_term)
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
def __init__(self, parent=None):
super(Truss, self).__init__(parent)
self.resize(800, 600)
self.filename = None
self.filetuple = None
self.dirty = False # Refers to Data Page only.
centralwidget = QWidget(self)
gridLayout = QGridLayout(centralwidget)
self.tabWidget = QTabWidget(centralwidget)
self.tab = QWidget()
font = QFont()
font.setFamily("Courier 10 Pitch")
font.setPointSize(12)
self.tab.setFont(font)
gridLayout_3 = QGridLayout(self.tab)
self.plainTextEdit = QPlainTextEdit(self.tab)
gridLayout_3.addWidget(self.plainTextEdit, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QWidget()
self.tab_2.setFont(font)
gridLayout_2 = QGridLayout(self.tab_2)
self.plainTextEdit_2 = QPlainTextEdit(self.tab_2)
gridLayout_2.addWidget(self.plainTextEdit_2, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab_2, "")
gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
self.setCentralWidget(centralwidget)
menubar = QMenuBar(self)
menubar.setGeometry(QRect(0, 0, 800, 29))
menu_File = QMenu(menubar)
self.menu_Solve = QMenu(menubar)
self.menu_Help = QMenu(menubar)
self.setMenuBar(menubar)
self.statusbar = QStatusBar(self)
self.setStatusBar(self.statusbar)
self.action_New = QAction(self)
self.actionSave_As = QAction(self)
self.action_Save = QAction(self)
self.action_Open = QAction(self)
self.action_Quit = QAction(self)
self.action_About = QAction(self)
self.actionShow_CCPL = QAction(self)
self.action_Solve = QAction(self)
self.action_CCPL = QAction(self)
self.action_Help = QAction(self)
menu_File.addAction(self.action_New)
menu_File.addAction(self.action_Open)
menu_File.addAction(self.actionSave_As)
menu_File.addAction(self.action_Save)
menu_File.addSeparator()
menu_File.addAction(self.action_Quit)
self.menu_Solve.addAction(self.action_Solve)
self.menu_Help.addAction(self.action_About)
self.menu_Help.addAction(self.action_CCPL)
self.menu_Help.addAction(self.action_Help)
menubar.addAction(menu_File.menuAction())
menubar.addAction(self.menu_Solve.menuAction())
menubar.addAction(self.menu_Help.menuAction())
self.setWindowTitle("Main Window")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab),\
"Data Page")
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2),\
"Solution Page")
menu_File.setTitle("&File")
self.menu_Solve.setTitle("&Solve")
self.menu_Help.setTitle("&Help")
self.tabWidget.setCurrentIndex(0)
self.action_New.setText("&New")
self.action_Open.setText("&Open")
self.actionSave_As.setText("Save &As")
self.action_Save.setText("&Save")
self.action_Quit.setText("&Quit")
self.action_Solve.setText("&Solve")
self.action_About.setText("&About")
self.action_CCPL.setText("&CCPL")
self.action_Help.setText("&Help")
self.action_Quit.triggered.connect(self.close)
allToolBar = self.addToolBar("AllToolBar")
allToolBar.setObjectName("AllToolBar")
self.addActions(allToolBar, (self.action_Open, self.actionSave_As,\
self.action_Save, self.action_Solve,\
self.action_Quit ))
self.action_New.triggered.connect(self.fileNew)
self.action_Open.triggered.connect(self.fileOpen)
self.actionSave_As.triggered.connect(self.fileSaveAs)
self.action_Save.triggered.connect(self.fileSave)
self.action_Solve.triggered.connect(self.trussSolve)
self.action_About.triggered.connect(self.aboutBox)
self.action_CCPL.triggered.connect(self.displayCCPL)
self.action_Help.triggered.connect(self.help)
self.plainTextEdit.textChanged.connect(self.setDirty)
self.action_New = self.editAction(self.action_New, None,\
'ctrl+N', 'filenew', 'New File.')
self.action_Open = self.editAction(self.action_Open, None,
'ctrl+O', 'fileopen', 'Open File.')
self.actionSave_As = self.editAction(self.actionSave_As,\
None, 'ctrl+A', 'filesaveas',\
'Save and Name File.')
self.action_Save = self.editAction(self.action_Save, None,
'ctrl+S', 'filesave', 'Save File.')
self.action_Solve = self.editAction(self.action_Solve, None,
#.........这里部分代码省略.........
示例15: Indicator
# 需要导入模块: from PySide.QtGui import QMenu [as 别名]
# 或者: from PySide.QtGui.QMenu import addSeparator [as 别名]
class Indicator(QSystemTrayIcon):
def __init__(self, *args, **kwargs):
QSystemTrayIcon.__init__(self, *args, **kwargs)
self.app = QApplication.instance()
self.menu = QMenu()
self.setContextMenu(self.menu)
self.menu.aboutToShow.connect(self.update)
self.opened_notes = {}
self.activated.connect(self._activated)
def _activated(self, reason):
if reason == QSystemTrayIcon.Trigger:
self.menu.popup(QCursor().pos())
def _add_note(self, struct):
note = Note.from_tuple(struct)
title = note.title[:40].replace("&", "&&")
self.menu.addAction(title, Slot()(partial(self.open, note=note)))
@Slot()
def update(self):
self.menu.clear()
try:
version = self.app.provider.get_api_version()
except (dbus.exceptions.UnknownMethodException, dbus.exceptions.DBusException): # dbus raise some magic
version = -1
if version != API_VERSION:
action = self.menu.addAction(self.tr("API version missmatch, please restart"))
action.setEnabled(False)
if version < API_VERSION:
handler = self.app.provider.kill
else:
handler = partial(os.execlp, "everpad", "--replace")
self.menu.addAction(self.tr("Restart everpad"), handler)
return
if get_auth_token():
pin_notes = self.app.provider.find_notes(
"", dbus.Array([], signature="i"), dbus.Array([], signature="i"), 0, 20, Note.ORDER_UPDATED_DESC, 1
)
notes = self.app.provider.find_notes(
"",
dbus.Array([], signature="i"),
dbus.Array([], signature="i"),
0,
20 - len(pin_notes),
Note.ORDER_UPDATED_DESC,
0,
)
if len(notes) + len(pin_notes) or self.app.provider.is_first_synced():
self.menu.addAction(self.tr("All Notes"), self.show_all_notes)
self.menu.addSeparator()
if len(pin_notes):
for struct in pin_notes:
self._add_note(struct)
self.menu.addSeparator()
for struct in notes:
self._add_note(struct)
self.menu.addSeparator()
self.menu.addAction(self.tr("Create Note"), self.create)
first_sync = False
else:
first_sync = True
if self.app.provider.get_status() == STATUS_SYNC:
action = self.menu.addAction(
self.tr("Wait, first sync in progress") if first_sync else self.tr("Sync in progress")
)
action.setEnabled(False)
else:
if first_sync:
label = self.tr("Please perform first sync")
else:
last_sync = self.app.provider.get_last_sync()
delta_sync = (datetime.now() - datetime.strptime(last_sync, "%H:%M")).seconds // 60
if delta_sync == 0:
label = self.tr("Last Sync: Just now")
elif delta_sync == 1:
label = self.tr("Last Sync: %s min ago") % delta_sync
else:
label = self.tr("Last Sync: %s mins ago") % delta_sync
self.menu.addAction(label, Slot()(self.app.provider.sync))
self.menu.addAction(self.tr("Settings and Management"), self.show_management)
self.menu.addSeparator()
self.menu.addAction(self.tr("Exit"), self.exit)
def open(self, note, search_term=""):
old_note_window = self.opened_notes.get(note.id, None)
if old_note_window and not getattr(old_note_window, "closed", True):
editor = self.opened_notes[note.id]
editor.activateWindow()
else:
editor = Editor(note)
editor.show()
self.opened_notes[note.id] = editor
if search_term:
editor.findbar.set_search_term(search_term)
editor.findbar.show()
return editor
@Slot()
def create(self, attach=None, notebook_id=NONE_ID):
#.........这里部分代码省略.........