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


Python Label.grid_forget方法代码示例

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


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

示例1: __init__

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

	def __init__(self, **kwargs):
		self.repr = kwargs['repr']
		self.path = kwargs['path']

	def config(self, **kwargs):
		if 'path' in kwargs:
			self.path = kwargs['path']
			self.picture = Image.open(self.path)
			self.picture = self.picture.resize((200, 200), Image.ANTIALIAS)
			self.image = ImageTk.PhotoImage(self.picture)
			self.label.config(image=self.image)

	def place(self, **kwargs):
		self.parent = kwargs['parent']
		self.row = kwargs['row']
		self.column = kwargs['column']

		self.picture = Image.open(self.path)
		self.image = ImageTk.PhotoImage(self.picture)

		self.label = Label(self.parent, image=self.image, bd=1)
		self.label.grid(row=self.row, column=self.column)
		self.label.bind('<Button-1>', lambda e: self.label.focus_set())

	def getData(self):
		return self.path

	def setData(self, data):
		#le sigh
		if data == '' or 'N/A': return
		self.config(path=data)

	def hide(self):
		self.label.grid_forget()
开发者ID:wasifzaman,项目名称:ryb_tms,代码行数:38,代码来源:photoWidget2.py

示例2: Graphics

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label 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

示例3: MLNQueryGUI

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

#.........这里部分代码省略.........
            self.project.dbs[old] = content
        else:
            if new in self.project.dbs:
                if askoverwrite:
                    savechanges = messagebox.askyesno("Save changes", "A file '{}' already exists. Overwrite?".format(new))
                    if savechanges:
                        self.project.dbs[new] = content
                    else:
                        logger.error('no name specified!')
                        return -1
            else:
                self.project.dbs[new] = content
        return 1


    def dbfiles(self):
        return list(self.project.dbs.keys())


    def dbfilecontent(self, filename):
        return self.project.dbs.get(filename, '').strip()

    # /DB FUNCTIONS #####################################

    # GENERAL FUNCTIONS #################################

    def select_method(self, *args):
        self.set_outputfilename()
        self.settings_setdirty()


    def onchange_use_emln(self, dirty=True, *args):
        if not self.use_emln.get():
            self.emln_label.grid_forget()
            self.emln_container.grid_forget()
        else:
            self.emln_label.grid(row=self.emlncontainerrow, column=0, sticky="NE")
            self.emln_container.grid(row=self.emlncontainerrow, column=1, sticky="NWES")
        if dirty:
            self.settings_setdirty()


    def onchange_cw(self, *args):
        if self.closed_world.get():
            self.entry_cw.configure(state=DISABLED)
        else:
            self.entry_cw.configure(state=NORMAL)
        self.settings_setdirty()


    def reset_gui(self):
        self.set_config({})
        self.db_container.clear()
        self.emln_container.clear()
        self.mln_container.clear()


    def set_config(self, newconf):
        self.config = newconf
        self.selected_grammar.set(ifnone(newconf.get('grammar'), 'PRACGrammar'))
        self.selected_logic.set(ifnone(newconf.get('logic'), 'FirstOrderLogic'))
        self.mln_container.selected_file.set(ifnone(newconf.get('mln'), ''))
        if self.use_emln.get():
            self.emln_container.selected_file.set(ifnone(newconf.get('mln'), ''))
        self.db_container.selected_file.set(ifnone(newconf.get('db'), ""))
        self.selected_method.set(ifnone(newconf.get("method"), InferenceMethods.name('MCSAT'), transform=InferenceMethods.name))
开发者ID:bbferka,项目名称:pracmln,代码行数:70,代码来源:mlnquery.py

示例4: Photo

# 需要导入模块: from tkinter import Label [as 别名]
# 或者: from tkinter.Label import grid_forget [as 别名]
class Photo(Widget):

	def __init__(self, **kwargs):

		try:
			self.repr = kwargs['repr']
			self.path = kwargs['path']
		except:
			print("widget could not be loaded")

		#self.script_dir = os.path.dirname(os.path.abspath(__file__))
		self.width = 200
		self.height = 200


	def config(self, **kwargs):

		try:
			self.path = kwargs['path']
			self.picture = Image.open(self.path)
			if 'resize_portr' in kwargs:
				self.picture = self.picture.resize((200, 200), Image.ANTIALIAS)
			self.image = ImageTk.PhotoImage(self.picture)
			self.label.config(image=self.image)
		except:
			pass
			#print("the widget could not be configured")

		try:
			self.bgc = kwargs['bg']
			self.label.config(bg=self.bgc)
		except:
			pass
			#print("the widget background color could not be changed")


	def trytoplace(self, **kwargs):
		self.parent = kwargs['parent']
		self.row = kwargs['row']
		self.column = kwargs['column']


	def place(self, **kwargs):

		try:
			self.trytoplace(**kwargs)
		except:
			print("widget could not be placed")

		self.picture = Image.open(self.path)
		self.image = ImageTk.PhotoImage(self.picture)

		self.label = Label(self.parent, image=self.image, bd=1)#, bg='black')
		self.label.grid(row=self.row, column=self.column, pady=5)
		self.label.bind('<Button-1>', lambda e: self.label.focus_set())


	def getData(self):
		return self.path


	def setData(self, data):
		#le sigh
		if data == '' or 'N/A': return
		self.config(path=data, resize_portr=True)


	def hide(self):
		self.label.grid_forget()
开发者ID:drinkingTea,项目名称:ryb_sms,代码行数:71,代码来源:photoWidget2.py


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