This project is designed to train students to gain programming knowledge through self-learning with generative AI tools, such as Copilot, HKUSPACE Chat, etc.
The Python modules used in this project are limited to Tkinter (Tkinter is the standard GUI library for Python), Pillow, ImageTk, Image, and random. All the other modules cannot be used in this project.
This project will explore Graphical User Interface (GUI) programming and will consist of two parts.
Part 1 [15 marks] Get a task based on a student’s name and ID.
In this part, you need to design a user interface that contains labels, input boxes, and buttons. When a student inputs the Student Name and Student ID into the corresponding input box, and clicks the “Get Task” button, the task will be displayed after the “Your Task:” label. Press the “Exit Program” button to end this program.
The task will be determined by the following logic:
· Assign task A to students with even-numbered student IDs. The task string displayed after “Your Task:” label is:
"To complete task A: Display an image by selection."
· Assign task B to students with odd-numbered student IDs. The task string displayed after “Your Task:” label is:
"To complete task B: Display all images then shuffle them."
Design and implement part 1 following the specifications below and save the source code in the AI_Proj_Task.py file.
1. Create various widgets, such as labels, buttons, OptionMenu widgets, and Entry boxes. You shall seek help from HKU SPACE Chat or other generative AI tools to find out how to create them and position them in the window. Use the form. in AI-Prompts.docx to complete your self-learning.
2. The control details:
· The initial status before entering the student’s name and student ID
o Replace “John Doe” with your name and replace the sample student ID 20242020 with your Student ID.
o Note that the entry box after “Your Task:” is in disabled status initially.
· Output task when student ID is an even number
After the student’s name and student ID are entered, press the “Get Task” button. The output is as below if the student ID is an even number.
· Output task when student ID is an odd number
After the student's name and student ID are entered, press the “Get Task” button. The output is as below when the student ID is an odd number.
Part 2 [15 marks]
Part 2 should be implemented based on the task you received in Part 1. Pay attention carefully to your own task.
Student ID
|
Task
|
Even number
|
Task A: Display an image by selection.
|
Odd number
|
Task B: Display all four images then shuffle them.
|
1. Task A: Display an image by selection
Four images are provided for this task. You need to create a user interface containing an “Exit Program” button, a drop-down menu and an image label. The names of the four images should be listed in a drop-down menu, and the corresponding image should be displayed when its name is selected. This program will end when you click the “Exit Program” button.
Design and implement this task and save the source code in AI_Proj_Selection.py file.
The control details are provided for task A:
· Initial status of Task A.
Replace “John Doe” with your name and replace the sample student ID “20242020” with your Student ID.
l Options in the OptionMenu.
l Image display after selecting an image in the OptionMenu.
2. Task B: Display all four images in a window then shuffle them
Four images are provided for this task. You need to display those images in a window containing 4 labels, an “Exit Program” button, and a “Shuffle” button. Shuffle all images by pressing the “Shuffle” button. Clicking the “Exit Program” button should close the window and end the program immediately.
Design and implement this task and save it in the AI_Proj_Shuffle.py file.
The control details of Task B:
Replace “Amy Doe” with your name and replace the sample student ID “20242021” with your Student ID in the title.
Images will be randomly displayed on each image label after pressing the “Shuffle” button.
The window will be closed, and the program ends after clicking the “Exit Program” button.
|