I try to create such a scrollbar for my g program and I cannot start the Python geometry service (G means GUI Graphical User Interface).

At least this is how Google Translate translates this error.

import os from tkinter import * MyGUIinterface = Tk() folderpathget = StringVar() MyGUIinterface.title("LSTIR Pratotype") MyGUIinterface.geometry('600x500') txt = Entry(MyGUIinterface, textvariable = folderpathget ,width=50) txt.grid(column=2, row=0) def clicked(): folderpathget_string =os.listdir(folderpathget.get()) i = 0 stringconvert = '' while i < len(folderpathget_string): stringconvert += folderpathget_string[i] + "\n" i += 1 folderpath = Message(MyGUIinterface, text=stringconvert) folderpath.grid(columnspan=1) #scroll bar scrollbar = Scrollbar(MyGUIinterface) scrollbar.pack( side = RIGHT, fill = Y ) mylist = Listbox(MyGUIinterface, yscrollcommand = scrollbar.set ) for line in range(100): mylist.insert(END) mylist.pack( side = LEFT, fill = BOTH ) scrollbar.config( command = mylist.yview ) btn = Button(MyGUIinterface, text="enter the folder path and click me", command = clicked ) btn.grid(column = 0, row=0) MyGUIinterface.mainloop() 

Mistake:

 Traceback (most recent call last): File "test.py", line 34, in <module> scrollbar.pack( side = RIGHT, fill = Y ) File "/usr/lib64/python3.6/tkinter/__init__.py", line 2140, in pack_configure + self._options(cnf, kw)) _tkinter.TclError: cannot use geometry manager pack inside . which already has slaves managed by grid 
  • Could write "for your gooey program" - we would understand. GUI is referred to as guinya. - 0-Level UNIX Monk
  • In general, you should write a complete mistake, and not a piece you liked. - 0-Level UNIX Monk
  • Here is a complete error - Koder surocecode
  • How nice that someone added it, not you, right? - 0-Level UNIX Monk

1 answer 1

According to the Tkinter documentation :

Never mix grid and pack in the same master window. You will be happy to spend a lot of time. Take it a look at your code. Some of the widgets.

Those. Do not use grid and pack managers in the same parent window. So I would recommend everywhere to use either only the grid , or only the pack . After I replaced the whole grid with a pack , it all worked for me.