def testSimple(self): #QObject.objectName(string) name = 'object1' obj = QObject() obj.setObjectName(name) self.assertEqual(name, obj.objectName())
def testTrUtf8AsInstanceMethod(self): #Test QObject.trUtf8 as instance invar1 = 'test1' outvar1 = QObject.trUtf8(self.obj, invar1) invar2 = 'test2' outvar2 = QObject.trUtf8(self.obj, invar2, 'test comment') self.assertEqual((invar1, invar2), (outvar1, outvar2))
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)
def testEmpty(self): #QObject.objectName('') name = '' obj = QObject() obj.setObjectName(name) self.assertEqual(name, obj.objectName())
def testQThreadReceiversExtern(self): #QThread.receivers() - Inherited protected method obj = QThread() self.assertEqual(obj.receivers(SIGNAL('destroyed()')), 0) QObject.connect(obj, SIGNAL("destroyed()"), self.cb) self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
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 timerEvent(self, event): QObject.timerEvent(self, event) event.accept() self.times_called += 1 if self.times_called == 5: self.app.exit(0)
def __init__(self, obj=None, event_type=None, *args): #Creates a new filter object QObject.__init__(self, *args) self.obj = obj self.event_type = event_type self.events_handled = 0 self.events_bypassed = 0
def testSimplePythonSignalNoArgs(self): #Connecting a lambda to a simple python signal without arguments obj = Dummy() QObject.connect(obj, SIGNAL('foo()'), lambda: setattr(obj, 'called', True)) obj.emit(SIGNAL('foo()')) self.assert_(obj.called)
def run(self): global thread_run thread_run = True QObject.connect(self.source, SIGNAL('source()'), self.target.myslot) while not self.target.called: pass
def testValueChanged(self): """Emission of a python signal to QSpinBox setValue(int)""" QObject.connect(self.obj, SIGNAL("dummy(int)"), self.spin, SLOT("setValue(int)")) self.assertEqual(self.spin.value(), 0) self.obj.emit(SIGNAL("dummy(int)"), 4) self.assertEqual(self.spin.value(), 4)
def setUp(self): #Acquire resources TimedQApplication.setUp(self, timeout=1000) self.view = QWebView() QObject.connect(self.view, SIGNAL('loadFinished(bool)'), self.load_finished) self.called = False
def testMetaData(self): self.view = QWebView() QObject.connect(self.view, SIGNAL('loadFinished(bool)'), self.load_finished) url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__)) self.view.setUrl(url) self.app.exec_()
def testIt(self): global called called = False o = QObject() o.connect(o, SIGNAL("ASignal"), functools.partial(someSlot, "partial ..")) o.emit(SIGNAL("ASignal")) self.assertTrue(called)
def __init__(self, widget, eventType, key): QObject.__init__(self) self.widget = widget self.eventType = eventType self.key = key self.processed = False
def testQStringDefault(self): obj = QObject() obj.setObjectName('foo') self.assertEqual(obj.objectName(), py3k.unicode_('foo')) obj.setObjectName(py3k.unicode_('áâãà')) self.assertEqual(obj.objectName(), py3k.unicode_('áâãà')) obj.setObjectName(None) self.assertEqual(obj.objectName(), py3k.unicode_(''))
def testQObjectReceiversExtern(self): #QObject.receivers() - Protected method external access obj = Dummy() self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0) QObject.connect(obj, SIGNAL("destroyed()"), self.cb) self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
def testConnection(self): o = TestObject(0) c = QObject() c.setObjectName("child") self._child = None o.childrenChanged.connect(self.childrenChanged) o.addChild(c) self.assertEquals(self._child.objectName(), "child")
def testThread(self): t = MyThread() QObject.connect(t, SIGNAL("test(const QString&)"), self._callback); t.start() self.app.exec_() t.wait() self.assert_(self.__called__);
def testSimplePythonSignal(self): #Connecting a lambda to a simple python signal witharguments obj = Dummy() arg = 42 QObject.connect(obj, SIGNAL('foo(int)'), lambda x: setattr(obj, 'arg', 42)) obj.emit(SIGNAL('foo(int)'), arg) self.assertEqual(obj.arg, arg)
def testDefaultArgs(self): #QUdpSocket.readDatagram pythonic return # @bug 124 QObject.connect(self.server, SIGNAL('readyRead()'), self.callback) self.sendPackage() self.app.exec_() self.assert_(self.called)
def testUtf8(self): translator = QTranslator() translator.load(os.path.join(self.trdir, 'trans_russian.qm')) self.app.installTranslator(translator) obj = QObject() obj.setObjectName(obj.tr('Hello World!')) self.assertEqual(obj.objectName(), py3k.unicode_('привет мир!'))
def testBasic(self): '''QObject.signalsBlocked() and blockSignals() The signals aren't blocked by default. blockSignals returns the previous value''' obj = QObject() self.assert_(not obj.signalsBlocked()) self.assert_(not obj.blockSignals(True)) self.assert_(obj.signalsBlocked()) self.assert_(obj.blockSignals(False))
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 testNoArgs(self): '''Connecting a lambda to a signal without arguments''' proc = QProcess() dummy = Dummy() QObject.connect(proc, SIGNAL('started()'), lambda: setattr(dummy, 'called', True)) proc.start(sys.executable, ['-c', '""']) proc.waitForFinished() self.assert_(dummy.called)
def testWithArgs(self): '''Connecting a lambda to a signal with arguments''' proc = QProcess() dummy = Dummy() QObject.connect(proc, SIGNAL('finished(int)'), lambda x: setattr(dummy, 'called', x)) proc.start(sys.executable, ['-c', '""']) proc.waitForFinished() self.assertEqual(dummy.called, proc.exitCode())
def testNoArgs(self): """Python signal and slots without arguments""" obj1 = Dummy() QObject.connect(obj1, SIGNAL("foo()"), self.callback) self.args = tuple() obj1.emit(SIGNAL("foo()"), *self.args) self.assert_(self.called)
def testShow(self): """Emission of a python signal to QWidget slot show()""" self.widget.hide() QObject.connect(self.obj, SIGNAL("dummy()"), self.widget, SLOT("show()")) self.assert_(not self.widget.isVisible()) self.obj.emit(SIGNAL("dummy()")) self.assert_(self.widget.isVisible())
def testNoArgs(self): """Connect signal using a Qt.ConnectionType as argument""" obj1 = Dummy() QObject.connect(obj1, SIGNAL('foo'), self.callback, Qt.DirectConnection) self.args = tuple() obj1.emit(SIGNAL('foo'), *self.args) self.assert_(self.called)
def testWithArgs(self): """Python signal and slots with integer arguments""" obj1 = Dummy() QObject.connect(obj1, SIGNAL("foo(int)"), self.callback) self.args = (42,) obj1.emit(SIGNAL("foo(int)"), *self.args) self.assert_(self.called)
def childEvent(obj, event): QObject.childEvent(obj, event) self.duck_childEvent_called = True
def eventFilter(self, obj, event): if event.type() == QEvent.KeyPress: if event.matches(QKeySequence.NextChild) or event.matches(QKeySequence.PreviousChild): return True return QObject.eventFilter(self, obj, event) # Pass event further
def setUp(self): self.emitter = QObject()
def testDestroyed(self): """Emission of QObject.destroyed() to a python slot""" obj = QObject() QObject.connect(obj, SIGNAL('destroyed()'), self.destroyed_cb) del obj self.assert_(self.called)
def __init__(self): QObject.__init__(self) # must init parent QObject,if you want to use signal self.widget = QWidget() self.ipLabel = QLabel(self.widget) self.thread = QThread() self.worker = Worker() self.worker.moveToThread(self.thread) self.man = SpiderThread() self.api = apiTester() # 1 2:loop 3: time self.testStatus = [False,1,0,"ip","mac"] # advance config self.findCoreStop = True self.cleanCacheSet = False self.useApiTest = False self.showTestProgress = True self.saveTestLog = False self.saveLogPath = "" self.chromePath = "" self.showChrome = False self.coreDumpPath = "" # ui form self.passwordLabel = QLabel(self.widget) self.ipLineEdit = QLineEdit(self.widget) self.passwordLineEdit = QLineEdit(self.widget) self.startBtn = QPushButton(self.widget) self.stopBtn = QPushButton(self.widget) self.messageBox = QTextEdit(self.widget) self.messageBox.setReadOnly(True) self.userLabel = QLabel(self.widget) self.userLineEdit = QLineEdit(self.widget) self.intervalLabel = QLabel(self.widget) self.intervalSpinBox = QSpinBox(self.widget) self.loopLabel = QLabel(self.widget) self.loopSpinBox = QSpinBox(self.widget) self.intervalSpinBox.setRange(0,9999) self.loopSpinBox.setRange(1,9999) self.radioReboot = QRadioButton(self.widget) self.radioProvision = QRadioButton(self.widget) self.radioFactory = QRadioButton(self.widget) # self.apiCheckBox = QCheckBox(self.widget) self.menu = QMenu() self.gxpAction = QAction("Classic UI") self.grp2602Action = QAction("Ant Design UI") self.gxpAction.setCheckable(True) self.grp2602Action.setCheckable(True) self.menu.addAction(self.gxpAction) self.menu.addAction(self.grp2602Action) self.webLabel = QLabel(self.widget) self.webBtn = QPushButton(self.widget) self.webBtn.setMenu(self.menu) self.clearBtn = QPushButton(self.widget) self.messageList = deque() self.timer = QTimer() self.advanceBtn = QPushButton(self.widget) self.infoLabel = QLabel(self.widget) # provision widget self.provWidget = QWidget(self.widget) self.ver1Label = QLabel(self.provWidget) self.ver2Label = QLabel(self.provWidget) self.ver3Label = QLabel(self.provWidget) self.ver1LineEdit = QLineEdit(self.provWidget) self.ver2LineEdit = QLineEdit(self.provWidget) self.ver3LineEdit = QLineEdit(self.provWidget) self.dir1Label = QLabel(self.provWidget) self.dir2Label = QLabel(self.provWidget) self.dir3Label = QLabel(self.provWidget) self.dir1LineEdit = QLineEdit(self.provWidget) self.dir2LineEdit = QLineEdit(self.provWidget) self.dir3LineEdit = QLineEdit(self.provWidget) self.radioHttp = QRadioButton(self.provWidget) self.radioHttps = QRadioButton(self.provWidget) self.radioTftp = QRadioButton(self.provWidget) self.radioFtp = QRadioButton(self.provWidget) self.radioFtps = QRadioButton(self.provWidget) self.radioWindow = QRadioButton(self.provWidget) # advance widget self.advanceWidget = QWidget() self.checkCoreBox = QCheckBox(self.advanceWidget) self.cleanCache = QCheckBox(self.advanceWidget) self.checkSaveLogBox = QCheckBox(self.advanceWidget) self.selectDirBtn = QPushButton(self.advanceWidget) self.saveDirLabel = QLabel(self.advanceWidget) self.saveDirLabel.setStyleSheet("background:white") self.checkProgressBox = QCheckBox(self.advanceWidget) self.advanceOkBtn = QPushButton(self.advanceWidget) self.selectChromeBtn = QPushButton(self.advanceWidget) self.chromePathLabel = QLabel(self.advanceWidget) self.chromePathLabel.setStyleSheet("background:white") self.checkShowChromeBox = QCheckBox(self.advanceWidget) self.chromeLabel = QLabel(self.advanceWidget) self.pcapLabel = QLabel(self.advanceWidget) self.apiCheckBox = QCheckBox(self.advanceWidget) self.corePathLabel = QLabel(self.advanceWidget) self.corePathLabel.setStyleSheet("background:white") self.corePathBtn = QPushButton(self.advanceWidget) self.interfaceMenu = QComboBox(self.advanceWidget) self.interfaceMenu.addItem('Default') self.aiOptionBox= QCheckBox(self.advanceWidget) a = IFACES print(a) for i in a.keys(): print(a[i].description) self.interfaceMenu.addItem(a[i].description) # connect singal and slot self.startBtn.clicked.connect(self.clickedStarBtn) self.radioProvision.clicked.connect(self.clickedProvision) self.radioReboot.clicked.connect(self.clickedOthers) self.radioFactory.clicked.connect(self.clickedOthers) self.stopBtn.clicked.connect(self.clickedStopBtn) self.grp2602Action.triggered.connect(self.clickedGrp2602) self.gxpAction.triggered.connect(self.clickedGxpType) self.timer.timeout.connect(self.updateMessage) self.apiCheckBox.stateChanged.connect(self.apiTestBoxCheck) self.clearBtn.clicked.connect(self.clickedClearBtn) self.advanceBtn.clicked.connect(self.clickedAdvanceBtn) self.advanceOkBtn.clicked.connect(self.clickedAdvanceOkBtn) self.checkSaveLogBox.stateChanged.connect(self.saveLogBoxCheck) self.selectChromeBtn.clicked.connect(self.clickedSelectChromeBtn) self.selectDirBtn.clicked.connect(self.clickedSelectDirBtn) self.corePathBtn.clicked.connect(self.clickedCorePathBtn) self.worker.signalJobEnd.connect(self.slotTestStoped) self.worker.apiTestFinished.connect(self.slotTestStoped) self.signalRun.connect(self.worker.dowork) self.signalRunApi.connect(self.worker.doworkApi)
def __init__(self): QObject.__init__(self)
def testInvalidDisconnection(self): o = QObject() self.assertRaises(RuntimeError, o.destroyed.disconnect, self.callback)
def __init__(self, parent=None): QObject.__init__(self, parent) self.p = 0
def __init__(self): # Initialize the PunchingBag as a QObject QObject.__init__(self)
class TestSignalsBlocked(unittest.TestCase): '''Test case to check if the signals are really blocked''' def setUp(self): #Set up the basic resources needed self.obj = QObject() self.args = tuple() self.called = False def tearDown(self): #Delete used resources del self.obj del self.args def callback(self, *args): #Default callback if args == self.args: self.called = True else: raise TypeError("Invalid arguments") def testShortCircuitSignals(self): #Blocking of Python short-circuit signals QObject.connect(self.obj, SIGNAL('mysignal()'), self.callback) self.obj.emit(SIGNAL('mysignal()')) self.assertTrue(self.called) self.called = False self.obj.blockSignals(True) self.obj.emit(SIGNAL('mysignal()')) self.assertTrue(not self.called) def testPythonSignals(self): #Blocking of Python typed signals QObject.connect(self.obj, SIGNAL('mysignal(int,int)'), self.callback) self.args = (1, 3) self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args) self.assertTrue(self.called) self.called = False self.obj.blockSignals(True) self.obj.emit(SIGNAL('mysignal(int,int)'), *self.args) self.assertTrue(not self.called)
def setUp(self): self.obj = QObject()
def testIt(self): a = QObject() a.connect(SIGNAL('foobar(Dummy)'), lambda x: 42) # Just connect with an unknown type self.assertRaises(TypeError, a.emit, SIGNAL('foobar(Dummy)'), 22)
def childEvent(self, event): QObject.childEvent(self, event)
def setupUi(self, Form): if Form.objectName(): Form.setObjectName(u"Form") Form.resize(765, 385) self.groupBox = QGroupBox(Form) self.groupBox.setObjectName(u"groupBox") self.groupBox.setGeometry(QRect(30, 40, 501, 211)) self.label = QLabel(self.groupBox) self.label.setObjectName(u"label") self.label.setGeometry(QRect(20, 150, 47, 14)) self.lineEdit_PinName = QLineEdit(self.groupBox) self.lineEdit_PinName.setObjectName(u"lineEdit_PinName") self.lineEdit_PinName.setEnabled(False) self.lineEdit_PinName.setGeometry(QRect(20, 170, 113, 20)) self.Output_Group = QGroupBox(self.groupBox) self.Output_Group.setObjectName(u"Output_Group") self.Output_Group.setGeometry(QRect(270, 10, 211, 71)) self.HighButton = QRadioButton(self.Output_Group) self.HighButton.setObjectName(u"HighButton") self.HighButton.setGeometry(QRect(10, 30, 83, 18)) self.LowButton = QRadioButton(self.Output_Group) self.LowButton.setObjectName(u"LowButton") self.LowButton.setGeometry(QRect(90, 30, 83, 18)) self.LowButton.setChecked(True) self.Input_Group = QGroupBox(self.groupBox) self.Input_Group.setObjectName(u"Input_Group") self.Input_Group.setEnabled(False) self.Input_Group.setGeometry(QRect(270, 80, 211, 61)) self.PullUpButton = QRadioButton(self.Input_Group) self.PullUpButton.setObjectName(u"PullUpButton") self.PullUpButton.setGeometry(QRect(10, 30, 83, 18)) self.PullUpButton.setChecked(True) self.HighImpedenceButton = QRadioButton(self.Input_Group) self.HighImpedenceButton.setObjectName(u"HighImpedenceButton") self.HighImpedenceButton.setGeometry(QRect(90, 30, 111, 18)) self.checkBox_Name = QCheckBox(self.groupBox) self.checkBox_Name.setObjectName(u"checkBox_Name") self.checkBox_Name.setGeometry(QRect(270, 170, 151, 18)) self.checkBox_Name.setChecked(True) self.groupBox_2 = QGroupBox(self.groupBox) self.groupBox_2.setObjectName(u"groupBox_2") self.groupBox_2.setGeometry(QRect(10, 20, 120, 121)) self.OutputButton = QRadioButton(self.groupBox_2) self.OutputButton.setObjectName(u"OutputButton") self.OutputButton.setGeometry(QRect(10, 20, 83, 18)) self.OutputButton.setChecked(True) self.InputButton = QRadioButton(self.groupBox_2) self.InputButton.setObjectName(u"InputButton") self.InputButton.setGeometry(QRect(10, 80, 101, 31)) self.lineEdit_OutputPath = QLineEdit(Form) self.lineEdit_OutputPath.setObjectName(u"lineEdit_OutputPath") self.lineEdit_OutputPath.setGeometry(QRect(30, 300, 341, 31)) self.GenerateButton = QPushButton(Form) self.GenerateButton.setObjectName(u"GenerateButton") self.GenerateButton.setGeometry(QRect(400, 302, 131, 31)) self.label_2 = QLabel(Form) self.label_2.setObjectName(u"label_2") self.label_2.setGeometry(QRect(30, 270, 111, 20)) font = QFont() font.setPointSize(11) self.label_2.setFont(font) self.Pins = QSpinBox(Form) self.Pins.setObjectName(u"Pins") self.Pins.setGeometry(QRect(90, 10, 42, 22)) self.Pins.setMaximum(32) self.label_3 = QLabel(Form) self.label_3.setObjectName(u"label_3") self.label_3.setGeometry(QRect(40, 10, 41, 20)) self.retranslateUi(Form) QObject.connect(self.OutputButton, SIGNAL("clicked(bool)"), self.Input_Group.setDisabled) QObject.connect(self.InputButton, SIGNAL("clicked(bool)"), self.Output_Group.setDisabled) QObject.connect(self.OutputButton, SIGNAL("clicked(bool)"), self.Output_Group.setEnabled) QObject.connect(self.InputButton, SIGNAL("clicked(bool)"), self.Input_Group.setEnabled) QObject.connect(self.checkBox_Name, SIGNAL("clicked(bool)"), self.lineEdit_PinName.setDisabled) self.GenerateButton.clicked.connect(self.GenerateFunction) QMetaObject.connectSlotsByName(Form)
def setupUi(self, Form): if Form.objectName(): Form.setObjectName(u"Form") Form.resize(400, 300) self.pin0_groupbox = QGroupBox(Form) self.pin0_groupbox.setObjectName(u"pin0_groupbox") self.pin0_groupbox.setGeometry(QRect(30, 10, 341, 211)) self.outputinput_groupBox = QGroupBox(self.pin0_groupbox) self.outputinput_groupBox.setObjectName(u"outputinput_groupBox") self.outputinput_groupBox.setGeometry(QRect(10, 20, 120, 80)) self.output_radioButton = QRadioButton(self.outputinput_groupBox) self.output_radioButton.setObjectName(u"output_radioButton") self.output_radioButton.setGeometry(QRect(20, 20, 83, 18)) self.input_radioButton = QRadioButton(self.outputinput_groupBox) self.input_radioButton.setObjectName(u"input_radioButton") self.input_radioButton.setGeometry(QRect(20, 50, 83, 18)) self.input_radioButton.setChecked(True) self.opconfiguration_groupBox = QGroupBox(self.pin0_groupbox) self.opconfiguration_groupBox.setObjectName(u"opconfiguration_groupBox") self.opconfiguration_groupBox.setEnabled(False) self.opconfiguration_groupBox.setGeometry(QRect(180, 20, 120, 80)) self.high_radiobutton = QRadioButton(self.opconfiguration_groupBox) self.high_radiobutton.setObjectName(u"high_radiobutton") self.high_radiobutton.setGeometry(QRect(20, 20, 83, 18)) self.low_radioButton = QRadioButton(self.opconfiguration_groupBox) self.low_radioButton.setObjectName(u"low_radioButton") self.low_radioButton.setGeometry(QRect(20, 50, 83, 18)) self.low_radioButton.setChecked(True) self.ipconfiguration_groupBox = QGroupBox(self.pin0_groupbox) self.ipconfiguration_groupBox.setObjectName(u"ipconfiguration_groupBox") self.ipconfiguration_groupBox.setGeometry(QRect(180, 120, 120, 80)) self.pur_radioButton = QRadioButton(self.ipconfiguration_groupBox) self.pur_radioButton.setObjectName(u"pur_radioButton") self.pur_radioButton.setGeometry(QRect(20, 20, 83, 18)) self.highimpedance_radioButton = QRadioButton(self.ipconfiguration_groupBox) self.highimpedance_radioButton.setObjectName(u"highimpedance_radioButton") self.highimpedance_radioButton.setGeometry(QRect(20, 50, 83, 18)) self.highimpedance_radioButton.setChecked(True) self.pinname_lineedit = QLineEdit(self.pin0_groupbox) self.pinname_lineedit.setObjectName(u"pinname_lineedit") self.pinname_lineedit.setEnabled(False) self.pinname_lineedit.setGeometry(QRect(10, 140, 113, 20)) self.defaultname_checkBox = QCheckBox(self.pin0_groupbox) self.defaultname_checkBox.setObjectName(u"defaultname_checkBox") self.defaultname_checkBox.setGeometry(QRect(10, 170, 121, 18)) self.defaultname_checkBox.setChecked(True) self.path_lineEdit = QLineEdit(Form) self.path_lineEdit.setObjectName(u"path_lineEdit") self.path_lineEdit.setGeometry(QRect(30, 240, 351, 20)) self.generate_pushButton = QPushButton(Form) self.generate_pushButton.setObjectName(u"generate_pushButton") self.generate_pushButton.setGeometry(QRect(30, 270, 351, 21)) self.retranslateUi(Form) QObject.connect(self.output_radioButton,SIGNAL("clicked(bool)"),self.opconfiguration_groupBox.setEnabled) QObject.connect(self.output_radioButton,SIGNAL("clicked(bool)"),self.ipconfiguration_groupBox.setDisabled) QObject.connect(self.input_radioButton,SIGNAL("clicked(bool)"),self.opconfiguration_groupBox.setDisabled) QObject.connect(self.input_radioButton,SIGNAL("clicked(bool)"),self.ipconfiguration_groupBox.setEnabled) QObject.connect(self.defaultname_checkBox,SIGNAL("clicked(bool)"),self.pinname_lineedit.setDisabled) self.generate_pushButton.clicked.connect(self.GenerateFunction) QMetaObject.connectSlotsByName(Form)
def setUp(self): #Set up the basic resources needed self.obj = QObject() self.args = tuple() self.called = False
def __init__(self, start_path, save_loc=None): QObject.__init__(self) self.start_path = start_path self.save_loc = save_loc
def __init__(self, chart): QObject.__init__(self) self.module_path = os.path.dirname(__file__) self.pca_matrix = np.array([]) self.labels = [] self.chart = chart self.model = Model() self.model_selection = Model() self.callout = Callout(self.chart) self.callout.hide() loader = QUiLoader() self.main_widget = loader.load(self.module_path + "/ui/table.ui") self.table_view = self.main_widget.findChild(QTableView, "table_view") table_cfg_frame = self.main_widget.findChild(QFrame, "table_cfg_frame") pc_frame = self.main_widget.findChild(QFrame, "pc_frame") button_load_data = self.main_widget.findChild(QPushButton, "button_load_data") self.pc1_variance_ratio = self.main_widget.findChild( QLabel, "pc1_variance_ratio") self.pc1_singular_value = self.main_widget.findChild( QLabel, "pc1_singular_value") self.pc2_variance_ratio = self.main_widget.findChild( QLabel, "pc2_variance_ratio") self.pc2_singular_value = self.main_widget.findChild( QLabel, "pc2_singular_value") self.legend = self.main_widget.findChild(QLineEdit, "legend_name") self.groupbox_axis = self.main_widget.findChild( QGroupBox, "groupbox_axis") self.groupbox_norm = self.main_widget.findChild( QGroupBox, "groupbox_norm") self.preprocessing_none = self.main_widget.findChild( QRadioButton, "radio_none") self.preprocessing_normalize = self.main_widget.findChild( QRadioButton, "radio_normalize") self.preprocessing_standardize = self.main_widget.findChild( QRadioButton, "radio_standardize") self.preprocessing_axis_features = self.main_widget.findChild( QRadioButton, "radio_axis_features") self.preprocessing_axis_samples = self.main_widget.findChild( QRadioButton, "radio_axis_samples") self.preprocessing_norm_l1 = self.main_widget.findChild( QRadioButton, "radio_norm_l1") self.preprocessing_norm_l2 = self.main_widget.findChild( QRadioButton, "radio_norm_l2") self.preprocessing_norm_max = self.main_widget.findChild( QRadioButton, "radio_norm_max") self.progressbar = self.main_widget.findChild(QProgressBar, "progressbar") self.progressbar.hide() self.table_view.horizontalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.table_view.verticalHeader().setSectionResizeMode( QHeaderView.ResizeToContents) self.table_view.setModel(self.model) # chart series self.series = QtCharts.QScatterSeries(self.table_view) self.series.setName("table") self.series.setMarkerSize(15) self.series.hovered.connect(self.on_hover) self.chart.addSeries(self.series) self.mapper = QtCharts.QVXYModelMapper() self.mapper.setXColumn(1) self.mapper.setYColumn(2) self.mapper.setSeries(self.series) self.mapper.setModel(self.model) # selection series self.series_selection = QtCharts.QScatterSeries(self.table_view) self.series_selection.setName("selection") self.series_selection.setMarkerShape( QtCharts.QScatterSeries.MarkerShapeRectangle) self.series_selection.setMarkerSize(15) self.series_selection.hovered.connect(self.on_hover) self.chart.addSeries(self.series_selection) self.mapper_selection = QtCharts.QVXYModelMapper() self.mapper_selection.setXColumn(1) self.mapper_selection.setYColumn(2) self.mapper_selection.setSeries(self.series_selection) self.mapper_selection.setModel(self.model_selection) # effects button_load_data.setGraphicsEffect(self.button_shadow()) table_cfg_frame.setGraphicsEffect(self.card_shadow()) pc_frame.setGraphicsEffect(self.card_shadow()) # signals button_load_data.clicked.connect(self.open_file) self.table_view.selectionModel().selectionChanged.connect( self.selection_changed) self.legend.returnPressed.connect(self.update_legend) self.preprocessing_none.toggled.connect(self.on_preprocessing_changed) self.preprocessing_normalize.toggled.connect( self.on_preprocessing_changed) self.preprocessing_standardize.toggled.connect( self.on_preprocessing_changed) self.preprocessing_axis_features.toggled.connect( self.on_preprocessing_axis_changed) self.preprocessing_axis_samples.toggled.connect( self.on_preprocessing_axis_changed) self.preprocessing_norm_l1.toggled.connect( self.on_preprocessing_norm_changed) self.preprocessing_norm_l2.toggled.connect( self.on_preprocessing_norm_changed) self.preprocessing_norm_max.toggled.connect( self.on_preprocessing_norm_changed) # event filter self.table_view.installEventFilter(self)
def testSignalWithObject(self): o = MyObject() o.sig6.connect(o.slotObject) arg = QObject() o.sig6.emit(arg) self.assertEqual(arg, o._o)
def safeDelete(obj: QObject) -> None: """ Calls deleteLater() on a QObject, doing nothing if the object was already deleted """ if obj and shiboken2.isValid(obj): obj.deleteLater()
def testUnicode(self): name = py3k.unicode_('não') #FIXME Strange error on upstream when using equal(name, obj) obj = QObject() obj.setObjectName(name) self.assertEqual(obj.objectName(), name)
def eventFilter(self, obj, event): if event.type() == QEvent.KeyPress: if event.key() == Qt.Key_Delete: self.remove_selected_rows() return True elif event.matches(QKeySequence.Copy): s_model = self.table_view.selectionModel() if s_model.hasSelection(): selection_range = s_model.selection().constFirst() table_str = "" clipboard = QGuiApplication.clipboard() for i in range(selection_range.top(), selection_range.bottom() + 1): row_value = [] for j in range(selection_range.left(), selection_range.right() + 1): row_value.append(s_model.model().index(i, j).data()) table_str += "\t".join(row_value) + "\n" clipboard.setText(table_str) return True elif event.matches(QKeySequence.Paste): s_model = self.table_view.selectionModel() if s_model.hasSelection(): clipboard = QGuiApplication.clipboard() table_str = clipboard.text() table_rows = table_str.splitlines( ) # splitlines avoids an empty line at the end selection_range = s_model.selection().constFirst() first_row = selection_range.top() first_col = selection_range.left() last_col_idx = 0 last_row_idx = 0 for i in range(len(table_rows)): model_i = first_row + i if model_i < self.model.rowCount(): row_cols = table_rows[i].split("\t") for j in range(len(row_cols)): model_j = first_col + j if model_j < self.model.columnCount(): self.model.setData( self.model.index(model_i, model_j), row_cols[j], Qt.EditRole) if model_j > last_col_idx: last_col_idx = model_j if model_i > last_row_idx: last_row_idx = model_i first_index = self.model.index(first_row, first_col) last_index = self.model.index(last_row_idx, last_col_idx) self.model.dataChanged.emit(first_index, last_index) return True else: return QObject.eventFilter(self, obj, event) else: return QObject.eventFilter(self, obj, event) return QObject.eventFilter(self, obj, event)
def __init__(self, app, *args): QObject.__init__(self, *args) self.app = app self.times_called = 0
def testDefault(self): #QObject.objectName() default obj = QObject() self.assertEqual('', obj.objectName())
def setupUi(self, Form): if Form.objectName(): Form.setObjectName(u"Form") Form.resize(520, 228) self.Out_lineEdit = QLineEdit(Form) self.Out_lineEdit.setObjectName(u"Out_lineEdit") self.Out_lineEdit.setGeometry(QRect(80, 200, 221, 20)) self.Out_label = QLabel(Form) self.Out_label.setObjectName(u"Out_label") self.Out_label.setGeometry(QRect(10, 200, 71, 20)) self.Generate_pushButton = QPushButton(Form) self.Generate_pushButton.setObjectName(u"Generate_pushButton") self.Generate_pushButton.setGeometry(QRect(310, 200, 75, 22)) self.PINA0_groupBox = QGroupBox(Form) self.PINA0_groupBox.setObjectName(u"PINA0_groupBox") self.PINA0_groupBox.setGeometry(QRect(10, 70, 381, 121)) self.ModeA0_groupBox = QGroupBox(self.PINA0_groupBox) self.ModeA0_groupBox.setObjectName(u"ModeA0_groupBox") self.ModeA0_groupBox.setGeometry(QRect(60, 10, 121, 71)) self.INA0_radioButton = QRadioButton(self.ModeA0_groupBox) self.INA0_radioButton.setObjectName(u"INA0_radioButton") self.INA0_radioButton.setGeometry(QRect(10, 20, 51, 18)) self.INA0_radioButton.setChecked(True) self.OutA0_radioButton = QRadioButton(self.ModeA0_groupBox) self.OutA0_radioButton.setObjectName(u"OutA0_radioButton") self.OutA0_radioButton.setGeometry(QRect(10, 40, 61, 18)) self.OutConfigA0_groupBox = QGroupBox(self.PINA0_groupBox) self.OutConfigA0_groupBox.setObjectName(u"OutConfigA0_groupBox") self.OutConfigA0_groupBox.setEnabled(False) self.OutConfigA0_groupBox.setGeometry(QRect(190, 48, 181, 33)) self.HighA0_radioButton = QRadioButton(self.OutConfigA0_groupBox) self.HighA0_radioButton.setObjectName(u"HighA0_radioButton") self.HighA0_radioButton.setGeometry(QRect(10, 12, 41, 18)) self.LowA0_radioButton = QRadioButton(self.OutConfigA0_groupBox) self.LowA0_radioButton.setObjectName(u"LowA0_radioButton") self.LowA0_radioButton.setGeometry(QRect(70, 12, 41, 20)) self.LowA0_radioButton.setChecked(True) self.InConfigA0_groupBox = QGroupBox(self.PINA0_groupBox) self.InConfigA0_groupBox.setObjectName(u"InConfigA0_groupBox") self.InConfigA0_groupBox.setGeometry(QRect(190, 10, 181, 33)) self.PullA0_radioButton = QRadioButton(self.InConfigA0_groupBox) self.PullA0_radioButton.setObjectName(u"PullA0_radioButton") self.PullA0_radioButton.setGeometry(QRect(10, 12, 51, 18)) self.PullA0_radioButton.setChecked(True) self.ImpA0_radioButton = QRadioButton(self.InConfigA0_groupBox) self.ImpA0_radioButton.setObjectName(u"ImpA0_radioButton") self.ImpA0_radioButton.setGeometry(QRect(70, 12, 101, 20)) self.DefA0_checkBox = QCheckBox(self.PINA0_groupBox) self.DefA0_checkBox.setObjectName(u"DefA0_checkBox") self.DefA0_checkBox.setGeometry(QRect(240, 90, 111, 18)) self.DefA0_checkBox.setChecked(True) self.PINA0_label = QLabel(self.PINA0_groupBox) self.PINA0_label.setObjectName(u"PINA0_label") self.PINA0_label.setGeometry(QRect(10, 20, 41, 20)) font = QFont() font.setBold(False) font.setWeight(50) self.PINA0_label.setFont(font) self.NewA0_lineEdit = QLineEdit(self.PINA0_groupBox) self.NewA0_lineEdit.setObjectName(u"NewA0_lineEdit") self.NewA0_lineEdit.setEnabled(False) self.NewA0_lineEdit.setGeometry(QRect(60, 90, 161, 20)) self.label = QLabel(Form) self.label.setObjectName(u"label") self.label.setGeometry(QRect(130, 30, 81, 16)) font1 = QFont() font1.setPointSize(10) font1.setBold(True) font1.setWeight(75) self.label.setFont(font1) self.PIN_comboBox = QComboBox(Form) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.addItem(str()) self.PIN_comboBox.setObjectName(u"PIN_comboBox") self.PIN_comboBox.setGeometry(QRect(220, 30, 62, 21)) self.label_2 = QLabel(Form) self.label_2.setObjectName(u"label_2") self.label_2.setGeometry(QRect(100, 50, 231, 21)) self.Picture_label = QLabel(Form) self.Picture_label.setObjectName(u"Picture_label") self.Picture_label.setGeometry(QRect(390, 30, 121, 191)) self.Picture_label.setPixmap(QPixmap(u"Avr0.png")) self.Picture_label.setScaledContents(True) self.label_file = QLabel(Form) self.label_file.setObjectName(u"label_file") self.label_file.setGeometry(QRect(20, 10, 21, 16)) self.comboBox_file = QComboBox(Form) self.comboBox_file.addItem(str()) self.comboBox_file.addItem(str()) self.comboBox_file.addItem(str()) self.comboBox_file.addItem(str()) self.comboBox_file.setObjectName(u"comboBox_file") self.comboBox_file.setGeometry(QRect(20, 30, 51, 22)) self.commandLinkButton_Help = QCommandLinkButton(Form) self.commandLinkButton_Help.setObjectName(u"commandLinkButton_Help") self.commandLinkButton_Help.setGeometry(QRect(430, -10, 81, 31)) font2 = QFont() font2.setFamily(u"Segoe UI") font2.setBold(True) font2.setWeight(75) self.commandLinkButton_Help.setFont(font2) self.label_3 = QLabel(Form) self.label_3.setObjectName(u"label_3") self.label_3.setEnabled(True) self.label_3.setGeometry(QRect(310, 0, 121, 20)) font3 = QFont() font3.setBold(True) font3.setWeight(75) self.label_3.setFont(font3) self.retranslateUi(Form) QObject.connect(self.INA0_radioButton, SIGNAL("toggled(bool)"), self.OutConfigA0_groupBox.setDisabled) #self.INA0_radioButton.toggled.connect(self.OutConfigA0_groupBox.setDisabled) QObject.connect(self.OutA0_radioButton, SIGNAL("toggled(bool)"), self.InConfigA0_groupBox.setDisabled) #self.OutA0_radioButton.toggled.connect(self.InConfigA0_groupBox.setDisabled) QObject.connect(self.DefA0_checkBox, SIGNAL("clicked(bool)"), self.NewA0_lineEdit.setDisabled) #self.DefA0_checkBox.clicked.connect(self.NewA0_lineEdit.setDisabled) self.commandLinkButton_Help.clicked.connect(self.label_3.hide) self.PIN_comboBox.activated.connect(self.Menu) self.PIN_comboBox.highlighted.connect(self.Save) self.Generate_pushButton.clicked.connect(self.Generate) self.comboBox_file.textActivated.connect(self.File) QMetaObject.connectSlotsByName(Form)
def __init__(self): QObject.__init__(self) self._spam = 5
def __init__(self): QObject.__init__(self) self.__listeNouvelEPI = [] #self.__liste_type_EPI =[] self.__monApi = api.API() self.__xmlg = xmlG.xmlGestion()
def __init__(self): QObject.__init__(self) self.called = False
def eventFilter(self, obj, event): if event.type() == QEvent.KeyPress: pass return QObject.eventFilter(self, obj, event)
def testQFlagsOnQVariant(self): o = QObject() o.setProperty("foo", QIODevice.ReadOnly | QIODevice.WriteOnly) self.assertEqual(type(o.property("foo")), QIODevice.OpenMode)