本文整理汇总了Python中PyQt5.QtWidgets.QWidget.setMinimumSize方法的典型用法代码示例。如果您正苦于以下问题:Python QWidget.setMinimumSize方法的具体用法?Python QWidget.setMinimumSize怎么用?Python QWidget.setMinimumSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QWidget
的用法示例。
在下文中一共展示了QWidget.setMinimumSize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DeckButton
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setMinimumSize [as 别名]
class DeckButton(QWidget):
def __init__(self, deck_no, parent):
super(DeckButton, self).__init__(parent)
self.parent = parent
self.deck_no = deck_no
self.hbox = QHBoxLayout()
self.hbox.setSpacing(0)
self.hbox.setContentsMargins(0,0,0,10)
self.setLayout(self.hbox)
self.state = QWidget(self)
self.state.setObjectName('state')
self.state.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,
QSizePolicy.Fixed))
self.state.setMinimumSize(QSize(10,10))
self.state.setMaximumSize(QSize(10,10))
self.hbox.addWidget(self.state)
self.button = QPushButton(self)
self.button.setCheckable(True)
if deck_no == 1:
self.button.setChecked(True)
else:
self.button.setChecked(False)
self.hbox.addWidget(self.button)
self.button.toggled.connect(self.toggled)
def toggled(self, checked):
if checked:
self.parent.on_deck_selected(self.deck_no)
self.update()
def checkStateSet(self):
self.update()
def update(self):
con = self.parent.con
deck = model.Port(con).deck(self.deck_no)
if not deck.is_null():
self.button.setText(deck.api_name)
self.state.setProperty('state', deck.state())
self.style().unpolish(self.state)
self.style().polish(self.state)
示例2: Ui_MetroProgressCircleBar
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setMinimumSize [as 别名]
class Ui_MetroProgressCircleBar(object):
def setupUi(self, MetroProgressCircle):
MetroProgressCircle.setObjectName("MetroProgressCircle")
MetroProgressCircle.resize(100, 100)
self.gridLayout = QGridLayout(MetroProgressCircle)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setSpacing(0)
self.gridLayout.setObjectName("gridLayout")
spacerItem = QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 0, 1, 1, 1)
spacerItem1 = QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem1, 2, 1, 1, 1)
spacerItem2 = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem2, 1, 0, 1, 1)
self.MetroProgressCircleBar = QWidget(MetroProgressCircle)
self.MetroProgressCircleBar.setMinimumSize(QSize(100, 100))
self.MetroProgressCircleBar.setMaximumSize(QSize(100, 100))
self.MetroProgressCircleBar.setObjectName("MetroProgressCircleBar")
self.MetroProgressBarCircle1 = QWidget(self.MetroProgressCircleBar)
self.MetroProgressBarCircle1.setGeometry(QRect(92, 46, 8, 8))
self.MetroProgressBarCircle1.setObjectName("MetroProgressBarCircle1")
self.MetroProgressBarCircle2 = QWidget(self.MetroProgressCircleBar)
self.MetroProgressBarCircle2.setGeometry(QRect(92, 46, 8, 8))
self.MetroProgressBarCircle2.setObjectName("MetroProgressBarCircle2")
self.MetroProgressBarCircle3 = QWidget(self.MetroProgressCircleBar)
self.MetroProgressBarCircle3.setGeometry(QRect(92, 46, 8, 8))
self.MetroProgressBarCircle3.setObjectName("MetroProgressBarCircle3")
self.MetroProgressBarCircle4 = QWidget(self.MetroProgressCircleBar)
self.MetroProgressBarCircle4.setGeometry(QRect(92, 46, 8, 8))
self.MetroProgressBarCircle4.setObjectName("MetroProgressBarCircle4")
self.MetroProgressBarCircle5 = QWidget(self.MetroProgressCircleBar)
self.MetroProgressBarCircle5.setGeometry(QRect(92, 46, 8, 8))
self.MetroProgressBarCircle5.setObjectName("MetroProgressBarCircle5")
self.gridLayout.addWidget(self.MetroProgressCircleBar, 1, 1, 1, 1)
spacerItem3 = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem3, 1, 2, 1, 1)
示例3: ShipCondition
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setMinimumSize [as 别名]
class ShipCondition(QWidget):
def __init__(self, parent):
super(ShipCondition, self).__init__(parent)
self.hbox = QHBoxLayout()
self.hbox.setSpacing(3)
self.hbox.setContentsMargins(0,0,0,10)
self.setLayout(self.hbox)
self.cond_signal = QWidget(self)
self.cond_signal.setObjectName('condition_signal')
self.cond_signal.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,
QSizePolicy.Fixed))
self.cond_signal.setMinimumSize(QSize(20,20))
self.cond_signal.setMaximumSize(QSize(20,20))
self.hbox.addWidget(self.cond_signal)
self.cond = QLabel(self)
self.hbox.addWidget(self.cond)
self.setProperty('condition', 'normal')
def set_cond(self, ship):
self.cond.setText(COND_FORMAT.format(str(ship.cond)))
self.setProperty('condition', ship.cond_state())
self.style().unpolish(self.cond_signal)
self.style().polish(self.cond_signal)
self.update()
# for apply stylesheet
def paintEvent(self, pe):
opt = QStyleOption()
opt.initFrom(self)
p = QPainter(self)
s = self.style()
s.drawPrimitive(QStyle.PE_Widget, opt, p, self)
示例4: PreferencesDialog
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setMinimumSize [as 别名]
class PreferencesDialog(PreferencesDialogBase):
def __init__(self, parent, app):
PreferencesDialogBase.__init__(self, parent, app)
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
def _setupPreferenceWidgets(self):
scanTypeLabels = [
tr("Filename"),
tr("Filename - Fields"),
tr("Filename - Fields (No Order)"),
tr("Tags"),
tr("Contents"),
tr("Audio Contents"),
]
self._setupScanTypeBox(scanTypeLabels)
self._setupFilterHardnessBox()
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
self.widget = QWidget(self)
self.widget.setMinimumSize(QSize(0, 40))
self.verticalLayout_4 = QVBoxLayout(self.widget)
self.verticalLayout_4.setSpacing(0)
self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
self.label_6 = QLabel(self.widget)
self.label_6.setText(tr("Tags to scan:"))
self.verticalLayout_4.addWidget(self.label_6)
self.horizontalLayout_2 = QHBoxLayout()
self.horizontalLayout_2.setSpacing(0)
spacerItem1 = QSpacerItem(15, 20, QSizePolicy.Fixed, QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
self._setupAddCheckbox('tagTrackBox', tr("Track"), self.widget)
self.horizontalLayout_2.addWidget(self.tagTrackBox)
self._setupAddCheckbox('tagArtistBox', tr("Artist"), self.widget)
self.horizontalLayout_2.addWidget(self.tagArtistBox)
self._setupAddCheckbox('tagAlbumBox', tr("Album"), self.widget)
self.horizontalLayout_2.addWidget(self.tagAlbumBox)
self._setupAddCheckbox('tagTitleBox', tr("Title"), self.widget)
self.horizontalLayout_2.addWidget(self.tagTitleBox)
self._setupAddCheckbox('tagGenreBox', tr("Genre"), self.widget)
self.horizontalLayout_2.addWidget(self.tagGenreBox)
self._setupAddCheckbox('tagYearBox', tr("Year"), self.widget)
self.horizontalLayout_2.addWidget(self.tagYearBox)
self.verticalLayout_4.addLayout(self.horizontalLayout_2)
self.widgetsVLayout.addWidget(self.widget)
self._setupAddCheckbox('wordWeightingBox', tr("Word weighting"))
self.widgetsVLayout.addWidget(self.wordWeightingBox)
self._setupAddCheckbox('matchSimilarBox', tr("Match similar words"))
self.widgetsVLayout.addWidget(self.matchSimilarBox)
self._setupAddCheckbox('mixFileKindBox', tr("Can mix file kind"))
self.widgetsVLayout.addWidget(self.mixFileKindBox)
self._setupAddCheckbox('useRegexpBox', tr("Use regular expressions when filtering"))
self.widgetsVLayout.addWidget(self.useRegexpBox)
self._setupAddCheckbox('removeEmptyFoldersBox', tr("Remove empty folders on delete or move"))
self.widgetsVLayout.addWidget(self.removeEmptyFoldersBox)
self._setupAddCheckbox('ignoreHardlinkMatches', tr("Ignore duplicates hardlinking to the same file"))
self.widgetsVLayout.addWidget(self.ignoreHardlinkMatches)
self._setupAddCheckbox('debugModeBox', tr("Debug mode (restart required)"))
self.widgetsVLayout.addWidget(self.debugModeBox)
self._setupBottomPart()
def _load(self, prefs, setchecked):
scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type)
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
setchecked(self.tagTrackBox, prefs.scan_tag_track)
setchecked(self.tagArtistBox, prefs.scan_tag_artist)
setchecked(self.tagAlbumBox, prefs.scan_tag_album)
setchecked(self.tagTitleBox, prefs.scan_tag_title)
setchecked(self.tagGenreBox, prefs.scan_tag_genre)
setchecked(self.tagYearBox, prefs.scan_tag_year)
setchecked(self.matchSimilarBox, prefs.match_similar)
setchecked(self.wordWeightingBox, prefs.word_weighting)
def _save(self, prefs, ischecked):
prefs.scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()]
prefs.scan_tag_track = ischecked(self.tagTrackBox)
prefs.scan_tag_artist = ischecked(self.tagArtistBox)
prefs.scan_tag_album = ischecked(self.tagAlbumBox)
prefs.scan_tag_title = ischecked(self.tagTitleBox)
prefs.scan_tag_genre = ischecked(self.tagGenreBox)
prefs.scan_tag_year = ischecked(self.tagYearBox)
prefs.match_similar = ischecked(self.matchSimilarBox)
prefs.word_weighting = ischecked(self.wordWeightingBox)
def resetToDefaults(self):
self.load(preferences.Preferences())
#--- Events
def scanTypeChanged(self, index):
scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()]
word_based = scan_type in (
ScanType.Filename, ScanType.Fields, ScanType.FieldsNoOrder,
ScanType.Tag
)
tag_based = scan_type == ScanType.Tag
self.filterHardnessSlider.setEnabled(word_based)
self.matchSimilarBox.setEnabled(word_based)
self.wordWeightingBox.setEnabled(word_based)
self.tagTrackBox.setEnabled(tag_based)
self.tagArtistBox.setEnabled(tag_based)
self.tagAlbumBox.setEnabled(tag_based)
#.........这里部分代码省略.........
示例5: Ui_Tip
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setMinimumSize [as 别名]
class Ui_Tip(object):
def setupUi(self, Tip, name = "", head = "", mood = "", pic1 = "", pic2 = "", pic3 = ""):
Tip.setObjectName("Tip")
Tip.resize(275, 180)
size = QSize(275, 180)
Tip.setMinimumSize(size)
Tip.setMaximumSize(size)
Tip.setWindowTitle("")
self.name = name
self.head = head
self.mood = mood
self.pic1 = pic1
self.pic2 = pic2
self.pic3 = pic3
self.mainWidget = QWidget(Tip)
self.mainWidget.setObjectName("tip")
self.verticalLayout = QVBoxLayout(self.mainWidget)
self.verticalLayout.setObjectName("verticalLayout")
self.widget = QWidget(self.mainWidget)
self.widget.setObjectName("widget")
self.widget.setMinimumHeight(80)
self.widget.setMaximumHeight(80)
self.horizontalLayout_2 = QHBoxLayout(self.widget)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.itemHeadLabel = QLabel(self.widget)
self.itemHeadLabel.setMinimumSize(QSize(80, 80))
self.itemHeadLabel.setMaximumSize(QSize(80, 80))
self.itemHeadLabel.setOpenExternalLinks(True)
self.itemHeadLabel.setObjectName("itemHeadLabel")
self.horizontalLayout_2.addWidget(self.itemHeadLabel)
self.widget_3 = QWidget(self.widget)
self.verticalLayout_2 = QVBoxLayout(self.widget_3)
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.itemNameLabel = QLabel(self.widget_3)
# self.itemNameLabel.setOpenExternalLinks(True)
self.itemNameLabel.setObjectName("itemNameLabel")
self.verticalLayout_2.addWidget(self.itemNameLabel)
self.itemMoodLabel = QLabel(self.widget_3)
# self.itemMoodLabel.setOpenExternalLinks(True)
self.itemMoodLabel.setObjectName("itemMoodLabel")
self.verticalLayout_2.addWidget(self.itemMoodLabel)
self.horizontalLayout_2.addWidget(self.widget_3)
self.verticalLayout.addWidget(self.widget)
self.widget_2 = QWidget(self.mainWidget)
self.widget_2.setMinimumSize(QSize(0, 80))
self.widget_2.setMaximumSize(QSize(16777215, 80))
self.widget_2.setObjectName("widget_2")
self.horizontalLayout = QHBoxLayout(self.widget_2)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.itemPicLabel_1 = QLabel(self.widget_2)
self.itemPicLabel_1.setObjectName("itemPicLabel_1")
self.horizontalLayout.addWidget(self.itemPicLabel_1)
self.itemPicLabel_2 = QLabel(self.widget_2)
self.itemPicLabel_2.setObjectName("itemPicLabel_2")
self.horizontalLayout.addWidget(self.itemPicLabel_2)
self.itemPicLabel_3 = QLabel(self.widget_2)
self.itemPicLabel_3.setObjectName("itemPicLabel_3")
self.horizontalLayout.addWidget(self.itemPicLabel_3)
self.verticalLayout.addWidget(self.widget_2)
self.mainWidget.setLayout(self.verticalLayout)
self.retranslateUi(self.mainWidget)
QMetaObject.connectSlotsByName(Tip)
def retranslateUi(self, Tip):
_translate = QCoreApplication.translate
if self.head:
self.itemHeadLabel.setStyleSheet("QLabel#itemHeadLabel {\n image: url(%s);\n}" % self.head)
self.itemHeadLabel.setToolTip(_translate("Tip", "进入空间"))
if self.name:
self.itemNameLabel.setToolTip(_translate("Tip", "%s 点击查看详细资料" % self.name))
self.itemNameLabel.setText(_translate("Tip", "<html><head/><body><p><a href=\"http://www.baidu.com\"><span style=\"color: black;text-decoration: none;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;\">%s</span></a></p></body></html>" % self.name))
self.itemMoodLabel.setToolTip(_translate("Tip", "点击查看心情"))
self.itemMoodLabel.setText(_translate("Tip", "<html><head/><body><p><a href=\"http://www.baidu.com\"><span style=\"color: black;text-decoration: none;text-overflow: ellipsis;white-space: nowrap;overflow: hidden;\">%s</span></a></p></body></html>" % self.mood if self.mood else "这个家伙太懒!什么都没说..."))
示例6: PreferencesDialog
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setMinimumSize [as 别名]
class PreferencesDialog(PreferencesDialogBase):
def _setupPreferenceWidgets(self):
self._setupFilterHardnessBox()
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
self.widget = QWidget(self)
self.widget.setMinimumSize(QSize(0, 40))
self.verticalLayout_4 = QVBoxLayout(self.widget)
self.verticalLayout_4.setSpacing(0)
self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
self.label_6 = QLabel(self.widget)
self.label_6.setText(tr("Tags to scan:"))
self.verticalLayout_4.addWidget(self.label_6)
self.horizontalLayout_2 = QHBoxLayout()
self.horizontalLayout_2.setSpacing(0)
spacerItem1 = QSpacerItem(15, 20, QSizePolicy.Fixed, QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
self._setupAddCheckbox('tagTrackBox', tr("Track"), self.widget)
self.horizontalLayout_2.addWidget(self.tagTrackBox)
self._setupAddCheckbox('tagArtistBox', tr("Artist"), self.widget)
self.horizontalLayout_2.addWidget(self.tagArtistBox)
self._setupAddCheckbox('tagAlbumBox', tr("Album"), self.widget)
self.horizontalLayout_2.addWidget(self.tagAlbumBox)
self._setupAddCheckbox('tagTitleBox', tr("Title"), self.widget)
self.horizontalLayout_2.addWidget(self.tagTitleBox)
self._setupAddCheckbox('tagGenreBox', tr("Genre"), self.widget)
self.horizontalLayout_2.addWidget(self.tagGenreBox)
self._setupAddCheckbox('tagYearBox', tr("Year"), self.widget)
self.horizontalLayout_2.addWidget(self.tagYearBox)
self.verticalLayout_4.addLayout(self.horizontalLayout_2)
self.widgetsVLayout.addWidget(self.widget)
self._setupAddCheckbox('wordWeightingBox', tr("Word weighting"))
self.widgetsVLayout.addWidget(self.wordWeightingBox)
self._setupAddCheckbox('matchSimilarBox', tr("Match similar words"))
self.widgetsVLayout.addWidget(self.matchSimilarBox)
self._setupAddCheckbox('mixFileKindBox', tr("Can mix file kind"))
self.widgetsVLayout.addWidget(self.mixFileKindBox)
self._setupAddCheckbox('useRegexpBox', tr("Use regular expressions when filtering"))
self.widgetsVLayout.addWidget(self.useRegexpBox)
self._setupAddCheckbox('removeEmptyFoldersBox', tr("Remove empty folders on delete or move"))
self.widgetsVLayout.addWidget(self.removeEmptyFoldersBox)
self._setupAddCheckbox('ignoreHardlinkMatches', tr("Ignore duplicates hardlinking to the same file"))
self.widgetsVLayout.addWidget(self.ignoreHardlinkMatches)
self._setupAddCheckbox('debugModeBox', tr("Debug mode (restart required)"))
self.widgetsVLayout.addWidget(self.debugModeBox)
self._setupBottomPart()
def _load(self, prefs, setchecked):
setchecked(self.tagTrackBox, prefs.scan_tag_track)
setchecked(self.tagArtistBox, prefs.scan_tag_artist)
setchecked(self.tagAlbumBox, prefs.scan_tag_album)
setchecked(self.tagTitleBox, prefs.scan_tag_title)
setchecked(self.tagGenreBox, prefs.scan_tag_genre)
setchecked(self.tagYearBox, prefs.scan_tag_year)
setchecked(self.matchSimilarBox, prefs.match_similar)
setchecked(self.wordWeightingBox, prefs.word_weighting)
# Update UI state based on selected scan type
scan_type = prefs.get_scan_type(AppMode.Music)
word_based = scan_type in (
ScanType.Filename, ScanType.Fields, ScanType.FieldsNoOrder,
ScanType.Tag
)
tag_based = scan_type == ScanType.Tag
self.filterHardnessSlider.setEnabled(word_based)
self.matchSimilarBox.setEnabled(word_based)
self.wordWeightingBox.setEnabled(word_based)
self.tagTrackBox.setEnabled(tag_based)
self.tagArtistBox.setEnabled(tag_based)
self.tagAlbumBox.setEnabled(tag_based)
self.tagTitleBox.setEnabled(tag_based)
self.tagGenreBox.setEnabled(tag_based)
self.tagYearBox.setEnabled(tag_based)
def _save(self, prefs, ischecked):
prefs.scan_tag_track = ischecked(self.tagTrackBox)
prefs.scan_tag_artist = ischecked(self.tagArtistBox)
prefs.scan_tag_album = ischecked(self.tagAlbumBox)
prefs.scan_tag_title = ischecked(self.tagTitleBox)
prefs.scan_tag_genre = ischecked(self.tagGenreBox)
prefs.scan_tag_year = ischecked(self.tagYearBox)
prefs.match_similar = ischecked(self.matchSimilarBox)
prefs.word_weighting = ischecked(self.wordWeightingBox)
示例7: PreferencesDialog
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setMinimumSize [as 别名]
class PreferencesDialog(PreferencesDialogBase):
def __init__(self, parent, app, **kwargs):
super().__init__(parent, app, **kwargs)
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
def _setupPreferenceWidgets(self):
scanTypeLabels = [
tr("Filename"),
tr("Contents"),
tr("Folders"),
]
self._setupScanTypeBox(scanTypeLabels)
self._setupFilterHardnessBox()
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
self.widget = QWidget(self)
self.widget.setMinimumSize(QSize(0, 136))
self.verticalLayout_4 = QVBoxLayout(self.widget)
self._setupAddCheckbox('wordWeightingBox', tr("Word weighting"), self.widget)
self.verticalLayout_4.addWidget(self.wordWeightingBox)
self._setupAddCheckbox('matchSimilarBox', tr("Match similar words"), self.widget)
self.verticalLayout_4.addWidget(self.matchSimilarBox)
self._setupAddCheckbox('mixFileKindBox', tr("Can mix file kind"), self.widget)
self.verticalLayout_4.addWidget(self.mixFileKindBox)
self._setupAddCheckbox('useRegexpBox', tr("Use regular expressions when filtering"), self.widget)
self.verticalLayout_4.addWidget(self.useRegexpBox)
self._setupAddCheckbox('removeEmptyFoldersBox', tr("Remove empty folders on delete or move"), self.widget)
self.verticalLayout_4.addWidget(self.removeEmptyFoldersBox)
self.horizontalLayout_2 = QHBoxLayout()
self._setupAddCheckbox('ignoreSmallFilesBox', tr("Ignore files smaller than"), self.widget)
self.horizontalLayout_2.addWidget(self.ignoreSmallFilesBox)
self.sizeThresholdEdit = QLineEdit(self.widget)
sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.sizeThresholdEdit.sizePolicy().hasHeightForWidth())
self.sizeThresholdEdit.setSizePolicy(sizePolicy)
self.sizeThresholdEdit.setMaximumSize(QSize(50, 16777215))
self.horizontalLayout_2.addWidget(self.sizeThresholdEdit)
self.label_6 = QLabel(self.widget)
self.label_6.setText(tr("KB"))
self.horizontalLayout_2.addWidget(self.label_6)
spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
self.verticalLayout_4.addLayout(self.horizontalLayout_2)
self._setupAddCheckbox(
'ignoreHardlinkMatches',
tr("Ignore duplicates hardlinking to the same file"), self.widget
)
self.verticalLayout_4.addWidget(self.ignoreHardlinkMatches)
self._setupAddCheckbox('debugModeBox', tr("Debug mode (restart required)"), self.widget)
self.verticalLayout_4.addWidget(self.debugModeBox)
self.widgetsVLayout.addWidget(self.widget)
self._setupBottomPart()
def _setupUi(self):
PreferencesDialogBase._setupUi(self)
if ISLINUX:
# Under linux, whether it's a Qt layout bug or something else, the size threshold text edit
# doesn't have enough space, so we make the pref pane higher to compensate.
self.resize(self.width(), 530)
elif ISWINDOWS:
self.resize(self.width(), 440)
def _load(self, prefs, setchecked):
scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type)
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
setchecked(self.matchSimilarBox, prefs.match_similar)
setchecked(self.wordWeightingBox, prefs.word_weighting)
setchecked(self.ignoreSmallFilesBox, prefs.ignore_small_files)
self.sizeThresholdEdit.setText(str(prefs.small_file_threshold))
def _save(self, prefs, ischecked):
prefs.scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()]
prefs.match_similar = ischecked(self.matchSimilarBox)
prefs.word_weighting = ischecked(self.wordWeightingBox)
prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox)
prefs.small_file_threshold = tryint(self.sizeThresholdEdit.text())
def resetToDefaults(self):
self.load(preferences.Preferences())
#--- Events
def scanTypeChanged(self, index):
scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()]
word_based = scan_type == ScanType.Filename
self.filterHardnessSlider.setEnabled(word_based)
self.matchSimilarBox.setEnabled(word_based)
self.wordWeightingBox.setEnabled(word_based)
示例8: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setMinimumSize [as 别名]
class MainWindow(QMainWindow):
"""Main window class."""
def __init__(self):
"""Init class."""
super(MainWindow, self).__init__()
self.pixmap_syncthingui = QPixmap(":/images/syncthingui.svg")
tf = QTransform()
self.pixmap_syncthingui0 = QPixmap(":/images/syncthingui.svg")
tf.rotate(90.0)
self.pixmap_syncthingui1 = self.pixmap_syncthingui0.transformed(tf)
tf.rotate(180.0)
self.pixmap_syncthingui2 = self.pixmap_syncthingui0.transformed(tf)
tf.rotate(270.0)
self.pixmap_syncthingui3 = self.pixmap_syncthingui0.transformed(tf)
self.init_gui()
self.init_menu()
self.init_systray()
self.run()
def init_gui(self):
"""init gui setup"""
self.setWindowIcon(QIcon(self.pixmap_syncthingui))
self.progressbar = QProgressBar()
self.statusBar().showMessage(getoutput(SYNCTHING + ' --version'))
self.statusBar().addPermanentWidget(self.progressbar)
self.setWindowTitle(__doc__.strip().capitalize())
self.setMinimumSize(900, 600)
self.setMaximumSize(1280, 1024)
self.resize(self.minimumSize())
self.center()
# QWebView
# self.view = QWebView(self)
self.view = QWebEngineView(self)
self.view.loadStarted.connect(self.start_loading)
self.view.loadFinished.connect(self.finish_loading)
self.view.loadProgress.connect(self.loading)
self.view.titleChanged.connect(self.set_title)
self.view.page().linkHovered.connect(
lambda link_txt: self.statusBar().showMessage(link_txt[:99], 3000))
QShortcut("Ctrl++", self, activated=lambda:
self.view.setZoomFactor(self.view.zoomFactor() + 0.2))
QShortcut("Ctrl+-", self, activated=lambda:
self.view.setZoomFactor(self.view.zoomFactor() - 0.2))
QShortcut("Ctrl+0", self, activated=lambda: self.view.setZoomFactor(1))
QShortcut("Ctrl+q", self, activated=lambda: self.close())
# syncthing console
self.consolewidget = QWidget(self)
# TODO: start at specify (w,h)
self.consolewidget.setMinimumSize(QSize(200, 100))
# TODO: setStyleSheet
# self.consolewidget.setStyleSheet("margin:0px; padding: 0px; \
# border:1px solid rgb(0, 0, 0);")
# border-radius: 40px;")
# TODO read syncthing console visible from setting
# self.consolewidget.setVisible(False)
# self.consolewidget.showEvent
# self.consoletextedit = QPlainTextEdit(parent=self.consolewidget)
self.consoletoolbar = QWidget(self)
hlayout = QHBoxLayout()
hlayout
self.consoletoolbar.setLayout(hlayout)
self.consoletextedit = QTextEdit(parent=self.consolewidget)
self.consoletextedit.setWordWrapMode(QTextOption.NoWrap)
# self.consoletextedit.setStyleSheet(" border:1px solid rgb(0, 0, 0);")
# self.consoletextedit.setStyleSheet("margin:0px; padding: 0px;")
layout = QVBoxLayout()
layout.addWidget(self.consoletoolbar)
layout.addWidget(self.consoletextedit)
self.consolewidget.setLayout(layout)
self.splitter = QSplitter(Qt.Vertical)
self.splitter.addWidget(self.view)
self.splitter.addWidget(self.consolewidget)
# process
self.process = QProcess()
self.process.error.connect(self._process_failed)
# QProcess emits `readyRead` when there is data to be read
self.process.readyRead.connect(self._process_dataReady)
self.process.stateChanged.connect(self._process_stateChanged)
# Just to prevent accidentally running multiple times
# Disable the button when process starts, and enable it when it finishes
# self.process.started.connect(lambda: self.runButton.setEnabled(False))
# self.process.finished.connect(lambda: self.runButton.setEnabled(True))
# backend options
self.chrt = QCheckBox("Smooth CPU ", checked=True)
self.ionice = QCheckBox("Smooth HDD ", checked=True)
self.chrt.setToolTip("Use Smooth CPUs priority (recommended)")
self.ionice.setToolTip("Use Smooth HDDs priority (recommended)")
self.chrt.setStatusTip(self.chrt.toolTip())
self.ionice.setStatusTip(self.ionice.toolTip())
#.........这里部分代码省略.........
示例9: PreferencesDialog
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setMinimumSize [as 别名]
class PreferencesDialog(PreferencesDialogBase):
def _setupPreferenceWidgets(self):
self._setupFilterHardnessBox()
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
self.widget = QWidget(self)
self.widget.setMinimumSize(QSize(0, 136))
self.verticalLayout_4 = QVBoxLayout(self.widget)
self._setupAddCheckbox('wordWeightingBox', tr("Word weighting"), self.widget)
self.verticalLayout_4.addWidget(self.wordWeightingBox)
self._setupAddCheckbox('matchSimilarBox', tr("Match similar words"), self.widget)
self.verticalLayout_4.addWidget(self.matchSimilarBox)
self._setupAddCheckbox('mixFileKindBox', tr("Can mix file kind"), self.widget)
self.verticalLayout_4.addWidget(self.mixFileKindBox)
self._setupAddCheckbox('useRegexpBox', tr("Use regular expressions when filtering"), self.widget)
self.verticalLayout_4.addWidget(self.useRegexpBox)
self._setupAddCheckbox('removeEmptyFoldersBox', tr("Remove empty folders on delete or move"), self.widget)
self.verticalLayout_4.addWidget(self.removeEmptyFoldersBox)
self.horizontalLayout_2 = QHBoxLayout()
self._setupAddCheckbox('ignoreSmallFilesBox', tr("Ignore files smaller than"), self.widget)
self.horizontalLayout_2.addWidget(self.ignoreSmallFilesBox)
self.sizeThresholdEdit = QLineEdit(self.widget)
sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.sizeThresholdEdit.sizePolicy().hasHeightForWidth())
self.sizeThresholdEdit.setSizePolicy(sizePolicy)
self.sizeThresholdEdit.setMaximumSize(QSize(50, 16777215))
self.horizontalLayout_2.addWidget(self.sizeThresholdEdit)
self.label_6 = QLabel(self.widget)
self.label_6.setText(tr("KB"))
self.horizontalLayout_2.addWidget(self.label_6)
spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
self.verticalLayout_4.addLayout(self.horizontalLayout_2)
self._setupAddCheckbox(
'ignoreHardlinkMatches',
tr("Ignore duplicates hardlinking to the same file"), self.widget
)
self.verticalLayout_4.addWidget(self.ignoreHardlinkMatches)
self._setupAddCheckbox('debugModeBox', tr("Debug mode (restart required)"), self.widget)
self.verticalLayout_4.addWidget(self.debugModeBox)
self.widgetsVLayout.addWidget(self.widget)
self._setupBottomPart()
def _load(self, prefs, setchecked):
setchecked(self.matchSimilarBox, prefs.match_similar)
setchecked(self.wordWeightingBox, prefs.word_weighting)
setchecked(self.ignoreSmallFilesBox, prefs.ignore_small_files)
self.sizeThresholdEdit.setText(str(prefs.small_file_threshold))
# Update UI state based on selected scan type
scan_type = prefs.get_scan_type(AppMode.Standard)
word_based = scan_type == ScanType.Filename
self.filterHardnessSlider.setEnabled(word_based)
self.matchSimilarBox.setEnabled(word_based)
self.wordWeightingBox.setEnabled(word_based)
def _save(self, prefs, ischecked):
prefs.match_similar = ischecked(self.matchSimilarBox)
prefs.word_weighting = ischecked(self.wordWeightingBox)
prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox)
prefs.small_file_threshold = tryint(self.sizeThresholdEdit.text())