Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tkinter while button not pressed

from tkinter import *

root = Tk()
root.geometry('250x250')

display = Label(root, text='Hello', font=('', 20))
display.pack(pady=40)

def restart():
    display['text'] = 'Restarting...'
    but['state'] = 'disable'            # Once restarted the button gets disabled

def cancel():
    # Cancel the current after with it id
    root.after_cancel(L)
    display['text'] = 'Cancelled'

# Take a reference of after
L = root.after(5000, restart)

but = Button(root, text='Cancel', command = cancel )
but.pack(side='bottom', pady=30)

mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: math function in python 
Python :: how to make a calculator 
Python :: List Nested Lists 
Python :: a int and float python 
Python :: using slug or .. instead of pk in django 
Python :: how to sum only the odd values in python 
Python :: numpy sign method 
Python :: python update dict if key not exist 
Python :: grab the first letter of each string in an array python 
Python :: what does manage.py do 
Python :: set index pandas 
Python :: python os check if file with extension exists 
Python :: py string find regex pos 
Python :: put grid behind matplotlib 
Python :: na in python 
Python :: optimization in python 
Python :: Can there be an if statement inside an if statement python 
Python :: Python Projects for Beginners: A Ten-Week Bootcamp Approach to Python Programming 
Python :: python excel sheet 
Python :: rezise object pygame 
Python :: python3 vowels and consonants filter 
Python :: how to change color of square in pygame with keypress 
Python :: make row readonly tablewidget pyqt 
Python :: ist comperension python 
Python :: mad libs game prompt python 
Shell :: remove steam from ubuntu 
Shell :: how to install obs on ubuntu 
Shell :: centos 7 apache restart 
Shell :: git set email and username 
Shell :: stop a process running on a port ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =