Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter
#3
This should help:

from tkinter import Tk, Button
button_tries = -1

def change_button (event) :
	global button_tries
	tries = ('Second', 'Third')
	button_tries += 1
	if button_tries <= 1 :
		button.configure (text = f'{tries [button_tries]} Try')
 
window = Tk ()
button = Button (window, text = 'First Try')
button.pack (padx = 10, pady = 10)
window.bind ('<Return>', change_button)
window.mainloop ()
Press Return to change the button text.
Reply


Messages In This Thread
tkinter - by nashenas - Feb-21-2021, 03:41 PM
RE: tkinter - by Yoriz - Feb-21-2021, 06:05 PM
RE: tkinter - by BashBedlam - Feb-21-2021, 06:21 PM
RE: tkinter - by deanhystad - Feb-21-2021, 06:25 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020