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


Python QPushButton.setMaximumSize方法代码示例

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


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

示例1: MasterSyncButtonHelper

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setMaximumSize [as 别名]
class MasterSyncButtonHelper(QObject):
    '''
    This is helper class to which contains a button and can emit signals. The
    MasterSyncItem can not emit signals, but is used in QStandardModel.
    '''
    clicked = Signal(bool, str)

    NOT_SYNC = 0
    SWITCHED = 1
    SYNC = 2

    ICON_PREFIX = 'irondevil'
#  ICON_PREFIX = 'crystal_clear'

    def __init__(self, master):
        QObject.__init__(self)
        self.name = master.name
        self._master = master
        self._syncronized = MasterSyncButtonHelper.NOT_SYNC
        self.ICONS = {MasterSyncButtonHelper.SYNC: QIcon(":/icons/%s_sync.png" % self.ICON_PREFIX),
                      MasterSyncButtonHelper.NOT_SYNC: QIcon(":/icons/%s_not_sync.png" % self.ICON_PREFIX),
                      MasterSyncButtonHelper.SWITCHED: QIcon(":/icons/%s_start_sync.png" % self.ICON_PREFIX)}
        self.widget = QPushButton()
#    self.widget.setFlat(True)
        self.widget.setIcon(self.ICONS[MasterSyncButtonHelper.NOT_SYNC])
        self.widget.setMaximumSize(48, 48)
        self.widget.setCheckable(True)
        self.widget.clicked.connect(self.on_sync_clicked)

    def on_sync_clicked(self, checked):
        self.set_sync_state(MasterSyncButtonHelper.SWITCHED)
        self.clicked.emit(checked, self._master.uri)

    def master(self):
        return self._master

    def get_sync_state(self):
        return self._syncronized

    def set_sync_state(self, value):
        if self._syncronized != value:
            self._syncronized = value
            if value in self.ICONS:
                self.widget.setIcon(self.ICONS[value])
                self.widget.setChecked(value == MasterSyncButtonHelper.SYNC)

    def __eq__(self, item):
        if isinstance(item, str) or isinstance(item, unicode):
            return self.master.name.lower() == item.lower()
        elif not (item is None):
            return self.master.name.lower() == item.master.name.lower()
        return False

    def __gt__(self, item):
        if isinstance(item, str) or isinstance(item, unicode):
            return self.master.name.lower() > item.lower()
        elif not (item is None):
            return self.master.name.lower() > item.master.name.lower()
        return False
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:61,代码来源:master_list_model.py

示例2: PathEditor

# 需要导入模块: from python_qt_binding.QtGui import QPushButton [as 别名]
# 或者: from python_qt_binding.QtGui.QPushButton import setMaximumSize [as 别名]
class PathEditor(QWidget):
    '''
    This is a path editor used as ItemDeligate in settings view. This editor
    provides an additional button for directory selection dialog.
    '''

    editing_finished_signal = Signal()

    def __init__(self, path, parent=None):
        QWidget.__init__(self, parent)
        self.path = path
        self._layout = QHBoxLayout(self)
        self._layout.setContentsMargins(0, 0, 0, 0)
        self._layout.setSpacing(0)
        self._button = QPushButton('...')
        self._button.setMaximumSize(QSize(24, 20))
        self._button.clicked.connect(self._on_path_select_clicked)
        self._layout.addWidget(self._button)
        self._lineedit = QLineEdit(path)
        self._lineedit.returnPressed.connect(self._on_editing_finished)
        self._layout.addWidget(self._lineedit)
        self.setLayout(self._layout)
        self.setFocusProxy(self._button)
        self.setAutoFillBackground(True)

    def _on_path_select_clicked(self):
        # Workaround for QFileDialog.getExistingDirectory because it do not
        # select the configuration folder in the dialog
        self.dialog = QFileDialog(self, caption='Select a new settings folder')
        self.dialog.setOption(QFileDialog.HideNameFilterDetails, True)
        self.dialog.setFileMode(QFileDialog.Directory)
        self.dialog.setDirectory(self.path)
        if self.dialog.exec_():
            fileNames = self.dialog.selectedFiles()
            path = fileNames[0]
            if os.path.isfile(path):
                path = os.path.basename(path)
            self._lineedit.setText(path)
            self.path = dir
            self.editing_finished_signal.emit()

    def _on_editing_finished(self):
        if self._lineedit.text():
            self.path = self._lineedit.text()
            self.editing_finished_signal.emit()
开发者ID:fkie,项目名称:multimaster_fkie,代码行数:47,代码来源:settings_widget.py


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