Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python tkinter delete label

import tkinter as tk

# Create Main window.
root = tk.Tk()
root.title('Label Destroyer')
root.geometry('250x100')

# Only use pack or grid can't use both interchangeably on the same frame
# or else you will get a Tkinter Error.

# Create label and grid/pack separately!
myLabel = tk.Label(root, text='This will be destroyed')
#myLabel.grid(row=0, column=0, padx=5, pady=5, sticky='n')
myLabel.pack(side=tk.TOP, padx=5, pady=5, anchor='n')

# Create a function to destroy label, else it'll be destroyed before it's seen.
# If not grid/pack separately you will get a, None Type Error.
def myFunc():
	myLabel.destroy() # <- destory label.
	myButton.config(text='Label destroyed!') # <- change button text.

# Create a button to call myFunc.
myButton = tk.Button(root, text='Destroy Label', command=myFunc)
#myButton.grid(row=1, column=0, padx=5, pady=5, sticky='s')
myButton.pack(side=tk.BOTTOM, padx=5, pady=5, anchor='s')

# Run main window.
root.mainloop()
Comment

destroy label tkinter

label.after(1000, label.master.destroy)
Comment

PREVIOUS NEXT
Code Example
Python :: code to take the picture 
Python :: how to convert tuple into list in python 
Python :: how to check if a string contains a word python 
Python :: python property decorator 
Python :: sphere volume formula 
Python :: training linear model sklearn 
Python :: gurobi python example 
Python :: pillow image from array 
Python :: binary to string python 
Python :: python array looping 
Python :: how to make every letter capital in python 
Python :: how to join two dataframe in pandas based on two column 
Python :: python join list 
Python :: matp[lotlib max y value 
Python :: python i++ 
Python :: global in python 
Python :: python if type dict 
Python :: dm user discord.py 
Python :: adding to python path 
Python :: set points size in geopandas plot 
Python :: python plot arrays from matrix 
Python :: numpy timedelta object has no attribute days 
Python :: python run code at the same time 
Python :: get median using python 
Python :: python plot label value 
Python :: how to create an integer validate python 
Python :: python argsort a list 
Python :: how to add space in st.write streamlit 
Python :: pandas loc for list 
Python :: python sleep 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =