Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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(\"\", lambda e: NewWindow(master)) btn.pack(pady = 10)

mainloop()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Considering the discussion in Box

Answered: 1 week ago