Python PyQt4.QtCore.SIGNAL Examples

The following are 30 code examples of PyQt4.QtCore.SIGNAL(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt4.QtCore , or try the search function .
Example #1
Source File: settings.py    From procexp with GNU General Public License v3.0 8 votes vote down vote up
def doSettings(millisecWait, depth, fontSize):
  global ui
  Dialog = QtGui.QDialog()
  settings = uic.loadUi(os.path.join(os.path.dirname(__file__), "./ui/settings.ui"), baseinstance=Dialog)
  ui = settings
  Dialog.setModal(True)
  QtCore.QObject.connect(settings.lineEditNfSamples,  QtCore.SIGNAL('textChanged (const QString&)'), onChange)
  QtCore.QObject.connect(settings.lineEditTimesSecond,  QtCore.SIGNAL('textChanged (const QString&)'), onChange)
  ui.lineEditTimesSecond.setText(str(float(1000.0 / (millisecWait * 1.0))))
  ui.lineEditNfSamples.setText(str(depth))
  ui.lineEditFontSize.setText(str(fontSize))
  Dialog.exec_()
  
  millisecWait = int(1000.0 / float(str(ui.lineEditTimesSecond.displayText())))
  depth = int(str(ui.lineEditNfSamples.displayText()))
  fontSize = int(str(ui.lineEditFontSize.displayText()))
  return(millisecWait, depth, fontSize) 
Example #2
Source File: universal_tool_template_v7.3.py    From universal_tool_template.py with MIT License 7 votes vote down vote up
def Establish_Connections(self):
        # loop button and menu action to link to functions
        for ui_name in self.uiList.keys():
            if ui_name.endswith('_btn'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("clicked()"), getattr(self, ui_name[:-4]+"_action", partial(self.default_action,ui_name)))
            elif ui_name.endswith('_atn'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("triggered()"), getattr(self, ui_name[:-4]+"_action", partial(self.default_action,ui_name)))
            elif ui_name.endswith('_btnMsg'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("clicked()"), getattr(self, ui_name[:-7]+"_message", partial(self.default_message,ui_name)))
            elif ui_name.endswith('_atnMsg'):
                QtCore.QObject.connect(self.uiList[ui_name], QtCore.SIGNAL("triggered()"), getattr(self, ui_name[:-7]+"_message", partial(self.default_message,ui_name)))
        # custom connection
    
    #=======================================
    # UI Response functions (custom + prebuilt functions)
    #=======================================
    #-- ui actions 
Example #3
Source File: dispatch.py    From cross3d with MIT License 6 votes vote down vote up
def dispatchObject(self, signal, *args):
		"""
			\remarks	dispatches a string based signal through the system from an application
			\param		signal	<str>
			\param		*args	<tuple> additional arguments
		"""
		if cross3d.application.shouldBlockSignal(signal, self.signalsBlocked()):
			return

		# emit a defined pyqtSignal
		if (hasattr(self, signal) and type(getattr(self, signal)).__name__ == 'pyqtBoundSignal') and args[0]:
			getattr(self, signal).emit(cross3d.SceneObject(cross3d.Scene.instance(), args[0]))

		# otherwise emit a custom signal
		else:
			from PyQt4.QtCore import SIGNAL
			self.emit(SIGNAL(signal), *args)

		# emit linked signals
		if (signal in self._linkedSignals):
			for trigger in self._linkedSignals[signal]:
				self.dispatch(trigger) 
Example #4
Source File: MainWindow.py    From PyEngine3D with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def run(self):
        self.lastTime = time.time()
        while self.running:
            # Timer
            self.delta = time.time() - self.lastTime
            if self.delta < self.limitDelta:
                time.sleep(self.limitDelta - self.delta)
            # print(1.0/(time.time() - self.lastTime))
            self.lastTime = time.time()

            # Process recieved queues
            if not self.cmdQueue.empty():
                # receive value must be tuple type
                cmd, value = self.cmdQueue.get()
                cmdName = get_command_name(cmd)
                # recieved queues
                if cmd == COMMAND.CLOSE_UI:
                    self.running = False
                # call binded signal event
                self.emit(QtCore.SIGNAL(cmdName), value) 
Example #5
Source File: shellScriptExecutor.py    From Stormy with GNU General Public License v2.0 6 votes vote down vote up
def run(self ):
        # make sure current user have access right to execute shellScriptFile
        try :
            isFileExecuteable = os.access( self.shellScriptFile, os.X_OK )
            if not isFileExecuteable :
                response = "Error: Please make sure your shell script file has execute permission!"
                self.emit(QtCore.SIGNAL("updateResponseShellScript(QString)"), response)

        except OSError as e:
            response = "Error: Cannot read shell script file!"
            self.emit(QtCore.SIGNAL("updateResponseShellScript(QString)"), response)


        if self.shellScriptType == "installer" :
            self.doInstall()

        else:
            self.visitService() 
Example #6
Source File: gui.py    From PrusaControl with GNU General Public License v3.0 6 votes vote down vote up
def create_slider(self, setterSlot, defaultValue=0, rangeMin=0, rangeMax=100, orientation=Qt.Horizontal, base_class=QSlider):
        if base_class == Gcode_slider:
            slider = base_class(orientation, self.controller)
        else:
            slider = base_class(orientation)

        slider.setRange(rangeMin, rangeMax)
        slider.setSingleStep(1)
        slider.setPageStep(1)
        slider.setTickInterval(1)
        slider.setValue(defaultValue)
        slider.setTickPosition(QSlider.TicksRight)

        if base_class == Gcode_slider:
            #self.connect(slider.slider, SIGNAL("valueChanged(int)"), setterSlot)
            slider.slider.valueChanged.connect(setterSlot)
        else:
            #self.connect(slider, SIGNAL("valueChanged(int)"), setterSlot)
            slider.valueChanged.connect(setterSlot)
        return slider 
Example #7
Source File: appgui.py    From mishkal with GNU General Public License v3.0 6 votes vote down vote up
def doHeavyLifting(self):
        """
        UI callback, starts the thread with the proper arguments.
        """
        if self.thread: # Sanity check.
            return

        self.singleProgress.setValue(1)
        self.progressDialog.show();
        self.mytimer.start(1000);
        QtGui.QApplication.setOverrideCursor(
            QtGui.QCursor(QtCore.Qt.WaitCursor))
        self.thread = WorkThread(target=self.display_result)
        QtCore.QObject.connect(self.thread, QtCore.SIGNAL("mainThread"),
                     self.mainThread)
        QtCore.QObject.connect(self.thread, QtCore.SIGNAL("finished()"), self.threadDone)

        self.thread.start() 
Example #8
Source File: shellScriptExecutor.py    From Stormy with GNU General Public License v2.0 6 votes vote down vote up
def visitService(self):

        softwareInstalled = self.ObjectForDisplayResponse.mainWidget.completeWidget.softwareInstalled

        infoResponse = "Try to find " + softwareInstalled + " location. Please wait until finish ..."
        self.emit(QtCore.SIGNAL("updateResponseInstalledLabel(QString)"), infoResponse)

        # command to run shell script file
        shellScriptRunner =  [self.shellScriptFile, ""]

        try:
            ## execute shell script
            popen = subprocess.Popen(shellScriptRunner, stdout=subprocess.PIPE)
            lines_iterator = iter(popen.stdout.readline, b"")

            for response in lines_iterator:
                self.emit(QtCore.SIGNAL("updateResponseShellScript(QString)"), response)

        except OSError as e:
            response = "Error: error at try to execute visit service shell script file!"
            self.emit(QtCore.SIGNAL("updateResponseShellScript(QString)"), response)

        infoResponse = "Finding  " + softwareInstalled + " service finish."
        self.emit(QtCore.SIGNAL("updateResponseInstalledLabel(QString)"), infoResponse) 
Example #9
Source File: PyQtPiClock.py    From PiClock with MIT License 6 votes vote down vote up
def getTiles(self, t, i=0):
        t = int(t / 600)*600
        self.getTime = t
        self.getIndex = i
        if i == 0:
            self.tileurls = []
            self.tileQimages = []
            for tt in self.tiletails:
                tileurl = "https://tilecache.rainviewer.com/v2/radar/%d/%s" \
                    % (t, tt)
                self.tileurls.append(tileurl)
        print self.myname + " " + str(self.getIndex) + " " + self.tileurls[i]
        self.tilereq = QNetworkRequest(QUrl(self.tileurls[i]))
        self.tilereply = manager.get(self.tilereq)
        QtCore.QObject.connect(self.tilereply, QtCore.SIGNAL(
                "finished()"), self.getTilesReply) 
Example #10
Source File: FlatCAMWorkerStack.py    From FlatCAM with MIT License 6 votes vote down vote up
def __init__(self):
        super(WorkerStack, self).__init__()

        self.workers = []
        self.threads = []
        self.load = {}                                  # {'worker_name': tasks_count}

        # Create workers crew
        for i in range(0, 2):
            worker = Worker(self, 'Slogger-' + str(i))
            thread = QtCore.QThread()

            worker.moveToThread(thread)
            worker.connect(thread, QtCore.SIGNAL("started()"), worker.run)
            worker.task_completed.connect(self.on_task_completed)

            thread.start()

            self.workers.append(worker)
            self.threads.append(thread)
            self.load[worker.name] = 0 
Example #11
Source File: playermodel.py    From pyqtggpo with GNU General Public License v2.0 6 votes vote down vote up
def sort(self, col, order=None):
        if col in PlayerModel.sortableColumns:
            reverse = False
            if order == QtCore.Qt.DescendingOrder:
                reverse = True
            self.lastSort = col
            self.lastSortOrder = order
            getter = operator.itemgetter(col)
            if col in [PlayerModel.PLAYER, PlayerModel.OPPONENT]:
                keyfunc = lambda x: getter(x).lower()
            else:
                keyfunc = getter
            self.emit(QtCore.SIGNAL("layoutAboutToBeChanged()"))
            self.players = sorted(self.players, key=keyfunc, reverse=reverse)
            self.players = sorted(self.players, key=operator.itemgetter(PlayerModel.STATE))
            self.emit(QtCore.SIGNAL("layoutChanged()")) 
Example #12
Source File: customemoticonsdialog_ui.py    From pyqtggpo with GNU General Public License v2.0 6 votes vote down vote up
def setupUi(self, EmoticonDialog):
        EmoticonDialog.setObjectName(_fromUtf8("EmoticonDialog"))
        EmoticonDialog.resize(300, 500)
        self.verticalLayout = QtGui.QVBoxLayout(EmoticonDialog)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.label = QtGui.QLabel(EmoticonDialog)
        self.label.setObjectName(_fromUtf8("label"))
        self.verticalLayout.addWidget(self.label)
        self.uiEmoticonTextEdit = QtGui.QTextEdit(EmoticonDialog)
        self.uiEmoticonTextEdit.setObjectName(_fromUtf8("uiEmoticonTextEdit"))
        self.verticalLayout.addWidget(self.uiEmoticonTextEdit)
        self.buttonBox = QtGui.QDialogButtonBox(EmoticonDialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
        self.verticalLayout.addWidget(self.buttonBox)

        self.retranslateUi(EmoticonDialog)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), EmoticonDialog.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), EmoticonDialog.reject)
        QtCore.QMetaObject.connectSlotsByName(EmoticonDialog) 
Example #13
Source File: interidentify.py    From specidentify with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def err_redraw_canvas(self, keepzoom=False):
        if keepzoom:
            # Store current zoom level
            xmin, xmax = self.erraxes.get_xlim()
            ymin, ymax = self.erraxes.get_ylim()
        else:
            self.xmin, self.xmax = self.axes.get_xlim()

        # Clear plot
        self.erraxes.clear()

        # Draw image
        self.plotErr()

        # Restore zoom level
        if keepzoom:
            self.erraxes.set_xlim((xmin, xmax))
            self.erraxes.set_ylim((ymin, ymax))
        else:
            self.erraxes.set_xlim((self.xmin, self.xmax))

        self.errfigure.draw()

        self.emit(QtCore.SIGNAL("fitUpdate()")) 
Example #14
Source File: lite_window.py    From encompass with GNU General Public License v3.0 6 votes vote down vote up
def waiting_dialog(self, f):
        s = Timer()
        s.start()
        w = QDialog()
        w.resize(200, 70)
        w.setWindowTitle('Encompass')
        l = QLabel(_('Sending transaction, please wait.'))
        vbox = QVBoxLayout()
        vbox.addWidget(l)
        w.setLayout(vbox)
        w.show()
        def ff():
            s = f()
            if s: l.setText(s)
            else: w.close()
        w.connect(s, QtCore.SIGNAL('timersignal'), ff)
        w.exec_()
        w.destroy() 
