def __init__(self, manager, name): """ Perform minimal plugin initialization. """ QObject.__init__(self) self.manager = manager self.name = name self._is_active = False
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 testSimple(self): #QObject.objectName(string) name = 'object1' obj = QObject() obj.setObjectName(name) self.assertEqual(name, obj.objectName())
def testEmpty(self): #QObject.objectName('') name = '' obj = QObject() obj.setObjectName(name) self.assertEqual(name, obj.objectName())
def __init__(self, adapterName=None, parent=None): QObject.__init__(self, parent) dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) self._devices = {} self._devPathToAddress = {} self._bus = dbus.SystemBus() self._manager = dbus.Interface(self._bus.get_object("org.bluez", "/"), "org.bluez.Manager") adapter = None if adapterName: try: adapter = self._manager.FindAdapter(adapterName) except: print "Adaper %s not found" % adapterName if not adapter: print "Using default adapter" adapter = self._manager.DefaultAdapter() self._adapter = dbus.Interface(self._bus.get_object("org.bluez", adapter), "org.bluez.Adapter") self._bus.add_signal_receiver(self._onDeviceFound, dbus_interface = "org.bluez.Adapter", signal_name = "DeviceFound") self._bus.add_signal_receiver(self._onDeviceDisappeared, dbus_interface = "org.bluez.Adapter", signal_name = "DeviceDisappeared")
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 __init__(self, ): QObject.__init__(self) if not os.path.exists(Note.NOTESPATH): try: os.mkdir(Note.NOTESPATH) except Exception, e: print 'Can t create note storage folder', str(e)
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 __init__(self, url, image_path): QObject.__init__(self) self.url = QUrl(url) self.image_path = image_path self.webpage = QWebPage(self) self.webpage.loadFinished.connect(self.render) self.webpage.mainFrame().load(self.url)
def __init__(self, ): QObject.__init__(self) self._settings = QSettings() self._token = '' self._timeremaining = '' self._serial = '' if self._settings.contains('REGION'): self._region = self._settings.value('REGION') if self._region not in ('EU', 'US'): self._set_region('US') else: self._region = 'US' if self._settings.contains('SECRET'): self._secret = unhexlify(self._settings.value('SECRET')) if not self._secret: self.new_serial() else: self.new_serial() if not self._serial: if self._settings.contains('SERIAL'): self._serial = self._settings.value('SERIAL') if self._token == '': self.sync()
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 __init__(self, filepath): QObject.__init__(self,) self._filename = os.path.basename(filepath) self._filepath = os.path.realpath(filepath) self._isdir = os.path.isdir(filepath) self._data = None self._ready = False
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 __init__(self,): QObject.__init__(self) self.config = ConfigParser.ConfigParser() if not os.path.exists(os.path.expanduser("~/.khtnotes.cfg")): self._write_default() else: self.config.read(os.path.expanduser("~/.khtnotes.cfg")) if not self.config.has_section("Favorites"): self.config.add_section("Favorites") self._write() # Added in 2.19 if not self.config.has_option("Webdav", "remoteFolder"): self.config.set("Webdav", "remoteFolder", "Notes") self._write() # Remove local sync index to prevent losing notes : if os.path.exists(os.path.join(NOTESPATH, ".index.sync")): os.remove(os.path.join(NOTESPATH, ".index.sync")) # Added in 2.20 if not self.config.has_option("Display", "displayHeader"): self.config.set("Display", "displayHeader", "true") self._write() # Added in 3.0 if not self.config.has_option("Keyboard", "hideVkb"): self.config.add_section("Keyboard") self.config.set("Keyboard", "hideVkb", "true") self._write() if not self.config.has_option("Webdav", "autoSync"): self.config.set("Webdav", "autoSync", "false") self._write()
def __init__(self,): QObject.__init__(self,) self.config = ConfigParser.ConfigParser() if not os.path.exists(os.path.expanduser('~/.khtsimpletext.cfg')): self._write_default() else: self.config.read(os.path.expanduser('~/.khtsimpletext.cfg'))
def __init__(self, files, parent, multi_component=False): QObject.__init__(self) self.files = files self.parent_ = parent self.multi_component = multi_component if not self.multi_component: self.files = { db[files[0]]['component'] : self.files }
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 __init__(self, root): QObject.__init__(self) self.root = root self.context_menu_actions = [] self.episode_list_title = u'' self.current_input_dialog = None self.root.config.add_observer(self.on_config_changed)
def __init__(self, ntype, watcher, poller): QObject.__init__(self) self.watcher = watcher self.poller = poller self.stype = self._N[ntype] self.notifier = QSocketNotifier(watcher, ntype, self) self.notifier.activated.connect(self.dispatcher)
def __init__(self, options, outputFolder, scenario='vanet-highway-test-thomas'): QRunnable.__init__(self) QObject.__init__(self) self.options = '' self.optionsDict = options self.prate = options['prate'] #print self.optionsDict for option in options: if option=='vel1' or option=='spl': speedInMs = options[option].getValue()*1000/3600 self.options += ' --%s=%s' % (option, speedInMs) else: self.options += ' --%s=%s' % (option, options[option]) self.runNumber = random.randint(1,10000) #self.runNumber = 1 self.options += ' --rn=%d' % self.runNumber # randomize the results self.command = './waf' self.scenario = scenario self.outputFolder = outputFolder settings = {} for option in options: #self.output['settings'][option+'| '+self.options[option].getName()] = self.options[option].getValue() if option=='prate': settings[option] = options[option] else: settings[option] = options[option].getValue() self.output = {'scenario':scenario, 'settings':settings,'command':'%s %s%s' % (self.command, ' --run \'', self.scenario+self.options+'\'')}
def __init__(self, args, gpodder_core, dbus_bus_name): QObject.__init__(self) self.dbus_bus_name = dbus_bus_name # TODO: Expose the same D-Bus API as the Gtk UI D-Bus object (/gui) # TODO: Create a gpodder.dbusproxy.DBusPodcastsProxy object (/podcasts) self.app = QApplication(args) signal.signal(signal.SIGINT, signal.SIG_DFL) self.quit.connect(self.on_quit) self.core = gpodder_core self.config = self.core.config self.db = self.core.db self.model = self.core.model self.config_proxy = ConfigProxy(self.config) # Initialize the gpodder.net client self.mygpo_client = my.MygPoClient(self.config) gpodder.user_extensions.on_ui_initialized(self.model, self.extensions_podcast_update_cb, self.extensions_episode_download_cb )
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 __init__(self,): QObject.__init__(self,) self.thread = None self._balance = '<b>0.00</b>000000' self._fiatSymbol = u'€' self._fiatRate = 0 self._fiatBalance = u'0 €' self._wallet = Wallet() self._wallet.onNewTransaction.connect(self.notifyNewTx) self._walletUnlocked = False self.settings = Settings() self.addressesModel = AddressesModel() self.transactionsModel = TransactionsModel() self.timer = QTimer(self) self.timer.setInterval(900000) # 15 min update self.timer.timeout.connect(self.update) self.timer.start() if self.settings.storePassKey: self._currentPassKey = self.settings.passKey try: self.unlockWallet(self._currentPassKey) except: self.onError.emit('Stored pass phrase is invalid') else: self._currentPassKey = None self._currentAddressIndex = 0
def timerEvent(self, event): QObject.timerEvent(self, event) event.accept() self.times_called += 1 if self.times_called == 5: self.app.exit(0)
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 initialize(self, arguments): self.initializeCalled = True obj = QObject(self) obj.setObjectName("MyPlugin3") self.addAutoReleaseObject(obj) return True, "No error"
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 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,): QObject.__init__(self) self._running = False #logging.getLogger(_defaultLoggerName).setLevel(logging.WARNING) self.logger = logger.getDefaultLogger() self._localDataFolder = Note.NOTESPATH self._remoteDataFolder = 'KhtNotes'
def __init__(self): QObject.__init__(self) # Indicates that the animation is paused in between self.__paused = False # Indicates that the animation have been started self.__started = False # Indicates that the animation is currently running self.__running = False # Indicates that the animation can be run in reverse self.__run_reversed = False # Indicate that the animation is canceled self.__cancel = False # Indicates that the animation is ended self.__end = False # Stores the start delay of the animation in seconds self.__start_delay = 0 # Stores the duration in which the animation should be completed self.__duration = 0 # Holds the shapes to which animation should be applied self.__shapes = [] # Framerate of the animation self.__fps = 60
def testConnectOldStyleEmitBoolSignal(self): def callbackOne(): self.one_called += 1 self.obj2.signalWithDefaultValue[bool].emit(True) def callbackTwo(): self.two_called += 1 QObject.connect(self.obj1, SIGNAL('signalWithDefaultValue()'), callbackOne) QObject.connect(self.obj2, SIGNAL('signalWithDefaultValue()'), callbackTwo) self.obj1.emitSignalWithDefaultValue_void() self.obj2.emitSignalWithDefaultValue_void() self.assertEqual(self.one_called, 1) self.assertEqual(self.two_called, 2)
def eventFilter(self, obj, event): "Call to handle relevant events." if obj == self.ui.image_label: if event.type() == QtCore.QEvent.MouseMove: self.handle_image_move(event) return True elif obj == self.ui.freq_label: if not self.ui.freq_label.isEnabled(): return False if event.type() == QtCore.QEvent.MouseMove: self.handle_freq_move(event) return True elif event.type() == QtCore.QEvent.MouseButtonPress: if event.button() == QtCore.Qt.MouseButton.LeftButton: self.handle_freq_modify(event) return True elif event.type() == QtCore.QEvent.MouseButtonRelease: if event.button() == QtCore.Qt.MouseButton.LeftButton: if self.current_brush: self.recompute_spatial_image() return True return QObject.eventFilter(self, obj, event)
def __init__(self, devices=None, filename=None, parent=None): QObject.__init__(self, parent) self.pullTimer = QTimer(self) self.buf = QByteArray() self.devices = devices self.device = QAudioDeviceInfo.defaultOutputDevice() self.generator = None self.audioOutput = None self.output = None self.fmt = QAudioFormat() self.pullMode = False self.dump = filename self._label = SUSPEND_LABEL self.initializeAudio()
def testReprFunction(self): reprPen = repr(QPen()) self.assertTrue(reprPen.startswith("<PySide.QtGui.QPen")) reprBrush = repr(QBrush()) self.assertTrue(reprBrush.startswith("<PySide.QtGui.QBrush")) reprObject = repr(QObject()) self.assertTrue(reprObject.startswith("<PySide.QtCore.QObject"))
def eventFilter(self, obj, event): if event.type() == QEvent.Paint: obj.setStyle(QStyleFactory.create('Windows')) p = QStylePainter(obj) tab = QStyleOptionTabV3() # selected = obj.currentIndex() for idx in range(obj.count()): obj.initStyleOption(tab, idx) if idx == 0: bg_color = QColor('#ADEBFF') fg_color = QColor('black') elif idx == 1: bg_color = QColor('#6CBED2') fg_color = QColor('black') elif idx == 2: bg_color = QColor('#0099CC') fg_color = QColor('black') elif idx == 3: bg_color = QColor('#297ACC') fg_color = QColor('black') elif idx == 4: bg_color = QColor('#006BB2') fg_color = QColor('black') elif idx == 5: bg_color = QColor('#003D7A') fg_color = QColor('black') tab.palette.setColor(QPalette.Window, bg_color) tab.palette.setColor(QPalette.WindowText, fg_color) p.drawControl(QStyle.CE_TabBarTab, tab) return True else: # standard event processing return QObject.eventFilter(self, obj, event)
def __init__(self): _assert(in_main_thread()) self._reads = {} self._writes = {} self._notifiers = {} self._timer = QTimer() self._timer.setSingleShot(True) QObject.connect(self._timer, SIGNAL("timeout()"), self.iterate) self.qApp = QCoreApplication.instance() self._ownApp=False if self.qApp is None: self.qApp=QCoreApplication([]) self._ownApp=True self._blockApp = None posixbase.PosixReactorBase.__init__(self)
def eventFilter(self, *args, **kwargs): if args[1].type() == QEvent.Resize: self.resizeFunc(None) if args[1].type() == QEvent.Paint: self.resizeFunc(None) return QObject.eventFilter(self, args[0], args[1])
def __init__(self, wrapper_manager, podcast, episode): QObject.__init__(self) self._wrapper_manager = wrapper_manager self.episode_wrapper_refcount = 0 self._podcast = podcast self._episode = episode # Caching of YouTube URLs, so we don't need to resolve # it every time we update the podcast item (doh!) # XXX: Maybe do this in the episode of the model already? self._qt_yt_url = None # Download progress tracking XXX: read directy from task self._qt_download_progress = 0 # Playback tracking self._qt_playing = False
def testWrongType(self): '''Wrong type passed to QFlags binary operators''' self.assertRaises(TypeError, Qt.NoItemFlags | '43') self.assertRaises(TypeError, Qt.NoItemFlags & '43') self.assertRaises(TypeError, 'jabba' & Qt.NoItemFlags) self.assertRaises(TypeError, 'hut' & Qt.NoItemFlags) self.assertRaises(TypeError, Qt.NoItemFlags & QObject())
def __init__(self): self._reads = {} self._writes = {} self._notifiers = {} self._timer = QTimer() self._timer.setSingleShot(True) QObject.connect(self._timer, SIGNAL("timeout()"), self.iterate) if QCoreApplication.instance() is None: # Application Object has not been started yet self.qApp = QCoreApplication([]) self._ownApp = True else: self.qApp = QCoreApplication.instance() self._ownApp = False self._blockApp = None posixbase.PosixReactorBase.__init__(self)
def __init__(self, key, text, color=QColor(0, 0, 0), parent=None): super(KeyWidget, self).__init__(parent) QObject.__init__(self) self.setCursor(Qt.OpenHandCursor) self.color = color self.color_dir = +1 self.text = text rect = key.get_rect_points() self.setPos(rect[0].x, rect[0].y) self.angle = key.r self.w = key.w self.h = key.h
def eventFilter(self, obj, event): e = event.type() if e == QEvent.KeyPress and event.key() == Qt.Key_Escape: obj.hide() elif e == QEvent.WindowDeactivate: obj.hide() return QObject.eventFilter(self, obj, event)
def __init__(self, gui): QObject.__init__(self) self.gui = gui self.ui = gui.ui if not self.gui.offline: self.robot_enable = RobotEnable() self.ui.btn_enable.clicked.connect(self.robot_enable.enable) self.ui.btn_disable.clicked.connect(self.robot_enable.disable) self.tucker = Tucker() if self.tucker.isTucked(): self.ui.btn_enable.setEnabled(False) else: self.ui.btn_enable.setEnabled(True) self.ui.btn_untuck.clicked.connect(self.untuck) self.ui.btn_tuck.clicked.connect(self.tuck) self.ui.btn_open_log_dir.clicked.connect(self.openLogDir)
def __init__(self, gui): QObject.__init__(self) self.sonar = Sonar() self.gui = gui self.ui = gui.ui self.post = Post(self) self.ui.btn_sonar_enable.clicked.connect(self.sonar.enable) self.ui.btn_sonar_disable.clicked.connect(self.sonar.disable) self.updateDistances.connect(self.updateGui) self.ui.btn_sonar_reset.clicked.connect(self.reset) for i in range(12): newItem = QtGui.QTableWidgetItem("Sensor " + str(i)) self.ui.tbl_sonar.setItem(i, 0, newItem) self.reset() self.post.callback()
def tab_music_players(self): """ Everything inside the Music players tab gets created here.""" # self.music_players # Creates the box with all the music players inside of it self.app_select_box = QComboBox(self.music_players) self.app_select_box.setGeometry(135, 10, 150, 25) # Whenever you change the application, it runs the selectnewapp func self.app_select_box.activated[str].connect(self.select_new_app) # Creates the label for the selection combobox self.selector_lbl = QLabel(self.music_players) self.selector_lbl.setGeometry(10, 10, 150, 25) self.selector_lbl.setText('Select your music player: ') # Creates the label for the current playing song (and the current # playing song label) self.current_playing_lbl = QLabel(self.music_players) self.current_playing_lbl.setGeometry(10, 45, 150, 25) self.current_playing_lbl.setText('Current playing song: ') self.current_playing = QLabel(self.music_players) self.current_playing.setGeometry(117, 45, 250, 25) self.current_playing.setText(Misc.noSongPlaying) # Creates a label which displays any additional messages self.misc_messages = QLabel(self.music_players) self.misc_messages.setGeometry(10, 80, 390, 24) self.misc_messages.setText(Misc.misc_message()) self.misc_messages.setOpenExternalLinks(True) # adds all the music players into the combobox self.app_select_box.addItem(None) for item in Constants.ACTIVEITEMS: if item == '__name__' or item == 'active': continue self.app_select_box.addItem(item) # creates the start button self.start_btn = QPushButton(self.music_players) self.start_btn.setGeometry(75, 120, 250, 35) self.start_btn.setText('Start') # links the start button to the self.start function QObject.connect( self.start_btn, SIGNAL("clicked()"), lambda: Thread(target=self.start, name='startbutton').start())
def __init__(self, gui): """ Load and display the OBS server list window. """ QObject.__init__(self) ObsLightGuiObject.__init__(self, gui) self.__srvListDialog = self.gui.loadWindow(u"obsServerList.ui") self.__listWidget = self.__srvListDialog.obsServersListWidget self.__serverConfigManager = None self.loadServerList() sld = self.__srvListDialog sld.addExistingServerButton.clicked.connect(self.on_addExistingServerButton_clicked) sld.createVirtualServerButton.clicked.connect(self.on_createVirtualServerButton_clicked) sld.modifyServerButton.clicked.connect(self.on_modifyServerButton_clicked) sld.deleteServerButton.clicked.connect(self.on_deleteServerButton_clicked) sld.checkConnectionButton.clicked.connect(self.on_testServerButton_clicked) sld.show()
def __init__(self, x, y, scaleFactor, text, obj, v, parent=None): """ Default class constructor. :param `x`: TOWRITE :type `x`: qreal :param `y`: TOWRITE :type `y`: qreal :param `scaleFactor`: TOWRITE :type `scaleFactor`: qreal :param `text`: TOWRITE :type `text`: QString :param `obj`: TOWRITE :type `obj`: `BaseObject` :param `v`: TOWRITE :type `v`: `View` :param `parent`: TOWRITE :type `parent`: `QUndoCommand`_ """ super(UndoableScaleCommand, self).__init__(parent) self.gview = v self.object = obj self.setText(text) # Prevent division by zero and other wacky behavior if scaleFactor <= 0.0: self.dx = 0.0 self.dy = 0.0 self.factor = 1.0 QMessageBox.critical(0, QObject.tr("ScaleFactor Error"), QObject.tr("Hi there. If you are not a developer, report this as a bug. " "If you are a developer, your code needs examined, and possibly your head too.")) else: # Calculate the offset oldX = self.object.x() # qreal oldY = self.object.y() # qreal scaleLine = QLineF(x, y, oldX, oldY) scaleLine.setLength(scaleLine.length() * scaleFactor) newX = scaleLine.x2() # qreal newY = scaleLine.y2() # qreal self.dx = newX - oldX self.dy = newY - oldY self.factor = scaleFactor
def testProdCon(self): #QThread producer-consumer example bucket = Bucket() prod = Producer(bucket) cons = Consumer(bucket) prod.start() cons.start() QObject.connect(prod, SIGNAL('finished()'), self.finishCb) QObject.connect(cons, SIGNAL('finished()'), self.finishCb) self.app.exec_() prod.wait() cons.wait() self.assertEqual(prod.production_list, cons.consumption_list)
def testRefCount(self): o = QObject() filt = MyFilter() o.installEventFilter(filt) self.assertEqual(sys.getrefcount(o), 2) o.installEventFilter(filt) self.assertEqual(sys.getrefcount(o), 2) o.removeEventFilter(filt) self.assertEqual(sys.getrefcount(o), 2)
def testBasic(self): self.machine = QStateMachine() s1 = QState() s2 = QState() s3 = QFinalState() QObject.connect(self.machine, SIGNAL("started()"), self.cb) self.anim = QParallelAnimationGroup() self.machine.addState(s1) self.machine.addState(s2) self.machine.addState(s3) self.machine.setInitialState(s1) self.machine.addDefaultAnimation(self.anim) self.machine.start() QTimer.singleShot(100, self.app.quit) self.app.exec_()
def testEmitOutsideThread(self): global thread_run app = QCoreApplication([]) source = Source() thread = ThreadJustConnects(source) QObject.connect(thread, SIGNAL('finished()'), lambda: app.exit(0)) thread.start() while not thread_run: pass source.emit_sig() app.exec_() thread.wait() self.assert_(thread.target.called)
def testWithoutArgs(self): '''Connect QProcess.started() to QTimeLine.togglePaused()''' process = QProcess() timeline = QTimeLine() QObject.connect(process, SIGNAL('finished(int, QProcess::ExitStatus)'), timeline, SLOT('toggleDirection()')) orig_dir = timeline.direction() process.start(sys.executable, ['-c', '"print 42"']) process.waitForFinished() new_dir = timeline.direction() if orig_dir == QTimeLine.Forward: self.assertEqual(new_dir, QTimeLine.Backward) else: self.assertEqual(new_dir, QTimeLine.Forward)
def eventFilter(self, obj, event): if event.type() == QEvent.WindowActivate: self.activated.emit() return True elif event.type() == QEvent.WindowDeactivate: self.deactivated.emit() return True else: # standard event processing return QObject.eventFilter(self, obj, event)
def __init__(self, gui): QObject.__init__(self) self.gui = gui self.ui = gui.ui self.sub = {} self.buff_size = 9 self.left_index = 0 self.right_index = 0 self.left_buffer = [0.0 for i in xrange(self.buff_size)] self.right_buffer = [0.0 for i in xrange(self.buff_size)] for side in ["left", "right"]: self.sub[side] = rospy.Subscriber("/robot/range/" + side + "_hand_range/state", Range, self.__sensorCallback, callback_args=side, queue_size=1) self.updateCalled.connect(self.updateGUI)
def testSetValue(self): """Direct signal emission: QSpinBox using valueChanged(int)/setValue(int)""" spinSend = QSpinBox() spinRec = QSpinBox() spinRec.setValue(5) spinSend.setValue(42) QObject.connect(spinSend, SIGNAL('valueChanged(int)'), spinRec, SLOT('setValue(int)')) self.assertEqual(spinRec.value(), 5) self.assertEqual(spinSend.value(), 42) spinSend.emit(SIGNAL('valueChanged(int)'), 3) self.assertEqual(spinRec.value(), 3) #Direct emission shouldn't change the value of the emitter self.assertEqual(spinSend.value(), 42) spinSend.emit(SIGNAL('valueChanged(int)'), 66) self.assertEqual(spinRec.value(), 66) self.assertEqual(spinSend.value(), 42)
def run_many(self, sender, signal, emitter, receivers, args=None): """Utility method to connect a list of receivers to a signal. sender - QObject that will emit the signal signal - string with the signal signature emitter - the callable that will trigger the signal receivers - list of BasicPySlotCase instances args - tuple with the arguments to be sent. """ if args is None: args = tuple() for rec in receivers: rec.setUp() QObject.connect(sender, SIGNAL(signal), rec.cb) rec.args = tuple(args) emitter(*args) for rec in receivers: self.assert_(rec.called)
def __init__(self, gui): QObject.__init__(self) ObsLightGuiObject.__init__(self, gui) self.__fileManager = FileManager(self.gui) # loaded in __loadPkgModel() self.__pkgModel = None # loaded in setCurrentProject() self.__project = None # in use in initializePackageFilters() self.__packageFilterInitialized = False # in use in on_addAndCommitButton_clicked() self.__commitDialog = None mw = self.mainWindow mw.packageTableView.setSelectionBehavior( QTableView.SelectionBehavior.SelectRows) mw.packageTableView.clicked.connect(self.on_packageTableView_activated) self.__connectButtons() self.__connectPackageFilterSignals()
def __init__(self, gui, name): """ Initialize a MicProjectManager. `gui` is a reference to the main Gui instance. `name` is the name of the MIC project to manage. """ QObject.__init__(self) ObsLightGuiObject.__init__(self, gui) self.__projectName = name self.__repoModel = KickstartRepositoriesModel(self.manager, self.currentProject) self.__pkgModel = KickstartPackagesModel(self.manager, self.currentProject) self.__pkgGrpModel = KickstartPackageGroupsModel( self.manager, self.currentProject) self.__cmdModel = KickstartCommandsModel(self.manager, self.currentProject) self.__scriptModel = KickstartScriptsModel(self.manager, self.currentProject) self.__overlayModel = KickstartOverlayFilesModel( self.manager, self.currentProject)
def setObjectLineWeight(self, lineWeight): """ TOWRITE :param `lineWeight`: TOWRITE :type `lineWeight`: qreal """ self.objPen.setWidthF(0) # NOTE: The objPen will always be cosmetic if lineWeight < 0: if lineWeight == OBJ_LWT_BYLAYER: self.lwtPen.setWidthF(0.35) # TODO: getLayerLineWeight elif lineWeight == OBJ_LWT_BYBLOCK: self.lwtPen.setWidthF(0.35) # TODO: getBlockLineWeight else: QMessageBox.warning(0, QObject.tr("Error - Negative Lineweight"), QObject.tr("Lineweight: %f" % lineWeight)) qDebug("Lineweight cannot be negative! Inverting sign.") self.lwtPen.setWidthF(-lineWeight) else: self.lwtPen.setWidthF(lineWeight)
def setupContextMenu(self, vobj, menu): """Set up the object's context menu in GUI (callback).""" action1 = QAction(QT_TRANSLATE_NOOP("Render", "Set GUI to this camera"), menu) QObject.connect(action1, SIGNAL("triggered()"), self.set_gui_from_camera) menu.addAction(action1) action2 = QAction(QT_TRANSLATE_NOOP("Render", "Set this camera to GUI"), menu) QObject.connect(action2, SIGNAL("triggered()"), self.set_camera_from_gui) menu.addAction(action2) action3 = QAction(QT_TRANSLATE_NOOP("Render", "Point at..."), menu) QObject.connect(action3, SIGNAL("triggered()"), self.point_at) menu.addAction(action3)