
#TKINTER TUTORIAL PYTHON PDF BOOK WINDOWS#
Our application should only have one root, but it is possible for us to create other windows which are separate from the main window.īutton and Label should be self-explanatory. We are using three widgets: Tk is the class which we use to create the root window – the main window of our application. All the widgets inside a window, like buttons and other controls, may look different in every GUI toolkit, but the way that the window frames and title bars look and behave is determined by your window manager and should always stay the same.

The window manager is the part of your operating system which handles windows. The window should have all the normal properties of any other window you encounter in your window manager – you are probably able to drag it around by the titlebar, resize it by dragging the frame, and maximise, minimise or close it using buttons on the titlebar. You should be able to see a window with a title, a text label and two buttons – one which prints a message in the console, and one which closes the window. pack () def greet ( self ): print ( "Greetings!" ) root = Tk () my_gui = MyFirstGUI ( root ) root. close_button = Button ( master, text = "Close", command = master.


greet_button = Button ( master, text = "Greet", command = self. label = Label ( master, text = "This is our first GUI!" ) self. From tkinter import Tk, Label, Button class MyFirstGUI : def _init_ ( self, master ): self.
