def __init__(self, btn_name: str, show_field, actions_map: list):
        """
        Creates a QPushButton with a dropdown menu on it.

        :param btn_name: Button name (always displayed)
        :type btn_name: str
        :param actions_map: list of actions to put in the dropdown menu [(action_name, action_key), (separator_name), ...]
        :type actions_map: list
        :param show_field: entry field to display on create operations
        :type show_field: function
        """
        QPushButton.__init__(self, btn_name)

        self.menu = QMenu(self)

        for a in actions_map:
            if a == 'sep':  # This is a separator
                self.menu.addSeparator()
            else:  # Regular action
                t, k = a
                if k.startswith(
                        'create_'
                ):  # If we have a create feature, we display the entry field
                    self.menu.addAction(t, lambda k=k: show_field(k))
                else:
                    self.menu.addAction(t, lambda k=k: self.sig_action.emit(k))

        self.setMenu(self.menu)
        self.menu.setStyleSheet(get_stylesheet("menu"))
    def __init__(self, _parent, _table, _row: int, _imgfileconf: str,
                 _functionmame: str, _translations: dict, _tooltips: dict,
                 _vars: list, _type: BlockType):
        self._parent = _parent
        self._table = _table
        self._row = _row
        self._Variables = []
        self._translations = Translations(_translations)
        self._tooltips = Translations(_tooltips)
        self._functionmame = _functionmame
        self._connections = {}
        self._imgfileconf = _imgfileconf
        self._imgfile = ConfigPathtoBlockPath(self._imgfileconf)
        self._typeImg = BlockImgType.SIMPLEBLOCK  # by default
        self._type = _type
        self._language = Language()

        _varstext = self.initVars(_vars=_vars)
        self.initConections()

        self._initIMG()

        QPushButton.__init__(self, _parent)
        Block.__init__(self,
                       _img=self._img,
                       _text1="",
                       _text2="",
                       _vars=_varstext,
                       _type=self._type,
                       _typeIMG=self._typeImg)

        self._language.changed.connect(self.changeLanguage)
        self.imgchanged.connect(self.updateImgButton)
        self._parent.ui.splitter.splitterMoved.connect(self.updateIconSize)
        self.clicked.connect(self.on_clickedButton)
Example #3
0
    def __init__(self):
        QPushButton.__init__(self)

        self.about = about.About()
        self.setIcon(QtGui.QIcon(assets.path('about.png')))
        self.setToolTip("About")
        self.clicked.connect(self.about.show)
Example #4
0
 def __init__(self, *args, **kwargs):
     QPushButton.__init__(self, *args, **kwargs)
     self.setAutoRepeat(True)
     self.setAutoRepeatDelay(1000)
     self.setAutoRepeatInterval(1000)
     self.clicked.connect(self.handleClicked)
     self._state = 0
Example #5
0
    def __init__(self):
        QPushButton.__init__(self)

        self.settings = settings.Settings()
        self.setIcon(QtGui.QIcon(assets.path('settings.png')))
        self.setToolTip("Settings")
        self.clicked.connect(self.settings.show)
Example #6
0
    def __init__(self, parent=None, name=None, *args, **kwargs):
        QPushButton.__init__(self, parent, *args, **kwargs)

        self._state = 0
        self.name = name
        self.longpressed = 0
        self.clicked.connect(self.longPress)
Example #7
0
 def __init__(self,
              tool,
              param,
              allow_real_time: bool = False,
              parent=None):
     QPushButton.__init__(self, parent)
     QParamHandler.__init__(self, tool, param, allow_real_time)
Example #8
0
    def __init__(self, is_visible):
        QPushButton.__init__(self)

        self.setIcon(QtGui.QIcon(assets.path('close.png')))
        self.setToolTip("Close")
        self.clicked.connect(self.close)
        if not is_visible:
            self.hide()
Example #9
0
 def __init__(self, entity, ops):
     if not entity:
         entity = {}
     self.entity = entity
     self.ops = ops
     self.displayname = entity.get('name') or entity.get('code') or entity.get('content') or self.getDisplayName()
     QPushButton.__init__(self, self.displayname)
     self.clicked.connect(lambda e=ops['extra']: self._goSeeEntity(e))
    def __init__(self):
        QPushButton.__init__(self)

        self.stat_type: str = StatsType.ZONE

        self.setIcon(QtGui.QIcon(assets.path('reset.png')))
        self.setToolTip("Reset")
        self.clicked.connect(self.reset)
