[Tkinter] GUI - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] GUI (/thread-23873.html) |
GUI - arbondioxide - Jan-21-2020 Hello, im creating a code for main menu for a game. Im using tkinter and want to make my buttons open a new window and so on . Basically making my buttons do something when pressed. any answers? from tkinter import * def main_screen(): screen= Tk() screen.geometry("300x250") screen.title("Bomberman") Label(text = "Bomberman", bg = "grey", font = ("Arial", 13)).pack() Button(text = "START").pack() Label(text = "").pack() Button(text = "LEADERBOARDS").pack() screen.mainloop() if __name__ == '__main__': main_screen() you absoilute snakes wtf you doing reply im in a computer science lesson and youre longing man out RE: GUI - Larz60+ - Jan-22-2020 define buttons as so: def myfunction(): ... Button(text = "START", command=myfunction).pack()I prefer to name buttons, and include pack, grid, place on separate line (most often grid) RE: GUI - arbondioxide - Jan-23-2020 Thankyou sir. what do i put inside the function to make it so when i click a button it opens a new window RE: GUI - Larz60+ - Jan-23-2020 There are many examples (google 'tkinter create new window on button click') for example: https://abdurrahmaanjanhangeer.wordpress.com/2017/05/07/python-tkinter-new-window-on-button-click/comment-page-1/ |