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( '<>', 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()

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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()

 
 
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education