| 7 | |
| 8 | |
| 9 | class WidgetGallery(QDialog): |
| 10 | def __init__(self, parent=None): |
| 11 | super(WidgetGallery, self).__init__(parent) |
| 12 | |
| 13 | self.originalPalette = QApplication.palette() |
| 14 | |
| 15 | styleComboBox = QComboBox() |
| 16 | styleComboBox.addItems(QStyleFactory.keys()) |
| 17 | |
| 18 | styleLabel = QLabel("&Style:") |
| 19 | styleLabel.setBuddy(styleComboBox) |
| 20 | |
| 21 | self.useStylePaletteCheckBox = QCheckBox("&Use style's standard palette") |
| 22 | self.useStylePaletteCheckBox.setChecked(True) |
| 23 | |
| 24 | disableWidgetsCheckBox = QCheckBox("&Disable widgets") |
| 25 | |
| 26 | self.createTopLeftGroupBox() |
| 27 | self.createTopRightGroupBox() |
| 28 | self.createBottomLeftTabWidget() |
| 29 | self.createBottomRightGroupBox() |
| 30 | self.createProgressBar() |
| 31 | |
| 32 | styleComboBox.activated[str].connect(self.changeStyle) |
| 33 | self.useStylePaletteCheckBox.toggled.connect(self.changePalette) |
| 34 | disableWidgetsCheckBox.toggled.connect(self.topLeftGroupBox.setDisabled) |
| 35 | disableWidgetsCheckBox.toggled.connect(self.topRightGroupBox.setDisabled) |
| 36 | disableWidgetsCheckBox.toggled.connect(self.bottomLeftTabWidget.setDisabled) |
| 37 | disableWidgetsCheckBox.toggled.connect(self.bottomRightGroupBox.setDisabled) |
| 38 | |
| 39 | topLayout = QHBoxLayout() |
| 40 | topLayout.addWidget(styleLabel) |
| 41 | topLayout.addWidget(styleComboBox) |
| 42 | topLayout.addStretch(1) |
| 43 | topLayout.addWidget(self.useStylePaletteCheckBox) |
| 44 | topLayout.addWidget(disableWidgetsCheckBox) |
| 45 | |
| 46 | mainLayout = QGridLayout() |
| 47 | mainLayout.addLayout(topLayout, 0, 0, 1, 2) |
| 48 | mainLayout.addWidget(self.topLeftGroupBox, 1, 0) |
| 49 | mainLayout.addWidget(self.topRightGroupBox, 1, 1) |
| 50 | mainLayout.addWidget(self.bottomLeftTabWidget, 2, 0) |
| 51 | mainLayout.addWidget(self.bottomRightGroupBox, 2, 1) |
| 52 | mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) |
| 53 | mainLayout.setRowStretch(1, 1) |
| 54 | mainLayout.setRowStretch(2, 1) |
| 55 | mainLayout.setColumnStretch(0, 1) |
| 56 | mainLayout.setColumnStretch(1, 1) |
| 57 | self.setLayout(mainLayout) |
| 58 | |
| 59 | self.setWindowTitle("Styles") |
| 60 | self.changeStyle('Windows') |
| 61 | |
| 62 | def changeStyle(self, styleName): |
| 63 | QApplication.setStyle(QStyleFactory.create(styleName)) |
| 64 | self.changePalette() |
| 65 | |
| 66 | def changePalette(self): |