1 Python Project Setup
Getting Started with Python
Overview
In this chapter, you will understand how set up your Python environment for your tkinter GUI development. We’ll cover installing Python, setting up a virtual environment, exploring professional Python IDEs suitable for tkinter development, and discussing notable coding platforms suitable for high schoolers.
TEKS Computer Science 1 (3): To foster students’ creativity and innovation by presenting opportunities to design, implement, and present meaningful programs through a variety of media
Content Objective
- Students will explore professional Python IDE for development (e.g., PyCharm).
- Students will explore and practice on a coding platform suitable for high schoolers (codehs sandbox)
- Students will learn how to create folders, files in their coding environment
- Students will learn how to share their code with other for collaborative purposes
- Keywords: IDE, documentation, pycharm, sandbox. prototype
Language Objective (read, write, speak):
- Students will be able to read technical documentation for python programming from W3school, Codehs inbuilt documentation, and other relevant sites
- Students will document the steps taken to setup their project in writing
- Student should be able to explain to their peers and the teacher their project setup and challenges faced
Tkinter and TTKBootstrap
Tkinter serves as the preinstalled and default graphical user interface (GUI) toolkit, for python offering a range of modules that enable developers to build small scale desktop applications with ease and speed. In addition, note that
- Tkinter is easy to learn, and comes built-in with Python, thus is often used by developers to quickly create prototype GUI applications before building the main app using more complex frameworks.
- Tkinter applications can be created using either functional or object oriented programming style
- Tkinter can be used for creating amazing projects for your Advanced Placement Computer Science create task
For this book we will be using a tkinter dependent library called ttkbootstrap which was developed by Israel Dryer and other contributors. This library provides easy customizations, better user experience, theme extensions, advanced widgets, and enhanced styling. However, ttkbootstrap needs to be manually installed using pip command.
Professional Python IDEs for Tkinter
An Integrated Development Environment (IDE) provides a comprehensive environment for writing, debugging, and testing code. Here are some professional Python IDEs suitable for tkinter development:
- PyCharm: Developed by JetBrains, PyCharm is a powerful and feature-rich IDE for Python development. It offers advanced files organization, code editing, debugging, and version control features. With PyCharm, you do not need to create a Virtual environment separately as it is automatically created when you start a project. pycharm also has a built-in terminal that allows you to use pip to install libraries. Another awesome features of pycharm is its autocompletion abilities that makes you to code faster
Suitable Coding Platforms for High Schoolers
There are several coding platforms and online IDEs that are suitable for high school students to practice Python programming and develop Tkinter projects. Some notable platforms include:
- Replit Python: Replit is an online IDE that supports multiple programming languages, including Python and can be used for tkinter projects. It provides a collaborative coding environment, version control, and deployment capabilities, making it ideal for classroom use and group projects. However most school districts do block this site.
- CodeHS Sandbox: CodeHS offers a free sandbox environment where students can write, run, and debug Python code directly in the browser. In addition, codehs sandbox allows for real time collaboration and teachers can track students progress in projects. The most noticeable limitation with codeHS sandbox for tkinter GUI is that the resulting GUI may not have the best looks or efficiency, as it would on a professional IDE. For example, the title of app or custom icons may not be seen
Guided Task
- Create a project called BASICS on codehs sandbox, follow my directive
- Create a file called myname.py, set it to be the main file
- Create a file called requirements.txt and type in the word ttkbootstrap in the forst line
- Click the link below to access the hello world program, copy the code and paste in your file
- Examine and Run the code, what can you do to change the displayed text from my name to yours.
- PROJECT LINK
Exercise
- In full and complete sentences, complete the tasks below
- Discuss with your peers why programmers need documentation.
- In your own words explain what a user interface is
- What is the difference between codehs sandbox and pycharm?
- What are the differences between building a text-based app on console and a GUI app? Why might someone choose a GUI app
- Review the Code in task one, answer the following
- What is the likely purpose of the function called lapp()
Conclusion
We covered installing Python, explored professional Python IDEs suitable for Tkinter development, and discussed notable coding platforms suitable for high schoolers. With your Python environment configured, you’re ready to start building Tkinter projects! Finally, go to ttkbootstrap to see sample project that has been built using this library.