本文整理汇总了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
示例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()