def __init__(self, parent=None): super(StockDialog, self).__init__(parent) self.setWindowTitle("QT painter") mainSplitter = QSplitter(Qt.Horizontal) mainSplitter.setOpaqueResize(True) frame = QFrame(mainSplitter) mainLayout = QGridLayout(frame) # mainLayout.setMargin(10) mainLayout.setSpacing(6) label1 = QLabel("形状:") label2 = QLabel("画笔线宽:") label3 = QLabel("画笔颜色:") label4 = QLabel("画笔风格:") label5 = QLabel("画笔顶端:") label6 = QLabel("画笔连接点:") label7 = QLabel("画刷风格:") label8 = QLabel("画刷颜色:") self.shapeComboBox = QComboBox() self.shapeComboBox.addItem("Line", "Line") self.shapeComboBox.addItem("Rectangle", "Rectangle") self.shapeComboBox.addItem('Rounded Rectangle', 'Rounded Rectangle') self.shapeComboBox.addItem('Ellipse', 'Ellipse') self.shapeComboBox.addItem('Pie', 'Pie') self.shapeComboBox.addItem('Chord', 'Chord') self.shapeComboBox.addItem('Path', 'Path') self.shapeComboBox.addItem('Polygon', 'Polygon') self.shapeComboBox.addItem('Polyline', 'Polyline') self.shapeComboBox.addItem('Arc', 'Arc') self.shapeComboBox.addItem('Points', 'Points') self.shapeComboBox.addItem('Text', 'Text') self.shapeComboBox.addItem('Pixmap', 'Pixmap') self.widthSpinBox = QSpinBox() self.widthSpinBox.setRange(0, 20) self.penColorFrame = QFrame() self.penColorFrame.setAutoFillBackground(True) self.penColorFrame.setPalette(QPalette(Qt.blue)) self.penColorPushButton = QPushButton("更改") self.penStyleComboBox = QComboBox() self.penStyleComboBox.addItem("Solid", Qt.SolidLine) self.penStyleComboBox.addItem('Dash', Qt.DashLine) self.penStyleComboBox.addItem('Dot', Qt.DotLine) self.penStyleComboBox.addItem('Dash Dot', Qt.DashDotLine) self.penStyleComboBox.addItem('Dash Dot Dot', Qt.DashDotDotLine) self.penStyleComboBox.addItem('None', Qt.NoPen) self.penCapComboBox = QComboBox() self.penCapComboBox.addItem("Flat", Qt.FlatCap) self.penCapComboBox.addItem('Square', Qt.SquareCap) self.penCapComboBox.addItem('Round', Qt.RoundCap) self.penJoinComboBox = QComboBox() self.penJoinComboBox.addItem("Miter", Qt.MiterJoin) self.penJoinComboBox.addItem('Bebel', Qt.BevelJoin) self.penJoinComboBox.addItem('Round', Qt.RoundJoin) self.brushStyleComboBox = QComboBox() self.brushStyleComboBox.addItem("Linear Gradient", Qt.LinearGradientPattern) self.brushStyleComboBox.addItem('Radial Gradient', Qt.RadialGradientPattern) self.brushStyleComboBox.addItem('Conical Gradient', Qt.ConicalGradientPattern) self.brushStyleComboBox.addItem('Texture', Qt.TexturePattern) self.brushStyleComboBox.addItem('Solid', Qt.SolidPattern) self.brushStyleComboBox.addItem('Horizontal', Qt.HorPattern) self.brushStyleComboBox.addItem('Vertical', Qt.VerPattern) self.brushStyleComboBox.addItem('Cross', Qt.CrossPattern) self.brushStyleComboBox.addItem('Backward Diagonal', Qt.BDiagPattern) self.brushStyleComboBox.addItem('Forward Diagonal', Qt.FDiagPattern) self.brushStyleComboBox.addItem('Diagonal Cross', Qt.DiagCrossPattern) self.brushStyleComboBox.addItem('Dense 1', Qt.Dense1Pattern) self.brushStyleComboBox.addItem('Dense 2', Qt.Dense2Pattern) self.brushStyleComboBox.addItem('Dense 3', Qt.Dense3Pattern) self.brushStyleComboBox.addItem('Dense 4', Qt.Dense4Pattern) self.brushStyleComboBox.addItem('Dense 5', Qt.Dense5Pattern) self.brushStyleComboBox.addItem('Dense 6', Qt.Dense6Pattern) self.brushStyleComboBox.addItem('Dense 7', Qt.Dense7Pattern) self.brushStyleComboBox.addItem('None', Qt.NoBrush) self.brushColorFrame = QFrame() self.brushColorFrame.setAutoFillBackground(True) self.brushColorFrame.setPalette(QPalette(Qt.green)) self.brushColorPushButton = QPushButton("更改") labelCol = 0 contentCol = 1 # 建立布局 mainLayout.addWidget(label1, 1, labelCol) mainLayout.addWidget(self.shapeComboBox, 1, contentCol) mainLayout.addWidget(label2, 2, labelCol) mainLayout.addWidget(self.widthSpinBox, 2, contentCol) mainLayout.addWidget(label3, 4, labelCol) mainLayout.addWidget(self.penColorFrame, 4, contentCol) mainLayout.addWidget(self.penColorPushButton, 4, 3) mainLayout.addWidget(label4, 6, labelCol) mainLayout.addWidget(self.penStyleComboBox, 6, contentCol) mainLayout.addWidget(label5, 8, labelCol) mainLayout.addWidget(self.penCapComboBox, 8, contentCol) mainLayout.addWidget(label6, 10, labelCol) mainLayout.addWidget(self.penJoinComboBox, 10, contentCol) mainLayout.addWidget(label7, 12, labelCol) mainLayout.addWidget(self.brushStyleComboBox, 12, contentCol) mainLayout.addWidget(label8, 14, labelCol) mainLayout.addWidget(self.brushColorFrame, 14, contentCol) mainLayout.addWidget(self.brushColorPushButton, 14, 3) mainSplitter1 = QSplitter(Qt.Horizontal) mainSplitter1.setOpaqueResize(True) stack1 = QStackedWidget() stack1.setFrameStyle(QFrame.Panel | QFrame.Raised) self.area = PaintArea() stack1.addWidget(self.area) frame1 = QFrame(mainSplitter1) mainLayout1 = QVBoxLayout(frame1) # mainLayout1.setMargin(10) mainLayout1.setSpacing(6) mainLayout1.addWidget(stack1) layout = QGridLayout(self) layout.addWidget(mainSplitter1, 0, 0) layout.addWidget(mainSplitter, 0, 1) self.setLayout(layout) # 信号和槽函数 self.shapeComboBox.activated.connect(self.slotShape) self.widthSpinBox.valueChanged.connect(self.slotPenWidth) self.penColorPushButton.clicked.connect(self.slotPenColor) self.penStyleComboBox.activated.connect(self.slotPenStyle) self.penCapComboBox.activated.connect(self.slotPenCap) self.penJoinComboBox.activated.connect(self.slotPenJoin) self.brushStyleComboBox.activated.connect(self.slotBrush) self.brushColorPushButton.clicked.connect(self.slotBrushColor) self.slotShape(self.shapeComboBox.currentIndex()) self.slotPenWidth(self.widthSpinBox.value()) self.slotBrush(self.brushStyleComboBox.currentIndex())
class CreateFunction(QDialog): """A dialog to allow the creation of functions using only one window and a QStackedWidget. For each function in functions, a dialog is created and displayed in the stacked widget.""" valschanged = pyqtSignal(object, name='valschanged') def __init__(self, prevfunc=None, selected_fields=None, parent=None, example=None, text=None): """tags is a list of the tags you want to show in the FunctionDialog. Each item should be in the form (DisplayName, tagname) as used in audioinfo. prevfunc is a Function object that is to be edited.""" QDialog.__init__(self, parent) self.setWindowTitle(translate('Functions Dialog', "Functions")) winsettings('createfunction', self) # Allow __selected field to be used. self.allowSelected = True self.realfuncs = [] # Get all the function from the functions module. for z, funcname in functions.functions.items(): if isinstance(funcname, PluginFunction): self.realfuncs.append(funcname) elif callable(funcname) and (not (funcname.__name__.startswith("__") or (funcname.__doc__ is None))): self.realfuncs.append(z) funcnames = [(Function(z).funcname, z) for z in self.realfuncs] funcnames.sort(key=lambda x: translate('Functions', x[0])) self.realfuncs = [z[1] for z in funcnames] self.vbox = QVBoxLayout() self.functions = QComboBox() self.functions.addItems( sorted([translate('Functions', x[0]) for x in funcnames])) self.vbox.addWidget(self.functions) self.stack = QStackedWidget() self.vbox.addWidget(self.stack) self.okcancel = OKCancel() self.stackWidgets = {} # Holds the created windows in the form self.functions.index: window self.setLayout(self.vbox) self.setMinimumHeight(self.sizeHint().height()) self.okcancel.ok.connect(self.okClicked) self.okcancel.cancel.connect(self.close) self.example = example self._text = text if not selected_fields: self.selectedFields = [] else: self.selectedFields = selected_fields self.exlabel = ScrollLabel('') if prevfunc is not None: index = self.functions.findText( translate('Functions', prevfunc.funcname)) if index >= 0: self.functions.setCurrentIndex(index) self.createWindow(index, prevfunc.tag, prevfunc.args) else: self.createWindow(0) self.functions.activated.connect(self.createWindow) self.vbox.addWidget(self.exlabel) self.vbox.addLayout(self.okcancel) self.setLayout(self.vbox) def createWindow(self, index, fields=None, args=None): """Creates a Function dialog in the stack window if it doesn't exist already.""" self.stack.setFrameStyle(QFrame.Box) if index not in self.stackWidgets: widget = FunctionDialog(self.realfuncs[index], self.selectedFields, args, fields, example=self.example, text=self._text) if args is None: widget.loadSettings() self.stackWidgets.update({index: widget}) self.stack.addWidget(widget) widget.updateExample.connect(self.updateExample) self.stack.setCurrentWidget(self.stackWidgets[index]) self.stackWidgets[index].showexample() self.controls = getattr(self.stackWidgets[index], 'controls', []) self.setMinimumHeight(self.sizeHint().height()) if self.sizeHint().width() > self.width(): self.setMinimumWidth(self.sizeHint().width()) def okClicked(self, close=True): w = self.stack.currentWidget() w.argValues() if not self.checkFields(w.func.tag): return if close: self.close() if w.func.tag: fields = gettaglist() new_fields = [z for z in w.func.tag if z not in fields] if new_fields: settaglist(sorted(new_fields + fields)) for widget in self.stackWidgets.values(): widget.saveSettings() self.saveSettings() self.valschanged.emit(w.func) def checkFields(self, fields): func = self.stack.currentWidget().func msg = translate('Actions', "Error: Using <b>__selected</b> in Actions is not allowed.") if not self.allowSelected and '__selected' in fields: QMessageBox.warning(self, 'puddletag', msg) return False elif func is not None and func not in functions.no_fields: msg = translate('Actions', "Please enter some fields to write to.") if not [_f for _f in fields if _f]: QMessageBox.information(self, 'puddletag', msg) return False return True def loadSettings(self): cparser = PuddleConfig() func_name = cparser.get('functions', 'last_used', '') if not func_name: return try: index = self.realfuncs.index(func_name) self.createWindow(index) self.functions.setCurrentIndex(index) except ValueError: return def saveSettings(self): cparser = PuddleConfig() funcname = self.realfuncs[self.functions.currentIndex()] cparser.set('functions', 'last_used', funcname) def updateExample(self, text): if not text: self.exlabel.setText('') else: self.exlabel.setText(displaytags(text))
class SettingsDialog(QDialog): """In order to use a class as an option add it to self.widgets""" def __init__(self, controls, parent=None, status=None): QDialog.__init__(self, parent) self.setWindowTitle("puddletag settings") winsettings('settingswin', self) built_in = [ (translate("Settings", 'General'), GeneralSettings(controls), controls), (translate("Settings", 'Confirmations'), confirmations.Settings(), None), (translate("Settings", 'Mappings'), TagMappings(), None), (translate("Settings", 'Playlist'), Playlist(), None), (translate("Settings", 'Colours'), ColorEdit(), status['table']), (translate("Settings", 'Genres'), genres.Genres(status=status), None), (translate("Settings", 'Tags'), Tags(status=status), status['table']), (translate("Settings", 'Plugins'), PluginConfig(), None), (translate("Settings", 'Shortcuts'), ActionEditorDialog(status['actions']), None), ] d = dict(enumerate(built_in)) i = len(d) for control in controls: if hasattr(control, SETTINGSWIN): c = getattr(control, SETTINGSWIN)(status=status) d[i] = [c.title, c, control] i += 1 for c in config_widgets: d[i] = [c.title, c(status=status), None] i += 1 self._widgets = d self.listbox = SettingsList() self.model = ListModel(d) self.listbox.setModel(self.model) self.stack = QStackedWidget() self.stack.setFrameStyle(QFrame.StyledPanel) self.grid = QGridLayout() self.grid.addWidget(self.listbox) self.grid.addWidget(self.stack, 0, 1) self.grid.setColumnStretch(1, 2) self.setLayout(self.grid) self.listbox.selectionChangedSignal.connect(self.showOption) selection = QItemSelection() self.selectionModel = QItemSelectionModel(self.model) index = self.model.index(0, 0) selection.select(index, index) self.listbox.setSelectionModel(self.selectionModel) self.selectionModel.select(selection, QItemSelectionModel.Select) self.okbuttons = OKCancel() self.okbuttons.okButton.setDefault(True) self.grid.addLayout(self.okbuttons, 1, 0, 1, 2) self.okbuttons.ok.connect(self.saveSettings) self.accepted.connect(self.saveSettings) self.okbuttons.cancel.connect(self.close) def showOption(self, option): widget = self._widgets[option][1] stack = self.stack if stack.indexOf(widget) == -1: stack.addWidget(widget) stack.setCurrentWidget(widget) if self.width() < self.sizeHint().width(): self.setMinimumWidth(self.sizeHint().width()) def saveSettings(self): for z in self._widgets.values(): try: z[1].applySettings(z[2]) except SettingsError as e: QMessageBox.warning(self, 'puddletag', translate('Settings', 'An error occurred while saving the settings of <b>%1</b>: %2').arg(z[0]).arg(str(e))) return self.close()
class LibChooseDialog(QDialog): """Dialog used to choose a library to load.""" adddock = pyqtSignal(str, 'QDialog', int, name='adddock') def __init__(self, parent=None): """Dialogs that allows users to load music libraries. A list of libraries is listed in a ListWidget on the left with the library module's InitWidget shown on the right. First all libraries stored in puddlestuff.libraries are loaded. Then puddlestuff.musiclib.extralibs is checked for an extra libraries. They should already be loaded. Useful methods: loadLib()->Loads the currently selected library. loadLibConfig() Libraries are module which should contain the following: name->The name of the library. InitWidget class->Used to allow the use to set options required for loading the library. """ QDialog.__init__(self, parent) self.listbox = QListWidget() self.setWindowTitle(translate('MusicLib', 'Import Music Library')) winsettings('importmusiclib', self) self.libattrs = [] for libname in libraries.__all__: try: lib = __import__('puddlestuff.libraries.%s' % libname, fromlist=['puddlestuff', 'libraries']) if not hasattr(lib, 'InitWidget'): raise Exception(translate('MusicLib', 'Invalid library')) except Exception as detail: msg = translate('MusicLib', 'Error loading %1: %2\n') msg = msg.arg(libname).arg(str(detail)) sys.stderr.write(msg) continue try: name = lib.name except AttributeError: name = translate('MusicLib', 'Anonymous Library') try: desc = lib.description except AttributeError: desc = translate('MusicLib', 'Description was left out.') try: author = lib.author except AttributeError: author = translate('MusicLib', 'Anonymous author.') self.libattrs.append({ 'name': name, 'desc': desc, 'author': author, 'module': lib }) self.libattrs.extend(extralibs) if not self.libattrs: raise MusicLibError(0, errors[0]) self.listbox.addItems([z['name'] for z in self.libattrs]) self.stackwidgets = [z['module'].InitWidget() for z in self.libattrs] self.listbox.currentRowChanged.connect(self.changeWidget) okcancel = OKCancel() okcancel.ok.connect(self.loadLib) okcancel.cancel.connect(self.close) self.stack = QStackedWidget() self.stack.setFrameStyle(QFrame.Box) list(map(self.stack.addWidget, self.stackwidgets)) hbox = QHBoxLayout() hbox.addWidget(self.listbox, 0) hbox.addWidget(self.stack, 1) vbox = QVBoxLayout() vbox.addLayout(hbox) vbox.addLayout(okcancel) self.setLayout(vbox) def changeWidget(self, number): if number > -1: self.stack.setCurrentWidget(self.stackwidgets[number]) self.currentlib = self.libattrs[number] def _loadLib(self): try: return self.stack.currentWidget().library() except MusicLibError as details: return str(details.strerror) def loadLib(self): """Loads the currently selected library. Emits 'adddock' signal if successful with a LibraryTree class as its widget. """ p = ProgressWin(self, 0, translate('MusicLib', 'Loading music library...'), False) p.show() t = PuddleThread(self._loadLib, self) t.start() while t.isRunning(): QApplication.processEvents() library = t.retval p.close() QApplication.processEvents() if isinstance(library, str): error_msg = library msg = translate( 'MusicLib', 'An error occured while loading the %1 library: <b>%2</b>') msg = msg.arg(self.currentlib['name']).arg(error_msg) QMessageBox.critical(self, translate('Defaults', "Error"), msg) else: dialog = partial(LibraryDialog, library) self.adddock.emit(translate('MusicLib', 'Music Library'), dialog, RIGHTDOCK) self.close()
class MovesetDatEditor (QWidget): def __init__(self, fname, save_directory='', owner=None): super().__init__() # reference to the main window because parent is overwritten by addTab self.owner = owner self.grid = QGridLayout(self) self.fname = fname self.editors_list = QListWidget(self) self.editors_list.setSizeAdjustPolicy(QListWidget.AdjustToContents) self.editors_list.setFixedWidth(150) self.frame = QStackedWidget(self) self.frame.setFrameStyle(QFrame.Panel | QFrame.Raised) self.initialize() self.grid.addWidget(QLabel(self.f.title(), self), 0, 0) self.grid.addWidget(self.editors_list, 1, 0) self.grid.addWidget(self.frame, 1, 1) self.grid.setColumnStretch(1, 1) def save(self): """Save the opened file (over itself)""" self.f.save(self.fname) self.last_save_directory = os.path.dirname(self.fname) def saveas(self): """Spawn a save file dialog and save as the selected file name""" self.fname = QFileDialog.getSaveFileName( self, 'Save Moveset File As', self.last_save_directory, 'Moveset dat files (*.dat)' )[0] if self.fname: self.save() # Retitle the tab to reflect the new filename. # QTabWidget uses a QStackedWidget internally, and that is the # parent of each tab, so we need parent() twice. tabs = self.parent().parent() tabs.setTabText(tabs.indexOf(self), os.path.basename(self.fname)) def close(self): self.f.close() self.deleteLater() def reload(self): """Reload same file from disk""" while self.editors_list.count() > 0: w = self.editors_list.takeItem(0) del w while self.frame.count() > 0: w = self.frame.currentWidget() self.frame.removeWidget(w) w.deleteLater() self.f.close() self.initialize() def initialize(self): self.f = moveset_datfile(self.fname) self.setup_stacked_frame() @property def last_save_directory(self): return self.owner.last_save_directory @last_save_directory.setter def last_save_directory(self, val): self.owner.last_save_directory = val def setup_stacked_frame(self): self.script_widget = ScriptEditor(self.f) self.frame.addWidget(self.script_widget) self.common_attributes_widget = AttributeEditor( 'Common Attributes', self.f.common_attributes_table ) self.frame.addWidget(self.common_attributes_widget) self.unique_attributes_widget = AttributeEditor( 'Unique Attributes', self.f.unique_attributes_table ) self.frame.addWidget(self.unique_attributes_widget) self.hurtboxes_widget = HurtboxEditor( self.f.hurtbox_header, self.f.hurtbox_table ) self.frame.addWidget(self.hurtboxes_widget) self.ledgegrab_editor = AttributeEditor( 'Ledge Grab Box', self.f.ledge_grab_data ) self.frame.addWidget(self.ledgegrab_editor) for i in range(self.frame.count()): new = QListWidgetItem(self.frame.widget(i).display_name) self.editors_list.addItem(new) self.editors_list.currentRowChanged.connect( self.frame.setCurrentIndex ) self.editors_list.setCurrentRow(0)
class ActivateDialog(QDialog): def __init__(self): QDialog.__init__(self) if not get_configs()['activate_codes']: random_activation_codes() self.setWindowTitle('激活TkPy3') self.permanent_activation = False self.layout = QGridLayout() self.view = QStackedWidget() self.activate = QWidget() self.evaluate = QWidget() self.get_activate_code = QPushButton('没有激活码?获取它!') self.activate_button = QPushButton() self.init_ui() def init_ui(self): self.create_activate_qwidget() self.create_evaluate_qwidget() self.activate_button.setText('激活') self.get_activate_code.clicked.connect(self.start_activate_code_game) self.activate_button.setDisabled(True) self.layout.addWidget(QLabel('<h1>TkPy3激活</h1>'), 0, 0) self.view.addWidget(self.activate) self.view.addWidget(self.evaluate) self.view.setCurrentIndex(0) self.layout.addWidget(self.view, 1, 0) self.layout.addWidget(self.get_activate_code, 2, 0) self.layout.addWidget(self.activate_button, 2, 1) self.activate_button.clicked.connect(self.activate_tkpy3) self.assert_activate_code() self.get_activate_code.setWhatsThis('没有激活码?通过玩游戏获取激活码。') self.setLayout(self.layout) self.view.setFrameStyle(QFrame.Box) def create_activate_qwidget(self): layout = QFormLayout() activate_text = QLineEdit() activate_text.textChanged.connect(self.assert_activate_code) activate_text.setInputMask('>AAAA-AAAA-AAAA-AAAA;_') activate_text.setWhatsThis('在此处输入激活码') layout.addRow('请输入TkPy3的激活码: ', activate_text) self.activate.setLayout(layout) def activate_tkpy3(self): add_config('is_activate', True) QMessageBox.information(self, '提示', '您已激活成功。') self.close() def assert_activate_code(self, code: str = ""): if code in get_configs()['activate_codes'] + get_configs( )['permanent_activation_codes']: self.activate_button.setWhatsThis('点击<b>此处</b>激活TkPy3') self.activate_button.setDisabled(False) if code in get_configs()['permanent_activation_codes']: self.permanent_activation = True elif not code.replace('-', ''): self.activate_button.setWhatsThis('请输入激活码') self.activate_button.setDisabled(True) elif len(code) != len('AAAA-AAAA-AAAA-AAAA'): self.activate_button.setWhatsThis('激活码输入位数不对') self.activate_button.setDisabled(True) else: self.activate_button.setWhatsThis('长度合适,请按激活按钮') self.activate_button.setDisabled(True) def start_activate_code_game(self): max_score = random.randint(20, 40) res = QMessageBox.question( self, '如何获取激活码', f'获取激活码规则:\n 玩飞船大战游戏,分数达到{max_score}分时即可获取激活码。') if res == QMessageBox.No: return self.setDisabled(True) score = run_activate_game() self.setDisabled(False) if score >= max_score: code = random.choice(get_configs()['activate_codes']) time.sleep(1) QMessageBox.information(self, '提示', f'激活码获取成功,激活码是{code},将自动为您将激活码复制到剪贴板。') clipboard = QApplication.clipboard() clipboard.clear() clipboard.setText(code) def create_evaluate_qwidget(self): pass
def __init__(self, parent=None): super(StockDialog, self).__init__(parent) self.setWindowTitle(self.tr("渐变效果")) self.startColor = Qt.green self.endColor = Qt.blue self.style = QGradient.LinearGradient self.spread = QGradient.PadSpread mainSplitter = QSplitter(Qt.Horizontal) mainSplitter.setOpaqueResize(True) frame = QFrame(mainSplitter) mainLayout = QGridLayout(frame) # mainLayout.setContentsMargins() # mainLayout.setMargin(10) # mainLayout.setSpacing(6) stack1 = QStackedWidget() stack1.setFrameStyle(QFrame.Panel | QFrame.Raised) mainSplitter1 = QSplitter(Qt.Horizontal) mainSplitter1.setOpaqueResize(True) self.area = PaintArea(self) stack1.addWidget(self.area) frame1 = QFrame(mainSplitter1) mainLayout1 = QVBoxLayout(frame1) # mainLayout1.setMargin(10) # mainLayout1.setSpacing(6) mainLayout1.addWidget(stack1) self.startPushButton = QPushButton(self.tr("start")) self.startPushButton.setAutoFillBackground(True) self.startPushButton.setPalette(QPalette(Qt.green)) self.endPushButton = QPushButton(self.tr("end")) self.endPushButton.setAutoFillBackground(True) self.endPushButton.setPalette(QPalette(Qt.blue)) self.startPushButton.clicked.connect(self.slotStartColor) self.endPushButton.clicked.connect(self.slotEndColor) # self.connect(self.startPushButton, SIGNAL("clicked()"), self.slotStartColor) # self.connect(self.endPushButton, SIGNAL("clicked()"), self.slotEndColor) self.grdientComboBox = QComboBox() self.grdientComboBox.addItem(self.tr("Linear Gradient"), QGradient.LinearGradient) self.grdientComboBox.addItem(self.tr("Radial Gradient"), QGradient.RadialGradient) self.grdientComboBox.addItem(self.tr("Conical Gradient"), QGradient.ConicalGradient) self.grdientComboBox.activated.connect(self.slotSetStyle) # self.connect(self.grdientComboBox, SIGNAL("activated(int)"), self.slotSetStyle) self.spreadComboBox = QComboBox() self.spreadComboBox.addItem(self.tr("PadSpread"), QGradient.PadSpread) self.spreadComboBox.addItem(self.tr("RepeatSpread"), QGradient.RepeatSpread) self.spreadComboBox.addItem(self.tr("ReflctSpread"), QGradient.ReflectSpread) self.spreadComboBox.activated.connect(self.slotSetSpread) # self.connect(self.spreadComboBox, SIGNAL("activated(int)"), self.slotSetSpread) mainLayout.addWidget(self.startPushButton, 1, 0) mainLayout.addWidget(self.endPushButton, 1, 1) mainLayout.addWidget(self.grdientComboBox, 1, 2) mainLayout.addWidget(self.spreadComboBox, 1, 3) layout = QGridLayout(self) layout.addWidget(mainSplitter1, 0, 0) layout.addWidget(mainSplitter, 1, 0) self.setLayout(layout)