Example #15
Source File: interidentify.py    From specidentify with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def updatesection(self):
        self.y1 = int(self.y1ValueEdit.text())
        self.y2 = int(self.y2ValueEdit.text())
        self.nrows = int(self.nrValueEdit.text())
        self.rstep = int(self.nsValueEdit.text())
        if abs(self.y1 - self.y2) != self.nrows:
            if self.log:
                self.log.warning(
                    "Warning: Update y2 to increase the row sampling")
        ## self.y1line.set_ydata([self.y1, self.y1])
        ## self.y2line.set_ydata([self.y2, self.y2])
        self.y1line.y1 = self.y1
        self.y1line.y2 = self.y1
        self.y2line.y1 = self.y2
        self.y2line.y2 = self.y2
        self.imdisplay.redraw(whence=3)
        self.emit(QtCore.SIGNAL("regionChange(int,int)"), self.y1, self.y2) 
Example #16
Source File: dispatch.py    From cross3d with MIT License 6 votes vote down vote up
def dispatch(self, signal, *args):
		"""
			\remarks	dispatches a string based signal through the system from an application
			\param		signal	<str>
			\param		*args	<tuple> additional arguments
		"""
		if cross3d.application.shouldBlockSignal(signal, self.signalsBlocked()):
			return

		# emit a defined pyqtSignal
		if (hasattr(self, signal) and type(getattr(self, signal)).__name__ == 'pyqtBoundSignal'):
			getattr(self, signal).emit(*args)

		# otherwise emit a custom signal
		else:
			from PyQt4.QtCore import SIGNAL
			self.emit(SIGNAL(signal), *args)

		# emit linked signals
		if (signal in self._linkedSignals):
			for trigger in self._linkedSignals[signal]:
				self.dispatch(trigger) 
