本文整理汇总了Python中gui.Gui.changeState方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.changeState方法的具体用法?Python Gui.changeState怎么用?Python Gui.changeState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gui.Gui
的用法示例。
在下文中一共展示了Gui.changeState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BatMonTh
# 需要导入模块: from gui import Gui [as 别名]
# 或者: from gui.Gui import changeState [as 别名]
class BatMonTh(Thread):
def __init__(self):
Thread.__init__(self)
self.count = 0
self.voltage = 0
self.state = "idle"
self.batNb = int(input("Entrez le numéro de la batterie :"))
self.fileName = ""
self.com = BatMon()
self.com.setPort('COM12')
self.verrou = Lock()
self.gui = Gui(self.verrou)
self.start()
self.gui.mainloop()
def run(self):
appRunning = True
while (appRunning):
self.voltage = 0
if (self.state == "idle"):
if (self.com.connect()):
if (self.com.getId()):
self.count = 0
self.state = "connected"
self.file = self.createFile()
else:
time.sleep(0.5)
else:
time.sleep(0.5)
else:
data = self.com.getData()
self.voltage = data[0]
self.state = data[1]
self.count += 1
if (self.count > 32767):
self.count = -32768
if (self.state == "idle"):
try:
self.file.close()
except:
self.fileName = ''
elif ((self.state == "discharging") and (self.count%60==0)):
if (self.verrou.acquire(False)):
self.gui.addData(self.count, self.voltage)
self.verrrou.release()
else:
appRunning = False
pickle.dump(self.count, self.file)
pickle.dump(self.voltage, self.file)
if (self.verrou.acquire(False)):
self.gui.changeVoltage(self.voltage)
self.gui.changeState(self.state)
self.verrou.release()
else:
appRunning = False
try:
self.file.close()
except:
self.fileName = ''
def createFile(self):
fileNb = 0
success = False
while(not(success)):
try:
self.fileName = "Bat%02i-%03i.BDi" % (self.batNb, fileNb)
open(self.fileName,'rb')
fileNb += 1
except:
success = True
newFile = open(self.fileName, 'wb')
return newFile