33 from python_qt_binding.QtWidgets
import QMenu, QToolButton
34 from .icon_tool_button
import IconToolButton
39 A widget which displays a pop-up menu when clicked 41 :param name: The name to give this widget. 43 :param icon: The icon to display in this widgets button. 46 def __init__(self, name, icons=None, clicked_icons=None, icon_paths=[]):
48 icons = [[
'bg-grey.svg',
'ic-motors.svg']]
49 super(MenuDashWidget, self).
__init__(name, icons=icons, suppress_overlays=
True, icon_paths=icon_paths)
50 self.setStyleSheet(
'QToolButton::menu-indicator {image: url(none.jpg);} QToolButton {border: none;}')
51 self.setPopupMode(QToolButton.InstantPopup)
54 self.pressed.disconnect(self._pressed)
55 self.released.disconnect(self._released)
58 self._menu.aboutToHide.connect(self._released)
59 self._menu.aboutToShow.connect(self._pressed)
61 self.setMenu(self.
_menu)
64 return self._menu.addSeparator()
68 Add an action to the menu, and return the newly created action. 70 :param name: The name of the action. 72 :param callback: Function to be called when this item is pressed. 73 :type callback: callable 75 return self._menu.addAction(name, callback)