0
votes

This is the current layout for the master frame: frame -- sub_frame2 -- Notebook -- (2 Tabs as frames, one called markit_tab and the other param_tab).

Problem:

Even though I am only using pack layout manager for param_tab (second tab), I get this error _tkinter.TclError: cannot use geometry manager pack inside .!frame.!frame2.!notebook.!frame2 which already has slaves managed by grid for row self.scrollbar_par.pack(side="right",fill="y") This doesn't make sense because I use the pack for markit_tab and also the previous line where I use pack for the same frame and it didn't give me error.

I changed that line to grid(row,column) and then I get this error: _tkinter.TclError: cannot use geometry manager grid inside .!frame.!frame2.!notebook.!frame2 which already has slaves managed by pack

This really doesn't make sense to me. How is it possible that I use 2 different geometry managers so neither lets me create something new?

Then

       self.sub_frame2 = tk.Frame(self.frame)
       
       nb = ttk.Notebook(self.sub_frame2)
       
       #Middle Frame including first and second tabs.
       
       # first tab
       self.markit_tab = ttk.Frame(nb)
        
       self.canvas = Canvas(self.markit_tab, bg="white")
       self.table_frame=Frame(self.canvas)
       self.scrollbar=Scrollbar(self.markit_tab ,orient="vertical",command=self.canvas.yview)
       self.canvas.configure(yscrollcommand=self.scrollbar.set)

       
       self.table_frame.pack(side="left", fill ='both')
       self.scrollbar.pack(side="right",fill="y")
       self.canvas.pack(fill='both')
       self.canvas.create_window((0,0),window=self.table_frame,anchor='nw')
       self.table_frame.bind("<Configure>", self.canvas_configure)
       

       # second tab
       self.param_tab = ttk.Frame(nb)

       self.canvas_par = Canvas(self.param_tab, bg="white")
       self.table_frame_par =Frame(self.canvas_par)
       self.scrollbar_par =Scrollbar(self.param_tab ,orient="vertical",command=self.canvas_par.yview)
       self.canvas_par.configure(yscrollcommand=self.scrollbar_par.set)
    

       self.table_frame_par.pack(side="left", fill ='both')
       #self.scrollbar.grid(row=0,column=1)
       self.scrollbar_par.pack(side="right",fill="y")
       self.canvas_par.pack(fill='both')
       self.canvas_par.create_window((0,0),window=self.table_frame_par,anchor='nw')
       self.table_frame_par.bind("<Configure>", self.canvas_configure)
   
       nb.add( self.markit_tab, text='Markit')
       nb.add(self.param_tab, text='Param')
       nb.grid(rows=1)

full error:

 File ".\single_stocks_project.py", line 520, in <module>
   app = MainApplication(root)
 File ".\single_stocks_project.py", line 142, in __init__
   self.scrollbar.grid(row=0,column=1)
 File "C:\Anaconda3\lib\tkinter\__init__.py", line 2226, in grid_configure
   + self._options(cnf, kw))
_tkinter.TclError: cannot use geometry manager grid inside .!frame.!frame2.!notebook.!frame which already has slaves managed by pack ```
1
Tried using pack() alone, everywhere? - Cool Cloud
Just remove the line self.scrollbar.grid(row=0,column=1) - בנימין כהן
That was actually commented out in the original code. I edited the code above. - lalalal
@CoolCloud I use grid but for other frames and they should not have any effects on this one. Also you can see that markit_tab is not affected and param_tab is even though they are literally the same code. - lalalal
Post the entire error code please. - Cool Cloud

1 Answers

0
votes

self.canvas and self.scrollbar both use self.markit_tab as their master. You call self.canvas.pack(fill='both') which means that self.markit_tab is using pack to manage its slaves.