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


Python Frame.winfo_children方法代码示例

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


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

示例1: TkList

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import winfo_children [as 别名]
class TkList(List):
	def __init__(self, file, tk):
		List.__init__(self, file)

		# Create the frame with list items
		self.frame = Frame(tk, padx = 0, pady = 10, bd = 0)
		self.frame.pack()

		# Create the field to input new list items
		self.input = Entry(tk, width = 32, bd = 1, insertborderwidth = 1, relief = FLAT)
		self.input.pack(anchor = N, pady = 4, side = LEFT, fill = X)
		self.input.focus_set()
		self.input.bind('<Return>', lambda l: self.add_item(self.input.get()))

		# Create an add button to the input field
		Button(tk, text = "+", relief = FLAT, command = lambda: self.add_item(self.input.get())).pack(anchor = N, side = RIGHT)

		# Update the list frame
		self.update()
		
	def add_item(self, text):
		List.add_item(self, text)

		# Clear input field
		self.input.delete(0, END)

		# Update the list frame
		self.update()

	def remove_item(self, text):
		List.remove_item(self, text)

		# Update the list frame
		self.update()

	def checkbox(self, text):

		# Return a button that will remove the list item
		return Button(self.frame, text = "-", relief = FLAT, command = lambda: self.remove_item(text))

	def update(self):

		# Remove previous list items
		for child in self.frame.winfo_children():
			child.destroy()

		# Draw each item in the list
		i = 0
		for item in self.list:
			self.checkbox(item).grid(row = i)
			Label(self.frame, text = item).grid(row = i, column = 1)
			i = i + 1

		# Save the list
		List.save_list(self)
开发者ID:Gabe-Linux,项目名称:Todo-List,代码行数:57,代码来源:lists.py

示例2: __init__

# 需要导入模块: from Tkinter import Frame [as 别名]
# 或者: from Tkinter.Frame import winfo_children [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.winfo_children方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。