Example #17
Source File: dispatchprocess.py    From cross3d with MIT License 6 votes vote down vote up
def dispatchEvent(self, signal, *args):
		print 'Dispatching event', signal
		if ( self.signalsBlocked() ):
			return
			
		# emit a defined pyqtSignal
		if ( hasattr(Dispatch,signal) and type(getattr(Dispatch,signal)).__name__ == 'pyqtBoundSignal' ):
			# this should identify the object type before emiting it if it needs to emit something
			getattr(Dispatch,signal).emit(SceneObject(Scene.instance(), args[0]))
		
		# elif process application specific signals like xsi's value changed
		
		# otherwise emit a custom signal
		else:
			from PyQt4.QtCore import SIGNAL
			self.emit( SIGNAL( signal ), *args )
		
		# emit linked signals
		if ( signal in self._linkedSignals ):
			for trigger in self._linkedSignals[signal]:
				self.dispatch( trigger ) 
Example #18
Source File: test_reference_editor.py    From anima with MIT License 5 votes vote down vote up
def show_dialog(self, dialog):
        """show the given dialog
        """
        dialog.show()
        self.app.exec_()
        self.app.connect(
            self.app,
            QtCore.SIGNAL("lastWindowClosed()"),
            self.app,
            QtCore.SLOT("quit()")
        ) 
Example #19
Source File: UITranslator_v1.0.py    From universal_tool_template.py with MIT License 5 votes vote down vote up
def loadLang(self):
        self.quickMenu(['language_menu;&Language'])
        cur_menu = self.uiList['language_menu']
        self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu)
        cur_menu.addSeparator()
        QtCore.QObject.connect( self.uiList['langDefault_atnLang'], QtCore.SIGNAL("triggered()"), partial(self.setLang, 'default') )
        # store default language
        self.memoData['lang']={}
        self.memoData['lang']['default']={}
        for ui_name in self.uiList:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtGui.QLabel, QtGui.QPushButton, QtGui.QAction, QtGui.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.text())
            elif type(ui_element) in [ QtGui.QGroupBox, QtGui.QMenu ]:
                # uiType: QMenu, QGroupBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.title())
            elif type(ui_element) in [ QtGui.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                tabNameList = []
                for i in range(tabCnt):
                    tabNameList.append(str(ui_element.tabText(i)))
                self.memoData['lang']['default'][ui_name]=';'.join(tabNameList)
            elif type(ui_element) == str:
                # uiType: string for msg
                self.memoData['lang']['default'][ui_name] = self.uiList[ui_name]
        
        # try load other language
        lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__))
        baseName = os.path.splitext( os.path.basename(self.location) )[0]
        for fileName in os.listdir(lang_path):
            if fileName.startswith(baseName+"_lang_"):
                langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","")
                self.memoData['lang'][ langName ] = self.readRawFile( os.path.join(lang_path,fileName) )
                self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', cur_menu)
                QtCore.QObject.connect( self.uiList[langName+'_atnLang'], QtCore.SIGNAL("triggered()"), partial(self.setLang, langName) )
        # if no language file detected, add export default language option
        if len(self.memoData['lang']) == 1:
            self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', cur_menu)
            QtCore.QObject.connect( self.uiList['langExport_atnLang'], QtCore.SIGNAL("triggered()"), self.exportLang ) 
