Program with Event-Driven Programming

Assignment: Working With Graphical Unit Interfaces and Event-Driven Programming

Outcomes addressed in this activity:

Unit Outcomes:

Design a graphical user interface.
Program with event-driven programming.
Course Outcome:

Compose software using advanced interface and program design techniques.

Purpose

The purpose of this assignment is to provide you with an opportunity to demonstrate your knowledge of creating a simple graphical user interface and allowing the user to control the program’s actions through event-driven programming.

Assignment Instructions

You must have Python and PyCharm installed to perform this assignment. You should use the free editions for each.

If you do not have the above software installed, please perform the required installations. The following documents will assist you with installation of the software:

Python
PyCharm
You will complete a program to demonstrate the skills presented in this unit. Please keep in mind that with all the assignments in this course, any given scenarios are hypothetical and intended solely to demonstrate specific skills.

Using the Python language in the PyCharm IDE, and the Tkinter library, please complete the following assignment:

You will create a GUI calculator program that will offer the user a button to clear the values and buttons for all digits 0 through 9, as well as the operator buttons for multiplication, division, addition, subtraction, and equal. You should be able to click the various digit buttons and have them display combined as a single number in an Entry object (e.g., if you click the 2, 4, and 7 buttons successively, the display should show 247). If you click on an operator button, the current value must be included in the running total based on the last operator button clicked. If no operator button has been clicked since the start of the program or since the last time the clear button has been clicked, then the current value will be added to the total by default. When the equal button is clicked, the current value will be added or subtracted from the total per the previous operator button, and then the final total will be shown in the Entry object display. All of this mimics a standard calculator that you have used before.

Assignment Requirements

Your program should display a frame with an Entry object across the top. Below that, the frame should display the buttons described in the assignment description above. (You might want to look at the calculator app on your phone for an example of the layout.)
Name all of your controls suitable names. Hint: prefixes can make control names easier to distinguish from each other. Examples include cmd for command button, txt for textbox, and lbl for label. Standard naming conventions are common in the software development field.
Most buttons should be the same size and neatly aligned in a grid pattern below the display. How you lay out the grid is up to you, but the recommendation is that you stick with the standard pattern for calculators. If you would like your operator buttons to be a different size from your digit buttons, that is fine, but all operator buttons should be the same size, and all digit buttons should be the same size. All buttons should display their value on their face and be centered.
Define any variables you need to keep up with that indicate what operator was last clicked, as well as the running total. Hint: This can be done with one variable for the total and one variable to indicate the last operator clicked.
Using events for the buttons, add functionality to each button.
Digit buttons should append their respective digit to the end of the displayed number.
Operator buttons should call for the currently displayed value to perform the appropriate operation called.
The equal button should call for the last operation to be completed just as the other operators do, then display the final total in the display.
The clear button should clear the display (either make it blank or make it display 0), as well as reset all variables as they were when the program began.
EXPECTED OUTPUT

The image below shows a working calculator for multiplication, division, addition, and subtraction:

Directions for Submitting Your Assignment

Submit the calculator program (note: program files end in .py). Also submit a screenshot of the calculator running. Since this includes multiple files, you may zip the files together and submit the zip file to the submission link.

Naming Your Project and Source Code File

It is always best to name your new assignment documents and code files with an appropriate name when you create them. Use the naming convention IN254_YourLastName_Unit2 for your assignment documents and code file.

Review the rubric before beginning this activity.

Do you need urgent help with this or a similar assignment? We got you. Simply place your order and leave the rest to our experts.

Order Now

Quality Guaranteed!

Written From Scratch.

We Keep Time!

Scroll to Top