Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Study guide

Python Beginner Course Note-7

Rating
-
Sold
-
Pages
30
Uploaded on
15-09-2020
Written in
2018/2019

This is the last series of the crash course material provided. Hope you had a great journey with Python.

Institution
Course

Content preview

Day-8: GUI
29/06/2018




Department Of
Computer Science
Engineering

SKFGI, Mankundu

, Python 3 - GUI Programming (Tkinter)
Python provides various options for developing graphical user interfaces
(GUIs). The most important features are listed below.
 Tkinter − Tkinter is the Python interface to the Tk GUI toolkit
shipped with Python. We would look this option in this chapter.
 wxPython − WxPython brings the wxWidgets cross-platform GUI
library from its native C++ to Python. WxPython is a slightly more
modern approach to, which looks a little more native than Tkinter
across different operating systems as it does not attempt to create
its own set of widgets (although these can be themed to look much
like native components). It's fairly easy to get started with as well,
and has a growing developer community. You may need to bundle
wxPython with your applications, as it is not automatically installed
with Python.
 PyQt −This is also a Python interface for a popular cross-platform
Qt GUI library.
 JPython − JPython is a Python port for Java, which gives Python
scripts seamless access to the Java class libraries on the local
machine
1.Tkinter Programming
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.
Creating a GUI application using Tkinter is an easy task. All you need to
do is perform the following steps −
Import the Tkinter module.
Create the GUI application main window.
Add one or more of widgets to the GUI application.

, Enter the main event loop to take action against each event triggered by
the user.
Example

From tkinter import *
# note that module name has changed from Tkinter in Python 2 to
tkinter in Python 3
top = Tk()
# Code to add widgets will go here...
top.mainloop()


The last line calls the mainloop function. This function calls the endless
loop of the window, so the window will wait for any user interaction till we
close it.
If you forget to call the mainloop function, nothing will appear to the
user.
1.1To rename the widgets
from tkinter import *
window = Tk()
window.title("Welcome ")
window.mainloop()


1.2Setting Window Size
We can set the default window size using the geometry function like
this:
window.geometry('350x200')
The above line sets the window width to 350 pixels and the height
to 200 pixels.
1.3Print the screen size
from tkinter import*
root=Tk()
w=root.winfo_screenwidth()
h=root.winfo_screenheight()
print(w)
print(h)

Connected book

Written for

Institution
Course

Document information

Uploaded on
September 15, 2020
Number of pages
30
Written in
2018/2019
Type
Study guide

Subjects

$5.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
snehat1410

Get to know the seller

Seller avatar
snehat1410 MAKAUT
Follow You need to be logged in order to follow users or courses
Sold
1
Member since
5 year
Number of followers
1
Documents
14
Last sold
5 year ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions