The lessons for M06 focus on building GUI (Graphical User Interface) programs.
Instead of a banner, include your name or initials in the main window title.
Exercise #1 (Hello World)
This is the simplest GUI program you can create. The objective here is to simply get a working GUI program under your belt.
Create a Hello World program. It will only have a single window. The only requirements are
- add your name or initials to the window title (per the standards)
- display Hello World on the window
Extra credit available: Display "Hello World" in a large font (3 points); change the color on the text (other than black) or window (other than white) or both (3 points)
Testing: Your results should look similar to the image below.
Exercise #2 (Temperature Converter)
Write a GUI program that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, then see the equivalent Fahrenheit temperature. Use the following formula to make the conversion: F=95C+32, where F is the Fahrenheit temperature, and C is the Celsius temperature. (Do NOT use F and C as variable names - use meaningful variable names).
The user should be able to enter a generic temperature, and then click one of 3 buttons:
- convert to Fahrenheit
- convert to Celsius
- clear the form
Display the results as a Label, not a Text Box.
Testing: Your results should look similar to the image below, although it is not necessary to include colors and make the window fancy. I will test using the values 89 to converted Celsius and 32 to convert to Fahrenheit. I will also try to Clear the window.
Extra credit available: Validate the user input make sure it is not blank and display an error message if it is blank (3 points)
Exercise #3 (Final Project Basic Form)
The goal of this assignment is to get your main window displayed with most of the labels, text boxes, and buttons (and other elements, if needed). None of the elements or buttons need to "do anything" (that is the next assignment). You do not need to worry about fonts, colors or anything else in terms of style, unless you wish to do that at this stage. You do not need to create a button for or plan for a second window at this point.
Create your program file. You must make several decisions about how to proceed with the basic design. Among these are:
- whether to use plain TKinter or using the breezypythongui library referenced in the book
- a naming scheme for your UI elements
- whether to primarily use the grid system or x/y coordinates to position your UI elements
There are a series of articles on GUI Coding on this site, that walks through creating a GUI program based on standard TKinter coding. It is an alternate to using the breezypythongui library listed in the book.
Screen display of the instructors sample program for the Final Project:
Exercise #4 (Clear the Form)
This assignment builds on Exercise 3. There are two goals:
- create a label message that can be used for errors and other information
- mock up the functions for any buttons
A message label will be used to display error messages or other information, as needed. It should normally be placed near the bottom of the window, and initially does not display anything. In this assignment, it can be used for task 2 above.
All main windows should have a Clear button to clear any text boxes. For this assignment, the task is to clear all text boxes on the window, and to update the message label with a message such as "Form cleared"; this will show the message label is positioned correctly and working.
Sample display of the instructors sample program for the clear button. The form itself does not change, but the function triggered by the clear button will delete the text from all text boxes and display a message. (This clear message may not ultimately be used, but for now it demonstrates how the message can be used.)