commotion_client.GUI.extension_toolbar.MenuItem Class Reference
Inheritance diagram for commotion_client.GUI.extension_toolbar.MenuItem:

Public Member Functions

def __init__
 
def set_menu
 

Public Attributes

 log
 
 translate
 
 viewport
 
 sub_menu
 

Detailed Description

The menu_item template object

To Make a basic toolbar button simply run the following.

#From within the ExtensionToolBar
my_button = MenuItem
my_button.setIcon(self.icon.save)
my_button.setText(self.translate("menu", "Save"))
my_button.triggered.connect(self.my_save_function)

To Make a toolbar with a menu run the following.

#From within the ExtensionToolBar
my_menu = MenuItem
my_menu.setIcon(self.icon.settings)
my_menu.setText(self.translate("menu", "Options"))
my_menu.set_menu(True)
menu_save = QtGui.QAction("Save", icons.save, self.my_save_function)
my_menu.sub_menu.addAction(menu_save)
#Using a custom icon from an extension.
menu_load = QtGui.QAction("Load", QtGui.QIcon("icons/load.png"), statusTip=self.translate("menu", "Load a item from a file"), triggered=self.my_load_function)
my_menu.menu.addAction(menu_load)

menuItems are QToolButtons
menuItems that have sub menu's are composed of a QMenu with QActions within it.

QToolButton:http://pyqt.sourceforge.net/Docs/PyQt4/qtoolbutton.html
QMenu: http://pyqt.sourceforge.net/Docs/PyQt4/qmenu.html
QAction: http://pyqt.sourceforge.net/Docs/PyQt4/qaction.html

Constructor & Destructor Documentation

def commotion_client.GUI.extension_toolbar.MenuItem.__init__ (   self,
  parent = None,
  viewport = None 
)
Sets up all the core components needed for a minimal menuItem

Args:
  viewport (object): The current viewport. This allows menu_items to have its actions interact with the current viewport.

References commotion_client.GUI.extension_toolbar.ExtensionToolBar._dirty, commotion_client.extensions.config_editor.main.ViewPort._dirty, commotion_client.GUI.extension_toolbar.MenuItem._dirty, commotion_client.GUI.crash_report.CrashReport.log, commotion_client.extensions.config_editor.main.ViewPort.log, commotion_client.GUI.extension_toolbar.ExtensionToolBar.log, commotion_client.commotion_client.HoldStateDuringRestart.log, commotion_client.GUI.extension_toolbar.MenuItem.log, commotion_client.GUI.crash_report.ReportGatherer.log, commotion_client.commotion_client.CommotionClientApplication.log, commotion_client.GUI.extension_toolbar.MenuItem.sub_menu, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.viewport, and commotion_client.GUI.extension_toolbar.MenuItem.viewport.

97 
98  def __init__(self, parent=None, viewport=None):
99  """Sets up all the core components needed for a minimal menuItem
100 
101  Args:
102  viewport (object): The current viewport. This allows menu_items to have its actions interact with the current viewport.
103 
104  """
105  super().__init__()
106  self._dirty = False
107  self.log = logging.getLogger("commotion_client."+__name__)
108  self.translate = QtCore.QCoreApplication.translate
109  self.viewport = viewport
def __init__
Definition: extension_toolbar.py:97
viewport
Definition: extension_toolbar.py:108
log
Definition: extension_toolbar.py:106
translate
Definition: extension_toolbar.py:107
_dirty
Definition: extension_toolbar.py:105

The documentation for this class was generated from the following file:
  • commotion_client/GUI/extension_toolbar.py