Example #20
Source File: interidentify.py    From specidentify with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def runauto(self):
        if self.log is not None:
            self.log.message("Running Auto")
        self.emit(
            QtCore.SIGNAL("runauto(int, int, int)"),
            self.y1,
            self.nrows,
            self.rstep) 
Example #21
Source File: interidentify.py    From specidentify with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def updatesection(self):
        self.y1 = int(self.y1ValueEdit.text())
        self.y2 = int(self.y2ValueEdit.text())
        self.nrows = int(self.nrValueEdit.text())
        self.rstep = int(self.nsValueEdit.text())
        if abs(self.y1 - self.y2) != self.nrows:
            if self.log:
                self.log.warning(
                    "Warning: Update y2 to increase the row sampling")
        self.y1line.set_ydata([self.y1, self.y1])
        self.y2line.set_ydata([self.y2, self.y2])
        self.imdisplay.draw()
        self.emit(QtCore.SIGNAL("regionChange(int,int)"), self.y1, self.y2) 
Example #22
Source File: interidentify.py    From specidentify with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, xarr, specarr, slines, sfluxes, ws, hmin=150, wmin=400, mdiff=20, wdiff=20,
                 filename=None, res=2.0, dres=0.1, dc=20, ndstep=20, sigma=5, smooth=0, niter=5, istart=None,
                 nrows=1, rstep=100, method='Zeropoint', ivar=None, cmap='gray', scale='zscale', contrast=1.0,
                 subback=0, textcolor='green', log=None, verbose=True, prefer_ginga=True):
        """Default constructor."""

        # Setup widget
        QtGui.QMainWindow.__init__(self)

        # Set main widget
        self.main = InterIdentifyWidget(xarr, specarr, slines, sfluxes, ws,
                                        hmin=150, wmin=400, mdiff=mdiff, wdiff=wdiff,
                                        filename=filename, res=res, dres=dres, dc=dc,
                                        ndstep=ndstep, sigma=sigma, smooth=smooth,
                                        niter=niter, istart=istart, nrows=nrows,
                                        rstep=rstep, method=method, ivar=ivar,
                                        cmap=cmap, scale=scale, contrast=contrast,
                                        subback=subback, textcolor=textcolor,
                                        log=log, verbose=verbose,
                                        prefer_ginga=prefer_ginga)

        # Set window title
        self.setWindowTitle("InterIdentify")

        # Set focus to main widget
        # self.main.setFocus()

        # Set the main widget as the central widget
        self.setCentralWidget(self.main)

        # Destroy widget on close
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        # Close when config dialog is closed
        ## self.connect(self.conf, QtCore.SIGNAL('destroyed()'),
        ##              self, QtCore.SLOT('close()')) 
Example #23
Source File: interidentify.py    From specidentify with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def regionChange(self, y1, y2):
        self.y1 = y1
        self.y2 = y2
        self.farr = apext.makeflat(self.specarr, self.y1, self.y2)
        self.farr = st.flatspectrum(self.xarr, self.farr, order=self.subback)
        # set up variables
        self.ws = self.newWS(0.5 * (self.y1 + self.y2))
        self.arcdisplay = ArcDisplay(
            self.xarr,
            self.farr,
            self.slines,
            self.sfluxes,
            self.ws,
            specarr=self.specarr,
            res=self.res,
            dres=self.dres,
            smooth=self.smooth,
            niter=self.niter,
            sigma=self.sigma,
            xp=[],
            wp=[],
            textcolor=self.textcolor,
            log=self.log,
            verbose=self.verbose)
        self.arcPage = arcWidget(
            self.arcdisplay,
            hmin=self.hmin,
            wmin=self.wmin,
            y1=self.y1,
            y2=self.y2)
        self.connect(self.arcPage, QtCore.SIGNAL('savews()'), self.saveWS)
        # set up the residual page
        self.errPage = errWidget(
            self.arcdisplay,
            hmin=self.hmin,
            wmin=self.wmin)
        # reset the pages
        self.tabWidget.removeTab(2)
        self.tabWidget.removeTab(1)
        self.tabWidget.insertTab(1, self.arcPage, 'Arc')
        self.tabWidget.insertTab(2, self.errPage, 'Residual') 
