======================= Python GUI with Tkinter ======================= Installing Tkinter ================== .. code-block:: none fabgt@fabgt-SAT:~$ sudo apt-get install python3-tk Hello World! ============ .. Tip:: https://www.youtube.com/watch?v=YXPyB4XeYLA .. code-block:: Python #!/usr/bin/env python3 from tkinter import * root = Tk() #Creating a label widget my_label = Label(root, text="Hello World!") #Shoving it onto the screen my_label.pack() root.mainloop() Positioning with the Grid System ================================ .. code-block:: Python #!/usr/bin/env python3 from tkinter import * root = Tk() #Creating a label widget myLabel1 = Label(root, text="Hello World!") myLabel2 = Label(root, text="My name is Fabien") #Shoving it onto the screen myLabel1.grid(row=0, column=0) myLabel2.grid(row=1, column=1) root.mainloop() Result: .. image:: ../attachments/TkinterGrid.png :width: 200 :alt: Grid Positioning System Widgets ======= Bind Multiple Commands to Tkinter Button ---------------------------------------- Multiple commands could be executed after the button is clicked. The Tkinter button has only one command property so that multiple commands or functions should be wrapped to one function that is bound to this command. We could use lambda to combine multiple commands as, .. code-block:: Python command=lambda:[funcA(), funcB(), funcC()]