當前位置: 首頁>>代碼示例>>Python>>正文


Python Ui_MainWindow.setupUi方法代碼示例

本文整理匯總了Python中gui.Ui_MainWindow.setupUi方法的典型用法代碼示例。如果您正苦於以下問題:Python Ui_MainWindow.setupUi方法的具體用法?Python Ui_MainWindow.setupUi怎麽用?Python Ui_MainWindow.setupUi使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gui.Ui_MainWindow的用法示例。


在下文中一共展示了Ui_MainWindow.setupUi方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ControlMainWindow

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class ControlMainWindow(QtGui.QMainWindow):
	def __init__(self, parent=None):
		super(ControlMainWindow, self).__init__(parent)
		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)
	def customSetUp(self):
		initialize_map()

		table = self.ui.mainboard
		table.setRowCount(upper_limit_x())
		table.setColumnCount(upper_limit_y())
	 	table.setHorizontalHeaderLabels(('0', '1', '2' , '3' , '4' ,'5'))
		table.setVerticalHeaderLabels(('0', '1', '2' , '3' , '4' ,'5'))
		table.cellClicked.connect(handleTableClick)
		#(y,x)
		#table.setItem(origin.y, origin.x, QtGui.QTableWidgetItem())
		#table.item(origin.y, origin.x).setBackground(QtGui.QColor(100,100,150))
		#table.setItem(finish.y, finish.x, QtGui.QTableWidgetItem())
		#table.item(finish.y, finish.x).setBackground(QtGui.QColor(100,100,150))
		self.ui.solveButton.clicked.connect(start_a_star)
		self.ui.cleanButton.clicked.connect(action_clean_board)
		self.ui.randomButton.clicked.connect(create_random_map)
		QtCore.QObject.connect(self.ui.aboutASTAR, QtCore.SIGNAL('triggered()'), action_about_a_star)
		QtCore.QObject.connect(self.ui.actionNewMap, QtCore.SIGNAL('triggered()'), action_new_map)

		clean_board()
開發者ID:PaytonZ,項目名稱:IC-Practica1,代碼行數:28,代碼來源:main.py

示例2: principal

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class principal(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)

        self.ventana = Ui_MainWindow()
        self.ventana.setupUi(self)

        command = 'systemctl is-active firewalld.service'
        serviceStatus = os.system(command)

        if serviceStatus == 0:
            self.ventana.label_2.setText("<html><head/><body><p><span style=\" font-size:12pt; font-weight:600;\">Activado</span></p></body></html>")
            self.ventana.pushButton.setText("Desactivar")

        self.connect(self.ventana.pushButton, QtCore.SIGNAL('clicked()'), self.switch)

    def switch(self):

        command = 'systemctl is-active firewalld.service'
        serviceStatus = os.system(command)

        if serviceStatus == 0:
            os.system('beesu systemctl stop firewalld.service')
            self.ventana.label_2.setText("<html><head/><body><p><span style=\" font-size:12pt; font-weight:600; color:#FF0000\">Desactivado</span></p></body></html>")
            self.ventana.pushButton.setText("Activar")
        elif serviceStatus == 768:
            os.system('beesu systemctl start firewalld.service')
            self.ventana.label_2.setText("<html><head/><body><p><span style=\" font-size:12pt; font-weight:600;\">Activado</span></p></body></html>")
            self.ventana.pushButton.setText("Desactivar")
開發者ID:MawCeron,項目名稱:firewalld-switch,代碼行數:31,代碼來源:main.py

示例3: MyForm

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        QtCore.QObject.connect(self.ui.pushButton_2, QtCore.SIGNAL("clicked()"), self.on_first_clicked )
        QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.on_second_clicked)
        QtCore.QObject.connect(self.ui.pushButton_3, QtCore.SIGNAL("clicked()"), self.on_merge_clicked)
     
    def on_first_clicked(self):
        File1 = QtGui.QFileDialog.getOpenFileName();
        self.ui.lineEdit_2.setText(File1)

    def on_second_clicked(self):
        File2 = QtGui.QFileDialog.getOpenFileName();
        self.ui.lineEdit.setText(File2)

    def on_merge_clicked(self):
        File1 = self.ui.lineEdit_2.text()
        File2 = self.ui.lineEdit.text()
        if File1 and File2:
            merge(File1, File2)
        else:
            print('specify a file')

    def add_entry(self):
        self.ui.lineEdit.selectAll()
        self.ui.lineEdit.cut()
        self.ui.textEdit.append("")
        self.ui.textEdit.paste()
