Python GUI

LusciousLarryDas 3,454 views 13 slides Feb 17, 2020
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
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.


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.

Events List
1.<Button>: <Button-1>(left), <Button-2>(middle), <Button-3>(right), <Button-4>(scroll
up), <Button-5>(scroll down)
2.<Double-Button>: <Double-Button-1>(left), <Double-Button-2>(middle),
<Double-Button-3>(right)
3.<Enter>
4.<Leave>
5.<Return>
6.<Key>

Connection with DB

Git links
1.Learning Python - https://github.com/larrydanny/learning-python
2.Some APPs - https://github.com/larrydanny/python-apps
3.Simple Calculator - https://github.com/larrydanny/very-simple-calculator-python
4.Some Games - https://github.com/larrydanny/python-games

Thank You