LusciousLarryDas
3,454 views
13 slides
Feb 17, 2020
Slide 1 of 13
1
2
3
4
5
6
7
8
9
10
11
12
13
About This Presentation
Python gui tkinter basic presentation for beginners. In my git repos get some sample code like weather app, tic-tac-toe game, simple calculator etc.
Size: 310.85 KB
Language: en
Added: Feb 17, 2020
Slides: 13 pages
Slide Content
Python GUI
Luscious Larry Das
About Python GUI
Python is an interactive programming which has multiple options
for developing GUI (Graphical User Interface). Some of them are
1.Kivy - Linux, Windows, OS X, Android, IOS, Raspberry Pi
2.PyQT - Linux, Windows, OS X, Android, IOS
3.PyForms - Linux, Windows, OS X
4.WxPython - Linux, Windows, OS X
5.Tkinter - Linux, Windows, OS X
About Tkinter
Tkinter is the standard GUI library for Python. Python when
combined with Tkinter provides a fast and easy way to create GUI
applications. Tkinter provides a powerful object-oriented interface
to the Tk GUI toolkit.
It’s built in library so no need to install. Just need to import.
How it work?
1.Tk() - To create a main window, tkinter offers a method Tk()
2.mainloop() - is an infinite loop used to run the application, wait
for an event to occur and process the event as long as the
window is not closed.
Widget
Tkinter provides various controls, such as buttons, labels and text
boxes used in a GUI application. There are currently 15 types of
widgets in Tkinter.
1.Button 6. Label 11. Radiobutton
2.Canvas 7. Listbox 12. Scrollbar
3.Checkbutton 8. Menubutton 13. Text
4.Entry 9. Menu 14. Toplevel
5.Frame 10. Message 15. PhotoImage
Geometry Configuration
Tkinter offers access to the geometric configuration of the widgets
which can organize the widgets in the parent windows. There are
mainly three geometry manager classes class.
1.pack() - organizes the widgets in blocks
2.grid() - organizes the widgets in grid (table-like structure)
3.place() - organizes the widgets by placing them on specific
positions
How to add widgets?
Button(window, option=value) - Options (activebackground,
activeforeground, bg, command, font, image, height, width)
Image Widget
Tkinter user PhotoImage() to display images. But with this widget
we only can display GIF images.
To display other format images we need to install pillow package.
Example code on pillow
Events and Binds
Tkinter provides a mechanism to let the programmer deal with
events. For each widget, it's possible to bind Python functions and
methods to an event.
widget.bind(event, handler)
If the defined event occurs in the widget, the "handler" function is
called with an event object. describing the event.