Need assistance running this code. Please include output. I am given an error. Python language
# This program allows the user to see the time zone
# for a selected city.
import tkinter
class TimeZone:
def __init__(self):
# Create the main window.
self.main_window = tkinter.Tk()
self.main_window.title('Time Zones')
# Create the widgets.
self._ _build_prompt_label()
self._ _build_listbox()
self._ _build_output_frame()
self._ _build_quit_button()
# Start the main loop.
tkinter.mainloop()
# This method creates the prompt_label widget.
def _ _build_prompt_label(self):
self.prompt_label = tkinter.Label(
self.main_window, text='Select a City')
self.prompt_label.pack(padx=5, pady=5)
# This method creates and populates the city_listbox widget.
def _ _build_listbox(self):
# Create a list of city names.
self._ _cities = ['Denver', 'Honolulu', 'Minneapolis',
'New York', 'San Francisco']
# Create and pack the Listbox.
self.city_listbox = tkinter.Listbox(
self.main_window, height=0, width=0)
self.city_listbox.pack(padx=5, pady=5)
# Bind a callback function to the Listbox.
self.city_listbox.bind(
'<<ListboxSelect>>', self._ _display_time_zone)
# Populate the Listbox.
for city in self._ _cities:
self.city_listbox.insert(tkinter.END, city)
# This method creates the output_frame and its contents.
def _ _build_output_frame(self):
# Create the frame.
self.output_frame = tkinter.Frame(self.main_window)
self.output_frame.pack(padx=5)
# Create the Label that reads "Time Zone:".
self.output_description_label = tkinter.Label(
self.output_frame, text='Time Zone:')
self.output_description_label.pack(
side='left', padx=(5, 1), pady=5)
# Create a StringVar variable to hold the time zone name.
self._ _timezone = tkinter.StringVar()
# Create the Label that displays the time zone name.
self.output_label = tkinter.Label(
self.output_frame, borderwidth=1, relief='solid',
width=15, textvariable=self._ _timezone)
self.output_label.pack(side='right', padx=(1, 5), pady=5)
# This method creates the Quit button.
def _ _build_quit_button(self):
self.quit_button = tkinter.Button(
self.main_window, text='Quit',
command=self.main_window.destroy)
self.quit_button.pack(padx=5, pady=5)
# Callback function for the city_listbox widget.
def _ _display_time_zone(self, event):
# Get the current selections.
index = self.city_listbox.curselection()
# Get the city.
city = self.city_listbox.get(index[0])
# Determine the time zone.
if city == 'Denver':
self._ _timezone.set('Mountain')
elif city == 'Honolulu':
self._ _timezone.set('Hawaii-Aleutian')
elif city == 'Minneapolis':
self._ _timezone.set('Central')
elif city == 'New York':
self._ _timezone.set('Eastern')
elif city == 'San Francisco':
self._ _timezone.set('Pacific')
# Create an instance of the TimeZoneclass
if _ _name_ _ == '_ _main_ _':
time_zone = TimeZone()
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- Using a gui in java please create a tic tac toe game. Player can verse player or computer (buttons) Please create one the program using JFrame implements action listener More requirements belowarrow_forwarddreamweaver creates a library folder in the _____ panel automatically when you set up the libraryarrow_forwardPlease help me create a trivia game using java. The trivia game should come up with random questions about cars, science, math, computers etc the program should have some of the following ( indicate what you've chosen Fractals 2D arrays recusrsion Gui classes methods A game menu pagearrow_forward
- Please following the instructions on the screenshot provided. Please create the program in Java code. Please include commenting.arrow_forwardDo this in JAVA Programmingarrow_forwardPlease create a game or software using java(I.e online document editor, tetris, etc. that uses includes some of the following below Fractals Inheritance Graphic user interface 2d arrays Recursion Classes and methodsarrow_forward
- Write a class that uses the command window that displays Programs comments are nonexecuting statements you add to a file for the purpose of documentationarrow_forwardJAVA Create a GUI program that prompts the user to enter the password "Password123". It should grant the user access to a grade book in which they can edit.arrow_forwardJava Programming: Advanced GUIs and Graphics (doing an Applet) Creat an applet to draw a digit using the method fillRect of the class Graphics. Fpr instance, if the input is 4, the applet will display 4. Thank you and for some reason I cannt paste my code for this program--sorryarrow_forward
- PYTHON!! class Triangle: def __init__(self,sides): self.a = sides[0] self.b = sides[1] self.c = sides[2] if __name__ == '__main__': t = Triangle([3,6,2]) print(f'Side1 = {t.a}') print(f'Side2 = {t.b}') print(f'Side3 = {t.c}') Based on the code. Assume you are in the Triangle class: Create a method called calcArea. It will calculate and return the area of the triangle using this formula:arrow_forwardJava Question - Instructions are in the attached pictures. The picture titled "Screenshot..." are the instructions for building the specific code, while the "Final Output" picture shows what the output of the code should look like. Thank you.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education