E
E
EnderToy2021-11-29 14:50:41
Python
EnderToy, 2021-11-29 14:50:41

How to refer to an element of another class?

Can you help in the classes, I'm confused.

class App(tk.Tk):
    def __init__(self):
        super().__init__()
        self.title('Manager')
        self.geometry('1050x500')
        # self.resizable(0, 0)
        self.style = ttk.Style()
        self.style.configure('WhileStyle.TLabel', font=('Comfortaa', 10))
        self['background'] = '#EBEBEB'
        self['width'] = '5'
        self.put_frames()

    def put_frames(self):
        self.show_items_frame = ShowItemsFrame(self).grid(column=0, row=1)
class ShowItemsFrame(tk.Frame):
    def __init__(self, parent):
        super().__init__(parent)
        self['background'] = self.master['background']
        self['width'] = '60'
        self.put_widgets()

    def put_widgets(self):
        table = ttk.Treeview(self, show='headings')
        table.bind("<Double-1>", self.OnDoubleClick)
        table.pack(expand=tk.YES, fill=tk.BOTH)

    def OnDoubleClick(self, event): #Как мне тут обратится к table?
        item = self.put_widgets.table.identify('item', event.x, event.y)
        print(self.put_widgets.table.item(item, "text"))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question