0

I have tkinter notebook and I'm trying to make the notebook and all of its widgets resizable. I know there is grid.columnconfigure and grid.rowconfigure, but I'm a begginer with OOP and I got lost in my own code. Is there any nice, simple way to make all of the widgets resizable?

Here is my code, I've tried to simplify it as much as possible: Sorry for my poor english and even poorer programming.

from tkinter import *
from tkinter import ttk

class Files(ttk.Frame):

    def __init__(self, master=None):

        ttk.Frame.__init__(self, master)
        self.grid()
        self.createWidgets()

    def createWidgets(self):

        self.benjamin = ttk.Button(self, text="Benjamin").grid(row=0, column=0, sticky = NSEW)
        self.box = Listbox(self)
        self.box.grid(row=1, column=0, columnspan=4, sticky=N+S+W+E)

class Results(ttk.Frame):

    def __init__(self, master=None):

        ttk.Frame.__init__(self, master)
        self.grid()
        self.create_widgets()

    def create_widgets(self):

        self.columns = ("0", "1", "2", "3")
        self.chart = ttk.Treeview(self, columns=self.columns, show="headings")
        self.chart.grid()
        self.button = ttk.Button(self, text="Also Benjamin").grid(row=1, column=2, sticky=E)


class App(Tk):
    def __init__(self):
        super().__init__()

        self.notebook = ttk.Notebook(master=self)
        self.frame1 = ttk.Frame(master=self.notebook)
        self.frame2 = ttk.Frame(master=self.notebook)

        self.notebook.add(self.frame1, text="TAB1")
        self.notebook.add(self.frame2, text="TAB2")
        self.notebook.grid()

        self.choose_files = Files(master=self.frame1)
        self.show_results = Results(master=self.frame2)
        self.show_results.grid()

        self.mainloop()


if __name__ == '__main__':
    App()
Xen
  • 11
  • 1
  • ***know there is` grid.columnconfigure` ...***: What stops you to used it? Does this answer your question? [what-does-weight-do-in-tkinter](https://stackoverflow.com/questions/45847313) – stovfl May 19 '20 at 12:15
  • My problem is not what to use, but how to use it. Do I have to place these grids to each widget? The code I'm showing is simplified, in real code I have about 25 widgets. I was wondering if there is any way to write it just once and make it apply to each widget. – Xen May 19 '20 at 15:06
  • ***but how to use it. ... make it apply to each widget***: Read [tkinter gui layout using frames and grid](https://stackoverflow.com/a/34277295/7414759) – stovfl May 19 '20 at 20:20

0 Answers0