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


Python Frame.after方法代码示例

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


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

示例1: Application

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import after [as 别名]
class Application(Frame):

    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.grid()
        self.createWidgets()
        self.turtle = Turtle()

    def createWidgets(self):       
        self.EntryFrame = Frame(self,bd=5)
        self.EntryFrame.grid(row=0, column=1)
        
        i = 0
        Label(self.EntryFrame, text='Type some Python code\n').grid(row=i, column=0, columnspan=2)

        i += 1
        Label(self.EntryFrame, text='The Code').grid(row=i, column=0, sticky=E)

        self.text = Text(self.EntryFrame, width=50, height=10)
        self.text.grid(row=i, column=1)
        
        self.EntryFrame.after(1000, self.runCode)
    
    def runCode(self):
        t = self.turtle
        script = self.text.get("1.0", "end-1c")
        try:
            t.tracer(100000)
            t.reset()
            exec script in globals(), locals()
            t.tracer(1)
        except:
            pass
        
        self.EntryFrame.after(1000, self.runCode)
开发者ID:donkirkby,项目名称:donkirkby,代码行数:37,代码来源:live_py.py

示例2: __init__

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import after [as 别名]
class App:                         ### (1)
    def __init__(self, myParent):      ### (1a)
        
        self.status = Tk.StringVar()
        self.status.set('Avaiting indicators from game session')
        self.statuswidg = Tk.Label(myParent, textvariable=self.status, fg=FG, bg=BG, font=labelfonts)
        try:
            if settings['STATUSBAR']==1:
                self.statuswidg.pack()
        except:
            pass
        
        self.frame = Frame(myParent)
        self.frame.pack()
        self.statusbar = Frame(myParent)
        self.statusbar.pack()
        self.frame.config(bg=BGG)
        self.ind = get_indicators()
       

        self.inds = {}
        self.t_m=time.time()
        self.frame.after(int(dt*1000), self.upd)
        
        
    def inds_to_disp(self, master):
        ind_d = {}
        for instr in NEEDED_INSTRUMENTS:
            if DRAW_ALL:
                ind_d[instr] = self.get_instr(instr, master)
            else:
                for available in self.ind.keys():
                    if instr in available:
                        ind_d[available] = self.get_instr(available, master)
                    try:
                        
                        if settings[instr+'_bind'] == available:
                            ind_d[instr] = self.get_instr(instr, master, label=True)
                    except:
                        pass
        return ind_d
                    
    def upd(self):
        d = get_indicators()
##        print len(d), 'en d'
        try:
##            print d['valid'], 'valid'
            if 'vario' not in d and len(d)>1:
                d['vario'] = (d['altitude_hour']-self.ind['altitude_hour'])/(time.time()-self.t_m)
                self.t_m=time.time()
        except Exception:
            try:
                if len(d)>1:
                    d['vario'] = '--'
            except:
                pass
        self.ind = d
        if len(d) == 0:
            for child in self.frame.winfo_children():
                child.destroy()
            self.inds={}
            self.ind ={}
            self.status.set('No response from game at: '+"HTTP://"+ADDRESS+":8111/indicators")
        elif d['valid'] and len(self.inds)>0:
            self.status.set('In game at: '+"HTTP://"+ADDRESS+":8111/indicators")
            for ind in self.inds.values():
                try:
                    ind.update(d[ind.name])
                except:
                    ind.update('--')
        elif d['valid']==False and len(self.inds)>0:
            for child in self.frame.winfo_children():
                child.destroy()
            self.inds={}
            self.ind ={}

        elif d['valid']==True and len(self.inds)<1:
            ds = self.inds_to_disp(self.frame)
            self.inds = ds
        if  len(d) != 0 and d['valid']==False:
            if len(self.frame.winfo_children())<1:
               self.status.set('Avaiting indicators from game session')

            
        self.frame.after(int(dt*1000), self.upd)

    def get_instr(self, instr, master, label=False):
    
        if 'water_temperature' in instr:
            return WaterTempInd(master, instr)
        elif label==True:
            
            return GenericLabel(master, instr)
        elif 'oil_temperature' in instr:
            return OilTempInd(master, instr)
        elif 'ammo' in instr:
            return AmmoInd(master, instr)
        elif 'vario' in instr:
            return VarioInd(master, instr)
        elif 'head_temperature' in instr:
#.........这里部分代码省略.........
开发者ID:mdovgialo,项目名称:Polish-Aerospace-Program,代码行数:103,代码来源:cockpitTK2.py


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