• Register
0 votes
3.8k views

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.config(command=tbxself.textbox.yview)
sbvertscroll.pack(side="right", fill="y", expand=False)
tbxself.textbox.config(yscrllcommand=sbvertscroll.set)
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

0 votes
1 answer 16 views
16 views
Problem: I will be so thankful if anybody have Any ideas on what I need to do to fix this: Cannot use geometry manager grid inside . which already has slaves managed by pack.
asked Mar 6 Wafa Abu Yousef 6.1k points
1 vote
1 answer 919 views
919 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 3 views
3 views
Problem: Please tell me how to check if two lines intersect?
asked Apr 3 Ifra 24.4k points
0 votes
1 answer 2 views
2 views
Problem: Help me &ldquo;Background image will scroll when user scrolls down unless which property is enabled&rdquo;?
asked Mar 30 tuhin1 48.4k points
0 votes
1 answer 2 views
2 views
Problem: Asking for help to get the circumference of a circle .
asked 10 hours ago salim1 34.8k points
0 votes
1 answer 8 views
8 views
Problem: Please help me to solve it... python takes 1 positional argument but 2 were given
asked Apr 2 Ifra 24.4k points
0 votes
1 answer 17 views
17 views
Problem: Why this happened: Tkinter.tclerror: no display name and no $display environment variable
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 7 views
7 views
Problem: how to Solve this: tkinter photoimage HELP! I need help understanding this: tkinter photoimage Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 13 Mashhoodch 13k points
0 votes
1 answer 4 views
4 views
Problem: how to Solve this: listbox in tkinter HELP! I need help understanding this: listbox in tkinter Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 13 Mashhoodch 13k points
0 votes
1 answer 3 views
3 views
Problem: how to Solve this: tkinter logo in python HELP! I need help understanding this: tkinter logo in python Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 13 Mashhoodch 13k points