Podklasowanie Tkintera w celu utworzenia niestandardowego widżetu
zobacz następujący kod: (W zasadzie próbuję utworzyć widget tekstowy z pionowym paskiem przewijania, zachowując wszystkie metody / funkcje z Tkinter.Text w mojej klasie)
class ScrollableTextWidget(Tkinter.Text):
def __init__(self, parent):
self.parent = parent
self.Frame = ttk.Frame(self.parent)
Tkinter.Text.__init__(self, self.Frame, width=1, height=1)
self.__initWidget()
def __initWidget(self):
self.Frame.grid(sticky="NSEW")
self.ScrollbarY = ttk.Scrollbar(self.Frame, orient="vertical", command=self.yview)
self.configure(yscrollcommand=self.ScrollbarY.set)
self.grid(column=0, row=0, sticky="NSEW")
self.ScrollbarY.grid(column=1, row=0, sticky="NS")
self.Frame.columnconfigure(0, weight=1)
self.Frame.rowconfigure(0, weight=1)
Czy można utworzyć własny widget w ten sposób, czy raczej powinienem umieścić go w ramce i napisać własne metody?