本文整理汇总了Python中guidata.qt.QtGui.QMenu类的典型用法代码示例。如果您正苦于以下问题:Python QMenu类的具体用法?Python QMenu怎么用?Python QMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QMenu类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent=None):
QMenu.__init__(self, parent)
self.options = {}
system_tray_menu = [
(self.START, lambda: agent_manager("start")),
(self.STOP, lambda: agent_manager("stop")),
(self.RESTART, lambda: agent_manager("restart")),
]
# First the version
self.addAction(self.ABOUT.format(get_version())).setEnabled(False)
self.addSeparator()
for name, action in system_tray_menu:
self.add_option(name, action)
# enable or disable mac login
if Platform.is_mac():
self.add_option(self.MAC_LOGIN.format(self.enable_or_disable_mac()),
lambda: self.enable_or_disable_login())
elif Platform.is_windows():
self.add_option(self.FLARE, lambda: thread.start_new_thread(windows_flare, ()))
# And finally the exit
self.add_option(self.EXIT, lambda: sys.exit(0))
self.connect(self, SIGNAL("aboutToShow()"), lambda: self.update_options())
示例2: __init__
def __init__(self, settings, parent=None):
QMenu.__init__(self, parent)
self.options = {}
for name, action in settings:
menu_action = self.addAction(name)
self.connect(menu_action, SIGNAL("triggered()"), action)
self.options[name] = menu_action
示例3: __init__
def __init__(self, parent=None, ):
QMenu.__init__(self, parent)
self.options = {}
for name, action in SYSTEM_TRAY_MENU:
menu_action = self.addAction(name)
self.connect(menu_action, SIGNAL('triggered()'), action)
self.options[name] = menu_action
self.connect(self, SIGNAL("aboutToShow()"), lambda: self.update_options())
示例4: __init__
def __init__(self):
QMainWindow.__init__(self)
self.setWindowIcon(get_icon(os.path.join(APP_RESOURCES, 'icons',
'python.png')))
self.setupUi(self)
# Redirect output to GUI's QTextEdit
sys.stdout = OutLog(self.outputTextEdit, sys.stdout)
sys.stderr = OutLog(self.outputTextEdit, sys.stderr, QColor(255,0,0) )
settings = QSettings()
size = settings.value("MainWindow/Size",
QVariant(QSize(600, 500))).toSize()
self.resize(size)
position = settings.value("MainWindow/Position",
QVariant(QPoint(0, 0))).toPoint()
self.move(position)
self.restoreState(
settings.value("MainWindow/State").toByteArray())
self.logger = Logger('Zupport.GUIloader')
self.logger.debugging = settings.value("Logging/debugging").toBool()
# Set up a ZupportManager to deal with the plugins
self.manager = Manager(self)
self.plugins = {}
# Set up the extents menu
self.extent = ExtentContainer()
self.menuExtent = QMenu("Extent")
resolutions = self.extent.resolutions
self.extenactiongroup = QActionGroup(self.menuExtent)
noneaction = QAction("None", self.menuExtent)
self.extenactiongroup.addAction(noneaction)
self.menuExtent.addAction(noneaction)
for resolution in resolutions:
resolution_text = str(resolution)
submenu = self.menuExtent.addMenu(resolution_text)
self.menuExtent.addMenu(submenu)
for area in self.extent.get_names(resolution):
subaction = QAction(str(area) + ": %s" % resolution_text,
submenu)
subaction.setCheckable(True)
self.extenactiongroup.addAction(subaction)
submenu.addAction(subaction)
noneaction.isChecked()
self.menuSettings.addMenu(self.menuExtent)
self.actionDebugging_messages.setChecked(self.logger.debugging)
self.setWindowTitle("Zupport GUI")
self.load_tools()
self.toolTreeWidget.itemSelectionChanged.connect(self.update_ui)
self.actionDebugging_messages.toggled.connect(self._set_debugging)
self.menuExtent.triggered.connect(self.update_ui)
self.actionLoad_tool.triggered.connect(self.show_tool_gui)
self.toolTreeWidget.doubleClicked.connect(self.show_tool_gui)
示例5: MainWindow
class MainWindow(QMainWindow, Ui_MainWindow):
'''Mainwindow for initial loading of different plugins.
'''
def __init__(self):
QMainWindow.__init__(self)
self.setWindowIcon(get_icon(os.path.join(APP_RESOURCES, 'icons',
'python.png')))
self.setupUi(self)
# Redirect output to GUI's QTextEdit
sys.stdout = OutLog(self.outputTextEdit, sys.stdout)
sys.stderr = OutLog(self.outputTextEdit, sys.stderr, QColor(255,0,0) )
settings = QSettings()
size = settings.value("MainWindow/Size",
QVariant(QSize(600, 500))).toSize()
self.resize(size)
position = settings.value("MainWindow/Position",
QVariant(QPoint(0, 0))).toPoint()
self.move(position)
self.restoreState(
settings.value("MainWindow/State").toByteArray())
self.logger = Logger('Zupport.GUIloader')
self.logger.debugging = settings.value("Logging/debugging").toBool()
# Set up a ZupportManager to deal with the plugins
self.manager = Manager(self)
self.plugins = {}
# Set up the extents menu
self.extent = ExtentContainer()
self.menuExtent = QMenu("Extent")
resolutions = self.extent.resolutions
self.extenactiongroup = QActionGroup(self.menuExtent)
noneaction = QAction("None", self.menuExtent)
self.extenactiongroup.addAction(noneaction)
self.menuExtent.addAction(noneaction)
for resolution in resolutions:
resolution_text = str(resolution)
submenu = self.menuExtent.addMenu(resolution_text)
self.menuExtent.addMenu(submenu)
for area in self.extent.get_names(resolution):
subaction = QAction(str(area) + ": %s" % resolution_text,
submenu)
subaction.setCheckable(True)
self.extenactiongroup.addAction(subaction)
submenu.addAction(subaction)
noneaction.isChecked()
self.menuSettings.addMenu(self.menuExtent)
self.actionDebugging_messages.setChecked(self.logger.debugging)
self.setWindowTitle("Zupport GUI")
self.load_tools()
self.toolTreeWidget.itemSelectionChanged.connect(self.update_ui)
self.actionDebugging_messages.toggled.connect(self._set_debugging)
self.menuExtent.triggered.connect(self.update_ui)
self.actionLoad_tool.triggered.connect(self.show_tool_gui)
self.toolTreeWidget.doubleClicked.connect(self.show_tool_gui)
def closeEvent(self, event):
settings = QSettings()
settings.setValue("Logging/debugging", self.logger.debugging)
settings.setValue("MainWindow/Size", QVariant(self.size()))
settings.setValue("MainWindow/Position",
QVariant(self.pos()))
settings.setValue("MainWindow/State",
QVariant(self.saveState()))
def load_tools(self):
plugins = self.manager.plugins
for name, plugin in plugins.iteritems():
item = QTreeWidgetItem(QStringList(name.capitalize()))
tool_items = []
for tool_name in plugin.tool_names():
tool_items.append(QTreeWidgetItem(QStringList(tool_name)))
item.addChildren(tool_items)
self.toolTreeWidget.addTopLevelItem(item)
item.setExpanded(True)
self.statusbar.showMessage("Succesfully loaded %s plugins" % len(plugins),
4000)
def show_tool_gui(self):
selected_tool = self.toolListWidget.currentItem()
toolname = str(selected_tool.text())
parameters = self.manager.plugins[toolname]
# Check if extent is available
extent = self.extenactiongroup.checkedAction()
if extent:
extent = str(extent.text())
# Extent is a String of the form "area: resolution"
area, resolution = extent.split(':')
resolution = int(resolution)
#.........这里部分代码省略.........