当前位置: 首页>>代码示例>>Python>>正文


Python QMenu.addSection方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QMenu.addSection方法的典型用法代码示例。如果您正苦于以下问题:Python QMenu.addSection方法的具体用法?Python QMenu.addSection怎么用?Python QMenu.addSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QMenu的用法示例。


在下文中一共展示了QMenu.addSection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_tab_add_clicked

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSection [as 别名]
 def on_tab_add_clicked(self):
     pos = QCursor.pos()
     planets = self.world.get_planets()
     # logger.debug('tab bar add clicked, cursor pos = ({0}, {1})'.format(pos.x(), pos.y()))
     menu = QMenu(self)
     # galaxy view
     galaxy_action = QAction(menu)
     galaxy_action.setText(self.tr('Add galaxy view'))
     galaxy_action.setData(QVariant('galaxy'))
     menu.addAction(galaxy_action)
     # planets
     menu.addSection(self.tr('-- Planet tabs: --'))
     for planet in planets:
         action = QAction(menu)
         action.setText('{0} {1}'.format(planet.name, planet.coords.coords_str()))
         action.setData(QVariant(planet.planet_id))
         menu.addAction(action)
     action_ret = menu.exec(pos)
     if action_ret is not None:
         # logger.debug('selected action data = {0}'.format(str(action_ret.data())))
         if action_ret == galaxy_action:
             logger.debug('action_ret == galaxy_action')
             self.add_tab_for_galaxy()
             return
         # else consider this is planet widget
         planet_id = int(action_ret.data())
         self.on_request_open_planet_tab(planet_id)
开发者ID:minlexx,项目名称:xnovacmd,代码行数:29,代码来源:main.py

示例2: contextMenuEvent

# 需要导入模块: from PyQt5.QtWidgets import QMenu [as 别名]
# 或者: from PyQt5.QtWidgets.QMenu import addSection [as 别名]
 def contextMenuEvent(self, event):
     menu = QMenu(self)
     for monitor in self.availableMonitors:
         menu.addAction(QAction(str(self.availableMonitors.index(monitor))+": "+monitor['resolution'], self, triggered=functools.partial(self.placeWindow, self.availableMonitors.index(monitor))))
             
     menu.addSection('')
     menu.addAction(QAction("Quit", self, triggered=self.quit))
     menu.exec_(event.globalPos())
开发者ID:leigholiver,项目名称:F2HabitBreaker,代码行数:10,代码来源:F2HabitBreaker.py


注:本文中的PyQt5.QtWidgets.QMenu.addSection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。