0% found this document useful (0 votes)
12 views

Python Application

Uploaded by

merryfil.adolfo
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Python Application

Uploaded by

merryfil.adolfo
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Python Application

Module 9
Python GUI Programming
● Python provides various options for developing graphical user
interfaces (GUIs). Most important are listed below:
○ Tkinter − Tkinter is the Python interface to the Tk GUI toolkit shipped with
Python
○ wxPython − This is an open-source Python interface for wxWindows
○ JPython − JPython is a Python port for Java which gives Python scripts
seamless access to Java class libraries on the local machine
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 the above-mentioned widgets to the GUI application.
○ Enter the main event loop to take action against each event triggered by the user.
Example
TKinter Widgets
● Tkinter provides various controls, such as buttons, labels and text boxes used
in a GUI application.
● These controls are commonly called widgets.
● There are currently 15 types of widgets in Tkinter.
TKinter Widgets
● Button - The Button widget is used to display buttons in your application.
● Canvas - The Canvas widget is used to draw shapes, such as lines, ovals, polygons and
rectangles, in your application.
● Checkbutton - The Checkbutton widget is used to display a number of options as
checkboxes. The user can select multiple options at a time.
● Entry - The Entry widget is used to display a single-line text field for accepting values from
a user.
● Frame - The Frame widget is used as a container widget to organize other widgets.
● Label - The Label widget is used to provide a single-line caption for other widgets. It can
also contain images.
● Listbox - The Listbox widget is used to provide a list of options to a user.
● Menubutton - The Menubutton widget is used to display menus in your application.
TKinter Widgets
● Menu - The Menu widget is used to provide various commands to a user.
These commands are contained inside Menubutton.
● Message - The Message widget is used to display multiline text fields for
accepting values from a user.
● Radiobutton - The Radiobutton widget is used to display a number of options
as radio buttons. The user can select only one option at a time.
● Scale - The Scale widget is used to provide a slider widget.
● Scrollbar - The Scrollbar widget is used to add scrolling capability to various
widgets, such as list boxes.
● Text - The Text widget is used to display text in multiple lines.
Simple TKinter Exercise
● Access the url link below for tkinter simulation:
○ https://realpython.com/python-gui-tkinter/
Web Scraping
● Web scraping is a term used to describe the use of a program or algorithm to
extract and process large amounts of data from the web
● Whether you are a data scientist, engineer, or anybody who analyzes large
amounts of datasets, the ability to scrape data from the web is a useful skill to
have
● Let's say you find data from the web, and there is no direct way to download
it, web scraping using Python is a skill you can use to extract the data into a
useful form that can be imported
Preliminary Requirements
● Installing the packages
○ pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-
oauthlib
■ (Alternative) for Python 3
■ pip3 install --upgrade google-api-python-client google-auth-httplib2 google-
auth-oauthlib

○ MAC Terminal
■ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
■ python3 get-pip.py
■ pip install gspread
Steps and Procedures
● Create google sheet
● Enable Google Drive and Sheets API
○ Go to Google Developers Console
○ Click Select a Project option
○ Click NEW PROJECT
○ Enter Project Name
○ Click CREATE
○ Select and click the created project
○ Search and enable API’s
■ Google Drive API
■ Google Spreadsheet API
○ Select Credentials and click CREATE CREDENTIALS
○ Select Service Account
○ Enter Service Account Name and click Create and Continue
○ Define Role (OPTIONAL), click Continue
○ Click Done
○ Click on the service account created and then select KEYS
○ Click Add Key and then select Create New Key
○ Select JSON and then click CREATE
○ The key will then be downloaded into your local directory folder
Work with the KEY file for the Google Sheet Access
● Open the JSON key file and locate the email client
● Copy the generated email client address
● Open the Google Sheet file and then click the Share button
● Paste the generated email client address and then click Send
Into Coding
● Create a project folder for your python code
● Create a python file (main) in that folder
● Copy the JSON key file into that folder
● Rename the JSON key file for it to be readable
● Let’s start coding:
○ Import libraries and packages
○ Open Google Developer Identity to search for SCOPE
○ Select OAuth 2.0 and select Scopes for Google API
○ Validate the credentials from the JSON key file
○ Open and access the google sheet file and the worksheet
Into Coding (manipulating content)

● Manipulate the google sheet file


○ Count the rows and columns
○ Get records
○ Update records
○ Add worksheets
○ Add content and updates on that worksheets
Thank you.

You might also like