• Register
0 votes

Problem :

I am trying to make the rss reader using my tkinter library, and in one of the methods I am creating the text widget. It displays pretty fine until I try to add the scrollbars to it.

Below is my code before the scrollbars:

def txtcreate_text(tbxself, root):
tbxself.textbox = Text(root, height = 10, width = 79, wrap = 'word')
tbxself.textbox.grid(column = 0, row = 0)

Below is my code after scrollbars :

def txtcreate_text(tbxself, root):
tbxself.textbox = Text(root, height = 10, width = 79, wrap = 'word')
sbvertscroll = ttk.Scrollbar(root)
sbvertscroll.pack(side="right", fill="y", expand=False)
tbxself.textbox.pack(side="left", fill="both", expand=True)
tbxself.textbox.grid(column = 0, row = 0)

This gives me below error :

"_tkinter.TclError: cannot use geometry manager pack inside .56155888 which already has slaves managed by grid on the line vertscroll.pack(side="right", fill="y", expand=False)"


Any ideas how to fix above error?

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

As per the docs, please do not mix the pack and the grid in your same master window:

Warning: Never mix the grid and pack in your same master window. Tkinter will happily spend your rest of the lifetime trying to negotiate the solution that both managers are happy with it. Instead of waiting for that, try to kill your application, and make sure to have another look at the code. The common mistake is to use your wrong parent for some of your widgets.

So if you want to call grid on the textbox, then please do not call pack on the scrollbar.


9 7 4
38,600 points

Related questions

1 vote
1 answer 622 views
Problem: I installed tkinter and I wrote this code to check if this works or not: import tkinter as tink a = tink.Tink() a.title('Total Seconds') button = tink.Button(a, text='Welcome', width=40, command=a.destroy) button.pack() a.mainloop() But after running this ... ", line 2, in <module> a = tink.Tink() AttributeError: module 'tkinter' has no attribute 'Tink' Can anyone help me to solve this?
asked Apr 29, 2020 samhaz 5k points
0 votes
1 answer 23 views
Problem Hello Kodlogs, What is a checkbox called in tkinter? I heard it is called checkButton if yes, how does it function. Can you please explain with a code example?
asked Oct 30, 2020 hashq 1.1k points
0 votes
1 answer 1.7K views
Problem : I am learning Python. I have written a basic python script and trying to run the basic python script on the server: import matplotlib.pyplot as plot import numpy as nump x = nump.random.randn(80) y = nump.random.randn(80) plot.scatter(x, y, s=30) ... , useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable Why am I facing above error? How can I fix it?
asked Feb 25, 2020 mphil 2.3k points
0 votes
1 answer 8 views
I am trying to make a table with fixed header and scrollable content using bootstrap. I need help because my solution does not work.
asked Nov 13, 2020 miki 1.9k points
0 votes
1 answer 161 views
Cannot create controller in thread that did not call Looper.prepare () What does the following exception mean? How can I fix it? Here is the code: Toast toast = Toast.makeText (mContext, "Something", Toast.LENGTH_SHORT); This is the exception: Java.lang.RuntimeException: Cannot ... :121)      on Android.widget.Toast. <init> (Toast.Java:68)      on Android.widget.Toast.makeText (Toast.Java:231)
asked Aug 17, 2020 game 4.6k points
1 vote
1 answer 929 views
Problem: When I try to run the following code: import tkinter as tk q = tk.Tk() q.title('Press The Button') button = tk.Button(q, text='Welcome Here', width=40, command=q.destroy) button.pack() q.mainloop() It shows me the error message: ... be configured for Tk ImportError: No module named '_tkinter Why this type of error message is appearing. Can anyone sort this out? Thanks in advance.
asked May 6, 2020 samhaz 5k points
3 votes
1 answer 616 views
Problem: Hello guys, I am facing an issue while working with the class tkinter I&rsquo;ve recently shifted to the upgraded version of python from my older ones. After completed the upgrading the version I am trying to run my old projects. Here comes the wired part. My project ... 'tk' is not defined I have no idea what could be going on here. I am looking forward to having a solution. Thanks.
asked May 6, 2020 Gavin 15.3k points
1 vote
1 answer 81 views
Problem: I tried to install tkinter in my system and tried to run the following code: import tkinter as tk q = tk.Tk() q.title('Total Members') button = tk.Button(q, text='Welcome Members', width=25, command=q.destroy) button.pack() q. ... _tkinter.TclError: no display name and no $DISPLAY environment variable ImportError: No module named '_tkinter How can I solve this error? Thanks in advance.
asked May 4, 2020 samhaz 5k points
0 votes
1 answer 48 views
Problem : I have written two different types of sticky menus for two different pages. Following is the error Inside the anonymous function, use jquery to select the footer div. it has an id of 'footer'. Following is the code for both Menus. $(document).ready(function () { ... the bottom doesn't work because the second line of code var contentNav = $('.content-nav').offset().top; fires a error .
asked Nov 19, 2019 peterlaw 6.9k points