0

here is my code i am trying get this kinf of GUI with multiple classes(because of the project' requırement and ı write this. My problem here is i need two frames while using classes but this code's output is just one of them. ı don't know table class will work but i couldn't find any solution for this too.

from tkinter import *

class RezervationAppGUI(Frame):
    def __init__(self, parent):
        self.parent = parent
        Frame.__init__(self, parent)
        self.initUI(parent)

    def initUI(self, parent):
        self.label_head = Label(self, text='Restaurant Reservation System', bg='blue', fg='white', anchor=CENTER,
                                font=('', '20', 'bold'))
        self.label_head.grid(row=0,column=0,columnspan=15,sticky= W+E)

        self.label_Table = Label(self, text='Table:')
        self.label_Table.grid(row=1,column=0,padx=5)

        self.label_SelectedTable =Label(self, text='[Not Selected]')
        self.label_SelectedTable.grid(row=1,column=2,padx=5)

        self.label_customer_name = Label(self, text='Customer Name:')
        self.label_customer_name.grid(row=1,column=3,padx=5)

        self.name_entry = Entry(self, width=25)
        self.name_entry.grid(row=1,column=4,padx=5)

        self.label_customer_phone_number = Label(self, text='Customer Phone:')
        self.label_customer_phone_number.grid(row=1,column=5,padx=5)

        self.phone_entry = Entry(self, width=25)
        self.phone_entry.grid(row=1,column=6,padx=5)

        self.save_button = Button (self, text='Save/Update Reservation',bg='white')
        self.save_button.grid(row=1,column=7,padx=5)

        self.delete_button = Button(self, text='Delete Reservation', bg='white')
        self.delete_button.grid(row=1,column=8,padx=5)

        self.label_feedback = Label(self, text='')
        self.label_feedback.grid(row=1, column=9, padx=10)



class Tables(RezervationAppGUI):
    def __init__(self,parent):
        self.parent = parent
        Frame.__init__(self,parent)
        self.tables(parent)
    def tables(self,parent):
        self.Table1 = Button(self, text=1, height=5, width=10, bg='green')
        self.Table1.grid(row=2, column=0, padx=5, pady=10)

        self.Table2 = Button(self, text=2, height=5, width=10, bg='green')
        self.Table2.grid(row=3, column=0, padx=5, pady=10)

        self.Table3 = Button(self, text=3, height=5, width=10, bg='green')
        self.Table3.grid(row=4, column=0, padx=5, pady=10)

        self.Table4 = Button(self, text=4, height=5, width=10, bg='green')
        self.Table4.grid(row=2, column=1, padx=5, pady=10)
      


def main():
    root = Tk()
    root.title('başlık')
    root.geometry('1200x400')
    app = RezervationAppGUI(root)
    app.pack(fill = BOTH, expand=True)
    root.mainloop()
main()

So what should i do to get this gui.

Screenshot enter image description here

Kuldeep J
  • 382
  • 5
  • 12
Kuluto
  • 1
  • As an aside, `import *` is generally bad practice. – AMC Mar 11 '20 at 22:53
  • I am pretty new at coding so can you tell me why? Thank you for your answer. – Kuluto Mar 11 '20 at 22:55
  • You inherit from `class Tables(RezervationAppGUI):` but you call `Frame.__init__(self,parent)`. You have to inherit from `class Tables(Frame)` – stovfl Mar 11 '20 at 22:57
  • You can find a question on the subject [right here on SO](https://stackoverflow.com/questions/3615125/should-wildcard-import-be-avoided). :) – AMC Mar 11 '20 at 22:58
  • @stovfl then how can ı fuse this two classes? – Kuluto Mar 11 '20 at 23:01
  • @Kuluto ***"how can ı fuse this two classes? –"***: Didn't understand the term ***fuse***? – stovfl Mar 11 '20 at 23:03
  • @AMC this is pretty intense for me right now because i get this project as a collage project. But thank you for this link, I will try to understand this. – Kuluto Mar 11 '20 at 23:03
  • @stovfl Sorry for wrong word choices. when i call the main function there was only one ''frame'' class. But i want this two in one window. – Kuluto Mar 11 '20 at 23:05
  • You have two options: **1.** Use `class` compounding **2.** Use the extended `class Tables` only. But either way, you have to adjust the `inheritance/__init__` accordingly. – stovfl Mar 11 '20 at 23:11

0 Answers0