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


Python Frame.grid_forget方法代码示例

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


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

示例1: __init__

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_forget [as 别名]
class Widget_:

	def __init__(self, parent_frame, row, column, width=50, height=50):
		self.widget_frame = Frame(parent_frame, width=width, height=height)
		self.widget_frame.grid(row=row, column=column)
		self.width, self.height = width, height
		return

	def add_tag(self, tag_library, string):
		tag_library[string] = self

	def delete_widget(self):
		for child in self.widget_frame.winfo_children():
			child.destroy()
		self.widget_frame.destroy()

	def hide_widget(self):
		self.widget_frame.grid_forget()

	def get_info(self):
		return

	def set_field(self):
		return

	pass
开发者ID:wasifzaman,项目名称:Project-RYB,代码行数:28,代码来源:widget_.py

示例2: Example

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_forget [as 别名]
class Example(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent
        self.initUI()

        
    def initUI(self):
      
        self.parent.title("EGUANA")
        self.style = ttk.Style()        
        self.style.theme_use("alt")        
        
        self.photoName = "eguana.gif"
        self.frame = Frame(self, relief=FLAT, borderwidth=10,bg='#FADC46')

        self.frame.pack(fill=BOTH, expand=True)        
        self.pack(fill=BOTH, expand=True)
        
        self.setupMenuBar()
        self.setupTopBar()  
        
    def setupMenuBar(self):
        
        self.menubar = EguanaMenu(self.parent,self)
        self.parent.config(menu=self.menubar)

    def setupTopBar(self):
        
        self.openButton3D = Button(self.frame,text="Select Directory for 3D EMA",relief=RAISED,command=self.askDirectory)
        self.openButton3D.grid(row=0,column=0, sticky=N+S+E+W,padx=2,pady =2)
        
        self.openButton2D = Button(self.frame,text="Select Directory for 2D EMA",relief=RAISED,command=self.askDirectory);
        self.openButton2D.grid(row=2,column=2, sticky=N+S+E+W,padx=2,pady =2)

        self.p1Button = Button(self.frame,text="Placeholder",relief=RAISED)
        self.p1Button.grid(row=0,column=1, sticky=N+S+E+W,padx=2,pady =2)
        self.p2Button = Button(self.frame,text="Placeholder",relief=RAISED)
        self.p2Button.grid(row=0,column=2, sticky=N+S+E+W,padx=2,pady =2)
        self.p3Button = Button(self.frame,text="Placeholder",relief=RAISED)
        self.p3Button.grid(row=1,column=0, sticky=N+S+E+W,padx=2,pady =2)
        self.p4Button = Button(self.frame,text="Placeholder",relief=RAISED)
        self.p4Button.grid(row=1,column=2, sticky=N+S+E+W,padx=2,pady =2)
        self.p5Button = Button(self.frame,text="Placeholder",relief=RAISED)
        self.p5Button.grid(row=2,column=0, sticky=N+S+E+W,padx=2,pady =2)
        self.p6Button = Button(self.frame,text="Placeholder",relief=RAISED)
        self.p6Button.grid(row=2,column=1, sticky=N+S+E+W,padx=2,pady =2)

        self.openButton3D.bind('<Motion>',self.cursorPosition)
        self.openButton2D.bind('<Motion>',self.cursorPosition)

        self.photo = PhotoImage(file="eguana.gif")
        self.photo = self.photo.subsample(2);
        self.photo_label = Label(self.frame,image=self.photo,borderwidth=0,highlightthickness=0)
        self.photo_label.configure(bg='#FADC46')
        
        self.photo_label.grid(row=1,column=1, sticky=N+S+E+W,padx=2,pady =2)
        
        self.photo_label.image = self.photo
    
    
        self.frame.columnconfigure(0, weight=1)
        self.frame.columnconfigure(1, weight=1)
        self.frame.columnconfigure(2, weight=1)
        self.frame.rowconfigure(0, weight=1)
        self.frame.rowconfigure(1, weight=1)
        self.frame.rowconfigure(2, weight=1)
        
    def askDirectory(self):

        dirStr = filedialog.askdirectory()
        
        if len(dirStr):
            self.openButton3D.destroy()
            self.openButton2D.destroy()
            self.p1Button.destroy()
            self.p2Button.destroy()
            self.p3Button.destroy()
            self.p4Button.destroy()
            self.p5Button.destroy()
            self.p6Button.destroy()

            self.menubar.entryconfigure('Filter', state = 'active')
            self.photo_label.destroy()

            dirStr = 'Input Path : '+dirStr
            
            
            self.frame.grid_forget()
            
           

            self.infoFrame = Frame(self.frame, relief=FLAT, bg='#FADC46')
            self.infoFrame.grid(row=0,column=0,columnspan=3, sticky=N+S+E+W,padx=2,pady =2)
               
        
            self.directoryLabel = Label(self.infoFrame, text="No project currently selected",relief=FLAT)
            self.directoryLabel.grid(row=0,column=0,columnspan=2, sticky=N+S+E+W,padx=2,pady =2)
#.........这里部分代码省略.........
开发者ID:VrishtiDutta,项目名称:EGUANA_Python,代码行数:103,代码来源:EGUANA.py

示例3: Graphics

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import grid_forget [as 别名]
class Graphics(object):
    def __init__(self, canvas, rows, cols, size, window):
        '''initialises the graphics object and its properties'''
        self.canvas = canvas
        self.window = window
        self.rows = rows*2+1
        self.cols = cols*2+1
        self.size = size/2
        self.label = {}
        self.label_vars = {}
        self.icons = (ImageTk.PhotoImage(file='png/faceicon0.png'),
                      ImageTk.PhotoImage(file='png/faceicon1.png'))
        self.draw_static_grid()
        self.draw_changing_grid()
        self.info_labels()
        self.make_creator_label()

    def make_creator_label(self):
        self.canvas.create_text(self.cols*self.size/2+self.size/2,
                                self.rows*self.size+self.size*2/3+2,
                                text='Created by Abel Svoboda, 08/07/15')

    def draw_static_grid(self):
        '''draws the grid that is made at the start of the game'''
        hardblock = PhotoImage(file='gifs/hardblock.gif')
        label = Label(image=hardblock)
        label.image = hardblock #keeping a reference
        self.regular = {}
        self.absolute = {}
        for col in range(self.cols):
            for row in range(self.rows):
                left = col * self.size
                right = left + self.size+.5*self.size
                top = row * self.size
                bot = top + self.size+.5*self.size
                left += .5*self.size
                top += .5*self.size

                if row%2==0 and col%2==0 or \
                   row==0 or col==0 or \
                   row==self.rows-1 or col==self.cols-1: #hardblock
                    self.absolute[(col-1,row-1)] = self.canvas.create_image(
                        (left+right)/2,(top+bot)/2,image=hardblock)
                else: #walkable
                    self.regular[(col-1,row-1)] = self.canvas.create_rectangle(
                        left,top,right,bot,fill='#307100',width=0)

    def draw_changing_grid(self):
        '''draws the grid that is made at the start of each round'''
        softblock = PhotoImage(file='gifs/softblock.gif')
        label = Label(image=softblock)
        label.image = softblock #keeping a reference
        self.rocks = {}
        for col in range(self.cols):
            for row in range(self.rows):
                left = col * self.size
                right = left + self.size+.5*self.size
                top = row * self.size
                bot = top + self.size+.5*self.size
                left += .5*self.size
                top += .5*self.size

                if (row==1 or row==2) and (col==1 or col==2) or \
                   (row==self.rows-2 or row==self.rows-3) and (col==self.cols-2 or col==self.cols-3) or \
                   row%2==0 and col%2==0 or \
                   row==0 or col==0 or row==self.rows-1 or col==self.cols-1:
                    pass
                elif randint(0,100) < 50: #soft block density
                    self.rocks[(col-1,row-1)] = self.canvas.create_image(
                        (left+right)/2,(top+bot)/2,image=softblock)

    def info_labels(self):
        '''creates some labels on the UI'''
        self.time_var = StringVar()
        self.time_var.set(0)
        time_label = Label(self.window,textvariable=self.time_var,
                           fg='white', bg='black',
                           font=('DINPro-Black',20), width=8)
        time_label.grid(row=0,column=2)
        self.pause_label = Label(self.window,text='PAUSE',
                                 fg='white',bg='black',
                                 font=('DINPro-Black',20),width=8)

    def pause_game(self):
        '''changes the UI to show the game is paused'''
        if 'row' in self.pause_label.grid_info():
            self.pause_label.grid_forget()
        else:
            self.pause_label.grid(row=0,column=2)

    def end_round_kill_screen(self, canvas, string, player):
        '''creates the end of round kill screen'''
        self.end_round_frame = Frame(self.window, background='#AF0000',bd=4)
        self.end_round_frame.grid(row=1, column=0, columnspan=6)
        if player is not None:
            winner_image = Label(self.end_round_frame,
                                 image=self.icons[player.player_number-1],
                                 borderwidth=18)
            winner_image.grid(row=0, column=0)
        end_kill_label=Label(self.end_round_frame, text=string+' ',
#.........这里部分代码省略.........
开发者ID:abel465,项目名称:DynaBLASTER,代码行数:103,代码来源:DynaBLASTER.py


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