"

1 Python Project Setup

Getting Started with Python

Introduction

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

Learning Objective

  • Students will be able to state the various platforms (used for professional Python IDE for development e.g., PyCharm).
  • Students will be able write source codes on a coding platform suitable for high schoolers (codehs sandbox)
  • 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 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 will explain to their peers their project setup and challenges faced
  • Students will learn how to create folders, files in their coding environment
  • Students will share their code with other for collaborative purposes

 

Tkinter and TTKBootstrap

Tkinter serves as the preinstalled and default graphical user interface (GUI) toolkit, for python offering a range of modules that developers can use to build small scale desktop applications with ease and speed. In addition, note that

  1. Tkinter is easy to learn, and comes built-in with Python, thus is often used by developers to quickly create prototype GUI applications.
  2. Tkinter applications source codes can be created using either functional or object oriented programming style
  3. 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:

  1. 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.
  2. VSCode: A product from microsoft that can also be used for developing very powerful application, it comes with a terminal which by default uses command prompts style or powershell, but can be configured to use linux styled terminal

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:

  1. 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.
  2. 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. Points to note when using codeHS sandbox include:
    • The resulting user interface 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 be truncated
    • Some libraries would not work on codeHS sandbox. For example, the python library used for analyzing sentiments from human text would not work.
    • To install libraries in codeHS, put all libraries into a document called requirements.txt located and the root directory (one library per line). However, you reinstall each time you rerun.

Guided Task

  1. Create a project called BASICS on codehs sandbox, follow my directive
  2. Create a file called myname.py, set it to be the main file
  3. Create a file called requirements.txt and type in the word ttkbootstrap in the forst line
  4. Click the link below to access the hello world program, copy the code and paste in your file
  5. Examine and Run the code, what can you do to change the displayed text from my name to yours.
  6. PROJECT LINK

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 librar and be motivated

 

Exit Ticket

  1. In full and complete sentences, complete the tasks below
    • Discuss with your peers why programmers need documentation. (3 minutes to write, 2 minutes to discuss)
    • 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
  2. Review the Code in task one, answer the following
  3. What is the likely purpose of the function called lapp()

License

Icon for the CC0 (Creative Commons Zero) license

To the extent possible under law, benyeogorosenwe has waived all copyright and related or neighboring rights to Building Apps with Tkinter, except where otherwise noted.