1

I would like to have a fixed window size and then scroll through tabs like in this example, each tab is a new page with many entries. But if I add a tab the window size gets bigger and if I add the scrollbar from the example it isn't working because I am using grid instead of pack. Any ideas how I can fix this two problems?

My main.py:

#libraries
import tkinter as tk
from tkinter import ttk
from ScrollableNotebook import *

from XXXXXXXXXXXX import createUI0
from YYYYYYYYYYYY import createUI1
from ZZZZZZZZZZZZ import createUI2
from XYXYXYXYXYXY import createUI3
from XYZXYZXYZXYZ import createUI4

# class MainFrame that inherits from ttk.Frame
class MainFrame(ttk.Frame):
    def __init__(self, container): #init method
        super().__init__(container)

        # noteboook
        self.notebook = ttk.Notebook()
        self.notebook.grid()
        
        # Frames
        self.Frame0 = createUI0(self.notebook)
        self.Frame1 = createUI1(self.notebook)
        self.Frame2 = createUI2(self.notebook)
        self.Frame3 = createUI3(self.notebook)
        self.Frame4 = createUI4(self.notebook)
        self.notebook.add(self.Frame0, text='XXXXXXXXXXXX')
        self.notebook.add(self.Frame1, text='YYYYYYYYYYYY')
        self.notebook.add(self.Frame2, text='ZZZZZZZZZZZZ')
        self.notebook.add(self.Frame3, text='XYXYXYXYXYXY')
        self.notebook.add(self.Frame4, text='XYZXYZXYZXYZ')

# class App that inherits from tk.Tk
class App(tk.Tk): 
    def __init__(self): #method
        super().__init__()
        #configure the root window
        self.title('PDF XYZ Creater')
        self.geometry('670x650')
        #self.resizable(0, 0)

if __name__ == "__main__":
    app = App() # Create Class App
    MainFrame(app)
    app.mainloop()

One of my tabs in a new file (XXXXXXXXXXXX.py) without content:

#libraries
import tkinter as tk
from tkinter import ttk

class createUI0(ttk.Frame):
    def __init__(self, container): #init method
        super().__init__(container)
martineau
  • 119,623
  • 25
  • 170
  • 301
thomkell
  • 195
  • 1
  • 11

0 Answers0