from tkinter import * from tkinter.ttk import * def my_button_behavior(): '''Executes when the 'hello' button is pressed''' button_text.set(button_text.get() + '!') # update the StringVar associated with the button def main(): window = Tk() global button_text # data is a global variable (OOP is better) button_text = StringVar() button_text.set('Hello') my_button = Button(window, textvariable=button_text, command=my_button_behavior) my_button.grid(row=0, column=0) my_button.configure(padding=50) # add 50 pixels of padding on all sides window.mainloop() # start the event loop main()