from tkinter import * # Importing gui module def button_function(): # The function that the button will run print("Text") screen = Tk() # Creating a screen button_quit = Button(screen, text="Quit", command=lambda:quit) # Creating a button button_quit.pack() # Putting the button on the screen button2 = Button(screen, text="BUTTON TEXT", command=lambda:button_function()) # Creating another button button2.pack() # Putting that button on the screen screen.mainloop # Opening the screen
Here is what the above code is Doing:
1. Importing the tkinter module
2. Creating a function that the button will run
3. Creating a screen
4. Creating a button that will quit the program
5. Putting the button on the screen
6. Creating another button that will run the function
7. Putting that button on the screen
8. Opening the screen