def __init__(self, *args, **kwargs): super(Widget_listMeshs, self).__init__(*args, **kwargs) mainLayout = QVBoxLayout(self) listWidget = QListWidget() button = QPushButton("Refresh") w_buttons = QWidget() lay_buttons = QHBoxLayout(w_buttons) lay_buttons.setContentsMargins(0, 0, 0, 0) buttonSelect = QPushButton("Select One Meterial Face Shaded Objects") buttonClear = QPushButton("Clear") lay_buttons.addWidget(buttonSelect) lay_buttons.addWidget(buttonClear) mainLayout.addWidget(listWidget) mainLayout.addWidget(w_buttons) mainLayout.addWidget(button) listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection) self.listWidget = listWidget self.load() QtCore.QObject.connect(button, QtCore.SIGNAL("clicked()"), self.load) QtCore.QObject.connect(buttonSelect, QtCore.SIGNAL("clicked()"), self.selectOneMeterialFaceShadedObjects) QtCore.QObject.connect(buttonClear, QtCore.SIGNAL("clicked()"), self.cmd_clear) QtCore.QObject.connect(listWidget, QtCore.SIGNAL("itemSelectionChanged()"), self.selectItems) self.currentIndex = 0
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout(self) label = QLabel() listWidget = QListWidget() listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection) hLayout = QHBoxLayout() buttonLoad = QPushButton("LOAD") buttonRemove = QPushButton("REMOVE") hLayout.addWidget(buttonLoad) hLayout.addWidget(buttonRemove) layout.addWidget(label) layout.addWidget(listWidget) layout.addLayout(hLayout) self.label = label self.listWidget = listWidget self.buttonLoad = buttonLoad self.buttonRemove = buttonRemove QtCore.QObject.connect(self.buttonLoad, QtCore.SIGNAL('clicked()'), self.loadCommand) QtCore.QObject.connect(self.buttonRemove, QtCore.SIGNAL('clicked()'), self.removeCommand)
def __init__(self, *args, **kwargs): super(ComboDialog, self).__init__(*args, **kwargs) self.combo_box = QComboBox() self.ok_btn = QPushButton("&Ok") # noinspection PyUnresolvedReferences self.ok_btn.clicked.connect(self.accept) self.ok_btn.setDefault(True) self.cancel_btn = QPushButton("&Cancel") # noinspection PyUnresolvedReferences self.cancel_btn.clicked.connect(self.reject) self.h_layout = QHBoxLayout() self.v_layout = QVBoxLayout() self.h_layout.addStretch(0) self.h_layout.addWidget(self.ok_btn) self.h_layout.addWidget(self.cancel_btn) self.v_layout.addWidget(self.combo_box) self.v_layout.addLayout(self.h_layout) self.setLayout(self.v_layout) # noinspection PyUnresolvedReferences self.accepted.connect(self.on_accept) # noinspection PyUnresolvedReferences self.rejected.connect(self.on_reject)
def __init__(self): """Constructor""" super(MultiButtonDemo, self).__init__() layout = QVBoxLayout() self.label = QLabel("You haven't pressed a button!") # use a normal signal / slot mechanic button1 = QPushButton("One") self.connect(button1, SIGNAL("clicked()"), self.one) # now let's use partial functions button2 = QPushButton("Two") self.connect(button2, SIGNAL("clicked()"), partial(self.onButton, "Two")) button3 = QPushButton("Three") self.btn3Callback = partial(self.onButton, "Three") button3.clicked.connect(self.btn3Callback) # now let's try using a lambda function button4 = QPushButton("Four") button4.clicked.connect(lambda name="Four": self.onButton(name)) layout.addWidget(self.label) layout.addWidget(button1) layout.addWidget(button2) layout.addWidget(button3) layout.addWidget(button4) self.setLayout(layout) self.setWindowTitle("PySide Demo")
def addPage(self, buttontext, widget): button = QPushButton(buttontext) button.setCheckable(True) button.setChecked(self.rightpane.count() == 0) self.buttongroup.addButton(button, self.rightpane.count()) self.groupbox.layout().addWidget(button) self.rightpane.addWidget(widget)
def createWidgets(self): """Create children widgets needed by this view""" fieldsWidth = 450 labelsFont = View.labelsFont() editsFont = View.editsFont() self.setLogo() self.localdirLabel = QLabel(self) self.localdirEdit = QLineEdit(self) self.localdirLabel.setText('Choose a folder') self.localdirLabel.setFont(labelsFont) self.localdirEdit.setFixedWidth(fieldsWidth) self.localdirEdit.setReadOnly(False) self.localdirEdit.setFont(editsFont) self.browseButton = QPushButton(self) self.browseButton.setText('Browse') self.browseButton.setFont(labelsFont) self.syncButton = QPushButton(self) self.syncButton.setText('Sync') self.syncButton.setFont(labelsFont) self.browseButton.clicked.connect(self.onBrowseClicked) self.syncButton.clicked.connect(self.onSyncClicked) settings = get_settings() self.localdirEdit.setText(settings.value(SettingsKeys['localdir'], '')) self.statusLabel = QLabel(self) self.statusLabel.setText('Status') self.statusLabel.setFont(View.labelsFont()) self.status = StatusArea(self)
def __init__(self, parent): super(ElastixMainDialog, self).__init__(parent) self.transformation = None self.transformations = AppResources.elastixTemplates() self.radioButtons = [] for transformation in self.transformations: self.radioButtons.append(QRadioButton(transformation.name)) self.radioButtons.append(QRadioButton("Load custom parameter file...")) self.radioButtons[0].setChecked(True) self.nextButton = QPushButton("Next") self.nextButton.clicked.connect(self.next) self.cancelButton = QPushButton("Cancel") self.cancelButton.clicked.connect(self.cancel) groupLayout = QVBoxLayout() for radioButton in self.radioButtons: groupLayout.addWidget(radioButton) self.groupBox = QGroupBox("Choose parameter file") self.groupBox.setLayout(groupLayout) self.setModal(True) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.addWidget(self.groupBox, 0, 0, 1, 2) layout.addWidget(self.cancelButton, 1, 0) layout.addWidget(self.nextButton, 1, 1) self.setLayout(layout)
def __init__(self, pluginManager): super(PluginDialog, self).__init__() self.view = PluginView(pluginManager, self) self.vbLayout = QVBoxLayout(self) self.vbLayout.setContentsMargins(0, 0, 0, 0) self.vbLayout.setSpacing(0) self.vbLayout.addWidget(self.view) self.hbLayout = QHBoxLayout() self.vbLayout.addLayout(self.hbLayout) self.hbLayout.setContentsMargins(0, 0, 0, 0) self.hbLayout.setSpacing(6) self.detailsButton = QPushButton("Details", self) self.errorDetailsButton = QPushButton("Error Details", self) self.detailsButton.setEnabled(False) self.errorDetailsButton.setEnabled(False) self.hbLayout.addWidget(self.detailsButton) self.hbLayout.addWidget(self.errorDetailsButton) self.hbLayout.addStretch(5) self.resize(650, 300) self.setWindowTitle("Installed Plugins") self.view.currentPluginChanged.connect(self.updateButtons) self.view.pluginActivated.connect(self.openDetails) self.detailsButton.clicked.connect(self.openDetails) self.errorDetailsButton.clicked.connect(self.openErrorDetails)
def testBoolinSignal(self): b = QPushButton() b.setCheckable(True) self._clicked = False b.toggled[bool].connect(self.buttonCb) b.toggle() self.assert_(self._clicked)
def __init__(self): super(TwoStepLandmarkWidget, self).__init__() self.textFrame = QTextEdit( "<p>Place your mouse over the desired " "landmark point. Press 'Space' to shoot a ray through the volume. " "Move the volume around and move the mouse to move the locator. " "Press 'Space' again to define the final place of the landmark.</p>" "<p>You can also use the ray profile to define the landmark's location.</p>" ) self.textFrame.setReadOnly(True) self.textFrame.setFrameShape(QFrame.NoFrame) self.textFrame.setAutoFillBackground(False) self.textFrame.setAttribute(Qt.WA_TranslucentBackground) self.textFrame.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.textFrame.setStyleSheet("background: #aaa") self.histogramWidget = TrackingHistogramWidget() self.histogramWidget.setMinimumHeight(100) self.histogramWidget.setVisible(False) self.button = QPushButton("Pick current landmark position") self.button.clicked.connect(self.applyButtonClicked) self.button.setVisible(False) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.textFrame) layout.addWidget(self.histogramWidget) layout.addWidget(self.button) self.setLayout(layout)
def testButtonClicked(self): """Connection of a python slot to QPushButton.clicked()""" button = QPushButton('Mylabel') QObject.connect(button, SIGNAL('clicked()'), self.cb) self.args = tuple() button.emit(SIGNAL('clicked(bool)'), False) self.assert_(self.called)
class ProfileCreation(QDialog): ''' classdocs ''' profileCreated = Signal(Athlete) def __init__(self): ''' Constructor ''' QDialog.__init__(self) self._initGUI() self.athleteProfile = False def _initGUI(self): self.setWindowTitle("Profile Creation") self.profileWidget = ProfileFormWidget() self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel) self.okBtn = QPushButton("Ok") self.okBtn.setDefault(True) self.okBtn.clicked.connect(self._createProfile) self.buttonBox.addButton(self.okBtn, QDialogButtonBox.AcceptRole) vLayout = QVBoxLayout() vLayout.addWidget(QLabel("<h3>Create a new profile!</h3><hr>")) vLayout.addWidget(self.profileWidget) vLayout.addWidget(self.buttonBox) self.setLayout(vLayout) def _createProfile(self): athleteProfile = self.profileWidget.getProfile() self.profileCreated.emit(athleteProfile)
def __init__(self): super(LandmarkLocationWidget, self).__init__() self._active = False self._font = QFont() self._font.setPointSize(10) self.indexLabel = QLabel() self.indexLabel.setMaximumWidth(8) self.indexLabel.setMinimumWidth(8) self.doneButton = QPushButton("Done") self.doneButton.setMaximumWidth(50) self.doneButton.setFont(self._font) self.doneButton.clicked.connect(self.doneButtonClicked) self.fixedButton = QPushButton("") self.fixedButton.setFont(self._font) self.movingButton = QPushButton("") self.movingButton.setFont(self._font) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.setContentsMargins(0, 0, 0, 0) layout.setHorizontalSpacing(4) layout.setVerticalSpacing(0) layout.addWidget(self.indexLabel, 0, 0) layout.addWidget(self.fixedButton, 0, 1) layout.addWidget(self.movingButton, 0, 2) layout.addWidget(self.doneButton, 0, 3) self.setLayout(layout) self._updateState()
def __init__(self, parent=None): super(Form, self).__init__(parent) #self.setWindowIcon(self.style().standardIcon(QStyle.SP_DirIcon)) #QtGui.QIcon(QtGui.QMessageBox.Critical)) self.txt = QLabel() self.txt.setText("This will remove ALL Suffix from selection objects. .\nDo you want to continue?\n\n\'suffix\'") self.le = QLineEdit() self.le.setObjectName("suffix_filter") self.le.setText(".step") self.pb = QPushButton() self.pb.setObjectName("OK") self.pb.setText("OK") self.pbC = QPushButton() self.pbC.setObjectName("Cancel") self.pbC.setText("Cancel") layout = QFormLayout() layout.addWidget(self.txt) layout.addWidget(self.le) layout.addWidget(self.pb) layout.addWidget(self.pbC) self.setLayout(layout) self.connect(self.pb, SIGNAL("clicked()"),self.OK_click) self.connect(self.pbC, SIGNAL("clicked()"),self.Cancel_click) self.setWindowTitle("Warning ...")
def deleteTab(self): dialog = QDialog( self ) dialog.setWindowTitle( "Remove Tab" ) dialog.resize( 300, 50 ) mainLayout = QVBoxLayout(dialog) description = QLabel( "'%s' ���� �����Ͻð� ���ϱ�?".decode('utf-8') % self.tabText( self.currentIndex() ) ) layoutButtons = QHBoxLayout() buttonDelete = QPushButton( "�����".decode('utf-8') ) buttonCancel = QPushButton( "���".decode('utf-8') ) layoutButtons.addWidget( buttonDelete ) layoutButtons.addWidget( buttonCancel ) mainLayout.addWidget( description ) mainLayout.addLayout( layoutButtons ) dialog.show() def cmd_delete(): self.removeTab( self.indexOf( self.currentWidget() ) ) dialog.deleteLater() def cmd_cancel(): dialog.deleteLater() QtCore.QObject.connect( buttonDelete, QtCore.SIGNAL('clicked()'), cmd_delete ) QtCore.QObject.connect( buttonCancel, QtCore.SIGNAL('clicked()'), cmd_cancel )
def __init__(self, currentGroupNames=[], parent=None): super(GroupNameDialog, self).__init__(parent) self._current_groupnames = [ groupname.lower() for groupname in currentGroupNames ] self.setModal(True) self.setWindowTitle(self.tr("Group name")) label_prompt = QLabel(self.tr("Enter new launch group name:")) self._lineedit__groupname = QLineEdit() self._label_warning = QLabel() self._label_warning.setStyleSheet(""" QLabel { color: rgb(213, 17, 27); font-weight: bold; } """) self._button_ok = QPushButton(self.tr("OK")) button_cancel = QPushButton(self.tr("Cancel")) self._button_ok.clicked.connect(self._checkGroupName) button_cancel.clicked.connect(self.reject) layout = QGridLayout() row = 0 col = 0 layout.addWidget(label_prompt, 0, 0, 1, 4) row += 1 layout.addWidget(self._lineedit__groupname, row, col, 1, 4) row += 1 col += 2 layout.addWidget(self._button_ok, row, col) col += 1 layout.addWidget(button_cancel, row, col) self.setLayout(layout)
def __init__(self, parent): super(PnLFilter, self).__init__() self.parent = parent self.layout = QtGui.QGridLayout(self) #lblFromDate self.lblFromDate = QLabel("From Date") self.lblFromDate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.lblFromDate, 1, 0) #dateFromDate self.dateFromDate = QDateEdit(self) self.dateFromDate.setDisplayFormat("dd-MM-yyyy") self.dateFromDate.setDate(date(2018, 1, 1)) self.dateFromDate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.dateFromDate, 1, 1) #lblToDate self.lblToDate = QLabel("To Date") self.lblToDate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.lblToDate, 2, 0) #dateToDate self.dateToDate = QDateEdit(self) self.dateToDate.setDisplayFormat("dd-MM-yyyy") self.dateToDate.setDate(QDate.currentDate()) self.dateToDate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.dateToDate, 2, 1) #btnSubmit self.btnSubmit = QPushButton("Submit", self) self.btnSubmit.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.btnSubmit) self.setFixedSize(190, 100) self.initListener()
def __init__(self, title, *args, **kwargs ): QWidget.__init__( self, *args ) self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_loadJoints_%s.txt" % title sgCmds.makeFile( self.infoPath ) layout = QVBoxLayout( self ); layout.setContentsMargins(0,0,0,0) groupBox = QGroupBox( title ) layout.addWidget( groupBox ) baseLayout = QVBoxLayout() groupBox.setLayout( baseLayout ) listWidget = QListWidget() hl_buttons = QHBoxLayout(); hl_buttons.setSpacing( 5 ) b_addSelected = QPushButton( "Add Selected" ) b_clear = QPushButton( "Clear" ) hl_buttons.addWidget( b_addSelected ) hl_buttons.addWidget( b_clear ) baseLayout.addWidget( listWidget ) baseLayout.addLayout( hl_buttons ) self.listWidget = listWidget QtCore.QObject.connect( listWidget, QtCore.SIGNAL( "itemClicked(QListWidgetItem*)" ), self.selectJointFromItem ) QtCore.QObject.connect( b_addSelected, QtCore.SIGNAL("clicked()"), self.addSelected ) QtCore.QObject.connect( b_clear, QtCore.SIGNAL( "clicked()" ), self.clearSelected ) self.otherWidget = None self.loadInfo()
class PingerView(QWidget): def __init__(self, parent=None): super(PingerView, self).__init__(parent) self.state = 0 layout = QVBoxLayout() self.btn_start_stop = QPushButton("Start Pinging") self.lbl_output = QLabel() self.btn_start_stop.clicked.connect(self.controlThread) layout.addWidget(self.btn_start_stop) layout.addWidget(self.lbl_output) self.setLayout(layout) def createPingerThread(self): req_data = RequestData(100, 1000, 1000, 3) self.receive_pipe, send_pipe = Pipe(duplex=False) self.pinger_process = Pinger(["www.google.com"], req_data, send_pipe) def controlThread(self): if self.state == 0: self.createPingerThread() self.state = 1 self.btn_start_stop.setText("Stop Pinging") self.pinger_process.start() data = self.receive_pipe.recv() self.lbl_output.setText(str(data)) self.pinger_process.terminate() self.pinger_process.wait() self.state = 0 self.btn_start_stop.setText("Start Pinging")
def bake(self): self.bakeWidget = QDialog( self ) def doCommand(): ctlsGroup = [] for widget in self.mainWindow.w_ctlListGroup.getChildrenWidgets(): ctls = widget.items allExists=True for ctl in ctls: if not pymel.core.objExists( ctl ): allExists=False break if not allExists: continue ctlsGroup.append( ctls ) mainCtl = self.mainWindow.w_mainCtl.lineEdit.text() minFrame = int( self.bakeWidget.le_minFrame.text() ) maxFrame = int( self.bakeWidget.le_maxFrame.text() ) BaseCommands.bake( mainCtl, ctlsGroup, minFrame, maxFrame ) def closeCommand(): self.bakeWidget.close() validator = QIntValidator( self ) minFrame = pymel.core.playbackOptions( q=1, min=0 ) maxFrame = pymel.core.playbackOptions( q=1, max=1 ) mainLayout = QVBoxLayout( self.bakeWidget ) timeRangeLayout = QHBoxLayout() l_minFrame = QLabel( "Min Frame : " ) le_minFrame = QLineEdit(); le_minFrame.setValidator( validator ) l_maxFrame = QLabel( "Max Frame : " ) le_maxFrame = QLineEdit(); le_maxFrame.setValidator( validator ) timeRangeLayout.addWidget( l_minFrame ) timeRangeLayout.addWidget( le_minFrame ) timeRangeLayout.addWidget( l_maxFrame ) timeRangeLayout.addWidget( le_maxFrame ) le_minFrame.setText( str( int(minFrame) ) ) le_maxFrame.setText( str( int(maxFrame) ) ) buttonsLayout = QHBoxLayout() b_bake = QPushButton( "Bake" ) b_close = QPushButton( "Close" ) buttonsLayout.addWidget( b_bake ) buttonsLayout.addWidget( b_close ) mainLayout.addLayout( timeRangeLayout ) mainLayout.addLayout( buttonsLayout ) QtCore.QObject.connect( b_bake, QtCore.SIGNAL( "clicked()" ), doCommand ) QtCore.QObject.connect( b_close, QtCore.SIGNAL( "clicked()" ), closeCommand ) self.bakeWidget.show() self.bakeWidget.le_minFrame = le_minFrame self.bakeWidget.le_maxFrame = le_maxFrame
def setButton(self): """ Function to add a quit button """ myButton = QPushButton('Quit', self) myButton.move(20, 100) # myButton.clicked.connect(myApp.quit) myButton.clicked.connect(self.quitApp)
def setupUi(self): self.mainlayout = QVBoxLayout(self) self.title = QLabel("CardBord Operator", self) self.mainlayout.addWidget(self.title) self.user_txtarea = QTextEdit(self) self.ai_txtarea = QTextEdit(self) self.users_edit_title = QLabel("質問に答えてください") self.users_edit = QLineEdit("", self) self.txtarea_layout = QHBoxLayout() self.txtarea_layout.addWidget(self.user_txtarea) self.txtarea_layout.addWidget(self.ai_txtarea) self.mainlayout.addLayout(self.txtarea_layout) self.mainlayout.addWidget(self.users_edit_title) self.mainlayout.addWidget(self.users_edit) self.send_btn = QPushButton("send", self) self.send_btn.setObjectName("send_btn") self.mainlayout.addWidget(self.send_btn) QMetaObject.connectSlotsByName(self)
def __init__(self, *args, **kwargs ): self.uiInfoPath = Window.infoBaseDir + '/Widget_ctlListGroup.json' QWidget.__init__( self, *args, **kwargs ) mainLayout = QVBoxLayout( self ) buttonLayout = QHBoxLayout() gridLayout = QGridLayout() mainLayout.addLayout( buttonLayout ) mainLayout.addLayout( gridLayout ) gridLayout.setSpacing(5) gridLayout.setVerticalSpacing(5) b_addList = QPushButton( "Add List" ) b_removeList = QPushButton( "Remove List" ) buttonLayout.addWidget( b_addList ) buttonLayout.addWidget( b_removeList ) w_ctlList = Widget_ctlList() gridLayout.addWidget( w_ctlList ) self.__gridLayout = gridLayout QtCore.QObject.connect( b_addList, QtCore.SIGNAL( "clicked()" ), self.addList ) QtCore.QObject.connect( b_removeList, QtCore.SIGNAL( "clicked()" ), self.removeList ) self.loadInfo()
def __init__(self): super(TransformationParameterWidget, self).__init__() self.cancelButton = QPushButton("Cancel") self.cancelButton.clicked.connect(self.cancelButtonClicked) self.applyButton = QPushButton("Apply") self.applyButton.clicked.connect(self.applyButtonClicked) self.mainLayout = QGridLayout() self.mainLayout.setSpacing(0) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.widget = QWidget() self.widget.setLayout(self.mainLayout) self.showControls(False) self.transformationWidget = None layout = QGridLayout() layout.setAlignment(Qt.AlignTop) layout.addWidget(self.widget, 0, 0, 1, 2) layout.addWidget(self.cancelButton, 1, 0) layout.addWidget(self.applyButton, 1, 1) self.setLayout(layout)
def __init__(self): super(TransformationHistoryWidget, self).__init__() self.actionContainer = ButtonContainer() self.transformationModel = TransformationModel() self.transformationView = TransformationListView() self.transformationView.setRootIsDecorated(False) self.transformationView.setModel(self.transformationModel) self.transformationView.setAttribute(Qt.WA_MacShowFocusRect, False) self.transformationView.clicked.connect(self.clickedTransformation) self._transformCount = 0 layout = QVBoxLayout() layout.setSpacing(0) layout.setAlignment(Qt.AlignTop) layout.addWidget(self.transformationView) layout.addWidget(self.actionContainer) self.setLayout(layout) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) removeButton.setToolTip("Remove the last transformation") self.actionContainer.addButton(removeButton)
def __init__(self, parent=None): global client super(CharacterSelect, self).__init__(parent) self.setWindowTitle("Select A Character") # Character Portrait # Character Sprite # Name # Current zone # Money self.charbuttons = {} for char in client.characters: button = QPushButton() button.setText(char) button.setIcon(QIcon.fromTheme('applications-games')) func = functools.partial(self.select_character, char=char) button.clicked.connect(func) self.charbuttons[char] = button layout = QVBoxLayout() for w in self.charbuttons.values(): layout.addWidget(w) self.setLayout(layout) self.character_chosen.connect(qtclient.choose_char)
def __init__(self): super(MovementFilterWidget, self).__init__() self.layout = QtGui.QGridLayout(self) #lblFromDate self.lblFromDate = QLabel("From Date") self.lblFromDate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.lblFromDate, 1, 0) #dateFromDate self.dateFromDate = QDateEdit(self) self.dateFromDate.setDisplayFormat("dd-MM-yyyy") self.dateFromDate.setDate(date(2001, 7, 14)) self.dateFromDate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.dateFromDate, 1, 1) #lblToDate self.lblToDate = QLabel("To Date") self.lblToDate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.lblToDate, 2, 0) #dateToDate self.dateToDate = QDateEdit(self) self.dateToDate.setDisplayFormat("dd-MM-yyyy") self.dateToDate.setDate(datetime.now()) self.dateToDate.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.dateToDate, 2, 1) #btnSubmit self.btnSubmit = QPushButton("Submit", self) self.btnSubmit.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.layout.addWidget(self.btnSubmit) self.setFixedSize(190, 100) self.initListener()
def __create_filter_ui(self): """ Create filter widgets """ filter_layout = QHBoxLayout() filter_layout.setSpacing(1) filter_layout.setContentsMargins(0, 0, 0, 0) self.filter_reset_btn = QPushButton() icon = QIcon(':/filtersOff.png') self.filter_reset_btn.setIcon(icon) self.filter_reset_btn.setIconSize(QSize(22, 22)) self.filter_reset_btn.setFixedSize(24, 24) self.filter_reset_btn.setToolTip('Reset filter') self.filter_reset_btn.setFlat(True) self.filter_reset_btn.clicked.connect( partial(self.on_filter_set_text, '')) self.filter_line = QLineEdit() self.filter_line.setPlaceholderText('Enter filter string here') self.filter_line.textChanged.connect(self.on_filter_change_text) completer = QCompleter(self) completer.setCaseSensitivity(Qt.CaseInsensitive) completer.setModel(QStringListModel([], self)) self.filter_line.setCompleter(completer) filter_layout.addWidget(self.filter_reset_btn) filter_layout.addWidget(self.filter_line) return filter_layout
def __init__(self, parent=None): QWidget.__init__(self, parent) self.__parent = parent self.title = "Add Designation" self.designation = ValidatingLineEdit("Designation", "[a-zA-Z0-9-_\s]+", self) self.da = ValidatingLineEdit("Dearness Allowance", QDoubleValidator(), self) self.hra = ValidatingLineEdit("House Rent Allowance", QDoubleValidator(), self) self.ta = ValidatingLineEdit("Transport Allowance", QDoubleValidator(), self) self.it = ValidatingLineEdit("Income Tax", QDoubleValidator(), self) self.pt = ValidatingLineEdit("Professional Tax", QDoubleValidator(), self) # inputs whos validity needs to checked are put in a list # so that we can loop through them to check validity self.inputs = [ self.designation, self.da, self.hra, self.ta, self.it, self.pt ] self.bttnAddDesignation = QPushButton("Add Designation") self.bttnCancel = QPushButton("Cancel") self.bttnAddDesignation.setObjectName("OkButton") self.bttnCancel.setObjectName("CancelButton") self.bttnCancel.clicked.connect(self.goBack) self.bttnAddDesignation.clicked.connect(self.add) self.setupUI()
def setup_gui(self): """Sets up a sample gui interface.""" central_widget = QWidget(self) central_widget.setObjectName('central_widget') self.label = QLabel('Hello World') self.input_field = QLineEdit() change_button = QPushButton('Change text') close_button = QPushButton('close') quit_button = QPushButton('quit') central_layout = QVBoxLayout() button_layout = QHBoxLayout() central_layout.addWidget(self.label) central_layout.addWidget(self.input_field) # a separate layout to display buttons horizontal button_layout.addWidget(change_button) button_layout.addWidget(close_button) button_layout.addWidget(quit_button) central_layout.addLayout(button_layout) central_widget.setLayout(central_layout) self.setCentralWidget(central_widget) # create a system tray icon. Uncomment the second form, to have an # icon assigned, otherwise you will only be seeing an empty space in # system tray self.systemtrayicon = QSystemTrayIcon(self) self.systemtrayicon.show() # set a fancy icon self.systemtrayicon.setIcon(QIcon.fromTheme('help-browser')) change_button.clicked.connect(self.change_text) quit_button.clicked.connect(QApplication.instance().quit) close_button.clicked.connect(self.hide) # show main window, if the system tray icon was clicked self.systemtrayicon.activated.connect(self.icon_activated)
def __init__(self, *args, **kwargs ): QWidget.__init__( self, *args ) title = "" if kwargs.has_key( 'title' ): title = kwargs['title'] self.infoPath = cmds.about(pd=True) + "/sg/fingerWeightCopy/Widget_LoadVertex_%s.txt" % title sgCmds.makeFile( self.infoPath ) vLayout = QVBoxLayout( self ); vLayout.setContentsMargins(0,0,0,0) groupBox = QGroupBox( title ) groupBox.setAlignment( QtCore.Qt.AlignCenter ) vLayout.addWidget( groupBox ) hLayout = QHBoxLayout() lineEdit = QLineEdit() button = QPushButton("Load"); button.setFixedWidth( 50 ) hLayout.addWidget( lineEdit ) hLayout.addWidget( button ) groupBox.setLayout( hLayout ) self.lineEdit = lineEdit QtCore.QObject.connect( button, QtCore.SIGNAL( "clicked()" ), self.loadVertex ) self.loadInfo()
def __init__(self, *args, **kwargs): title = "" if kwargs.has_key("title"): title = kwargs.pop("title") super(Widget_mesh, self).__init__(*args, **kwargs) label = QLabel(title) label.setFixedWidth(90) lineEdit = QLineEdit() button = QPushButton("Load") button.setFixedWidth(60) mainLayout = QHBoxLayout(self) mainLayout.setContentsMargins(0, 0, 0, 0) mainLayout.addWidget(label) mainLayout.addWidget(lineEdit) mainLayout.addWidget(button) self.title = title self.lineEdit = lineEdit QtCore.QObject.connect(button, QtCore.SIGNAL("clicked()"), self.loadSelected) WidgetInfo(self.lineEdit).loadText(Window.infoPath, 'Widget_mesh_%s_lineEdit' % title)
def testButtonClick(self): """Indirect qt signal emission using the QPushButton.click() method """ button = QPushButton('label') QObject.connect(button, SIGNAL('clicked()'), self.cb) self.args = tuple() button.click() self.assert_(self.called)
def setLayout(self): self.myStatusBar = QStatusBar() self.setStatusBar(self.myStatusBar) self.duckIcon = QIcon("duck.jpeg") self.happyDuckIcon = QIcon("happy-duck.jpeg") qWidget = QWidget() gridLayout = QGridLayout(qWidget) row = 0 self.setCentralWidget(qWidget) row = row + 1 self.rebootButton = QPushButton("Click to reset") #self.rebootButton.setIcon(QIcon("duck.jpeg")) self.rebootButton.setIconSize(QSize(200, 200)) gridLayout.addWidget(self.rebootButton, row, 0) self.rebootButton.clicked.connect(self.reboot) if filecmp.cmp("wpa_supplicant.conf", "wpa_supplicant.conf.orig"): self.myStatusBar.showMessage("Waiting to onboard.") self.rebootButton.setIcon(self.duckIcon) self.thread = Timer(5, self.checkFiles) self.thread.start() else: self.rebootButton.setIcon(self.happyDuckIcon) self.myStatusBar.showMessage("waiting for DHCP address") interface = "wlan1" p = subprocess.Popen(["/sbin/dhclient", interface], shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) res, err = p.communicate()
def createWidgets(self): self.filenameLabelLabel = QLabel("New Filename") self.filenameLabel = QLabel() self.filenameLabel.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) self.filenameButton = QPushButton("C&hoose...") self.tooltips.append((self.filenameButton, """\ <p><b>Choose</b></p> <p>Choose the {} <tt>.xix</tt> file to copy the current index's options, spelling words, etc., to.</p>""".format(QApplication.applicationName()))) self.copyGroupBox = QGroupBox("Copy") self.configCheckBox = QCheckBox("&Options") self.tooltips.append((self.configCheckBox, """\ <p><b>Options</b></p> <p>If checked, copy all the current index's option and output option settings (language, sort as and page range rules, display preferences, fonts, output style, etc.) to the new empty copy.</p>""")) self.spellWordsCheckBox = QCheckBox("&Spelling Words") self.tooltips.append((self.spellWordsCheckBox, """\ <p><b>Spelling Words</b></p> <p>If checked, copy all the current index's spelling words to the new empty copy.</p>""")) self.ignoredFirstWordsCheckBox = QCheckBox( "&Ignored Subentry Function Words") self.tooltips.append((self.ignoredFirstWordsCheckBox, """\ <p><b>Ignored Subentry Function Words</b></p> <p>If checked, copy all the current index's ignored subentry function words words to the new empty copy.</p>""")) self.customMarkupCheckBox = QCheckBox("Custom &Markup") self.tooltips.append((self.customMarkupCheckBox, """\ <p><b>Custom Markup</b></p> <p>If checked, copy all the current index's custom markup to the new empty copy.</p>""")) self.groupsCheckBox = QCheckBox("&Groups") self.tooltips.append((self.groupsCheckBox, """\ <p><b>Groups</b></p> <p>If checked, copy all the current index's groups to the new empty copy.</p>""")) self.autoReplaceCheckBox = QCheckBox("&Auto Replacements") self.tooltips.append((self.autoReplaceCheckBox, """\ <p><b>Auto Replacements</b></p> <p>If checked, copy all the current index's auto replacements to the new empty copy.</p>""")) for checkbox in (self.configCheckBox, self.spellWordsCheckBox, self.ignoredFirstWordsCheckBox, self.customMarkupCheckBox, self.groupsCheckBox, self.autoReplaceCheckBox): checkbox.setChecked(True) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append( (self.helpButton, "Help on the New Empty Copy dialog")) self.newCopyButton = QPushButton(QIcon(":/document-new.svg"), "&New Empty Copy") self.tooltips.append((self.newCopyButton, """\ <p><b>New Empty Copy</b></p> <p>Create a new empty index and copy the options, spelling words, etc.—providing they have been checked—into the new index.</p>""")) self.cancelButton = QPushButton(QIcon(":/dialog-close.svg"), "&Cancel") self.tooltips.append((self.cancelButton, """<p><b>Cancel</b></p> <p>Close the dialog without making a new empty copy.</p>"""))
def initUI(self): self.layoutFile = FileBrowseWidget( "Layout settings file .yaml (*.yaml)") self.layoutFile.setText(DEFAULT_LAYOUT_FILE) self.rfSettingsFile = FileBrowseWidget( "Device settings file .yaml (*.yaml)") self.rfSettingsFile.setText(DEFAULT_RF_FILE) layout = QFormLayout() layout.addRow(QLabel("Layout settings file (.yaml):"), self.layoutFile) layout.addRow(QLabel("RF settings file (.yaml):"), self.rfSettingsFile) self.idLine = QLineEdit() self.idLine.setText(str(DEFAULT_DEVICE_ID)) self.idLine.setMaximumWidth(50) self.idLine.setValidator(QIntValidator(0, 63)) layout.addRow(QLabel("Device id (0-63):"), self.idLine) self.generateButton = QPushButton("Generate new RF settings") self.generateButton.setMaximumWidth(230) self.generateButton.clicked.connect(self.generateRFSettings) layout.addRow(None, self.generateButton) label = QLabel( "<b>Note:</b> These settings only need to be loaded on each " "device once and are persistent when you update the layout. " "To ensure proper operation and security, each device must " "have a unique device ID for a given RF settings file. " "Since RF settings file contains your encryption key, make " "sure to keep it secret.") label.setTextInteractionFlags(Qt.TextSelectableByMouse) label.setWordWrap(True) layout.addRow(label) self.setLayout(layout)
def __init__(self, *args, **kwargs ): QMainWindow.__init__( self, *args, **kwargs ) self.installEventFilter( self ) self.setObjectName( Window.objectName ) self.setWindowTitle( Window.title ) mainWidget = QWidget(); self.setCentralWidget( mainWidget ) mainLayout = QVBoxLayout( mainWidget ) addButtonsLayout = QHBoxLayout() buttonAddTab = QPushButton( 'Add Tab' ) buttonAddLine = QPushButton( 'Add Line' ) addButtonsLayout.addWidget( buttonAddTab ) addButtonsLayout.addWidget( buttonAddLine ) tabWidget = TabWidget() self.tabWidget = tabWidget buttonLayout = QHBoxLayout() buttonCreate = QPushButton( "Create" ) buttonClose = QPushButton( "Close" ) buttonLayout.addWidget( buttonCreate ) buttonLayout.addWidget( buttonClose ) mainLayout.addLayout( addButtonsLayout ) mainLayout.addWidget( tabWidget ) mainLayout.addLayout( buttonLayout ) QtCore.QObject.connect( buttonAddTab, QtCore.SIGNAL( 'clicked()' ), partial( self.addTab ) ) QtCore.QObject.connect( buttonAddLine, QtCore.SIGNAL( "clicked()" ), partial( tabWidget.addLine ) ) QtCore.QObject.connect( buttonCreate, QtCore.SIGNAL( "clicked()" ), self.cmd_create ) QtCore.QObject.connect( buttonClose, QtCore.SIGNAL( "clicked()" ), self.cmd_close )
def __init__(self, parent=None): QWidget.__init__(self, parent) self.__parent = parent self.setWindowTitle("Add Designation") self.designation = QLineEdit() self.da = QLineEdit() self.da.setValidator(QDoubleValidator()) self.hra = QLineEdit() self.hra.setValidator(QDoubleValidator()) self.ta = QLineEdit() self.ta.setValidator(QDoubleValidator()) self.it = QLineEdit() self.it.setValidator(QDoubleValidator()) self.pt = QLineEdit() self.pt.setValidator(QDoubleValidator()) self.bttnAddDesignation = QPushButton("Add Designation") self.bttnCancel = QPushButton("Cancel") self.bttnAddDesignation.setObjectName("OkButton") self.bttnCancel.setObjectName("CancelButton") self.bttnCancel.clicked.connect(self.goBack) self.bttnAddDesignation.clicked.connect(self.add) self.setupUI()
def initialize(self, words): self.removeComboBox = QComboBox() self.removeComboBox.addItems(words) self.tooltips.append((self.removeComboBox, """\ <p><b>Spelling Words combobox</b></p> <p>This index's list of words that have been remembered as correctly spelled or to be ignored even though they aren't in the dictionary for the index's language.</p>""")) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append((self.helpButton, "Help on the Forget Spelling Words dialog")) self.removeButton = QPushButton(QIcon(":/spelling-remove.svg"), "&Forget") self.tooltips.append((self.removeButton, """\ <p><b>Forget</b></p> <p>Permanently forget the selected word from the index's spelling words list. Afterwards, if this word appears in any entry, it will be highlighted as misspelled.</p>""")) closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((closeButton, """<p><b>Close</b></p> <p>Close the dialog.</p>""")) self.buttonBox = QDialogButtonBox() self.buttonBox.addButton(closeButton, QDialogButtonBox.RejectRole) self.buttonBox.addButton( self.removeButton, QDialogButtonBox.ApplyRole) self.buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) layout = QFormLayout() layout.addRow("F&orget", self.removeComboBox) layout.addRow(self.buttonBox) self.setLayout(layout) self.helpButton.clicked.connect(self.help) self.removeButton.clicked.connect(self.remove) self.buttonBox.rejected.connect(self.reject)
def __init__(self, display, parent=None): super(uiSearch, self).__init__(parent) self.openResults = tfmlib.openResults() self.mkShortcut = tfmlib.shortcutFunc() self.escPath = tfmlib.escapeFunc() # self.mkresdir() # Screen object then used to read monitor size self.screen = display self.txtSearch = QLineEdit(self) self.txtSearch.setToolTip('Seperate your tags by spaces or commas.') btnSearch = QPushButton('Search',self) btnSearch.setToolTip('Search by tags.') layout = QVBoxLayout() layout.addWidget(self.txtSearch) layout.addWidget(btnSearch) self.setLayout(layout) self.setWindowTitle('Search') self.setGeom(300, 75) btnSearch.clicked.connect(self.search)
def doneCreating(): name = nameToCreate.text() created = QPushButton() created.setText("{0} @ {1}".format(name, hex(id(created)))) createdLayout.addWidget(created) doneButton.hide() nameToCreate.hide() createButton.show()
def create_button(self, parent, label=""): """ Returns an adapted button. """ control = QPushButton(check_parent(parent)) control.setText(label) control.setAutoDefault(False) return control_adapter_for(control)
def mouseReleaseEvent(self, event): QPushButton.mouseReleaseEvent(self, event) if event.button() == Qt.RightButton: if self.is_right_press: self.rightClick.emit() self.setDown(False) self.is_right_press = False
def _createLayout(self): 'Create the Widget Layout' self._txtLogbook = QLineEdit() self._txtLogbook.setReadOnly(True) self._lblLogbook = QLabel(self.tr('&Logbook File:')) self._lblLogbook.setBuddy(self._txtLogbook) self._btnBrowse = QPushButton('...') self._btnBrowse.clicked.connect(self._btnBrowseClicked) self._btnBrowse.setStyleSheet('QPushButton { min-width: 24px; max-width: 24px; }') self._btnBrowse.setToolTip(self.tr('Browse for a Logbook')) self._cbxComputer = QComboBox() self._lblComputer = QLabel(self.tr('Dive &Computer:')) self._lblComputer.setBuddy(self._cbxComputer) self._btnAddComputer = QPushButton(QPixmap(':/icons/list-add.png'), self.tr('')) self._btnAddComputer.setStyleSheet('QPushButton { min-width: 24px; min-height: 24; max-width: 24px; max-height: 24; }') self._btnAddComputer.clicked.connect(self._btnAddComputerClicked) self._btnRemoveComputer = QPushButton(QPixmap(':/icons/list-remove.png'), self.tr('')) self._btnRemoveComputer.setStyleSheet('QPushButton { min-width: 24px; min-height: 24; max-width: 24px; max-height: 24; }') self._btnRemoveComputer.clicked.connect(self._btnRemoveComputerClicked) hbox = QHBoxLayout() hbox.addWidget(self._btnAddComputer) hbox.addWidget(self._btnRemoveComputer) gbox = QGridLayout() gbox.addWidget(self._lblLogbook, 0, 0) gbox.addWidget(self._txtLogbook, 0, 1) gbox.addWidget(self._btnBrowse, 0, 2) gbox.addWidget(self._lblComputer, 1, 0) gbox.addWidget(self._cbxComputer, 1, 1) gbox.addLayout(hbox, 1, 2) gbox.setColumnStretch(1, 1) self._pbTransfer = QProgressBar() self._pbTransfer.reset() self._txtStatus = QTextEdit() self._txtStatus.setReadOnly(True) self._btnTransfer = QPushButton(self.tr('&Transfer Dives')) self._btnTransfer.clicked.connect(self._btnTransferClicked) self._btnExit = QPushButton(self.tr('E&xit')) self._btnExit.clicked.connect(self.close) hbox = QHBoxLayout() hbox.addWidget(self._btnTransfer) hbox.addStretch() hbox.addWidget(self._btnExit) vbox = QVBoxLayout() vbox.addLayout(gbox) vbox.addWidget(self._pbTransfer) vbox.addWidget(self._txtStatus) vbox.addLayout(hbox) self.setLayout(vbox)
def __init__(self, help_instance): QPushButton.__init__(self, "Toggle Help") self.setContentsMargins(1, 1, 1, 1) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.setFont(QFont('SansSerif', 12)) self.setAutoDefault(False) self.setDefault(False) self.help_instance = help_instance self.clicked.connect(self.toggle_help)
def testReturnWindow(self): widget = QWidget() button = QPushButton(widget) self.assertEqual(sys.getrefcount(widget), 2) window = button.window() self.assertEqual(sys.getrefcount(widget), 3) self.assertEqual(sys.getrefcount(window), 3) del widget
def testWindowButtonClickClose(self): button = QPushButton() window = QWidget() window.connect(button, SIGNAL('clicked()'), SLOT('close()')) window.show() self.assert_(window.isVisible()) button.click() self.assert_(not window.isVisible())
def testButton(self): #Connecting a lambda to a QPushButton.clicked() obj = QPushButton('label') ctr = Control() func = lambda: setattr(ctr, 'arg', True) QObject.connect(obj, SIGNAL('clicked()'), func) obj.click() self.assert_(ctr.arg) QObject.disconnect(obj, SIGNAL('clicked()'), func)
def __init__(self): generic.GenericGui.__init__(self) window = QWidget() window.setWindowTitle('quichem-pyside') self.compiler_view = QListWidget() self.compiler_view.currentRowChanged.connect(self.show_source) self.stacked_widget = QStackedWidget() self.stacked_widget.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) self.edit = QLineEdit() self.edit.setPlaceholderText('Type quichem input...') self.edit.textChanged.connect(self.change_value) self.view = QWebView() self.view.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) self.view.page().action(QWebPage.Reload).setVisible(False) self.view.setMaximumHeight(0) self.view.setUrl('qrc:/web/page.html') self.view.setZoomFactor(2) self.view.page().mainFrame().contentsSizeChanged.connect( self._resize_view) # For debugging JS: ## from PySide.QtWebKit import QWebSettings ## QWebSettings.globalSettings().setAttribute( ## QWebSettings.DeveloperExtrasEnabled, True) button_image = QPushButton('Copy as Image') button_image.clicked.connect(self.set_clipboard_image) button_image.setToolTip('Then paste into any graphics program') button_word = QPushButton('Copy as MS Word Equation') button_word.clicked.connect(self.set_clipboard_word) button_html = QPushButton('Copy as Formatted Text') button_html.clicked.connect(self.set_clipboard_html) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) button_layout = QHBoxLayout() button_layout.addStretch() button_layout.addWidget(button_image) button_layout.addWidget(button_word) button_layout.addWidget(button_html) source_layout = QHBoxLayout() source_layout.addWidget(self.compiler_view) source_layout.addWidget(self.stacked_widget, 1) QVBoxLayout(window) window.layout().addWidget(self.edit) window.layout().addWidget(self.view) window.layout().addLayout(button_layout) window.layout().addWidget(line) window.layout().addLayout(source_layout, 1) window.show() window.resize(window.minimumWidth(), window.height()) # To prevent garbage collection of internal Qt object. self._window = window
def __init__(self): super(MainWindow, self).__init__() btn = QPushButton(self) QObject.connect(btn, SIGNAL('clicked()'), self.startRunToAnthill) btn.setText('Start') self.setGeometry(200, 200, 500, 300) self.setWindowTitle('Mr Ant') self.show()
def mouseMoveEvent(self, event): QPushButton.mouseMoveEvent(self, event) if event.buttons() & Qt.RightButton: if self.contentsRect().contains(event.pos()): self.setDown(True) self.is_right_press = True else: self.setDown(False) self.is_right_press = False
def __CreateButton(self, folderIcon, txt, pxSize, actionFunction): """ Function to add a button """ if folderIcon != None: folderIcon = QIcon('folder.png') myButton = QPushButton(folderIcon, "") else: myButton = QPushButton(txt) myButton.setMaximumWidth(pxSize) myButton.clicked.connect(actionFunction) return myButton
def __init__(self, help_instance, help_text, informative_text = None): QPushButton.__init__(self, "?") self.setFont(QFont('SansSerif', 12)) self.setFlat(True) self.setFixedWidth(15) self.setFixedHeight(20) self.help_text = help_text self.informative_text = informative_text self.help_instance = help_instance self.clicked.connect(self.show_message) self.destroyed.connect(lambda: help_instance.remove_button(self)) # This uses a trick to send an extra parameter.
def paintEvent(self, event): mouse_pos = self.mapFromGlobal(QCursor.pos()) is_hover = self.contentsRect().contains(mouse_pos) QPushButton.paintEvent(self, event) painter = QPainter(self) painter.drawPixmap(2, 1, self.icon) if is_hover: painter.setCompositionMode(QPainter.CompositionMode_Screen) painter.drawPixmap(2, 1, self.icon)
def testButtonClickClose(self): button = QPushButton() button.connect(button, SIGNAL('clicked()'), SLOT('close()')) button.show() self.assert_(button.isVisible()) button.click() self.assert_(not button.isVisible())