import tkinter as tk
from tkinter import ttk

parent = tk.Tk()

tvar = tk.StringVar()

def swaptext():
    tvar.set('There' if tvar.get() == 'Hi' else 'Hi')

my_button = ttk.Button(parent, textvariable=tvar, command=swaptext)
my_button.pack()

parent.mainloop()

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading