Question 4 Develop GUI for an application based on user requirements. The GUI helps customer plan and compute the total

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Question 4 Develop GUI for an application based on user requirements. The GUI helps customer plan and compute the total

Post by answerhappygod »

Question 4 Develop Gui For An Application Based On User Requirements The Gui Helps Customer Plan And Compute The Total 1
Question 4 Develop Gui For An Application Based On User Requirements The Gui Helps Customer Plan And Compute The Total 1 (125.82 KiB) Viewed 39 times
Question 4 Develop Gui For An Application Based On User Requirements The Gui Helps Customer Plan And Compute The Total 2
Question 4 Develop Gui For An Application Based On User Requirements The Gui Helps Customer Plan And Compute The Total 2 (283.6 KiB) Viewed 39 times
Question 4 Develop Gui For An Application Based On User Requirements The Gui Helps Customer Plan And Compute The Total 3
Question 4 Develop Gui For An Application Based On User Requirements The Gui Helps Customer Plan And Compute The Total 3 (302.43 KiB) Viewed 39 times
PART A & B PLEASE.
PYTHON OOP
THANK YOU
Question 4 Develop GUI for an application based on user requirements. The GUI helps customer plan and compute the total cost of trips based on Table Q4. Calculation based on Distance (km) Type of trip Cost $1 per km $10 for trips 12km and under $20 for trips beyond 12km Table 04 You do not need to use any of the classes in Q1 to Q3. Refer to the partial code in Figure Q4(e). Figure Q4(a) shows the initial GUI. When the user clicks on the button Add Trip If the selected radiobutton is By Trip, the distance entered determines the type of trip (either long or short), and 1 is added to either self._longTrip or self._short Trip accordingly. If the selected radiobutton is By Distance, the distance entered is added to self._distance. The GUI shows the values of these variables before and after the increment, as shown in Figure Q4(b). Get Total The GUI computes the total cost for each category of trips based on Table Q4 and shows the computation, as shown in Figure Q4(c). • Clear The GUI clears the text field for distance and selects the radiobutton By Trip, as shown in Figure Q4(d). Reset The GUI clears the text field for distance, selects the radiobutton By Trip, clears the scrolltext and sets the variables self._longTrip, self._shortTrip and self._distance to 0 (zero), thus, reverting to the GUI as shown in Figure Q4(a).
х Travel Card Trip Planner Distance: o By Trip By Distance Add Trip Get Total х Travel Card Trip Planner Distance: 122 By Trip By Distance Add Trip Get Total Clear Reset Before adding trip, accumulated long trips = 0 short trips = O distance = 0 After adding trip, accumulated long trips - 1 short trips - o distance - 0 long trips - 1X20 = $ 20 short trips = OX10 = $ 0 distance 0.00km = $ 0.00 Clear Reset Figure 04(c) Travel Card Trip Planner x х Distance: © By Trip By Distance Add Trip Get Total Clear Reset Before adding trip, accumulated long trips = 0 short trips = o distance = 0 After adding trip, accumulated long trips = 1 short trips = 0 distance = 0 long trips = 1x20 = $ 20 short trips - Ox10 - S 0 distance 0.00km - $ 0.00 Figure 04(a) Travel Card Trip Planner Х Distance: 12.1 o By Trip By Distance Add Trip Get Total Clear Reset Before adding trip, accumulated long trips = 0 short trips o distance = 0 After adding trip, accumulated long trips = 1 short trips = o distance = 0 Figure 040) import tkinter as tk from tkinter import ttk from tkinter import scrolledtext class TravelCardGui: def __init__(self): self._longTrip = 0 self._short Trip - self._distance - self win - tk. Tk() self._win.title("Travel Card Trip Planner") self.create_widgets() self._win.geometry(650x310) self._win.mainloop() Figure Q4(b)
(a) Show the containment (parent-child) hierarchy of the GUI components. (6 marks) def enableOutput (self): self.scrol_stxt.config(state - tk.NORMAL) def disableOutput (self): self.scrol_stxt.see( 'end') self.scrol_stxt.config(state - tk.DISABLED) def clearOutput (self): self.enableOutput) self.scrol_stxt.delete(1.0, tk.END) self.disableOutput() def writeToScrollText (self, message): self.enableOutput) self.scrol_stxt.insert('end', f'{message}'+'\n') self.scrol_stxt.see( 'end) self.disableOutput() def create_widgets(self): dataFrame - ttk. Frame(self._win) self._distance_lbl - ttk. Label(dataFrame, text="Distance:") self distanceValue - tk. Stringvar() self._distance_Ety - ttk. Entry(dataFrame, width=18, textvariable-self._distanceValue) self._distance_lbl.grid(column-e, row-) self._distance_Ety.grid(column=1, row=e, sticky-tk. Ew) radioFrame - ttk.Frame(dataFrame) radioFrame.grid(column=1, row=1, sticky-tk.EW) self._cardType - tk. IntVar() self._cardType.set() trip_rdbtn - tk. Radiobutton(radioFrame, text - 'By Trip', variable-self._cardType, value=) distance_rdbtn - tk.Radiobutton(radioFrame, text - 'By Distance', variable-self._cardType, value=1) trip_rdbtn.grid(column=1, row=0, sticky-tk.w) distance_rdbtn.grid(column=2, row=0, sticky-tk.w) actionFrame - ttk.Frame(dataFrame) actionFrame.grid(column-1, row=3) self._travel_btn- ttk.Button(actionFrame, text="Add Trip) self. travel_btn.pack(side - tk. LEFT) self total_btn - ttk.Button(actionFrame, text="Get Total") self._total_btn.pack(side - tk. LEFT) self._clear_btn - ttk.Button(actionFrame, text="Clear") self._clear_btn.pack (side - tk.LEFT) self._reset_btn - ttk.Button(actionFrame, text="Reset") self._reset_btn. pack (side - tk. LEFT) (b) Implement event handling so that the GUI can respond to left button clicks on all the buttons. (14 marks) dataFrame.pack(side - tk. TOP) outputFrame - ttk. Frame(self._win) output Frame.pack(side - tk. TOP) self.scrol_stxt - scrolledtext.ScrolledText (outputFrame, width=60, height=10, wrap=tk.WORD) self.scrol_stxt.grid(column=e, row=0, sticky='WE', columnspan-2) Figure 04(e)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply