diff --git a/Esp.py b/Esp.py index 1eed8b4..5f2602c 100644 --- a/Esp.py +++ b/Esp.py @@ -40,15 +40,18 @@ CHIP_ERASE_TIMEOUT = 120 # timeout for full chip erase SYNC_TIMEOUT = 0.1 # timeout for syncing with bootloader -from PyQt4.QtGui import * -from PyQt4.QtCore import * +from PyQt5.QtCore import * + class ESPTool(QObject): + percentchange = pyqtSignal(int) + eraseStartSig = pyqtSignal() + def __init__(self,parent=None): super(ESPTool,self).__init__(parent) def updatePer(self,per): - self.emit(SIGNAL("percentchange"),per) + self.percentchange.emit(per) def eraseStart(self): - self.emit(SIGNAL("eraseStart")) + self.eraseStartSig.emit() esptool=None updateOkReset=None @@ -2438,6 +2441,7 @@ def __call__(self, parser, namespace, value, option_string=None): clk,q,d,hd,cs = values value = (hd << 24) | (cs << 18) | (d << 12) | (q << 6) | clk else: + # FIXME raise argparse.ArgumentError(self, '%s is not a valid spi-connection value. ' + 'Values are SPI, HSPI, or a sequence of 5 pin numbers CLK,Q,D,HD,CS).' % values) setattr(namespace, self.dest, value) diff --git a/check.py b/check.py index bb3f1f3..d288c26 100644 --- a/check.py +++ b/check.py @@ -10,8 +10,9 @@ import zipfile -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * nowIDEVersion ="1.1" nowExamplesVersion="v0.0" @@ -19,6 +20,12 @@ rootDirectoryPath =rootDirectoryPath.replace("\\","/") class checkVersionExampleFire(QThread): + updateThing = pyqtSignal(str, str) + updatePer = pyqtSignal(int) + reflushExamples = pyqtSignal() + changeUpdateFirmwareList = pyqtSignal(dict) + changeIsCheckFirmware = pyqtSignal(bool) + def __init__(self,parent): super(checkVersionExampleFire,self).__init__(parent) self.ui=parent @@ -35,7 +42,7 @@ def __init__(self,parent): self.downloadOk=False self.status=404 - self.connect(self.ui,SIGNAL("exitCheckThread"),self.exitCheckThread) + self.ui.exitCheckThread.connect(self.exitCheckThread) def run(self): global nowExamplesVersion @@ -77,8 +84,7 @@ def run(self): myfile.write(page) myfile.close() - self.emit(SIGNAL("changeIsCheckFirmware"),True) - + self.changeIsCheckFirmware.emit(True) self.system = platform.system()#system check print(self.system) @@ -94,21 +100,25 @@ def run(self): self.firmwareList = jsonmsg['firmware'] self.examplesList = jsonmsg['examples'] - self.emit(SIGNAL("changeUpdateFirmwareList"),self.firmwareList) + self.changeUpdateFirmwareList.emit(self.firmwareList) - self.connect(self.ui,SIGNAL("confirmUpdata"),self.confirmUpdata) + self.ui.confirmUpdata.connect(self.confirmUpdata) #IDE if self.ideList[0]["version"]>nowIDEVersion: print("ide has new version") self.isDownload=True - self.emit(SIGNAL("updateThing"),"update uPyCraft IDE","There is a new version available for uPyCraft, would you like to upgrade now?") + self.updateThing.emit("update uPyCraft IDE", + "There is a new version available for uPyCraft, would you like to upgrade now?") else: #examples if self.examplesList[0]["version"]>nowExamplesVersion: print("examples has new version") self.isDownload=True - self.emit(SIGNAL("updateThing"),"update uPyCraft Examples","There is a new version available for EXAMPLES, would you like to upgrade now?") + self.updateThing.emit("update uPyCraft Examples", + "There is a new version available for EXAMPLES, would you like to upgrade now?" + ) + while 1: if self.isDownload==True: if self.nowDownload=="": @@ -125,7 +135,8 @@ def run(self): if self.examplesList[0]["version"]>nowExamplesVersion: print("examples has new version") - self.emit(SIGNAL("updateThing"),"update uPyCraft Examples","There is a new version available for EXAMPLES, would you like to upgrade now?") + self.updateThing.emit("update uPyCraft Examples", + "There is a new version available for EXAMPLES, would you like to upgrade now?") else: self.isDownload=False elif self.nowDownload == "Examples": @@ -140,7 +151,7 @@ def run(self): for afile in f.namelist(): f.extract(afile,"%s/AppData/Local/uPyCraft"%rootDirectoryPath) f.close() - self.emit(SIGNAL("reflushExamples")) + self.reflushExamples.emit() self.isDownload=False else: break @@ -152,7 +163,7 @@ def exitCheckThread(self): def reDownload(self): if self.reDownloadNum==3: self.downloadOk=False - self.emit(SIGNAL("updatePer"),-1) + self.updatePer.emit(-1) return try: socket.setdefaulttimeout(3) @@ -175,7 +186,8 @@ def confirmUpdata(self,gotoUpdata): elif gotoUpdata=="IDEcancel": if self.examplesList[0]["version"]>nowExamplesVersion: print("examples has new version") - self.emit(SIGNAL("updateThing"),"update uPyCraft Examples","There is a new version available for EXAMPLES, would you like to upgrade now?") + self.updateThing.emit("update uPyCraft Examples", + "There is a new version available for EXAMPLES, would you like to upgrade now?") else: self.isDownload=False elif gotoUpdata=="Examples": @@ -192,10 +204,10 @@ def cbkUpdate(self,blocknum,blocksize,totalsize): self.per=100.0*blocknum*blocksize/self.updateSize if self.per>=100: self.per=100 - self.emit(SIGNAL("updatePer"),self.per) + self.updatePer.emit(self.per) return - self.emit(SIGNAL("updatePer"),self.per) + self.updatePer.emit(self.per) class attentionUpdata(QDialog): def __init__(self,title,labelmsg,parent=None): @@ -220,8 +232,8 @@ def __init__(self,title,labelmsg,parent=None): self.setLayout(layout) self.setFixedSize(500, 100) - self.connect(self.okButton,SIGNAL("clicked()"),self.chooseOk) - self.connect(self.cancelButton,SIGNAL("clicked()"),self.chooseCancel) + self.okButton.clicked.connect(self.chooseOk) + self.cancelButton.clicked.connect(self.chooseCancel) def chooseOk(self): self.close() diff --git a/ctrl.py b/ctrl.py index fd7290b..58e63b5 100644 --- a/ctrl.py +++ b/ctrl.py @@ -7,29 +7,36 @@ import threading import json -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5.QtCore import * + rootDirectoryPath =os.path.expanduser("~") rootDirectoryPath =rootDirectoryPath.replace("\\","/") currentTempPath="%s/AppData/Local/uPyCraft/temp/"%rootDirectoryPath class ctrlAction(QThread): + uiRecvFromCtrl = pyqtSignal(str) + reflushTree = pyqtSignal(str) + checkFiremware = pyqtSignal(str) + loadFileSig = pyqtSignal(str) + deleteBoardFileSig = pyqtSignal(str) + renameDirDeleteDirTab = pyqtSignal(str) + def __init__(self,readWriteUart,readWriteQueue,ctrltouiQueue,parent): super(ctrlAction,self).__init__(parent) self.readWriteUart=readWriteUart self.ui = parent self.currentBoard="esp32" - self.connect(self.ui,SIGNAL("changeCurrentBoard"),self.changeCurrentBoard) + self.ui.changeCurrentBoard.connect(self.changeCurrentBoard) self.ctrltouiQueue=ctrltouiQueue self.ctrltouartQueue=readWriteQueue self.rootDir="" - self.connect(self.readWriteUart,SIGNAL("ctrlRecvUartMsg"),self.ctrlRecvUartMsg) + self.readWriteUart.ctrlRecvUartMsg.connect(self.ctrlRecvUartMsg) self.clear() self.recvAllData="" self.dragDropModel=False - self.connect(self.ui,SIGNAL("changeDragDropModel"),self.changeDragDropModel) + self.ui.changeDragDropModel.connect(self.changeDragDropModel) def run(self): while True: @@ -142,7 +149,7 @@ def importUos(self): if endTime-startTime>3: self.importUosBool=False self.importUosMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"import os timeout") + self.uiRecvFromCtrl.emit("import os timeout") return if self.importUosMsg.find("Traceback")>=0 or self.importUosMsg.find("... ")>=0: @@ -150,7 +157,7 @@ def importUos(self): returnData=self.importUosMsg self.importUosMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),"import os false") + self.uiRecvFromCtrl.emit("import os false") else: self.ctrltouartQueue.put("uitouart:::\x03") time.sleep(0.01) @@ -174,21 +181,21 @@ def getcwd(self): if endTime-startTime>3: self.getcwdBool=False self.getcwdMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"getcwd timeout") + self.uiRecvFromCtrl.emit("getcwd timeout") return if self.getcwdMsg.find("Traceback")>=0 or self.getcwdMsg.find("... ")>=0: self.getcwdBool=False returnData=self.getcwdMsg self.getcwdMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),"getcwd false") + self.uiRecvFromCtrl.emit("getcwd false") else: self.ctrltouartQueue.put("uitouart:::\x03") time.sleep(0.01) return rootDir=self.getcwdMsg.split("\r\n") - self.emit(SIGNAL("uiRecvFromCtrl"),"rootDir:%s"%rootDir[1][1:-1]) + self.uiRecvFromCtrl.emit("rootDir:%s"%rootDir[1][1:-1]) self.rootDir=rootDir[1][1:-1] self.getcwdBool=False self.getcwdMsg="" @@ -305,7 +312,7 @@ def rename(self,oldname,newname): if endTime-startTime>1: self.renameBool=False self.renameMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rename timeout") + self.uiRecvFromCtrl.emit("rename timeout") return if self.renameMsg.find("Traceback")>=0 or self.renameMsg.find("... ")>=0: @@ -313,13 +320,13 @@ def rename(self,oldname,newname): returnData=self.renameMsg self.renameMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rename error") + self.uiRecvFromCtrl.emit("rename error") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rename error") + self.uiRecvFromCtrl.emit("rename error") return isdir=self.renameMsg.split("\r\n") @@ -342,20 +349,20 @@ def rename(self,oldname,newname): if endTime-startTime>1: self.renameBool=False self.renameMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rename file false") + self.uiRecvFromCtrl.emit("rename file false") return if self.renameMsg.find("Traceback")>=0 or self.renameMsg.find("... ")>=0: self.renameBool=False returnData=self.renameMsg self.renameMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),"rename file false") + self.uiRecvFromCtrl.emit("rename file false") else: self.ctrltouartQueue.put("ctrltouart:::\x03") - self.emit(SIGNAL("uiRecvFromCtrl"),"rename file false") + self.uiRecvFromCtrl.emit("rename file false") return - self.emit(SIGNAL("uiRecvFromCtrl"),"rename ok") + self.uiRecvFromCtrl.emit("rename ok") else:#dir self.ctrltouartQueue.put("ctrltouart:::os.listdir(\'%s\')\r\n"%str(oldname)) startTime=time.time() @@ -368,7 +375,7 @@ def rename(self,oldname,newname): if endTime-startTime>1: self.renameBool=False self.renameMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rename dir false1") + self.uiRecvFromCtrl.emit("rename dir false1") return if self.renameMsg.find("Traceback")>=0 or self.renameMsg.find("... ")>=0: @@ -376,10 +383,10 @@ def rename(self,oldname,newname): returnData=self.renameMsg self.renameMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),"rename dir false2") + self.uiRecvFromCtrl.emit("rename dir false2") else: self.ctrltouartQueue.put("ctrltouart:::\x03") - self.emit(SIGNAL("uiRecvFromCtrl"),"rename dir false3") + self.uiRecvFromCtrl.emit("rename dir false3") return inDirFile = self.renameMsg[str(self.renameMsg).find("["):str(self.renameMsg).find("]")+1] @@ -397,12 +404,12 @@ def rename(self,oldname,newname): if dirreturn==False: self.renameBool=False self.renameMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rename false") + self.uiRecvFromCtrl.emit("rename false") return print(self.returnUIinDirFile) - self.emit(SIGNAL("renameDirDeleteDirTab"),self.returnUIinDirFile) + self.renameDirDeleteDirTab.emit(self.returnUIinDirFile) self.renameMsg="" self.ctrltouartQueue.put("ctrltouart:::os.rename(\'%s\',\'%s\')\r\n"%(str(oldname),str(newname))) @@ -416,20 +423,20 @@ def rename(self,oldname,newname): if endTime-startTime>1: self.renameBool=False self.renameMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rename false1") + self.uiRecvFromCtrl.emit("rename false1") return if self.renameMsg.find("Traceback")>=0 or self.renameMsg.find("... ")>=0: self.renameBool=False returnData=self.renameMsg self.renameMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),"rename false2") + self.uiRecvFromCtrl.emit("rename false2") else: self.ctrltouartQueue.put("ctrltouart:::\x03") - self.emit(SIGNAL("uiRecvFromCtrl"),"rename false3") + self.uiRecvFromCtrl.emit("rename false3") return - self.emit(SIGNAL("uiRecvFromCtrl"),"rename ok") + self.uiRecvFromCtrl.emit("rename ok") self.renameBool=False self.renameMsg="" @@ -450,21 +457,21 @@ def createNewDir(self,path,name): if endTime-startTime>1: self.createNewDirBool=False self.createNewDirMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"dir false:time out") + self.uiRecvFromCtrl.emit("dir false:time out") return if self.createNewDirMsg.find("Traceback")>=0 or self.createNewDirMsg.find("... ")>=0: self.createNewDirBool=False returnData=self.createNewDirMsg self.createNewDirMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"dir false:cmd not full") + self.uiRecvFromCtrl.emit("dir false:cmd not full") return - self.emit(SIGNAL("uiRecvFromCtrl"),"newdir ok") + self.uiRecvFromCtrl.emit("newdir ok") self.createNewDirBool=False self.createNewDirMsg="" @@ -482,21 +489,21 @@ def checkFirmware(self): if endTime-startTime>2: self.checkFirmwareBool=False self.checkFirmwareMsg="" - self.emit(SIGNAL("checkFiremware"),"false") + self.checkFiremware.emit("false") return if self.checkFirmwareMsg.find("Traceback")>=0 or self.checkFirmwareMsg.find("... ")>=0: self.checkFirmwareBool=False returnData=self.checkFirmwareMsg self.checkFirmwareMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("checkFiremware"),"false") + self.checkFiremware.emit("false") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("checkFiremware"),"false") + self.checkFiremware.emit("false") return else: - self.emit(SIGNAL("checkFiremware"),self.checkFirmwareMsg) + self.checkFiremware.emit(self.checkFirmwareMsg) self.checkFirmwareMsg="" self.checkFirmwareBool=False return @@ -522,20 +529,20 @@ def setDefaultProg(self,filename): if endTime-startTime>1: self.setDefaultProgBool=False self.setDefaultProgMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default Program open file timeout") + self.uiRecvFromCtrl.emit("set Default Program open file timeout") return if self.setDefaultProgMsg.find("Traceback")>=0 or self.setDefaultProgMsg.find("... ")>=0: self.setDefaultProgBool=False returnData=self.setDefaultProgMsg self.setDefaultProgMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default Program false") + self.uiRecvFromCtrl.emit("set Default Program false") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default Program false") + self.uiRecvFromCtrl.emit("set Default Program false") return self.setDefaultProgMsg="" @@ -562,20 +569,20 @@ def setDefaultProg(self,filename): if endTime-startTime>3: self.setDefaultProgBool=False self.setDefaultProgMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default Program false") + self.uiRecvFromCtrl.emit("set Default Program false") return if self.setDefaultProgMsg.find("Traceback")>=0 or self.setDefaultProgMsg.find("... ")>=0: self.setDefaultProgBool=False returnData=self.setDefaultProgMsg self.setDefaultProgMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default Program false") + self.uiRecvFromCtrl.emit("set Default Program false") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default Program false") + self.uiRecvFromCtrl.emit("set Default Program false") return self.setDefaultProgMsg="" @@ -596,23 +603,23 @@ def setDefaultProg(self,filename): if endTime-startTime>1: self.setDefaultProgBool=False self.setDefaultProgMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default Program false") + self.uiRecvFromCtrl.emit("set Default Program false") return if self.setDefaultProgMsg.find("Traceback")>=0 or self.setDefaultProgMsg.find("... ")>=0: self.setDefaultProgBool=False returnData=self.setDefaultProgMsg self.setDefaultProgMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default Program false") + self.uiRecvFromCtrl.emit("set Default Program false") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default Program false") + self.uiRecvFromCtrl.emit("set Default Program false") return - self.emit(SIGNAL("uiRecvFromCtrl"),"set Default ok") + self.uiRecvFromCtrl.emit("set Default ok") self.setDefaultProgBool=False self.setDefaultProgMsg="" @@ -635,7 +642,7 @@ def deleteMicroBit(self,filename): if endTime-startTime>3: self.deleteFileBool=False self.deleteFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rm file false1") + self.uiRecvFromCtrl.emit("rm file false1") return if self.deleteFileMsg.find("Traceback")>=0 or self.deleteFileMsg.find("... ")>=0: @@ -643,16 +650,16 @@ def deleteMicroBit(self,filename): returnData=self.deleteFileMsg self.deleteFileMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rm file false2") + self.uiRecvFromCtrl.emit("rm file false2") else: self.ctrltouartQueue.put("uitouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rm file false3") + self.uiRecvFromCtrl.emit("rm file false3") return - self.emit(SIGNAL("deleteBoardFileSig"),filename) + self.deleteBoardFileSig.emit(filename) self.deleteFileBool=False self.deleteFileMsg="" @@ -680,7 +687,7 @@ def deleteFile(self,filename): if endTime-startTime>1: self.deleteFileBool=False self.deleteFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"delete error stat timeout") + self.uiRecvFromCtrl.emit("delete error stat timeout") return if self.deleteFileMsg.find("Traceback")>=0 or self.deleteFileMsg.find("... ")>=0: @@ -688,13 +695,13 @@ def deleteFile(self,filename): returnData=self.deleteFileMsg self.deleteFileMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"delete error") + self.uiRecvFromCtrl.emit("delete error") else: self.ctrltouartQueue.put("uitouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"delete error") + self.uiRecvFromCtrl.emit("delete error") return @@ -718,7 +725,7 @@ def deleteFile(self,filename): if endTime-startTime>2: self.deleteFileBool=False self.deleteFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rm file false1") + self.uiRecvFromCtrl.emit("rm file false1") return if self.deleteFileMsg.find("Traceback")>=0 or self.deleteFileMsg.find("... ")>=0: @@ -726,16 +733,16 @@ def deleteFile(self,filename): returnData=self.deleteFileMsg self.deleteFileMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rm file false2") + self.uiRecvFromCtrl.emit("rm file false2") else: self.ctrltouartQueue.put("uitouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rm file false3") + self.uiRecvFromCtrl.emit("rm file false3") return - self.emit(SIGNAL("deleteBoardFileSig"),filename) + self.deleteBoardFileSig.emit(filename) else:#rmdir self.deleteFileMsg="" self.ctrltouartQueue.put("ctrltouart:::os.listdir(\'%s\')\r\n"%str(filename)) @@ -749,7 +756,7 @@ def deleteFile(self,filename): if endTime-startTime>1: self.deleteFileBool=False self.deleteFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rm dir false") + self.uiRecvFromCtrl.emit("rm dir false") return if self.deleteFileMsg.find("Traceback")>=0 or self.deleteFileMsg.find("... ")>=0: @@ -757,13 +764,13 @@ def deleteFile(self,filename): returnData=self.deleteFileMsg self.deleteFileMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rm dir false") + self.uiRecvFromCtrl.emit("rm dir false") else: self.ctrltouartQueue.put("uitouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rm dir false") + self.uiRecvFromCtrl.emit("rm dir false") return inDirFile = "" @@ -781,10 +788,10 @@ def deleteFile(self,filename): if dirreturn==False: self.deleteFileBool=False self.deleteFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rm dir false") + self.uiRecvFromCtrl.emit("rm dir false") return - self.emit(SIGNAL("renameDirDeleteDirTab"),self.returnUIinDirFile) + self.renameDirDeleteDirTab.emit(self.returnUIinDirFile) self.deleteFileMsg="" @@ -799,7 +806,7 @@ def deleteFile(self,filename): if endTime-startTime>1: self.deleteFileBool=False self.deleteFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"rm dir false") + self.uiRecvFromCtrl.emit("rm dir false") return if self.deleteFileMsg.find("Traceback")>=0 or self.deleteFileMsg.find("... ")>=0: @@ -807,16 +814,16 @@ def deleteFile(self,filename): returnData=self.deleteFileMsg self.deleteFileMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rm dir false") + self.uiRecvFromCtrl.emit("rm dir false") else: self.ctrltouartQueue.put("uitouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"rm dir false") + self.uiRecvFromCtrl.emit("rm dir false") return - self.emit(SIGNAL("uiRecvFromCtrl"),"rmdir ok") + self.uiRecvFromCtrl.emit("rmdir ok") self.deleteFileBool=False self.deleteFileMsg="" @@ -871,7 +878,7 @@ def loadFile(self,filename): if endTime-startTime>3: self.loadFileBool=False self.loadFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"open board file timeout") + self.uiRecvFromCtrl.emit("open board file timeout") return if self.loadFileMsg.find("Traceback")>=0 or self.loadFileMsg.find("... ")>=0: @@ -879,13 +886,13 @@ def loadFile(self,filename): returnData=self.loadFileMsg self.loadFileMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"open board file false") + self.uiRecvFromCtrl.emit("open board file false") else: readwriteQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"open board file false") + self.uiRecvFromCtrl.emit("open board file false") return self.loadfileMsg=self.loadFileMsg.replace("\r\n","\r") @@ -925,7 +932,7 @@ def loadFile(self,filename): myfile.write(appendMsg) myfile.close() - self.emit(SIGNAL("loadFileSig"),filename,appendMsg) + self.loadFileSig.emit(filename,appendMsg) self.loadFileMsg="" self.loadFileBool=False @@ -957,7 +964,7 @@ def downloadFile(self,filename): fileHandle=open(filename,'rbU') except Exception: self.downloadFileBool=False - self.emit(SIGNAL("uiRecvFromCtrl"),"no suport for download dir") + self.uiRecvFromCtrl.emit("no suport for download dir") return afile=self.dropDownFileName elif sys.platform=="linux" and filename.find(rootDirectoryPath)<0: @@ -991,11 +998,11 @@ def downloadFile(self,filename): fileHandle.close() self.downloadFileBool=False self.downloadFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"runningFileBreakFalse") + self.uiRecvFromCtrl.emit("runningFileBreakFalse") return - self.emit(SIGNAL("uiRecvFromCtrl"),self.downloadFileMsg) - self.emit(SIGNAL("uiRecvFromCtrl"),"Ready to download this file,please wait!") + self.uiRecvFromCtrl.emit(self.downloadFileMsg) + self.uiRecvFromCtrl.emit("Ready to download this file,please wait!") ################## #open(filename,'w') @@ -1021,7 +1028,7 @@ def downloadFile(self,filename): fileHandle.close() self.downloadFileBool=False self.downloadFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"download false") + self.uiRecvFromCtrl.emit("download false") return if self.downloadFileMsg.find("Traceback")>=0 or self.downloadFileMsg.find("... ")>=0: fileHandle.close() @@ -1029,13 +1036,13 @@ def downloadFile(self,filename): returnData=self.downloadFileMsg self.downloadFileMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"download false") + self.uiRecvFromCtrl.emit("download false") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"download false") + self.uiRecvFromCtrl.emit("download false") return ################## @@ -1050,7 +1057,7 @@ def downloadFile(self,filename): if(str(aline)!="b''"): if self.currentBoard=="microbit": - self.emit(SIGNAL("uiRecvFromCtrl"),".") + self.uiRecvFromCtrl.emit(".") self.downloadFileMsg="" try: aline=aline.decode() @@ -1077,11 +1084,11 @@ def downloadFile(self,filename): aline=aline.replace("\r\n","\r") aline=aline.replace("\n","\r") aline=aline.encode('utf-8') - self.emit(SIGNAL("uiRecvFromCtrl"),".") + self.uiRecvFromCtrl.emit(".") self.downloadFileMsg="" self.ctrltouartQueue.put("ctrltouart:::myfile.write(%s)\r\n"%aline) except: - self.emit(SIGNAL("uiRecvFromCtrl"),".") + self.uiRecvFromCtrl.emit(".") self.downloadFileMsg="" self.ctrltouartQueue.put("ctrltouart:::myfile.write(%s)\r\n"%aline) @@ -1096,7 +1103,7 @@ def downloadFile(self,filename): fileHandle.close() self.downloadFileBool=False self.downloadFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"download false4") + self.uiRecvFromCtrl.emit("download false4") return if self.downloadFileMsg.find("Traceback")>=0 or self.downloadFileMsg.find("... ")>=0: fileHandle.close() @@ -1106,14 +1113,14 @@ def downloadFile(self,filename): self.downFileFalseDeal(afile) if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"download false5") + self.uiRecvFromCtrl.emit("download false5") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) - self.emit(SIGNAL("uiRecvFromCtrl"),"download false6") + self.uiRecvFromCtrl.emit(returnData) + self.uiRecvFromCtrl.emit("download false6") return else: done=1 @@ -1141,7 +1148,7 @@ def downloadFile(self,filename): if endTime-startTime>3: self.downloadFileBool=False self.downloadFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"download false7") + self.uiRecvFromCtrl.emit("download false7") return if self.downloadFileMsg.find("Traceback")>=0 or self.downloadFileMsg.find("... ")>=0: self.downloadFileBool=False @@ -1150,19 +1157,19 @@ def downloadFile(self,filename): self.downFileFalseDeal(afile) if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"download false") + self.uiRecvFromCtrl.emit("download false") else: #self.readuart.serial.ser.write("\x03") self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"download false") + self.uiRecvFromCtrl.emit("download false") return self.downloadFileBool=False self.downloadFileMsg="" - self.emit(SIGNAL("uiRecvFromCtrl"),"download ok") + self.uiRecvFromCtrl.emit("download ok") return def treeWaitUart(self): @@ -1176,7 +1183,7 @@ def treeWaitUart(self): if endTime-startTime>3: self.reflushTreeBool=False self.reflushTreeMsg="" - self.emit(SIGNAL("reflushTree"),"err") + self.reflushTree.emit("err") return "err" def getFileTree(self,dir): @@ -1193,13 +1200,13 @@ def getFileTree(self,dir): self.reflushTreeMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"reflush tree false") + self.uiRecvFromCtrl.emit("reflush tree false") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"reflush tree false") + self.uiRecvFromCtrl.emit("reflush tree false") return "err" filemsg=self.reflushTreeMsg[self.reflushTreeMsg.find("["):self.reflushTreeMsg.find("]")+1] @@ -1229,13 +1236,13 @@ def getFileTree(self,dir): self.reflushTreeMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"reflush tree false") + self.uiRecvFromCtrl.emit("reflush tree false") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"reflush tree false") + self.uiRecvFromCtrl.emit("reflush tree false") return "err" isdir=self.reflushTreeMsg.split("\r\n") @@ -1254,7 +1261,7 @@ def getFileTree(self,dir): else: ret[dir].append(i) except: - self.emit(SIGNAL("uiRecvFromCtrl"),"reflush tree false") + self.uiRecvFromCtrl.emit("reflush tree false") return "err" return ret @@ -1277,13 +1284,13 @@ def getFileTreeBit(self,dir): self.reflushTreeMsg="" if returnData.find("Traceback")>=0: - self.emit(SIGNAL("uiRecvFromCtrl"),returnData) + self.uiRecvFromCtrl.emit(returnData) time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"reflush tree false") + self.uiRecvFromCtrl.emit("reflush tree false") else: self.ctrltouartQueue.put("ctrltouart:::\x03") time.sleep(0.01) - self.emit(SIGNAL("uiRecvFromCtrl"),"reflush tree false") + self.uiRecvFromCtrl.emit("reflush tree false") return "err" filemsg=self.reflushTreeMsg[self.reflushTreeMsg.find("["):self.reflushTreeMsg.find("]")+1] @@ -1343,7 +1350,7 @@ def treeModel(self): self.ui.myDefaultProgram="" pass - self.emit(SIGNAL("reflushTree"),res) + self.reflushTree.emit(res) self.reflushTreeMsg="" self.reflushTreeBool=False @@ -1435,7 +1442,7 @@ def ctrlRecvUartMsg(self,data): self.recvAllData="" return else: - self.emit(SIGNAL("uiRecvFromCtrl"),data) + self.uiRecvFromCtrl.emit(data) diff --git a/graphicsInterface.py b/graphicsInterface.py index 4f65174..1b65d3d 100644 --- a/graphicsInterface.py +++ b/graphicsInterface.py @@ -1,16 +1,17 @@ # -*- coding: utf-8 -* -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * import sys import time import serial import serial.tools.list_ports -if sys.platform=="darwin": - pass -else: - QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8")) +#if sys.platform=="darwin": +# pass +#else: +# QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8")) class findReplaceText(QDialog): def __init__(self,parent=None): @@ -68,8 +69,8 @@ def __init__(self,parent=None): self.saveFileWidget.hide() self.setLayout(saveFileLayout) - self.connect(self.okButton,SIGNAL("clicked()"),self.saveFileEditOk) - self.connect(self.cancelButton,SIGNAL("clicked()"),self.saveFileEditCancle) + self.okButton.clicked.connect(self.saveFileEditOk) + self.cancelButton.clicked.connect(self.saveFileEditCancle) def saveFileEditOk(self): self.close() @@ -94,8 +95,8 @@ def __init__(self,parent=None): self.cancelButton=QPushButton(self.tr("cancel")) - self.connect(self.okButton,SIGNAL("clicked()"),self.renameOk) - self.connect(self.cancelButton,SIGNAL("clicked()"),self.renameCancel) + self.okButton.clicked.connect(self.renameOk) + self.cancelButton.clicked.connect(self.renameCancel) layout=QGridLayout() layout.addWidget(self.nameLabel,0,0) @@ -135,8 +136,8 @@ def __init__(self,parent=None): self.nameWidget.hide() self.setLayout(layout) - self.connect(self.okButton,SIGNAL("clicked()"),self.nameEditOk) - self.connect(self.cancelButton,SIGNAL("clicked()"),self.nameEditCancel) + self.okButton.clicked.connect(self.nameEditOk) + self.cancelButton.clicked.connect(self.nameEditCancel) def nameEditOk(self): self.close() @@ -261,9 +262,9 @@ def __init__(self,parent=None): self.configUpdate=updateConfig() tabWidget=QTabWidget() - tabWidget.setTabPosition(QTabWidget.North); + tabWidget.setTabPosition(QTabWidget.North) tabWidget.addTab(self.configUpdate,"config") - tabWidget.addTab(self.landlocation,"Languare Location") + tabWidget.addTab(self.landlocation,"Language Location") tabWidget.addTab(SerialWidget(self),"Serial") layout.addWidget(tabWidget,1,0) diff --git a/mainComponents.py b/mainComponents.py index 24f8b30..a2e5938 100644 --- a/mainComponents.py +++ b/mainComponents.py @@ -3,9 +3,11 @@ import shutil import time -from PyQt4.QtGui import * -from PyQt4.QtCore import * -from PyQt4.Qsci import QsciScintilla, QsciScintillaBase, QsciLexerPython +from PyQt5.QtGui import * +from PyQt5.QtCore import * +from PyQt5.Qsci import QsciScintilla, QsciScintillaBase, QsciLexerPython +from PyQt5.QtWidgets import * + rootDirectoryPath =os.path.expanduser("~") @@ -13,6 +15,7 @@ currentExamplesPath="%s/AppData/Local/uPyCraft/examples"%rootDirectoryPath class myTerminal(QTextEdit): + customContextMenuRequestedSig = pyqtSignal(QPoint) def __init__(self,queue,parent): super(myTerminal,self).__init__(parent) self.eventFilterEnable=False @@ -49,9 +52,9 @@ def __init__(self,queue,parent): self.ui=parent self.queue=queue self.currentBoard="esp32" - self.connect(self.ui,SIGNAL("changeCurrentBoard"),self.changeBoard) - self.connect(self.ui,SIGNAL("initRecvdata"),self.initRecvdata) - self.connect(self.ui,SIGNAL("initMessycode"),self.initMessycode) + self.ui.changeCurrentBoard.connect(self.changeBoard) + self.ui.initRecvdata.connect(self.initRecvdata) + self.ui.initMessycode.connect(self.initMessycode) self.keyPressMsg="" self.recvdata="" @@ -65,7 +68,7 @@ def __init__(self,queue,parent): def createTerminalRightMenu(self): self.setContextMenuPolicy(Qt.CustomContextMenu) - self.connect(self,SIGNAL("customContextMenuRequested(const QPoint&)"),self.slotTerminalRightClickMenu) + self.customContextMenuRequestedSig.connect(self.slotTerminalRightClickMenu) self.terminalRightMenu=QMenu(self) self.terminalRightMenu.setStyleSheet( """QMenu{background-color:rgb(67,67,67); @@ -75,10 +78,10 @@ def createTerminalRightMenu(self): ) terminalCopy=QAction(QIcon(":/copy.png"),self.tr("copy"),self) - self.connect(terminalCopy,SIGNAL("triggered()"),self.slotCopy) + terminalCopy.triggered.connect(self.slotCopy) terminalPaste=QAction(QIcon(":/copy.png"),self.tr("paste"),self) - self.connect(terminalPaste,SIGNAL("triggered()"),self.slotPaste) + terminalPaste.triggered.connect(self.slotPaste) self.terminalRightMenu.addAction(terminalCopy) self.terminalRightMenu.addAction(terminalPaste) @@ -453,7 +456,7 @@ def mousePressEvent(self,event): self.startCursorPosition =event.pos() self.cursor = self.cursorForPosition(self.startCursorPosition) self.startPosition = self.cursor.position() - self.emit(SIGNAL("setCursor")) + self.setCursor.emit() def mouseMoveEvent(self,event): if event.button()==Qt.NoButton: @@ -473,6 +476,7 @@ def mouseReleaseEvent(self,event): class myTreeView(QTreeView): + customContextMenuRequestedSig = pyqtSignal(QPoint) def __init__(self,parent): super(myTreeView,self).__init__(parent) self.ui=parent @@ -507,7 +511,9 @@ def __init__(self,parent): self.dragFrom="" self.dropDir="" #self.connect(self,SIGNAL("clicked(QModelIndex)"),self.chooseFile) - self.connect(self,SIGNAL("pressed(QModelIndex)"),self.treepressed) + + # self.connect(self,SIGNAL("pressed(QModelIndex)"),self.treepressed) + self.pressed.connect(self.treepressed) def setmodel(self,model): self.setModel(model) @@ -524,25 +530,25 @@ def createRightMenu(self): self.setContextMenuPolicy(Qt.CustomContextMenu) self.runFile=QAction(self.tr("Run"),self) - self.connect(self.runFile,SIGNAL("triggered()"),self.rightMenuRunFile) - + self.runFile.triggered.connect(self.rightMenuRunFile) + self.openFile=QAction(self.tr("Open"),self) - self.connect(self.openFile,SIGNAL("triggered()"),self.rightMenuOpenFile) + self.openFile.triggered.connect(self.rightMenuOpenFile) self.closeFile=QAction(self.tr("Close"),self) - self.connect(self.closeFile,SIGNAL("triggered()"),self.rightMenuCloseFile) - - self.deleteFile=QAction(self.tr("Delete"),self) - self.connect(self.deleteFile,SIGNAL("triggered()"),self.rightMenuDeleteFile) + self.closeFile.triggered.connect(self.rightMenuCloseFile) + + self.deleteFile=QAction(self.tr("Delete"),self) + self.deleteFile.triggered.connect(self.rightMenuDeleteFile) self.defaultProgram=QAction(self.tr("Default Run"),self) - self.connect(self.defaultProgram,SIGNAL("triggered()"),self.rightMenuDefaultProgram) + self.defaultProgram.triggered.connect(self.rightMenuDefaultProgram) self.rename=QAction(self.tr("Rename"),self) - self.connect(self.rename,SIGNAL("triggered()"),self.rightMenuRename) + self.rename.triggered.connect(self.rightMenuRename) self.newDir=QAction(self.tr("New Dir"),self) - self.connect(self.newDir,SIGNAL("triggered()"),self.rightMenuNewDir) + self.newDir.triggered.connect(self.rightMenuNewDir) self.rightClickMenu=QMenu(self) self.rightClickMenu.setStyleSheet( @@ -559,7 +565,7 @@ def createRightMenu(self): self.rightClickMenu.addAction(self.rename) self.rightClickMenu.addAction(self.newDir) - self.connect(self,SIGNAL("customContextMenuRequested(const QPoint&)"),self.slotRightClickMenu) + self.customContextMenuRequestedSig.connect(self.slotRightClickMenu) def slotRightClickMenu(self,point): self.rightClickMenu.clear() @@ -715,7 +721,7 @@ def dropEvent(self,event): if not self.ui.myserial.ser.isOpen(): self.ui.terminal.append("serial not open,can not download file") return - self.ui.emit(SIGNAL("changeDragDropModel"),True) + self.ui.changeDragDropModel.emit(True) self.ui.uitoctrlQueue.put("dropdownfile:::%s:::%s"%(filename,dropDownFileName)) print("filename=%s"%filename) print("dropDownFileName=%s"%dropDownFileName) @@ -785,7 +791,7 @@ def dropEvent(self,event): else: newDropFileName=newDropFileName[7:str(newDropFileName).find(dirListDrop[-1])-1] newDropFileName=self.ui.rootDir+newDropFileName - self.ui.emit(SIGNAL("changeDragDropModel"),True) + self.ui.changeDragDropModel.emit(True) self.ui.uitoctrlQueue.put("dragChangeDir:::%s:::%s"%(oldDragFileName,newDropFileName)) else: pass @@ -813,8 +819,8 @@ def __init__(self,editorRightMenu,fileitem,parent): self.line=0 self.index=0 - self.connect(self, SIGNAL("tabCloseRequested(int)"),self.closeTab) - self.connect(self, SIGNAL("currentChanged(int)"),self.currentTabChange) + self.tabCloseRequested.connect(self.closeTab) + self.currentChanged.connect(self.currentTabChange) def closeTab(self,tabId): if tabId<0: @@ -920,7 +926,7 @@ def createNewTab(self,filename,msg,lexer): editor.setText(msg) editor.setContextMenuPolicy(Qt.CustomContextMenu) - self.connect(editor,SIGNAL("customContextMenuRequested(const QPoint&)"),self.slotEditorRightClickMenu) + editor.customContextMenuRequested.connect(self.slotEditorRightClickMenu) if self.editorRightMenu==None: self.editorRightMenu=QMenu(self) @@ -933,23 +939,23 @@ def createNewTab(self,filename,msg,lexer): undo=QAction(self.tr("Undo"),self) undo.setShortcut("Ctrl+Z") - self.connect(undo,SIGNAL("triggered()"),self.slotUndo) + undo.triggered.connect(self.slotUndo) redo=QAction(self.tr("Redo"),self) redo.setShortcut("Ctrl+Y") - self.connect(redo,SIGNAL("triggered()"),self.slotRedo) + redo.triggered.connect(self.slotRedo) cut=QAction(self.tr("Cut"),self) cut.setShortcut("Ctrl+X") - self.connect(cut,SIGNAL("triggered()"),self.slotCut) + cut.triggered.connect(self.slotCut) copy=QAction(self.tr("Copy"),self) copy.setShortcut("Ctrl+C") - self.connect(copy,SIGNAL("triggered()"),self.slotCopy) + copy.triggered.connect(self.slotCopy) paste=QAction(self.tr("Paste"),self) paste.setShortcut("Ctrl+V") - self.connect(paste,SIGNAL("triggered()"),self.slotPaste) + paste.triggered.connect(self.slotPaste) self.editorRightMenu.addAction(undo) self.editorRightMenu.addAction(redo) @@ -1001,13 +1007,13 @@ def createNewTab(self,filename,msg,lexer): self.fileitem.list.append(filename) - self.connect(editor,SIGNAL("dragOpenFile"),self.dragOpenFile) + editor.dragOpenFile.connect(self.dragOpenFile) - self.connect(editor,SIGNAL("textChanged()"),self.editorTextChange) - self.connect(editor,SIGNAL("selectionChanged()"),self.selectionChanged) - self.connect(editor,SIGNAL("linesChanged()"),self.linesChanged) - self.connect(editor,SIGNAL("cursorPositionChanged(int,int)"),self.cursorPositionChanged) - self.connect(editor,SIGNAL("userListActivated(int,const QString)"),self.userListActivated) + editor.textChanged.connect(self.editorTextChange) + editor.selectionChanged.connect(self.selectionChanged) + editor.linesChanged.connect(self.linesChanged) + editor.cursorPositionChanged.connect(self.cursorPositionChanged) + editor.userListActivated.connect(self.userListActivated) #self.connect(editor,SIGNAL("SCN_AUTOCSELECTION(const char*,int)"),self.scn_updateui) def slotEditorRightClickMenu(self,point): @@ -1157,6 +1163,14 @@ def dragOpenFile(self,filename): self.ui.pcOpenFile(filename) class myQsciScintilla(QsciScintilla): + customContextMenuRequested = pyqtSignal() + dragOpenFile = pyqtSignal(str) + textChanged = pyqtSignal() + selectionChanged = pyqtSignal() + linesChanged = pyqtSignal() + cursorPositionChanged = pyqtSignal(int, int) + userListActivated = pyqtSignal(int, str) + def __init__(self,parent=None): super(myQsciScintilla,self).__init__(parent) @@ -1175,7 +1189,7 @@ def dropEvent(self,event): dropOpenFileName="" for url in urls: dropOpenFileName=url.toLocalFile() - self.emit(SIGNAL("dragOpenFile"),dropOpenFileName) + self.dragOpenFile.emit(dropOpenFileName) diff --git a/qrc_resources.py b/qrc_resources.py index 82b04a7..2fb9099 100644 --- a/qrc_resources.py +++ b/qrc_resources.py @@ -6,7 +6,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore +from PyQt5 import QtCore qt_resource_data = b"\ \x00\x00\x02\xc4\ diff --git a/readWriteUart.py b/readWriteUart.py index b4aee16..6f3da68 100644 --- a/readWriteUart.py +++ b/readWriteUart.py @@ -5,10 +5,14 @@ import time import threading -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * class readWriteUart(QThread): + ctrlRecvUartMsg = pyqtSignal(str) + uiRecvFromUart = pyqtSignal(str) + def __init__(self,queue,parent): super(readWriteUart,self).__init__(parent) self.ui=parent @@ -18,7 +22,7 @@ def __init__(self,queue,parent): self.queue=queue self.maybeCN=b"" self.currentBoard="esp32" - self.connect(self.ui,SIGNAL("changeCurrentBoard"),self.changeCurrentBoard) + self.ui.changeCurrentBoard.connect(self.changeCurrentBoard) def run(self): readNum=0 @@ -49,7 +53,7 @@ def run(self): if self.writemsg.decode()=="\x03": self.lastmodel="" elif self.lastmodel=="exec_": - self.emit(SIGNAL("uiRecvFromUart"),"program is running,do anything with stop it!1\n") + self.uiRecvFromUart.emit("program is running,do anything with stop it!1\n") continue try: self.ui.myserial.ser.write(self.writemsg) @@ -61,7 +65,7 @@ def run(self): break elif self.model=="ctrltouart": if self.lastmodel=="exec_": - self.emit(SIGNAL("uiRecvFromUart"),"program is running,do anything with stop it!2\n") + self.uiRecvFromUart.emit("program is running,do anything with stop it!2\n") self.model="uitouart" continue try: @@ -74,7 +78,7 @@ def run(self): break elif self.model=="exec_": if self.lastmodel=="exec_": - self.emit(SIGNAL("uiRecvFromUart"),"program is running,do anything with stop it!3\n") + self.uiRecvFromUart.emit("program is running,do anything with stop it!3\n") self.model="uitouart" continue self.lastmodel="exec_" @@ -106,7 +110,7 @@ def run(self): execSendData="" self.lastmodel="" - self.emit(SIGNAL("uiRecvFromUart"),data) + self.uiRecvFromUart.emit(data) #if self.ui.myserial.ser.inWaiting()>=128: # self.ui.myserial.ser.flushInput() @@ -125,7 +129,7 @@ def run(self): elif execSendData.find(">>> ")>=0: execSendData="" self.lastmodel="" - self.emit(SIGNAL("uiRecvFromUart"),data) + self.uiRecvFromUart.emit(data) if self.ui.myserial.ser.inWaiting()>=128: self.ui.myserial.ser.flushInput() elif self.model=="ctrltouart": @@ -197,14 +201,14 @@ def run(self): if data=="" or data==None: readNum+=1 if readNum==6: - self.emit(SIGNAL("ctrlRecvUartMsg"),sendData) + self.ctrlRecvUartMsg.emit(sendData) sendData="" readNum=0 else: sendData+=data readNum=0 else: - self.emit(SIGNAL("uiRecvFromUart"),"error read model") + self.uiRecvFromUart.emit("error read model") else: time.sleep(0.01) diff --git a/threadDownloadFirmware.py b/threadDownloadFirmware.py index 03ab9ee..aca44ab 100644 --- a/threadDownloadFirmware.py +++ b/threadDownloadFirmware.py @@ -4,19 +4,22 @@ import sys import time import threading -import Esp +import uPyCraft_src.Esp import urllib from urllib import request import socket import shutil import codecs - -#from PyQt4 import QtGui, QtCore -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5.QtCore import * +from uPyCraft_src.Esp import ESPTool, Burn, downOkReset class threadUserFirmware(QThread): + firmwareAnyDown = pyqtSignal(int) + firmwareAnyUpdate = pyqtSignal(int) + firmwareAnyErase = pyqtSignal(int) + goMicrobitUpdate = pyqtSignal() + def __init__(self, board, savepath, com, iserase, size, addr, parent): super(threadUserFirmware,self).__init__(parent) @@ -37,44 +40,46 @@ def __init__(self, board, savepath, com, iserase, size, addr, parent): print("burnaddr=====%d"%self.burnaddr) def run(self): - esptool=Esp.ESPTool() - self.connect(esptool,SIGNAL("percentchange"),self.updateFirmwarePer) - self.connect(esptool,SIGNAL("eraseStart"),self.eraseStart) + esptool=ESPTool() + esptool.percentchange.connect(self.updateFirmwarePer) + + esptool.eraseStartSig.connect(self.eraseStart) if self.iserase=="yes": self.erasetimer=threading.Timer(0.1,self.eraseTimer) self.erasetimer.start() try: - Esp.Burn(esptool,str(self.board),self.savepath,self.com,True) + Burn(esptool,str(self.board),self.savepath,self.com,True) time.sleep(1) self.erasePer=100 - self.emit(SIGNAL("firmwareAnyErase"),self.erasePer) + self.firmwareAnyErase.emit(self.erasePer) self.erasetimer.cancel() except: time.sleep(1) self.erasePer=-1 - self.emit(SIGNAL("firmwareAnyErase"),self.erasePer) + self.firmwareAnyErase.emit(self.erasePer) self.erasetimer.cancel() self.erasestart=False self.exit() return if self.iserase=="yes": - self.emit(SIGNAL("firmwareAnyErase"),100) + self.firmwareAnyErase.emit(100) try: if self.board=="esp32" or self.board=="esp8266" or self.board=="TPYBoardV202": - Esp.Burn(esptool,str(self.board),self.savepath,self.com,False,self.burnaddr) + Burn(esptool,str(self.board),self.savepath,self.com,False,self.burnaddr) else:#microbit print("In threaddownloadfirmware:savepath=%s"%self.savepath) - self.emit(SIGNAL("firmwareAnyUpdate"),-2) + self.firmwareAnyErase.emit(-2) time.sleep(0.5) - self.emit(SIGNAL("goMicrobitUpdate")) + self.goMicrobitUpdate.emit() + except: - self.emit(SIGNAL("firmwareAnyUpdate"),-1) + self.firmwareAnyUpdate.emit(-1) self.exit() return if self.board=="esp8266": - Esp.downOkReset() + downOkReset() self.exit() @@ -86,14 +91,14 @@ def cbdownFramware(self,blocknum,blocksize,totalsize): per=100.0*blocknum*blocksize/self.size if per>=100: per=100 - self.emit(SIGNAL("firmwareAnyDown"),per) + self.firmwareAnyDown.emit(per) return - self.emit(SIGNAL("firmwareAnyDown"),per) + self.firmwareAnyDown.emit(per) def updateFirmwarePer(self,per): print("updateFirmwarePer:%d"%per) - self.emit(SIGNAL("firmwareAnyUpdate"),per) + self.firmwareAnyUpdate.emit(per) def eraseStart(self): self.erasestart=True @@ -104,15 +109,20 @@ def eraseTimer(self): if self.erasePer>=99: self.erasePer=99 - self.emit(SIGNAL("firmwareAnyErase"),self.erasePer) + self.firmwareAnyErase.emit(self.erasePer) self.erasestart=False return - self.emit(SIGNAL("firmwareAnyErase"),self.erasePer) + self.firmwareAnyErase.emit(self.erasePer) self.erasetimer=threading.Timer(0.1,self.eraseTimer) self.erasetimer.start() class threadDownloadFirmware(QThread): + firmwareAnyDown = pyqtSignal(int) + firmwareAnyUpdate = pyqtSignal(int) + firmwareAnyErase = pyqtSignal(int) + goMicrobitUpdate = pyqtSignal() + def __init__(self, url, board, savepath, com, iserase, size, addr, parent): super(threadDownloadFirmware,self).__init__(parent) self.url=url @@ -141,51 +151,51 @@ def run(self): self.reDownload() if self.downloadOk==True: - esptool=Esp.ESPTool() - self.connect(esptool,SIGNAL("percentchange"),self.updateFirmwarePer) - self.connect(esptool,SIGNAL("eraseStart"),self.eraseStart) + esptool=ESPTool() + esptool.percentchange.connect(self.updateFirmwarePer) + esptool.eraseStartSig.connect(self.eraseStart) if self.iserase=="yes": self.erasetimer=threading.Timer(0.1,self.eraseTimer) self.erasetimer.start() try: - Esp.Burn(esptool,str(self.board),self.savepath,self.com,True) + Burn(esptool,str(self.board),self.savepath,self.com,True) time.sleep(1) self.erasePer=100 - self.emit(SIGNAL("firmwareAnyErase"),self.erasePer) + self.firmwareAnyErase.emit(self.erasePer) self.erasetimer.cancel() except: time.sleep(1) self.erasePer=-1 - self.emit(SIGNAL("firmwareAnyErase"),self.erasePer) + self.firmwareAnyErase.emit(self.erasePer) self.erasetimer.cancel() self.erasestart=False self.exit() return if self.iserase=="yes": - self.emit(SIGNAL("firmwareAnyErase"),100) + self.firmwareAnyErase.emit(100) try: if self.board=="esp32" or self.board=="esp8266" or self.board=="TPYBoardV202": - Esp.Burn(esptool,str(self.board),self.savepath,self.com,False,self.burnaddr) + Burn(esptool,str(self.board),self.savepath,self.com,False,self.burnaddr) else:#microbit print("In threaddownloadfirmware:savepath=%s"%self.savepath) - self.emit(SIGNAL("firmwareAnyUpdate"),-2) + self.firmwareAnyUpdate.emit(-2) time.sleep(0.5) - self.emit(SIGNAL("goMicrobitUpdate")) + self.goMicrobitUpdate.emit() except: - self.emit(SIGNAL("firmwareAnyUpdate"),-1) + self.firmwareAnyUpdate.emit(-1) self.exit() return if self.board=="esp8266" or self.board=="TPYBoardV202": - Esp.downOkReset() + downOkReset() self.exit() def reDownload(self): if self.reDownloadNum==3: self.downloadOk=False - self.emit(SIGNAL("firmwareAnyDown"),-1) + self.firmwareAnyDown.emit(-1) return try: socket.setdefaulttimeout(5) @@ -207,14 +217,14 @@ def cbdownFramware(self,blocknum,blocksize,totalsize): per=100.0*blocknum*blocksize/self.size if per>=100: per=100 - self.emit(SIGNAL("firmwareAnyDown"),per) + self.firmwareAnyDown.emit(per) return - self.emit(SIGNAL("firmwareAnyDown"),per) + self.firmwareAnyDown.emit(per) def updateFirmwarePer(self,per): print("updateFirmwarePer:%d"%per) - self.emit(SIGNAL("firmwareAnyUpdate"),per) + self.firmwareAnyUpdate.emit(per) def eraseStart(self): self.erasestart=True @@ -225,10 +235,10 @@ def eraseTimer(self): if self.erasePer>=99: self.erasePer=99 - self.emit(SIGNAL("firmwareAnyErase"),self.erasePer) + self.firmwareAnyErase.emit(self.erasePer) self.erasestart=False return - self.emit(SIGNAL("firmwareAnyErase"),self.erasePer) + self.firmwareAnyErase.emit(self.erasePer) self.erasetimer=threading.Timer(0.1,self.eraseTimer) self.erasetimer.start() diff --git a/uPyCraft.py b/uPyCraft.py index 93f7ea6..b2b8977 100644 --- a/uPyCraft.py +++ b/uPyCraft.py @@ -1,21 +1,21 @@ # -*- coding: utf-8 -*- -from PyQt4.QtGui import * -from PyQt4.QtCore import * -from PyQt4 import Qsci -from PyQt4.Qsci import QsciScintilla, QsciScintillaBase, QsciLexerPython +from PyQt5.QtGui import * +from PyQt5.QtCore import * +from PyQt5 import Qsci +from PyQt5.Qsci import QsciScintilla, QsciScintillaBase, QsciLexerPython +from PyQt5.QtWidgets import * import binascii -import PyQt4 import queue import base64 import sys import math import json import os -import Esp +import uPyCraft_src.Esp import shutil import webbrowser -import qrc_resources +import uPyCraft_src.qrc_resources import time import platform import threading @@ -29,17 +29,17 @@ from urllib import request from pyflakes.api import main as pyflakesMain -from graphicsInterface import saveUntitled, createBoardNewDirName, findReplaceText, \ +from uPyCraft_src.graphicsInterface import saveUntitled, createBoardNewDirName, findReplaceText, \ SerialWidget, LanLocWidget, Preferences, treeRightClickRename -from readWriteUart import readWriteUart -from ctrl import ctrlAction -from updateNewFirmware import updateNewFirmware, updateNewFirmwareBar -from mainComponents import myTerminal,myTreeView,myTabWidget -from check import checkVersionExampleFire, attentionUpdata, ProgressIDEorExampleBar -from threadDownloadFirmware import threadDownloadFirmware, threadUserFirmware -from microbit_api import MICROPYTHON_APIS +from uPyCraft_src.readWriteUart import readWriteUart +from uPyCraft_src.ctrl import ctrlAction +from uPyCraft_src.updateNewFirmware import updateNewFirmware, updateNewFirmwareBar +from uPyCraft_src.mainComponents import myTerminal,myTreeView,myTabWidget +from uPyCraft_src.check import checkVersionExampleFire, attentionUpdata, ProgressIDEorExampleBar +from uPyCraft_src.threadDownloadFirmware import threadDownloadFirmware, threadUserFirmware +from uPyCraft_src.microbit_api import MICROPYTHON_APIS -from SourceCodePro import SourceCodePro +from uPyCraft_src.SourceCodePro import SourceCodePro mainShow=True nowIDEVersion ="1.1" @@ -77,6 +77,19 @@ def __init__(self): self.list=[] class MainWidget(QMainWindow): + changeCurrentBoard = pyqtSignal(str) + changeDragDropModel = pyqtSignal(bool) + setCursor = pyqtSignal() + timerCloseTerminalSig = pyqtSignal() + timerAddComMenuSig = pyqtSignal(str) + timerSetComMenuSig = pyqtSignal(str) + timerClearComMenuSig = pyqtSignal() + exitCheckThread = pyqtSignal() + confirmUpdata = pyqtSignal(str) + changeDragDropModel = pyqtSignal(bool) + initRecvdata = pyqtSignal() + initMessycode = pyqtSignal() + def __init__(self,parent=None): super(MainWidget,self).__init__(parent) #self.setWindowFlags(Qt.WindowCloseButtonHint)#HelpButtonHint? @@ -99,6 +112,8 @@ def __init__(self,parent=None): self.workspacePath="" self.canNotIdentifyBoard=False + + #self.setStyleSheet("background-color: rgb(254, 138, 58);") self.clipboard=QApplication.clipboard() @@ -156,33 +171,33 @@ def __init__(self,parent=None): #thread self.readuart=readWriteUart(self.readwriteQueue,self) - self.connect(self.readuart,SIGNAL("uiRecvFromUart"),self.uiRecvFromUart) + self.readuart.uiRecvFromUart.connect(self.uiRecvFromCtrl) self.ctrl=ctrlAction(self.readuart,self.readwriteQueue,self.uitoctrlQueue,self) - self.connect(self.ctrl,SIGNAL("uiRecvFromCtrl"),self.uiRecvFromCtrl) - self.connect(self.ctrl,SIGNAL("reflushTree"),self.reflushTree) - self.connect(self.ctrl,SIGNAL("checkFiremware"),self.checkFiremware) - self.connect(self.ctrl,SIGNAL("loadFileSig"),self.loadFileSig) - self.connect(self.ctrl,SIGNAL("deleteBoardFileSig"),self.deleteBoardFileSig) - self.connect(self.ctrl,SIGNAL("renameDirDeleteDirTab"),self.renameDirDeleteDirTab) + self.ctrl.uiRecvFromCtrl.connect(self.uiRecvFromCtrl) + self.ctrl.reflushTree.connect(self.reflushTree) + self.ctrl.checkFiremware.connect(self.checkFiremware) + self.ctrl.loadFileSig.connect(self.loadFileSig) + self.ctrl.deleteBoardFileSig.connect(self.deleteBoardFileSig) + self.ctrl.renameDirDeleteDirTab.connect(self.renameDirDeleteDirTab) #self.connect(self.ctrl,SIGNAL("intoFuncSig"),self.intoFuncSig) #timer for serial check self.timerClose=False global timer timer=threading.Timer(1,self.fun_timer) - self.connect(self,SIGNAL("timerCloseTerminal"),self.timerCloseTerminal) - self.connect(self,SIGNAL("timerAddComMenu"),self.timerAddComMenu) - self.connect(self,SIGNAL("timerSetComMenu"),self.timerSetComMenu) - self.connect(self,SIGNAL("timerClearComMenu"),self.timerClearComMenu) + self.timerCloseTerminalSig.connect(self.timerCloseTerminal) + self.timerAddComMenuSig.connect(self.timerAddComMenu) + self.timerSetComMenuSig.connect(self.timerSetComMenu) + self.timerClearComMenuSig.connect(self.timerAddComMenu) timer.start() #check version(IDE,examples) self.check=checkVersionExampleFire(self) - self.connect(self.check,SIGNAL("updateThing"),self.updateThing) - self.connect(self.check,SIGNAL("updatePer"),self.updataPer) - self.connect(self.check,SIGNAL("reflushExamples"),self.reflushExamples) - self.connect(self.check,SIGNAL("changeUpdateFirmwareList"),self.changeUpdateFirmwareList) - self.connect(self.check,SIGNAL("changeIsCheckFirmware"),self.setIsCheckFirmware) + self.check.updateThing.connect(self.updateThing) + self.check.updatePer.connect(self.updataPer) + self.check.reflushExamples.connect(self.reflushExamples) + self.check.changeUpdateFirmwareList.connect(self.changeUpdateFirmwareList) + self.check.changeIsCheckFirmware.connect(self.setIsCheckFirmware) self.check.start() @@ -231,7 +246,8 @@ def setFont(self): def createTree(self): self.tree=myTreeView(self) - self.connect(self.tree,SIGNAL("doubleClicked(QModelIndex)"),self.slotTreeDoubleClickOpenFile) + # self.connect(self.tree,SIGNAL("doubleClicked(QModelIndex)"),self.slotTreeDoubleClickOpenFile) + self.tree.doubleClicked.connect(self.slotTreeDoubleClickOpenFile) self.rootDevice=QStandardItem(QIcon(":/treeMenuClosed.png"),"device") self.rootSD=QStandardItem(QIcon(":/treeMenuClosed.png"),"sd") @@ -279,10 +295,11 @@ def createTerminal(self): self.cursor=self.terminal.textCursor() self.cursorLeftOrRight=0 self.moveposition=0 - - self.connect(self.terminal,SIGNAL("cursorPositionChanged()"),self.slotTerminalCursorChanged) - self.connect(self.terminal,SIGNAL("setCursor"),self.slotTerminalSetCursor) - + + self.terminal.cursorPositionChanged.connect(self.slotTerminalCursorChanged) + self.terminal.setCursor = self.setCursor + self.terminal.setCursor.connect(self.slotTerminalSetCursor) + def createTabWidget(self): self.tabWidget=myTabWidget(self.editorRightMenu,self.fileitem,self) self.tabWidget.setTabsClosable(True) @@ -352,49 +369,50 @@ def createActions(self): self.fileOpenAction=QAction(self.tr("Open"),self) self.fileOpenAction.setShortcut("Ctrl+O") self.fileOpenAction.setStatusTip(self.tr("open a new file")) - self.connect(self.fileOpenAction,SIGNAL("triggered()"),self.slotOpenFile) + + self.fileOpenAction.triggered.connect(self.slotOpenFile) self.fileOpenToolsAction=QAction(QIcon(":/fileOpen.png"),self.tr("Open"),self) #self.fileOpenToolsAction.setShortcut("Ctrl+O") self.fileOpenToolsAction.setStatusTip(self.tr("open a new file")) - self.connect(self.fileOpenToolsAction,SIGNAL("triggered()"),self.slotOpenFile) + self.fileOpenToolsAction.triggered.connect(self.slotOpenFile) #self.fileNewAction=QAction(QIcon(":/newFile.png"),self.tr("New"),self) self.fileNewAction=QAction(self.tr("New"),self) self.fileNewAction.setShortcut("Ctrl+N") self.fileNewAction.setStatusTip(self.tr("create a new file")) - self.connect(self.fileNewAction,SIGNAL("triggered()"),self.slotNewFile) + self.fileNewAction.triggered.connect(self.slotNewFile) self.fileNewToolsAction=QAction(QIcon(":/newFile.png"),self.tr("New"),self) #self.fileNewToolsAction.setShortcut("Ctrl+N") self.fileNewToolsAction.setStatusTip(self.tr("create a new file")) - self.connect(self.fileNewToolsAction,SIGNAL("triggered()"),self.slotNewFile) + self.fileNewToolsAction.triggered.connect(self.slotNewFile) #self.fileSaveAction=QAction(QIcon(":/save.png"),self.tr("Save"),self) self.fileSaveAction=QAction(self.tr("Save"),self) self.fileSaveAction.setShortcut("Ctrl+S") self.fileSaveAction.setStatusTip(self.tr("save the file")) - self.connect(self.fileSaveAction,SIGNAL("triggered()"),self.slotSaveFile) + self.fileSaveAction.triggered.connect(self.slotSaveFile) self.fileSaveToolsAction=QAction(QIcon(":/save.png"),self.tr("Save"),self) #self.fileSaveToolsAction.setShortcut("Ctrl+S") #must delete,else ctrl+s not work self.fileSaveToolsAction.setStatusTip(self.tr("save the file")) - self.connect(self.fileSaveToolsAction,SIGNAL("triggered()"),self.slotSaveFile) + self.fileSaveToolsAction.triggered.connect(self.slotSaveFile) #self.fileSaveAsAction=QAction(QIcon(":/saveas.png"),self.tr("Save as"),self) self.fileSaveAsAction=QAction(self.tr("Save as"),self) self.fileSaveAsAction.setStatusTip(self.tr("save as a file")) - self.connect(self.fileSaveAsAction,SIGNAL("triggered()"),self.slotSaveFileAs) + self.fileSaveAsAction.triggered.connect(self.slotSaveFileAs) #self.refreshBoardFileAction=QAction(QIcon(":/flush.png"),self.tr("Reflush Directory "),self) self.refreshBoardFileAction=QAction(self.tr("Reflush Directory "),self) self.refreshBoardFileAction.setStatusTip(self.tr("refresh board file")) - self.connect(self.refreshBoardFileAction,SIGNAL("triggered()"),self.slotTreeModel) + self.refreshBoardFileAction.triggered.connect(self.slotTreeModel) #self.exampleTools=QAction(QIcon(":/examples.png"),self.tr("Examples"),self) self.exampleTools=QAction(self.tr("Examples"),self) self.exampleMenu=QMenu(self.tr("example")) - self.connect(self.exampleMenu,SIGNAL("triggered(QAction*)"),self.showExamples) + self.exampleMenu.triggered.connect(self.showExamples) self.exampleMenu.setStyleSheet("""QMenu {background-color: rgb(254,254,254);} QMenu::item::selected { background-color: rgb(255,239,227); color: #000;}""") @@ -421,63 +439,63 @@ def createActions(self): self.exitAction=QAction(self.tr("Exit"),self) self.exitAction.setShortcut("Ctrl+Q") self.setStatusTip(self.tr("Out")) - self.connect(self.exitAction,SIGNAL("triggered()"),self.close) + self.exitAction.triggered.connect(self.close) #Edit #self.cutAction=QAction(QIcon(":/cut.png"),self.tr("Cut"),self) self.cutAction=QAction(self.tr("Cut"),self) self.cutAction.setShortcut("Ctrl+X") - self.connect(self.cutAction,SIGNAL("triggered()"),self.slotCut) + self.cutAction.triggered.connect(self.slotCut) #self.copyAction=QAction(QIcon(":/copy.png"),self.tr("Copy"),self) self.copyAction=QAction(self.tr("Copy"),self) self.copyAction.setShortcut("Ctrl+C") - self.connect(self.copyAction,SIGNAL("triggered()"),self.slotCopy) + self.copyAction.triggered.connect(self.slotCopy) #self.pasteAction=QAction(QIcon(":/paste.png"),self.tr("Paste"),self) self.pasteAction=QAction(self.tr("Paste"),self) self.pasteAction.setShortcut("Ctrl+V") - self.connect(self.pasteAction,SIGNAL("triggered()"),self.slotPaste) + self.pasteAction.triggered.connect(self.slotPaste) #self.undoAction=QAction(QIcon(":/undo.png"),self.tr("Undo"),self) self.undoAction=QAction(self.tr("Undo"),self) self.undoAction.setShortcut("Ctrl+Z") - self.connect(self.undoAction,SIGNAL("triggered()"),self.slotUndo) + self.undoAction.triggered.connect(self.slotUndo) self.undoToolsAction=QAction(QIcon(":/undo.png"),self.tr("Undo"),self) #self.undoToolsAction.setShortcut("Ctrl+Z") - self.connect(self.undoToolsAction,SIGNAL("triggered()"),self.slotUndo) + self.undoToolsAction.triggered.connect(self.slotUndo) #self.redoAction=QAction(QIcon(":/redo.png"),self.tr("Redo"),self) self.redoAction=QAction(self.tr("Redo"),self) - self.redoAction.setShortcut("Ctrl+Y") - self.connect(self.redoAction,SIGNAL("triggered()"),self.slotRedo) + self.redoAction.setShortcut("Ctrl+Y") + self.redoAction.triggered.connect(self.slotRedo) self.redoToolsAction=QAction(QIcon(":/redo.png"),self.tr("Redo"),self) #self.redoToolsAction.setShortcut("Ctrl+Y") - self.connect(self.redoToolsAction,SIGNAL("triggered()"),self.slotRedo) + self.redoToolsAction.triggered.connect(self.slotRedo) #self.syntaxCheckAction=QAction(QIcon(":/syntaxCheck.png"),self.tr("syntaxCheck"),self) self.syntaxCheckAction=QAction(self.tr("syntaxCheck"),self) self.syntaxCheckAction.setStatusTip("the program syntax check") - self.connect(self.syntaxCheckAction,SIGNAL("triggered()"),self.slotSyntaxCheck) + self.syntaxCheckAction.triggered.connect(self.slotSyntaxCheck) self.syntaxCheckToolsAction=QAction(QIcon(":/syntaxCheck.png"),self.tr("syntaxCheck"),self) self.syntaxCheckToolsAction.setStatusTip("the program syntax check") - self.connect(self.syntaxCheckToolsAction,SIGNAL("triggered()"),self.slotSyntaxCheck) + self.syntaxCheckToolsAction.triggered.connect(self.slotSyntaxCheck) #self.clearTerminalAction=QAction(QIcon(":/clear.png"),self.tr("Clear"),self) self.clearTerminalAction=QAction(self.tr("Clear"),self) self.clearTerminalAction.setStatusTip(self.tr("clear Terminal")) - self.connect(self.clearTerminalAction,SIGNAL("triggered()"),self.slotClearTerminal) + self.clearTerminalAction.triggered.connect(self.slotClearTerminal) self.clearTerminalToolsAction=QAction(QIcon(":/clear.png"),self.tr("Clear"),self) self.clearTerminalToolsAction.setStatusTip(self.tr("clear Terminal")) - self.connect(self.clearTerminalToolsAction,SIGNAL("triggered()"),self.slotClearTerminal) + self.clearTerminalToolsAction.triggered.connect(self.slotClearTerminal) #self.findAction=QAction(QIcon(":/find.png"),self.tr("find replace"),self) self.findAction=QAction(self.tr("find replace"),self) self.findAction.setShortcut("Ctrl+F") - self.connect(self.findAction,SIGNAL("triggered()"),self.slotFindReplaceText) + self.findAction.triggered.connect(self.slotFindReplaceText) #tools #self.comMenuTools=QAction(QIcon(":/serial.png"),self.tr("Serial"),self) self.comMenuTools=QAction(self.tr("Serial"),self) @@ -492,7 +510,7 @@ def createActions(self): self.comMenu.addAction(self.comActionGroup.addAction(i)) self.comActionGroup.setExclusive(True) - self.connect(self.comMenu,SIGNAL("triggered(QAction*)"),self.slotChooseCom) + self.comMenu.triggered.connect(self.slotChooseCom) self.comMenuTools.setMenu(self.comMenu) self.comMenu.setStyleSheet("""QMenu {background-color: rgb(254,254,254);} @@ -500,45 +518,45 @@ def createActions(self): #self.serialConnect=QAction(QIcon(":/connect.png"),self.tr("Connect"),self) self.serialConnect=QAction(self.tr("Connect"),self) - self.connect(self.serialConnect,SIGNAL("triggered()"),self.slotConnectSerial) + self.serialConnect.triggered.connect(self.slotConnectSerial) self.serialConnectToolsAction=QAction(QIcon(":/serialConnect.png"),self.tr("Connect"),self) - self.connect(self.serialConnectToolsAction,SIGNAL("triggered()"),self.slotConnectSerial) + self.serialConnectToolsAction.triggered.connect(self.slotConnectSerial) #self.serialClose=QAction(QIcon(":/serialClose.png"),self.tr("disconnect"),self) self.serialClose=QAction(self.tr("disconnect"),self) - self.connect(self.serialClose,SIGNAL("triggered()"),self.slotCloseSerial) + self.serialClose.triggered.connect(self.slotCloseSerial) self.serialCloseToolsAction=QAction(QIcon(":/serialClose.png"),self.tr("disconnect"),self) - self.connect(self.serialCloseToolsAction,SIGNAL("triggered()"),self.slotCloseSerial) + self.serialCloseToolsAction.triggered.connect(self.slotCloseSerial) self.esp8266=QAction(self.tr("esp8266"),self) - self.connect(self.esp8266,SIGNAL("triggered()"),self.boardEsp8266) + self.esp8266.triggered.connect(self.boardEsp8266) self.esp8266.setCheckable(True) self.esp32=QAction(self.tr("esp32"),self) - self.connect(self.esp32,SIGNAL("triggered()"),self.boardEsp32) + self.esp32.triggered.connect(self.boardEsp32) self.esp32.setCheckable(True) self.pyboard=QAction(self.tr("pyboard"),self) - self.connect(self.pyboard,SIGNAL("triggered()"),self.boardPyboard) + self.pyboard.triggered.connect(self.boardPyboard) self.pyboard.setCheckable(True) self.microbit=QAction(self.tr("microbit"),self) - self.connect(self.microbit,SIGNAL("triggered()"),self.boardMicrobit) + self.microbit.triggered.connect(self.boardMicrobit) self.microbit.setCheckable(True) self.TPYBoardV202=QAction(self.tr("TPYBoardV202"),self) - self.connect(self.TPYBoardV202,SIGNAL("triggered()"),self.boardTPYBoardV202) + self.TPYBoardV202.triggered.connect(self.boardTPYBoardV202) self.TPYBoardV202.setCheckable(True) self.TPYBoardV102=QAction(self.tr("TPYBoardV102"),self) - self.connect(self.TPYBoardV102,SIGNAL("triggered()"),self.boardTPYBoardV102) + self.TPYBoardV102.triggered.connect(self.boardTPYBoardV102) self.TPYBoardV102.setCheckable(True) self.otherBoard=QAction(self.tr("other"),self) - self.connect(self.otherBoard,SIGNAL("triggered()"),self.boardOther) + self.otherBoard.triggered.connect(self.boardOther) self.otherBoard.setCheckable(True) self.boardActionGroup=QActionGroup(self) @@ -570,44 +588,44 @@ def createActions(self): #self.downloadAction=QAction(QIcon(":/download.png"),self.tr("Download"),self) self.downloadAction=QAction(self.tr("Download"),self) self.downloadAction.setStatusTip(self.tr("download file to the board")) - self.connect(self.downloadAction,SIGNAL("triggered()"),self.slotDownloadFile) + self.downloadAction.triggered.connect(self.slotDownloadFile) #self.downloadAndRunAction=QAction(QIcon(":/downloadAndRun.png"),self.tr("DownloadAndRun"),self) self.downloadAndRunAction=QAction(self.tr("DownloadAndRun"),self) self.downloadAndRunAction.setShortcut("F5") self.downloadAndRunAction.setStatusTip(self.tr("download file and run")) - self.connect(self.downloadAndRunAction,SIGNAL("triggered()"),self.slotDownloadFileAndRun) + self.downloadAndRunAction.triggered.connect(self.slotDownloadFileAndRun) self.downloadAndRunToolsAction=QAction(QIcon(":/downloadAndRun.png"),self.tr("DownloadAndRun"),self) #self.downloadAndRunToolsAction.setShortcut("F5") self.downloadAndRunToolsAction.setStatusTip(self.tr("download file and run")) - self.connect(self.downloadAndRunToolsAction,SIGNAL("triggered()"),self.slotDownloadFileAndRun) + self.downloadAndRunToolsAction.triggered.connect(self.slotDownloadFileAndRun) self.isDownloadFileAndRun=False #self.stopProgramAction=QAction(QIcon(":/stop.png"),self.tr("Stop"),self) self.stopProgramAction=QAction(self.tr("Stop"),self) self.stopProgramAction.setStatusTip(self.tr("stop the program")) - self.connect(self.stopProgramAction,SIGNAL("triggered()"),self.slotStopProgram) + self.stopProgramAction.triggered.connect(self.slotStopProgram) self.stopProgramToolsAction=QAction(QIcon(":/stop.png"),self.tr("Stop"),self) self.stopProgramToolsAction.setStatusTip(self.tr("stop the program")) - self.connect(self.stopProgramToolsAction,SIGNAL("triggered()"),self.slotStopProgram) + self.stopProgramToolsAction.triggered.connect(self.slotStopProgram) #self.preferenceAction=QAction(QIcon(":/edit.png"),self.tr("Preferences"),self) self.preferenceAction=QAction(self.tr("Preferences"),self) - self.connect(self.preferenceAction,SIGNAL("triggered()"),self.slotPreferences) + self.preferenceAction.triggered.connect(self.slotPreferences) #self.initconfig=QAction(QIcon(":/init.png"),self.tr("InitConfig"),self) self.initconfig=QAction(self.tr("InitConfig"),self) - self.connect(self.initconfig,SIGNAL("triggered()"),self.slotInitConfig) + self.initconfig.triggered.connect(self.slotInitConfig) #self.burnfirmware=QAction(QIcon(":/burnFirmware.png"),self.tr("BurnFirmware"),self) self.burnfirmware=QAction(self.tr("BurnFirmware"),self) - self.connect(self.burnfirmware,SIGNAL("triggered()"),self.slotBurnFirmware) + self.burnfirmware.triggered.connect(self.slotBurnFirmware) #help #self.aboutAction=QAction(QIcon(":/about.png"),self.tr("Tutorial online"),self) self.aboutAction=QAction(self.tr("Tutorial online"),self) - self.connect(self.aboutAction,SIGNAL("triggered()"),self.slotAbout) + self.aboutAction.triggered.connect(self.slotAbout) def createMenus(self): #Files @@ -645,7 +663,7 @@ def createMenus(self): toolMenu.setStyleSheet("background-color: rgb(254,254,254);") - self.connect(toolMenu,SIGNAL("hovered(QAction*)"),self.slotToolMenuHover) + toolMenu.hovered.connect(self.slotToolMenuHover) #Help aboutMenu=self.menuBar().addMenu(self.tr("Help")) aboutMenu.addAction(self.aboutAction) @@ -881,13 +899,13 @@ def createWorkSpacePath(self): #create graphics interface def createGraphicsInterface(self): self.saveUntitled=saveUntitled() - self.connect(self.saveUntitled.okButton,SIGNAL("clicked()"),self.saveUntitledOK) + self.saveUntitled.okButton.clicked.connect(self.saveUntitledOK) self.newBoardDirName=createBoardNewDirName() - self.connect(self.newBoardDirName.okButton,SIGNAL("clicked()"),self.getBoardDirName) + self.newBoardDirName.okButton.clicked.connect(self.getBoardDirName) self.getTreeRightMenuRename=treeRightClickRename() - self.connect(self.getTreeRightMenuRename.okButton,SIGNAL("clicked()"),self.getTreeRenameOk) + self.getTreeRightMenuRename.okButton.clicked.connect(self.getTreeRenameOk) def createBasicConfig(self): path=os.getcwd() @@ -925,16 +943,16 @@ def createBasicConfig(self): os.remove("%s/AppData/Local/uPyCraft/config.json"%rootDirectoryPath) return False - if jsonDict.get("workSpace") != None: + if jsonDict.get("workSpace") is not None: self.workspacePath=jsonDict['workSpace'] else: self.workspacePath=path+"/workSpace" - if jsonDict.get('serial')==None or \ - jsonDict.get('updateURL')==None or \ - jsonDict.get('checkFirmware')==None or \ - jsonDict.get('address')==None or \ - jsonDict.get('workSpace')==None: + if jsonDict.get('serial') is None or \ + jsonDict.get('updateURL') is None or \ + jsonDict.get('checkFirmware') is None or \ + jsonDict.get('address') is None or \ + jsonDict.get('workSpace') is None: configFile=open("%s/AppData/Local/uPyCraft/config.json"%rootDirectoryPath,'w') configFile.write("{'serial':'None','updateURL':'https://git.oschina.net/dfrobot/upycraft/raw/master/uPyCraft.json',\ 'checkFirmware':'check update','address':'China Mainland','workSpace':'%s'}"%self.workspacePath) @@ -1084,9 +1102,9 @@ def saveUntitledOK(self): self.terminal.append("filename error") return else: - tabname=tabname+"py" + tabname = tabname + "py" else: - tabname=str(tabname) + tabname = str(tabname) if tabname[-3:].lower()==".py": tabname=tabname[0:-3]+".py" elif tabname[-5:].lower()==".json": @@ -1325,8 +1343,8 @@ def slotFindReplaceText(self): if self.tabWidget.currentWidget() == None: return self.findmsg=findReplaceText() - self.connect(self.findmsg.findButton,SIGNAL("clicked()"),self.slotFindText) - self.connect(self.findmsg.replaceButton,SIGNAL("clicked()"),self.slotReplaceText) + self.findmsg.findButton.clicked.connect(self.slotFindText) + self.findmsg.replaceButton.clicked.connect(self.slotReplaceText) self.findmsg.show() def slotFindText(self): @@ -1478,7 +1496,7 @@ def slotChooseCom(self,action): self.uitoctrlQueue.put("getcwd") - self.emit(SIGNAL("changeCurrentBoard"),self.currentBoard) + self.changeCurrentBoard.emit(self.currentBoard) time.sleep(0.005) self.terminal.setReadOnly(False) self.slotTreeModel() @@ -1602,7 +1620,7 @@ def slotConnectSerial(self): else: self.uitoctrlQueue.put("getcwd") - self.emit(SIGNAL("changeCurrentBoard"),self.currentBoard) + self.changeCurrentBoard.emit(self.currentBoard) time.sleep(0.005) self.terminal.setReadOnly(False) self.slotTreeModel() @@ -1652,8 +1670,8 @@ def slotCloseSerial(self): while not self.readwriteQueue.empty(): self.readwriteQueue.get() - self.emit(SIGNAL("initRecvdata")) - self.emit(SIGNAL("initMessycode")) + self.initRecvdata.emit() + self.initMessycode.emit() time.sleep(0.1) self.myserial.ser.close() #if self.currentBoard=="esp32" or self.currentBoard=="esp8266": @@ -1717,7 +1735,7 @@ def slotDownloadFile(self): myfile.write(filemsg) myfile.close() - self.emit(SIGNAL("changeDragDropModel"),False) + self.changeDragDropModel.emit(False) self.uitoctrlQueue.put("downloadfile:::%s"%afile) return True @@ -1794,8 +1812,8 @@ def slotPreferences(self): else: self.preferencesDialog.configUpdate.checkBinComBox.setCurrentIndex(1) - self.connect(self.preferencesDialog.landlocation.locationComboBox,SIGNAL("activated(int)"),self.slotLanlocLocation) - self.connect(self.preferencesDialog.configUpdate.checkBinComBox,SIGNAL("activated(int)"),self.slotWetherUpdateFirmware) + self.preferencesDialog.landlocation.locationComboBox.activated.connect(self.slotLanlocLocation) + self.preferencesDialog.configUpdate.checkBinComBox.activated.connect(self.slotWetherUpdateFirmware) self.preferencesDialog.show() def slotLanlocLocation(self,item): @@ -1919,7 +1937,7 @@ def editClassFileitem(self,filename): return True def asciiTOutf8(self,path): - if(os.path.isfile(path)): + if os.path.isfile(path): self.convert(path) elif os.path.isdir(path): self.explore(path) @@ -1943,7 +1961,7 @@ def explore(self,dir): def boardEsp32(self): self.currentBoard="esp32" - self.emit(SIGNAL("changeCurrentBoard"),self.currentBoard) + self.changeCurrentBoard.emit(self.currentBoard) time.sleep(0.005) self.autoAPI.clear() @@ -1952,7 +1970,7 @@ def boardEsp32(self): self.exampleTools.setMenu(None) #self.exampleMenu.clear() #QMenu.clear is not work self.exampleMenu=QMenu(self.tr("example")) - self.connect(self.exampleMenu,SIGNAL("triggered(QAction*)"),self.showExamples) + self.exampleMenu.triggered.connect(self.showExamples) self.exampleMenu.setStyleSheet("""QMenu {background-color: rgb(254,254,254);} QMenu::item::selected { background-color: rgb(255,239,227); color: #000;}""") @@ -1961,7 +1979,7 @@ def boardEsp32(self): def boardTPYBoardV202(self): self.currentBoard="TPYBoardV202" - self.emit(SIGNAL("changeCurrentBoard"),self.currentBoard) + self.changeCurrentBoard.emit(self.currentBoard) time.sleep(0.005) self.autoAPI.clear() self.autoAPI.prepare() @@ -1972,7 +1990,7 @@ def boardTPYBoardV202(self): def boardTPYBoardV102(self): self.currentBoard="TPYBoardV102" - self.emit(SIGNAL("changeCurrentBoard"),self.currentBoard) + self.changeCurrentBoard.emit(self.currentBoard) time.sleep(0.005) self.autoAPI.clear() self.autoAPI.prepare() @@ -1983,7 +2001,7 @@ def boardTPYBoardV102(self): def boardEsp8266(self): self.currentBoard="esp8266" - self.emit(SIGNAL("changeCurrentBoard"),self.currentBoard) + self.changeCurrentBoard.emit(self.currentBoard) time.sleep(0.005) self.autoAPI.clear() self.autoAPI.prepare() @@ -1995,7 +2013,7 @@ def boardEsp8266(self): def boardPyboard(self): self.currentBoard="pyboard" - self.emit(SIGNAL("changeCurrentBoard"),self.currentBoard) + self.changeCurrentBoard.emit(self.currentBoard) time.sleep(0.005) self.autoAPI.clear() @@ -2007,7 +2025,7 @@ def boardPyboard(self): self.createExampleMenu() def boardMicrobit(self): self.currentBoard="microbit" - self.emit(SIGNAL("changeCurrentBoard"),self.currentBoard) + self.changeCurrentBoard.emit(self.currentBoard) time.sleep(0.005) for i in MICROPYTHON_APIS: @@ -2348,15 +2366,15 @@ def updateFirmware(self,isAuto=False): self.updateBin = updateNewFirmware("Burn Firmware",isAuto) else: self.updateBin = updateNewFirmware("update Firmware",isAuto) - self.connect(self.updateBin.okButton,SIGNAL("clicked()"),self.updateFirmwareOk) - self.connect(self.updateBin.chooseFirmwareButton,SIGNAL("clicked()"),self.chooseUserFirmware) + self.updateBin.okButton.clicked.connect(self.updateFirmwareOk) + self.updateBin.chooseFirmwareButton.clicked.connect(self.chooseUserFirmware) self.updateBin.exec_() def chooseUserFirmware(self): self.updateBin.hide() usersFirmware=QFileDialog.getOpenFileName(self) self.updateBin.show() - usersFirmware=usersFirmware.replace("\\","/") + usersFirmware=usersFirmware[0].replace("\\","/") self.updateBin.firmwareName.setText(usersFirmware) def updateFirmwareOk(self): @@ -2406,10 +2424,10 @@ def updateFirmwareOk(self): self.firmwareAny=threadDownloadFirmware(url,self.updateBin.boardComboBox.currentText(),self.firmwareSavePath,self.updateFirmwareCom,\ self.updateBin.eraseComboBox.currentText(),self.updateSize,\ self.updateBin.burnAddrComboBox.currentText(),self) - self.connect(self.firmwareAny,SIGNAL("firmwareAnyDown"),self.firmwareAnyDown) - self.connect(self.firmwareAny,SIGNAL("firmwareAnyErase"),self.firmwareAnyErase) - self.connect(self.firmwareAny,SIGNAL("firmwareAnyUpdate"),self.firmwareAnyUpdate) - self.connect(self.firmwareAny,SIGNAL("goMicrobitUpdate"),self.microbitUpdate) + self.firmwareAny.firmwareAnyDown.connect(self.firmwareAnyDown) + self.firmwareAny.firmwareAnyErase.connect(self.firmwareAnyErase) + self.firmwareAny.firmwareAnyUpdate.connect(self.firmwareAnyUpdate) + self.firmwareAny.goMicrobitUpdate.connect(self.microbitUpdate) self.firmwareAny.start() return else: @@ -2456,10 +2474,10 @@ def updateFirmwareOk(self): self.firmwareAny=threadUserFirmware(self.updateBin.boardComboBox.currentText(),userFirmwareName,self.updateFirmwareCom,\ self.updateBin.eraseComboBox.currentText(),userFirmwareSize,\ self.updateBin.burnAddrComboBox.currentText(),self) - self.connect(self.firmwareAny,SIGNAL("firmwareAnyDown"),self.firmwareAnyDown) - self.connect(self.firmwareAny,SIGNAL("firmwareAnyErase"),self.firmwareAnyErase) - self.connect(self.firmwareAny,SIGNAL("firmwareAnyUpdate"),self.firmwareAnyUpdate) - self.connect(self.firmwareAny,SIGNAL("goMicrobitUpdate"),self.microbitUpdate) + self.firmwareAny.firmwareAnyDown.connect(self.firmwareAnyDown) + self.firmwareAny.firmwareAnyErase.connect(self.firmwareAnyErase) + self.firmwareAny.firmwareAnyUpdate.connect(self.firmwareAnyUpdate) + self.firmwareAny.goMicrobitUpdate.connect(self.microbitUpdate) self.firmwareAny.start() return @@ -2563,19 +2581,19 @@ def reflushExamples(self): def updateThing(self,windowname,title): self.updateThingWindowName=windowname self.updateIdeExample=attentionUpdata(windowname,title) - self.connect(self.updateIdeExample.okButton,SIGNAL("clicked()"),self.updateIdeExampleOk) - self.connect(self.updateIdeExample.cancelButton,SIGNAL("clicked()"),self.updateIdeExampleCancel) + self.updateIdeExample.okButton.clicked.connect(self.updateIdeExampleOk) + self.updateIdeExample.cancelButton.clicked.connect(self.updateIdeExampleCancel) self.updateIdeExample.exec_() def updateIdeExampleCancel(self): - self.emit(SIGNAL("confirmUpdata"),self.updateThingWindowName.split(" ")[-1]+"cancel") + self.confirmUpdata.emit(self.updateThingWindowName.split(" ")[-1]+"cancel") self.updateIdeExample.close() def updateIdeExampleOk(self): self.updataIDEorExamplesBar=ProgressIDEorExampleBar(self.updateThingWindowName+"...") self.updataIDEorExamplesBar.show() - self.emit(SIGNAL("confirmUpdata"),self.updateThingWindowName.split(" ")[-1]) + self.confirmUpdata.emit(self.updateThingWindowName.split(" ")[-1]) self.updateIdeExample.close() def updataPer(self,per): @@ -2911,8 +2929,8 @@ def timerCloseTerminal(self): while not self.readwriteQueue.empty(): self.readwriteQueue.get() - self.emit(SIGNAL("initRecvdata")) - self.emit(SIGNAL("initMessycode")) + self.initRecvdata.emit() + self.initMessycode.emit() self.terminal.clear() self.terminal.setReadOnly(True) @@ -2941,21 +2959,21 @@ def fun_timer(self): continue self.serialComList.append(i) - self.emit(SIGNAL("timerAddComMenu"),i) + self.timerAddComMenu.emit(i) for i in self.serialComList: if i not in mylist: self.serialComList.remove(i) - self.emit(SIGNAL("timerClearComMenu")) + self.timerClearComMenu.emit() time.sleep(0.1) for j in self.serialComList: - self.emit(SIGNAL("timerSetComMenu"),j) + self.timerSetComMenu.emit(j) if self.currentCom=="": self.serialConnectToolsAction.setVisible(True) self.serialCloseToolsAction.setVisible(False) elif self.currentCom not in self.serialComList: self.currentCom="" - self.emit(SIGNAL("timerCloseTerminal")) + self.timerCloseTerminal.emit() timer=threading.Timer(0.2,self.fun_timer) timer.start() diff --git a/updateNewFirmware.py b/updateNewFirmware.py index 00a70cc..7dcc04e 100644 --- a/updateNewFirmware.py +++ b/updateNewFirmware.py @@ -4,8 +4,9 @@ import serial.tools.list_ports import time -from PyQt4.QtCore import * -from PyQt4.QtGui import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * class updateNewFirmwareBar(QDialog): def __init__(self,windowname,isErase,isUPY,parent=None): @@ -226,11 +227,11 @@ def __init__(self,windowname,isAuto=False,parent=None): self.resize(450,200) self.setLayout(layout) - self.connect(self.okButton,SIGNAL("clicked()"),self.chooseOk) - self.connect(self.cancelButton,SIGNAL("clicked()"),self.chooseCancel) - self.connect(self.boardComboBox,SIGNAL("activated(int)"),self.boardChange) - self.connect(self.radioUPY,SIGNAL("toggled(bool)"),self.radioUPYChanged) - self.connect(self.radioUser,SIGNAL("toggled(bool)"),self.radioUserChanged) + self.okButton.clicked.connect(self.chooseOk) + self.cancelButton.clicked.connect(self.chooseCancel) + self.boardComboBox.activated.connect(self.boardChange) + self.radioUPY.toggled.connect(self.radioUPYChanged) + self.radioUser.toggled.connect(self.radioUserChanged) def radioUPYChanged(self,choosed): if choosed: