I have provided a file travelSystem6-API.py.
You will copy this file to travelSystem6.py, then modify it to present a GUI with the top-level window shown here created in the class myApp.
You can change this GUI to improve its contents and/or layout, but it must have the following elements:
A title in the top-level window.
A label for a text box into which the user will type an item ID.
A text box into which the user will type an item ID.
A button to show the availability for the item with the ID entered by the user.
A button to quit the application. After the user enters a valid ID and clicks the Show button to show the availability, the application then will present the availability for that item in a separate window, as shown here.
You can change this GUI to improve its contents and/or layout, but it must have labels and values for the ID, name, starting availability, and ending availability of the item requested by the user.
This information is read from the items file and transactions file via the functions readItems() and readTransactions() into the itemRecords dictionary. (So, working versions of travelClass.py and travelToolbox.py and the input files from Assignment 4 are required.)
Show transcribed image textTravel Show Item ID Quit
Expert Answer
script.py
#
# Start Here
#
class travelItem:
def __init__(self, itemID, itemName, itemCount):
self.itemID = itemID
self.itemName = itemName
self.availableStart = itemCount
self.transactions = []
def getID(self):
return self.itemID
def getName(self):
return self.itemName
def setName(self, newName):
self.itemName = newName
def getAvailableStart(self):
return self.getAvailableStart
def appendTransaction(self, num):
self.transactions.append(num)
def getTransactions(self):
return self.getTransaction
def getReservations(self):
reservations = 0
for item in self.transactions:
if item>0:
reservations += item
return reservations
def getCancellations(self):
cancellations = 0
for item in self.transactions:
if item < 0:
cancellations += item
return cancellations
def getAvailableEnd(self):
return self.availableStart – self.getReservations() – self.getCancellations()
from tkinter import *
root = Tk()
toplevel = Frame(root)
secondlevel = Frame(root)
toplevel.pack()
def quit():
root.destroy()
def show():
global itemID
gotid = itemID.get()
toplevel.destroy()
secondlevel.pack()
# Here you should get the details of the object with object id gotid variable
# and then extract all the info from that object into appropriate variables
# and then call the
# idvalue.config(text=object_name.getID )
# namevalue.config(text = object_name.getName )
# startvalue.config(text= object_name.getAvailableStart )
# endvalue.config(text = object_name.getAvailableEnd )
# CHANGE THE VALUE OF TEXT FROM BELOW LINES OF CODE LIKE ABOVE CODE
idvalue = Label(secondlevel, text = gotid).grid(row=1, column=2)
namevalue = Label(secondlevel, text = “sample text”).grid(row=2, column=2)
startvalue = Label(secondlevel, text = “sample text”).grid(row=3, column=2)
endvalue = Label(secondlevel, text = “sample text”).grid(row=4, column=2)
########################## top level windows ##################################
label = Label(toplevel, text =”ItemID”)
itemID = Entry(toplevel)
showbtn = Button(toplevel, text=”Show”, comman = show)
quit = Button(toplevel, text=”Quit”,command = quit)
label.grid(row=1, column=1)
itemID.grid(row=1, column=2)
showbtn.grid(row=1, column=3)
quit.grid(row=2, column=1, columnspan=3)
############################ second level window items ########################
id = Label(secondlevel, text=”ID”).grid(row=1,column=1)
name = Label(secondlevel, text=”Name”).grid(row=2, column=1)
start = Label(secondlevel, text=”Start”).grid(row=3, column=1)
end = Label(secondlevel, text=”End”).grid(row=4, column=1)
###############################################################################
root.mainloop()
CODE:
SAMPLE OUTPUT:
After hitting show button
I have done all that is requred to create the GUI , you have not provided the file from where objects information can be read so , According to what information you have given the answer is completed ,