当前位置: 首页>>代码示例>>Python>>正文


Python Gui.mainloop方法代码示例

本文整理汇总了Python中gui.Gui.mainloop方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.mainloop方法的具体用法?Python Gui.mainloop怎么用?Python Gui.mainloop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gui.Gui的用法示例。


在下文中一共展示了Gui.mainloop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: elif

# 需要导入模块: from gui import Gui [as 别名]
# 或者: from gui.Gui import mainloop [as 别名]
    print '\n\n Highest emotion: ' + highest + '\n\n'
    print 'Accumulated so far: '
    print tweetprocessor.counts
    # logger.logCounts(tweetprocessor.counts)
    
    print '\n\n'
    if (highest == 'happy'):
        gui.setColor('green')
    elif (highest == 'angry'):
        gui.setColor('red')
    elif (highest == 'sad'):
        gui.setColor('blue')
    elif (highest == 'profane'):
        gui.setColor('orange')
    # Do process again after 15 sec
    _job = gui.after(QUERY_FREQ, searchEvent)

def quitCallback():
    print "Exited."
    gui.stopGui()

def get_string():
    search_text = gui.search.get()
    if len(search_text) > 0:
        return search_text

if __name__ == '__main__':
    gui = Gui(quitCallback,get_string)
    _job = gui.after(QUERY_FREQ, searchEvent)
    gui.mainloop()
开发者ID:pbehrens,项目名称:human-computer-interaction,代码行数:32,代码来源:main.py

示例2: BatMonTh

# 需要导入模块: from gui import Gui [as 别名]
# 或者: from gui.Gui import mainloop [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    
开发者ID:miosee,项目名称:batteryMonitor,代码行数:75,代码来源:main.py


注:本文中的gui.Gui.mainloop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。