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 :: python get time difference in milliseconds 
Python :: ordered char list 
Python :: python sum comprehension 
Python :: python dictionary get keys with condition on value 
Python :: How to make an simple python client 
Python :: python discord how to get user variables 
Python :: how to filter mask results in python cv2 
Python :: django make migrations 
Python :: django foreign key error Cannot assign must be a instance 
Python :: f string decimal places 
Python :: return column of matrix numpy 
Python :: pandas drop rows with empty list 
Python :: create pdf from images python 
Python :: python working directory executed file 
Python :: change all columns in dataframe to string 
Python :: flask api response code 
Python :: python find closest value in list to zero 
Python :: tkinter hover button 
Python :: docker pyinstaller windowa 
Python :: all column except pandas 
Python :: check pip installed packages inside virtualenv 
Python :: python get the key with the max or min value in a dictionary 
Python :: delete space in string python 
Python :: import stopwords 
Python :: space to underscore python 
Python :: python ls 
Python :: python async threading 
Python :: rename a column in python 
Python :: extract link from text python 
Python :: creating virtual environment python 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =