HI, this is my program so far. It's using Tkinter GUI for Python. I want it to be able to display a car image and its information on the main window once a user displays their preference in the blanks created under the button "settings" (which is a separate window). How do I make it do so? Can you give me an idea and provide an example of it being done? Thanks!

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter16: Graphics
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Question

HI, this is my program so far. It's using Tkinter GUI for Python. I want it to be able to display a car image and its information on the main window once a user displays their preference in the blanks created under the button "settings" (which is a separate window). How do I make it do so? Can you give me an idea and provide an example of it being done? Thanks!

# This will import all the widgets
# and modules which are available in
from tkinter import *
from tkinter import messagebox
  
  
class NewWindow(Toplevel):
  
def __init__(self, master = None):
  
super().__init__(master = master)
  
self.title("Settings")
self.geometry("500x500")
  
self.columnconfigure(0,weight=1)
#Creating settings entries
self.label1= Label(self,text="Car Make: ",\
font=("Arial", 14))
self.label1.grid(row=0, column=0)
  
self.entry1 = Entry(self,width="20", font=("Arial", 14))
self.entry1.grid(row=10,column=0)
  
self.label2= Label(self,text="Car Model: ",\
font=("Arial", 14))
self.label2.grid(padx=(0,10))
  
self.entry2= Entry(self,width="20", font=("Arial", 14))
self.entry2.grid()
  
self.label3= Label(self,text="Colour: ",\
font=("Arial", 14))
self.label3.grid(padx=(0,10))
  
self.entry3= Entry(self,width="20", font=("Arial", 14))
self.entry3.grid()
  
self.label4= Label(self,text="Distance (Km): ",\
font=("Arial", 14))
self.label4.grid(padx=(0,10))
  
w = Spinbox(self, from_=0, to=500)
w.grid()
  
self.button1 = Button(self, text="Search")
self.button1.grid()
  
self.button2 = Button(self, text="Quit", command=self.master.destroy)
self.button2.grid()
  
  
  
  
#Main Window
  
master = Tk()
master.geometry("500x500")
master.title("Airbnb Car Rentals")
master.columnconfigure(0,weight=1)

#making background image
canvas = Canvas(master, width = 1000, height = 1000)
canvas.pack(fill=BOTH, expand=1)
img = PhotoImage(file="car_background.png")
canvas.create_image(0,0, anchor=NW, image=img)
  
label = Label(canvas, text ="Search Car",fg= "brown", font=("Arial", 30))
label.pack(side="top")

# a button widget which will
# open a new window on button click
btn = Button(canvas, text ="Settings", font=("Arial", 20))

# Following line will bind click event
# On any click left / right button
# of mouse a new window will be opened
btn.bind("<Button>",
lambda e: NewWindow(master))
btn.pack(pady = 10)   


mainloop()

Expert Solution
steps

Step by step

Solved in 2 steps

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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT