Programming Exercises 1. Name and Address Write a GUI program that displays your name and address when a button is clicked. The program's window should appear as the sketch on the left side of Figure 13-61 when it runs. When the user clicks the Show Info button, the program should display your name and address, as shown in the sketch on the right of the figure. re 13-61 Name and address program Show Info Quit Steven Marcus 274 Baily Drive Waynesville, NC 27999 Show Info Quit

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 18RQ
icon
Related questions
Question

Can someone help me solve this program? The only result shown is the empty window. 

Below is the codes I have: 

import tkinter as tk

import tkinter.messagebox

 

def myWindow: 

def --unit--(self): 

self.main_window = tkinter.Tk()

#This is a button for show info 

#When the user clicks the show info button

# The name and address should be displayed 

self.my_button = tkinter.Button(self.main_window, text = 'Click', command = self.do_something) 

 

#quit-button. When the user clicks on it, 

# the info should be deleted or closed

self.quit_button = tkinter.Button('Response', text = 'Quit', command = self.main_window.destroy)

 

#pack the button 

self.my_button.pack()

self.quit_button.pack()

 

#manin loop

tkinter.mainloop()

 

#enter the do something callback function for the button widget

def do_something(): 

#display info dialog box

tkinter.message box.showinfo('Response', Name and Address comes here') 

 

window =tk.Tk()

window.title(My Adrress) 

window.mainloop()

 

if --name-- == '--main--':

my-window = myWindow()

 

Chp12: GUI

Python: Fifth Edition (Tony GaDDis) 

 

 

d
em
Programming Exercises
1. Name and Address
Write a GUI program that displays your name and address when a button is clicked. The
program's window should appear as the sketch on the left side of Figure 13-61 when it
runs. When the user clicks the Show Info button, the program should display your name
and address, as shown in the sketch on the right of the figure.
igure 13-61 Name and address program
Show Info
Quit
Steven Marcus
274 Baily Drive
Waynesville, NC 27999
Show Info
Quit
Transcribed Image Text:d em Programming Exercises 1. Name and Address Write a GUI program that displays your name and address when a button is clicked. The program's window should appear as the sketch on the left side of Figure 13-61 when it runs. When the user clicks the Show Info button, the program should display your name and address, as shown in the sketch on the right of the figure. igure 13-61 Name and address program Show Info Quit Steven Marcus 274 Baily Drive Waynesville, NC 27999 Show Info Quit
ain.py - Lab12_GUI - Replit X +
replit.com/@katy21/Lab12GUI#main.py
012_GUI
y21
al
=t
+o
68
1
Help
3
Threads
Storage
8
9
⠀ 10
11
12 #def main():
13 ▼ class myGUI:
14
15
16▼
17
18
19
20
21
22
23
24
Debugger
8
main.py x +
X
25
26
27
28
29
30
31
32
33
import tkinter as tk
import tkinter.messagebox
#create main window widget
def __unit__(self):
self.main_window = tkinter.Tk()
#Create a button widget. The text "Click"
#do_somthing method should be executed
#when the user clicks the button
#
▶ Run
self.my_button = tkinter.Button self.main_window, \
self.do_something)
text = 'Click', command =
#Quit_button. When the button is clicked
#The root widget's destroy method is called
#(The main_window variable references the root widget,
# so the callback function is self.main_window.destroy.)
self.quit_button = tkinter. Button('Response',
text = 'Quit', command =
self.main_window.destroy)
Transcribed Image Text:ain.py - Lab12_GUI - Replit X + replit.com/@katy21/Lab12GUI#main.py 012_GUI y21 al =t +o 68 1 Help 3 Threads Storage 8 9 ⠀ 10 11 12 #def main(): 13 ▼ class myGUI: 14 15 16▼ 17 18 19 20 21 22 23 24 Debugger 8 main.py x + X 25 26 27 28 29 30 31 32 33 import tkinter as tk import tkinter.messagebox #create main window widget def __unit__(self): self.main_window = tkinter.Tk() #Create a button widget. The text "Click" #do_somthing method should be executed #when the user clicks the button # ▶ Run self.my_button = tkinter.Button self.main_window, \ self.do_something) text = 'Click', command = #Quit_button. When the button is clicked #The root widget's destroy method is called #(The main_window variable references the root widget, # so the callback function is self.main_window.destroy.) self.quit_button = tkinter. Button('Response', text = 'Quit', command = self.main_window.destroy)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Running Time of Application
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,