開發者ID:Fabioamd87,項目名稱:wlm-log-merger,代碼行數:32,代碼來源:merge_xml.py

示例4: MyForm

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        #buttons
        self.ui.browsebutton.clicked.connect(self.set_directory)
        self.ui.clearbutton.clicked.connect(self.clear_directory)
        
    def set_directory(self):
        self.ui.directorybox.clear()
        self.ui.directorybox.setText(QFileDialog.getExistingDirectory())
        self.display_scripts()
	
    def clear_directory(self):
        self.ui.scriptlist.clear()
        self.ui.directorybox.clear()
        
    def display_scripts(self):
        self.ui.scriptlist.clear()
        path = self.ui.directorybox.text()
        os.chdir(path)
        filelist = os.listdir()
        
        for i in filelist:
            if(i.endswith('.py')):
                self.ui.scriptlist.append(i)
開發者ID:nsmith15PCC,項目名稱:pythonfinalproject,代碼行數:29,代碼來源:final.py

示例5: MyForm

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        QtCore.QObject.connect(self.ui.goto_channel_0,
            QtCore.SIGNAL("clicked()"), self.move_program_to_channel)  # lint:ok

        QtCore.QObject.connect(self.ui.create_null,
            QtCore.SIGNAL("clicked()"), self.create_null)  # lint:ok
        
        # Create a QTimer
        self.channel_timer = QtCore.QTimer()
        # Connect it to f
        self.channel_timer.timeout.connect(self.update_gui)
        # Call f() every 5 seconds
        self.channel_timer.start(1000)

    def update_sinks(self, sink_inputs):                
        for sink in sink_inputs:
            old_items = self.ui.sinks.findItems(sink['appname'], QtCore.Qt.MatchFixedString)
            
            if not old_items:
                item = QtGui.QListWidgetItem("%s" % sink['appname'])            
                self.ui.sinks.addItem(item)
                
        for index in range(self.ui.sinks.count()):
            item = self.ui.sinks.item(index)
            found = False
            for sink in sink_inputs:
                if sink['appname'] == item.text():
                    found = True
            if not found:
                self.ui.sinks.takeItem(index)                

    def update_channels(self, channels):
        for channel in channels:
            item = QtGui.QListWidgetItem("%s" % channel['name'])
            self.ui.channel1.addItem(item)

            if channel['name'] == 'streamer':
                self.ui.create_null.setEnabled(False)

    def update_gui(self):
        self.update_sinks(get_active_player_programs())
        
    def move_program_to_channel(self):
        return

    def create_null(self):
        cmd = ["pactl"]
        paramter = ["load-module", "module-null-sink", "sink_name=streamer"]

        try:
            sink_number = subprocess.call(cmd + paramter)

        except OSError as e:
            print >>sys.stderr, "Execution failed:", e
開發者ID:buzzz321,項目名稱:ljudman,代碼行數:61,代碼來源:ljudman.py

示例6: Main

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class Main(QMainWindow):
    def __init__(self, parent):

        super(Main, self).__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.ui.textEdit.initInterpreter(locals())
        self.ui.textEdit.updateInterpreterLocals(self.ui.dockWidget)
開發者ID:sir-wiggles,項目名稱:iComm,代碼行數:11,代碼來源:test.py

示例7: main

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
def main():
    app = QtGui.QApplication(sys.argv)
    MainWindow = QtGui.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)

    MainWindow.show()
    
    sys.exit(app.exec_())
開發者ID:imagingearth,項目名稱:imageProc,代碼行數:11,代碼來源:__main__.py