Example #24
Source File: robot_gui.py    From Learning-Robotics-using-Python-Second-Edition with MIT License 5 votes vote down vote up
def run(self):
		while True:
			time.sleep(0.3) # artificial time delay
			self.emit( QtCore.SIGNAL('update(QString)'), " " ) 
#			print "Hello"
	
   
  		return 
Example #25
Source File: robot_gui.py    From Learning-Robotics-using-Python-Second-Edition with MIT License 5 votes vote down vote up
def update_values(self):
  	self.thread =  WorkThread() 
  	QtCore.QObject.connect( self.thread,  QtCore.SIGNAL("update(QString)"), self.add )
  	self.thread.start() 
Example #26
Source File: robot_gui.py    From Learning-Robotics-using-Python-Second-Edition with MIT License 5 votes vote down vote up
def run(self):
		while True:
			time.sleep(0.3) # artificial time delay
			self.emit( QtCore.SIGNAL('update(QString)'), " " ) 
#			print "Hello"
	
   
  		return 
Example #27
Source File: Sniffer.py    From SimpleSniffer with GNU General Public License v3.0 5 votes vote down vote up
def initUI(self):
        device_data = get_iface_name()
        iface_num = len(device_data)
        iface_keys = device_data.keys()
        #网卡列表
        self.radio_lists = []
        self.gridlayout = QtGui.QGridLayout()
        self.label_name = QtGui.QLabel(u'接口名')
        self.label_ip = QtGui.QLabel(u'IP地址')
        self.label_receive = QtGui.QLabel(u'接受流量')
        self.label_send = QtGui.QLabel(u'发送流量')
        self.gridlayout.addWidget(self.label_name, 1, 1)
        self.gridlayout.addWidget(self.label_ip, 1, 2)
        self.gridlayout.addWidget(self.label_receive, 1, 3)
        self.gridlayout.addWidget(self.label_send, 1, 4)
        self.setLayout(self.gridlayout)
        for i in range(iface_num):
            iface_name = iface_keys[i]
            self.iface_radio = QtGui.QRadioButton(iface_name)
            if iface_name == 'eth0':
                self.iface_radio.setChecked(True)
            self.gridlayout.addWidget(self.iface_radio, i+2, 1)
            self.radio_lists.append(self.iface_radio)
            self.ip_label = QtGui.QLabel(get_ip_address(iface_name))
            self.gridlayout.addWidget(self.ip_label, i+2, 2)
            data = device_data[iface_name].split(';')
            self.receive_label = QtGui.QLabel(data[0])
            self.send_label = QtGui.QLabel(data[1])
            self.gridlayout.addWidget(self.receive_label, i+2, 3)
            self.gridlayout.addWidget(self.send_label, i+2, 4)
            self.setLayout(self.gridlayout)
        #添加按钮
        self.start_but = QtGui.QPushButton(u'确定', self)
        self.start_but.clicked.connect(self.exit_me)
        self.start_but.setCheckable(False)
        self.gridlayout.addWidget(self.start_but, iface_num + 2, 2)
        self.cancel_but = QtGui.QPushButton(u'取消', self)
        self.connect(self.cancel_but, QtCore.SIGNAL('clicked()'), QtCore.SLOT('close()'))
        self.cancel_but.setCheckable(False)
        self.gridlayout.addWidget(self.cancel_but, iface_num + 2, 3) 
Example #28
Source File: robot_gui.py    From Learning-Robotics-using-Python-Second-Edition with MIT License 5 votes vote down vote up
def update_values(self):
  	self.thread =  WorkThread() 
  	QtCore.QObject.connect( self.thread,  QtCore.SIGNAL("update(QString)"), self.add )
  	self.thread.start() 
Example #29
Source File: FrameLayout.py    From pyqt-collapsible-widget with MIT License 5 votes vote down vote up
def initCollapsable(self):
        QtCore.QObject.connect(self._title_frame, QtCore.SIGNAL('clicked()'), self.toggleCollapsed) 
Example #30
Source File: interidentify.py    From specidentify with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def savews(self):
        """Save the wcs to the """
        self.emit(QtCore.SIGNAL("savews()"))