Example #11
0
 def __init__(self):
     QPushButton.__init__(self)
     self.setText("Apply")
     def restart():
         os.execl(sys.executable, sys.executable, *sys.argv)
     self.clicked.connect(apply)
     self.clicked.connect(config)
     self.clicked.connect(restart)
Example #12
0
 def __init__(self, parent=None):
     QPushButton.__init__(self, parent)
     self.setFixedSize(20, 20)
     self.setIconSize(QSize(12, 12))
     if SIGNAL is None:
         self.clicked.connect(self.choose_color)
     else:
         self.connect(self, SIGNAL("clicked()"), self.choose_color)
     self._color = QColor()
Example #13
0
 def __init__(self, parent, size: QSize, icon: QIcon, tooltip: str):
     QPushButton.__init__(self, parent)
     self._icon = icon
     self.setFlat(True)
     self.setFixedSize(size)
     #icon = QIcon( pathToIcon )
     self.setIcon(icon)
     self.setIconSize(size)
     self.setToolTip(tooltip)
Example #14
0
 def __init__(self, parent=None):
     QPushButton.__init__(self, 'New Board', parent)
     self.setStyleSheet('''
         QPushButton {
             font-size: 11pt;
             background-color: #2e2e2e;
             color: #cccccc;
         };
     ''')
     return
Example #15
0
 def __init__(self):
     QPushButton.__init__(self, 'Del')
     self.setStyleSheet('''
         QPushButton {
             font-size: 10pt;
             background-color: #2e2e2e;
             color: #cccccc;
             max-width: 30px;
         };
     ''')
     return
Example #16
0
 def __init__(self, parent, isOkButton: bool = True, callbackFnc=None):
     QPushButton.__init__(self, parent)
     self.setText("")
     self._isOkButton: bool = isOkButton
     self.userdata: Any
     self.clicked.connect(callbackFnc)
     fnc = self.clicked
     if isOkButton:
         self.setIcon(ImageFactory.inst().getOkIcon())
     else:
         self.setIcon(ImageFactory.inst().getNokIcon())
Example #17
0
    def __init__(self, clipboard):
        QPushButton.__init__(self)
        self.clipboard = clipboard
        self.prefix = '<< INITIAL PREFIX >>'
        self.players: PlayerListItem = []
        self.mode = StatsType.ZONE
        self.fame = 0.0

        self.clicked.connect(self.copy)
        self.setIcon(QtGui.QIcon(assets.path('copy.png')))
        self.setToolTip("Copy to clipboard")
Example #18
0
    def __init__(self, label, parent, cmd):
        """Initialization of the BarrenButton.

        Args:
            label (str): Text to display on the button.
            parent (QWidget): Parent widget.
            cmd (callback): Method to call once clicked.
        """
        QPushButton.__init__(self, label, parent)
        self.setCursor(Qt.PointingHandCursor)
        # Add the callback
        self.clicked.connect(cmd)
Example #19
0
 def __init__(self, title, parent=None):
     QPushButton.__init__(self, title)
     self.title = title
     self.setStyleSheet('''
         QPushButton {
             font-size: 11pt;
             background-color: #2e2e2e;
             color: #cccccc;
             max-width: 145px;
             min-width: 145px;
         };
     ''')
     return
Example #20
0
    def __init__(self, config):
        """
        Button handling the FromDigirule operation
        """
        QPushButton.__init__(self)

        self.setIcon(assets_mgr.get_icon("from_digirule"))
        self.setIconSize(assets_mgr.ICON_SIZE)
        self.setToolTip("From Digirule")
        self.setStyleSheet('border: none; background-color: ' +
                           config.get('colors', 'toolbar_icon_btn_bg') + ';')

        self.clicked.connect(self.from_digirule)
Example #21
0
    def __init__(self, config):
        """
        Button for the firmware update
        """
        QPushButton.__init__(self)

        self.setIcon(assets_mgr.get_icon("firmware"))
        self.setIconSize(assets_mgr.ICON_SIZE)
        self.setToolTip("Firmware update")
        self.setStyleSheet('border: none; background-color: ' +
                           config.get('colors', 'toolbar_icon_btn_bg') + ';')

        self.clicked.connect(self.firmware_update)
Example #22
0
    def __init__(self, parent):
        QPushButton.__init__(self, parent)
        self.p_account_id = 0

        self.Menu = QMenu(self)
        self.Menu.addAction(g_tr('AccountButton', "Choose account"),
                            self.ChooseAccount)
        self.Menu.addAction(g_tr('AccountButton', "Any account"),
                            self.ClearAccount)
        self.setMenu(self.Menu)

        self.dialog = AccountListDialog()
        self.setText(self.dialog.SelectedName)
Example #23
0
    def __init__(self, parent):
        QPushButton.__init__(self, parent)
        self.db = None
        self.p_account_id = 0
        self.setText(g_tr('AccountButton', "ANY"))

        self.Menu = QMenu(self)
        self.Menu.addAction(g_tr('AccountButton', "Choose account"),
                            self.ChooseAccount)
        self.Menu.addAction(g_tr('AccountButton', "Any account"),
                            self.ClearAccount)
        self.setMenu(self.Menu)

        self.dialog = None
Example #24
0
    def __init__(self, config):
        """
        Button handling the clear operation on the serial out field
        """
        QPushButton.__init__(self)

        self.config = config

        self.setIcon(assets_mgr.get_icon("clear"))
        self.setIconSize(assets_mgr.ICON_SIZE)
        self.setToolTip("Clear Serial out")
        self.set_style()

        self.clicked.connect(self.on_clear)
Example #25
0
    def __init__(self, config):
        """
        Button handling the refresh ports operation
        """
        QPushButton.__init__(self)

        self.config = config

        self.setIcon(assets_mgr.get_icon("refresh"))
        self.setIconSize(assets_mgr.ICON_SIZE)
        self.setToolTip("Refresh")
        self.set_style()

        self.clicked.connect(self.on_refresh)
    def __init__(self, params):
        IWB.__init__(self, params)
        QPushButton.__init__(self, "Select")
        self.setStyleSheet('''
            color: #cccccc;
            border-radius: 5px;
            border: 1px solid #aaaaaa;
            padding-top: 3px;
            padding-bottom: 3px;
            padding-left: 25px;
            padding-right: 25px;
            background: transparent;
        ''')

        self.clicked.connect(M(self.button_clicked))
Example #27
0
		def __init__(self, i3, ws_info):
			QPushButton.__init__(self, i3)
			
			self.num = ws_info['num']

			# bind workspace swap
			self.clicked.connect(lambda x: i3.switch_to_workspace(self))
		
			if 'workspaces' in i3.config[i3.name] and \
			self.num in i3.config[i3.name]['workspaces']:
				self.setText(i3.config[i3.name]['workspaces'][self.num]) 
			else:
				self.setText(str(self.num))

			i3.layout.insertWidget(self.num, self)
Example #28
0
    def __init__(self, icon, tooltip, callback):
        """
        Button widget for the toolbar
        """
        QPushButton.__init__(self)

        self.setIcon(get_icon(icon))
        self.setToolTip(tooltip)
        self.setFixedSize(BUTTON_SIZE)
        self.setIconSize(ICON_SIZE)
        self.clicked.connect(callback)

        self.setStyleSheet(
            "QPushButton:hover {background-color: #E0F2F7;} QPushButton {border: none; margin: 5px;}"
        )
Example #29
0
    def __init__(self, color: str, callback, selected: bool):
        """
        Button color for the Color edition

        :param color: button's background color
        :param callback: callback method with color as parameter
        :param selected: default selection
        """
        QPushButton.__init__(self)

        self.color = color.upper()
        self.is_selected = False
        self.clicked.connect(lambda: callback(self.color))

        self.select(self.color if selected else "")  # init style
Example #30
0
    def __init__(self, name, stbar, parent_bar, default_config={}):
        QPushButton.__init__(self, parent_bar)
        QThread.__init__(self)

        self.stbar = stbar
        self.parent_bar = parent_bar
        self.name = name
        self.setObjectName(name)
        self.config = stbar.deep_update(default_config, stbar.config)
        self.show()

        if hasattr(self, 'on_click'):
            self.clicked.connect(self.on_click)

        if hasattr(self, 'run'):
            self.start()
Example #31
0
 def __init__(self, parent=None):
     QPushButton.__init__(self, parent)
     self._painted = False