示例8: StartQT4

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class StartQT4(QtGui.QMainWindow):
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        # Force consistent theme and font size
        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create("Plastique"))

        # Disable resizing
        self.setFixedSize(self.size())

        #######################################################
        # Interface Object Connections                        #
        #######################################################
        itemClicked = QtCore.SIGNAL("itemClicked(QListWidgetItem *)")
        clicked = QtCore.SIGNAL("clicked()")

        ## Buttons
        QtCore.QObject.connect(self.ui.pushButton_convert, clicked, self.convertImage)
        QtCore.QObject.connect(self.ui.pushButton_loadImage, clicked, self.loadImage)

    def loadImage(self):
        imageName = str(QtGui.QFileDialog.getOpenFileName())
        self.ui.label_imageFile.setText(imageName)
        
        
    def convertImage(self):
        imageName = str(self.ui.label_imageFile.text())
        imageTitle = self.ui.lineEdit_title.text()
        if not imageTitle == '':
            filename, extension = os.path.splitext(imageName)
            directory, file = os.path.split(filename)
            image = Image.open(imageName)
            #scale image
            imageWidth, imageHeight = image.size
            ratio = min(128/imageWidth, 98/imageHeight)
            newImageHeight = int(imageHeight*ratio)
            newImageWidth = int(imageWidth*ratio)
            size = newImageWidth, newImageHeight
            image = image.resize(size)
            #add white bar to bottom for text
            horizontalImageSpacing = int((128-newImageWidth)/2)
            image = image.crop(( -1*horizontalImageSpacing,0,newImageWidth+horizontalImageSpacing,128))
            draw = ImageDraw.Draw(image)
            myFont = ImageFont.truetype("Arial.ttf", 20, encoding="unic")
            textWidth, textHeight = myFont.getsize(imageTitle)
            textHorizontalPosition = 64 - (textWidth/2)
            textVerticalPosition = 98 + (15 - (textHeight/2))
            draw.text((textHorizontalPosition, textVerticalPosition), imageTitle, fill="white", font=myFont)
            image = image.convert("RGB")
            #convert to png
            validFileName = ''.join(c for c in imageTitle if not c in NonValidChars)
            image.save(os.path.join(directory, validFileName) + ".png", quality=100)
            QtGui.QMessageBox.information(self, "Image Converted", "The image has been converted and is ready for use on the Sifteo Cubes")
開發者ID:nklose,項目名稱:CMPUT302,代碼行數:57,代碼來源:SifteoImageProcessor.py

示例9: MyForm

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        
        ''' Examples of connecting signals (assumes your form has a pushButton, lineEdit, and textEdit)
        self.ui.pushButton.clicked.connect(self.ui.textEdit.clear)
        self.ui.lineEdit.returnPressed.connect(self.add_entry)
        '''
        ''' Example of signal callback (performed when return is pressed on lineEdit, see above)
開發者ID:derricw,項目名稱:Python,代碼行數:13,代碼來源:PyQt4GUIWrapper.py

示例10: main

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
def main():
        #dbProcessor('CREATE', 'localhost','root','levon92','MYDATABASE')
        #dbProcessor('DROP', 'localhost','root','levon92','MYDATABASE')		

        #budgetTbProcessor('CREATE', 'localhost','root','levon92','MYDATABASE')
        #budgetTbProcessor('DROP', 'localhost','root','levon92','MYDATABASE')		

	app  =  QApplication(sys.argv)
	window  =  QMainWindow()
	ui =  Ui_MainWindow()
	ui.setupUi(window)
	
	
	window.show()

	ui.ADD_btn.clicked.connect(lambda: add(ui))
	ui.REPORT_ALL_btn.clicked.connect(lambda: report_all(ui))
	ui.REMOVE_btn.clicked.connect(lambda: remove(ui))
	ui.BALANCE_btn.clicked.connect(lambda: balance(ui))
	ui.EXIT_btn.clicked.connect(lambda: ex(ui))
	sys.exit(app.exec_())
開發者ID:levensg,項目名稱:BudgetImplementation,代碼行數:23,代碼來源:Budget.py

示例11: GStatusSetter

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class GStatusSetter(QtGui.QMainWindow):
	def __init__(self):
		super(GStatusSetter, self).__init__()
		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)
		self.show()
		self.thread = None
		self.ui.start.clicked.connect(self.start)
		self.ui.stop.clicked.connect(self.stop)

	def start(self):
		self.enabled = True
		self.interval = int(self.ui.interval.text())
		self.index = 0
		self.statuses = self.ui.statuses.toPlainText().split('\n')
		if self.thread == None:
			self.thread = threading.Thread(target=self.run)
			self.thread.start()

	def run(self):
		while self.enabled:
			self.setStatus(self.statuses[self.index])
			self.index = (self.index + 1) % len(self.statuses)
			time.sleep(self.interval)
		self.thread = None
	
	def stop(self):
		self.enabled = False

	def setStatus(self, statusmsg):
		client = Client(server='gmail.com', debug=[])
		if not client.connect(server=('talk.google.com', 5222)):
			raise IOError('Cannot connect to server')
		if not client.auth(self.ui.username.text(), self.ui.password.text(), 'gmail.com'):
			raise IOError('Authentication failed')
		client.send(Iq('set', 'google:shared-status', payload=[
					Node('show', payload=['dnd']),
					Node('status', payload=[statusmsg])
					]))
		client.disconnect()
開發者ID:sathyamvellal,項目名稱:gstatus-changer,代碼行數:42,代碼來源:main.py

示例12: loadConfig

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]

#.........這裏部分代碼省略.........
			return	
		msg = mess.getBody()
		patern = re.compile('^#(getkey|sendkey|mesg|getlastmesg) ?(.*)')
		res = patern.search(msg)
		if res:
			#Проверка
			a = res.groups()[0]
			if a == "getkey":
				self.sendKey(mess.getFrom())
				if  self.crypt.hasKey(mess.getFrom())!=False:
					conn.send(mess.getFrom(),"#getkey")	
			elif a == "sendkey":
				if res.groups()[1]!='':
					a = self.crypt.decodeKey(res.groups()[1].decode("hex"))
					self.crypt.saveKey(mess.getFrom().getStripped(),a)
			elif a == "mesg":
				decryptMess = self.crypt.decryptMesg(res.groups()[1])
				if decryptMess=="#errorDecrypt":
					self.sendKey(mess.getFrom())
					self.print_("Error decrypt sendKey")
				else:
					self.print_(self.to+"--> "+decryptMess)
			elif a == "getlastmesg*":
				print a
	def print_(self,text):
		self.ui.textBrowser.append(text)
	def sendKey(self,to):
		#Берем публичный ключ и прегоняем его в hex и отправляем
		key = '#sendkey '+ self.crypt.pubKey.save_pkcs1(format='DER').encode('hex')
		self.jb.send(to,key)
	def sendMsg(self):
		#Ужастная функция с костылем которая прверяет наличие ключа
		#При наличии отправляет собщение иначе иницирует обмен ключами
		if self.crypt.hasKey(self.to)==False:
			self.getKey(self.to)
			return
		text = unicode(self.ui.lineEdit.text().toUtf8(), "utf-8")	
		if text=="":
			return
		print text
		acam = ""
		#Проблема модуля шифрования в ограничении длины строки, поэтому костыль
		while(len(text)>0):
			if(len(text)>29):
				cutText = text[0:29]
				text = text[29:]
			else:
				cutText = text
				text = ""

			mes = self.crypt.cryptMesg(self.to,cutText)
			self.ui.lineEdit.clear()
			self.jb.send(self.to,"#mesg "+mes)
			acam = acam + cutText
		self.print_(self.to+"<-- "+acam)
	def setToRow(self,alpha):
		#Устанавливаем кому отправлять сообещния, в списке делаем его в фокусе
		self.to = unicode(self.ui.listWidget.item(alpha).text().toUtf8(), "utf-8")
		self.ui.lineEdit.setFocus()
		self.print_("Now mesg to "+self.to)
	def __init__(self):
		#Первым делом загрузим настройки
		self.loadConfig()
		#Создадим объект для шифорования
		self.crypt = Crypt()
		
		#Создадим и подключимся к жабберу
		self.jb = sjabber(self.xmpp_jid,self.xmpp_pwd)
		self.jb.connect()
		
		#Зададим колбек для приходящих сообщений
		self.jb.setCB(self.messageCB)

		#Создадим Qt обработчик событий для графики
		self.app = QApplication(sys.argv)

		self.window = QMainWindow()
		self.ui = Ui_MainWindow()
		self.ui.setupUi(self.window)
		#Подключим сигналы нажатия на кнопку отправить и нажатие энтер
		self.ui.pushButton.clicked.connect(self.sendMsg)
		self.ui.lineEdit.returnPressed.connect(self.sendMsg)

		self.window.show()

		#А теперь заполним юзерлист 
		userList = self.jb.userList()
		for i in userList:
			self.ui.listWidget.addItem(i)	
		#Меняем пользователя для отправки собщения
		self.ui.listWidget.currentRowChanged.connect(self.setToRow)
		#Выберем по умолчанию первого пользователя
		self.ui.listWidget.setCurrentRow(0)

		#Создадим рабочего который будет "дергать" обработчик жаббера
		self.workThread = WorkThread()
		self.workThread.setWorker(self.jb)
		self.workThread.start()
		#собственно запускаем обработчик сигналов и ожидаем его завершения
		sys.exit(self.app.exec_())
開發者ID:Gordey,項目名稱:rsaChat,代碼行數:104,代碼來源:core.py

示例13: MyForm

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class MyForm(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.popup = SubForm()
        self._files = None

        #buttons
        self.ui.browsebutton.clicked.connect(self.set_directory)
        self.ui.clearbutton.clicked.connect(self.clear_directory)
        self.ui.define_inout.clicked.connect(self.get_inout)
        self.ui.scriptlist.itemClicked.connect(self.doFile)
        self.ui.exportbutton.clicked.connect(self.writetoFile)

    def writetoFile(self):
        path = QFileDialog.getSaveFileName()
        f = open(path, 'w')
        f.write(str(self))
        f.close()


    def reset(self, listoftuples):
        if (self._files != None):
            self._files.createAlltests(listoftuples)
            self._files.runTests()

    def doFile(self):
        index = self.ui.scriptlist.currentRow()
        b = self._files._files[index]
        self.ui.StatusBox.setText(str(b))
        count = check_comments(b._filename)
        self.ui.linenumbers.setText(str(count._linecount))
        self.ui.commentnumbers.setText(str(count._commentcount))
        self.ui.functionnumbers.setText(str(count._functioncount))
        t = tabulate(b.getResults(), linecount=count._linecount, commentcount=count._commentcount, functioncount=count._functioncount, correctweight= int(self.ui.correctweight.text()), wrongweight = int(self.ui.incorrectweight.text()), errorweight = int(self.ui.errorweight.text()), commentfreq= int(self.ui.comment_freq.text()), functionfreq= int(self.ui.avg_func_len.text()), includeComments= self.ui.commentcheck.checkState(), includeFunctions= self.ui.functioncheck.checkState())
        self.ui.Total_score.setText(str(t.getScore()))
        self.ui.IO_score.setText(str(t.getIOScore()))
        self.ui.correctnum.setText(str(t._correctraw))
        self.ui.errornum.setText(str(t._errorraw))
        self.ui.incorrectnum.setText(str(t._incorrectraw))
        if (self.ui.commentcheck.checkState()):
            self.ui.comment_score.setText(str(t.getCommentScore()))
        else:
            self.ui.comment_score.setText("N/A")
        if (self.ui.functioncheck.checkState()):
            self.ui.Function_score.setText(str(t.getFunctionScore()))
        else:
            self.ui.Function_score.setText("N/A")


    def set_directory(self):
        self.ui.directorybox.clear()
        self.ui.directorybox.setText(QFileDialog.getExistingDirectory())
        path = self.ui.directorybox.text()
        self._files = allFiles(path,timeout = int(self.ui.timeout_box.text()), testcases= self.popup.pairlist)
        self._files.runTests()
        self.display_scripts()
	
    def clear_directory(self):
        self.ui.scriptlist.clear()
        self.ui.directorybox.clear()
        
    def display_scripts(self):
        self.ui.scriptlist.clear()
        path = self.ui.directorybox.text()
        os.chdir(path)
        filelist = os.listdir(path)
        
        for i in self._files._files:
            # if(i.endswith('.py')):
            self.ui.scriptlist.addItem(i._filename)
                

        if self.ui.scriptlist.size() != 0:
            self.startsession(path)
            
    def startsession(self, path):
        timelimit = self.ui.timeout_box.text()

        # print('file path: ' + path)
        # print('timeout: ' + timelimit)
        
    def get_inout(self):
        self.popup.show()

    def __str__(self):
        outs = str()
        for b in self._files._files:
            outs += str(b)
            count = check_comments(b._filename)
            outs +="\n\n    Lines: "+str(count._linecount)
            outs +="\n    Comments: "+str(count._commentcount)
            outs +="\n    Functions: "+str(count._functioncount)
            t = tabulate(b.getResults(), linecount=count._linecount, commentcount=count._commentcount, functioncount=count._functioncount, correctweight= int(self.ui.correctweight.text()), wrongweight = int(self.ui.incorrectweight.text()), errorweight = int(self.ui.errorweight.text()), commentfreq= int(self.ui.comment_freq.text()), functionfreq= int(self.ui.avg_func_len.text()), includeComments= self.ui.commentcheck.checkState(), includeFunctions= self.ui.functioncheck.checkState())
            outs+= "\n    Correct: "+str(t._correctraw)
            outs+= "\n    Errors: "+str(t._errorraw)
            outs+= "\n    Incorrect: "+str(t._incorrectraw)

            outs+= "\n    Total Score: "+str(t.getScore())
#.........這裏部分代碼省略.........
開發者ID:nsmith15PCC,項目名稱:cs3cfinal,代碼行數:103,代碼來源:final.py

示例14: MainWindow

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.q = Queue()
        self.task_list = []

        self.check_status_cmd = 'adb devices'
        self.check_status = False
        self.under_autotesting = False        #switch; lock buttons while under autotesting
        self.under_testing = False    #switch; lock buttons while under testing
        self.bgtimer = QTimer()
        self.bgtimer.setInterval(1000)
        self.bgtimer.timeout.connect(lambda:self.update_ui(self.check_status))
        self.bgtimer.start()

        self.ui.btnFirmwareversion.clicked.connect(lambda: self.on_btn(self.ui.btnFirmwareversion))
        self.ui.btnNand.clicked.connect(lambda: self.on_btn(self.ui.btnNand))
        self.ui.btnFirmwareversion_2.clicked.connect(lambda: self.on_btn(self.ui.btnFirmwareversion_2))
        self.ui.btnNand_2.clicked.connect(lambda: self.on_btn(self.ui.btnNand_2))
        self.ui.btnFirmwareversion_3.clicked.connect(lambda: self.on_btn(self.ui.btnFirmwareversion_3))
        self.ui.btnNand_3.clicked.connect(lambda: self.on_btn(self.ui.btnNand_3))
        self.ui.autotest.clicked.connect(lambda: self.on_btn(self.ui.autotest))


        self.auto_test_task = auto_test.AutoTest(self)
        self.auto_test_task.sig_update_ui.connect(self.update_message)
        self.firmware_version_task = firmware_version.FirmwareVersion(self)
        self.task_list.append(self.firmware_version_task)
        self.nand_task = nand.Nand(self)
        self.task_list.append(self.nand_task)
        self.firmware_version_task2 = firmware_version.FirmwareVersion(self)
        self.task_list.append(self.firmware_version_task2)
        self.nand_task2 = nand.Nand(self)
        self.task_list.append(self.nand_task2)
        self.firmware_version_task3 = firmware_version.FirmwareVersion(self)
        self.task_list.append(self.firmware_version_task3)
        self.nand_task3 = nand.Nand(self)
        self.task_list.append(self.nand_task3)
        for task in self.task_list:
            task.sig_update_ui.connect(self.update_message)


    def on_btn(self,button):
        running_btn_name = button.text()
        if running_btn_name == 'Auto Test':
            if self.q.empty():
                for task in self.task_list:
                    self.q.put(task)
            self.auto_test_task.start()

        if running_btn_name == 'Firmwareversion':
            self.firmware_version_task.start()

        if running_btn_name == 'NAND':
            self.nand_task.start()

        if running_btn_name == 'Firmwareversion2':
            self.firmware_version_task2.start()

        if running_btn_name == 'NAND2':
            self.nand_task2.start()

        if running_btn_name == 'Firmwareversion3':
            self.firmware_version_task3.start()

        if running_btn_name == 'NAND3':
            self.nand_task3.start()


    def update_message(self, data):
        self.ui.listWidget.addItem(data)


    def update_ui(self, data):
        adb_result = subprocess.Popen(self.check_status_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
        (output, err) = adb_result.communicate()
        adb_return_code = adb_result.wait()
        check_status = data
        if '2-1' in str(output):
            print('Log: ' + str(adb_return_code) + '; device connected')
            self.check_status = True
            if self.under_autotesting or self.under_testing:
                self.disable_button()
            else:
                self.enable_button()

        else:
            print('Log: ' + str(adb_return_code) + '; decice disconnected')
            self.disable_button()
            self.check_status = False


    def enable_button(self):    #set button enable
        self.ui.autotest.setEnabled(True)
        self.ui.btnFirmwareversion.setEnabled(True)
        self.ui.btnNand.setEnabled(True)
        self.ui.btnFirmwareversion_2.setEnabled(True)
#.........這裏部分代碼省略.........
開發者ID:vincenttjc,項目名稱:cp_test2,代碼行數:103,代碼來源:main_app.py

示例15: Pyssenlit

# 需要導入模塊: from gui import Ui_MainWindow [as 別名]
# 或者: from gui.Ui_MainWindow import setupUi [as 別名]
class Pyssenlit(QObject):

    def __init__(self):
        QObject.__init__(self)

        self.m = Model('example.db')

        self.app = QtGui.QApplication(sys.argv)
        self.window = QtGui.QMainWindow()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self.window)

        self.ui.code.setLexer(QsciLexerPython())


        self.ui.packages.itemSelectionChanged.connect(self.UpdateClasses)
        self.ui.classes.itemClicked.connect(self.ShowImports)
        self.ui.classes.itemSelectionChanged.connect(self.UpdateMethods)
        self.ui.methods.itemSelectionChanged.connect(self.UpdateCode)
        savekey = QtGui.QShortcut(Qt.CTRL + Qt.Key_S, self.ui.code, self.save)
        self.ui.newpackage.clicked.connect(self.newPackage)
        self.ui.newclass.clicked.connect(self.newClass)
        self.ui.newmethod.clicked.connect(self.newMethod)

        #fill packages list
        self.UpdatePackage()

        self.window.show()

        self.app.exec_()


    def __del__(self):
        print 'application closing'
        QObject.__del__(self)
        del self.m

    def UpdatePackage(self):
        self.ui.packages.clear()
        self.ui.classes.clear()
        self.ui.methods.clear()
        self.ui.code.clear()
        res = self.m.getAllPackages()
        itemslist = []
        for row in res:
            item  = QtGui.QTreeWidgetItem()
            item.setText(0,row[2])
            item.setText(1,str(row[0]))
            itemslist.append(item)
            if row[1]==0:
                self.ui.packages.addTopLevelItem(item)
            else:
                itemslist[row[1]-1].addChild(item)
    
    def UpdateClasses(self):
        self.ui.classes.clear()
        self.ui.methods.clear()
        self.ui.code.clear()
        self.currentpackage = self.ui.packages.selectedItems()[0]
        res = self.m.getClassesFromPackage(self.currentpackage.text(0))
        for row in res:
            item = QtGui.QListWidgetItem()
            item.setText(row[2])
            self.ui.classes.addItem(item)

    def ShowImports(self,item):
        name, inherits,imports = self.m.getInfosFromClass(item.text())
        signature = 'class '+name
        if inherits!='':
            signature = signature+'('+inherits+')'
        self.ui.methods.clearSelection()
        self.ui.code.clear()
        self.ui.code.setText(signature)
        self.currentclass = item

    def UpdateMethods(self):
        self.ui.code.clear()
        self.ui.methods.clear()
        
        if len(self.ui.classes.selectedItems()) > 0:
            res = self.m.getMethodsFromClass(self.ui.classes.selectedItems()[0].text())
            for row in res:
                item = QtGui.QListWidgetItem()
                item.setText(row[1])
                self.ui.methods.addItem(item)

    def UpdateCode(self):
        self.ui.code.clear()
        if len(self.ui.methods.selectedItems()) > 0 :
            print self.ui.methods.selectedItems()[0].text()
            code=self.m.getCodeFromMethod(self.ui.methods.selectedItems()[0].text())
            name,args,comments = self.m.getInfosFromMethod(self.ui.methods.selectedItems()[0].text())

            method = ''
            for line in comments.split('\n'):
                method += '#'+line+'\n'
            method += "def "+name+'('
            arguments = args.split(',')
            if len(arguments) > 0:
                if len(arguments)==1:
#.........這裏部分代碼省略.........
開發者ID:Geal,項目名稱:Pyssenlit,代碼行數:103,代碼來源:pyssenlit.py


注:本文中的gui.Ui_MainWindow.setupUi方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。