1 Replies - 3335 Views - Last Post: 16 December 2013 - 03:38 AM Rate Topic: -----

#1 chan 06   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 67
  • Joined: 07-October 12

Problems with Tkinter (Scrollbar placing)

Posted 16 December 2013 - 12:39 AM

I am having problems with adjusting a the height of scrollbar to two of the listbox. I have two listbox, and they both are using place(), however when I use place() it would not go all the way down to my listbox size. I tried using width() which only changed the x-position on my frame.

Any suggestions? All my widgets are using place() method, if that is any useful information.

This is a rough sample code that I snatched from my program.
from tkinter import*

root = Tk()
root.geometry("330x200")

# Name label
nameLabel = Label(text = "Listbox 1")
nameLabel.place(x = 0, y = 0)
nameLabel1 = Label(text = "Listbox 2")
nameLabel1.place(x = 190, y = 0)

scrollbar = Scrollbar(root)
scrollbar1 = Scrollbar(root)
scrollbar.place(x = 124, y = 20)
scrollbar1.place(x = 313, y = 20)

lb1 = Listbox(root, yscrollcommand = scrollbar.set)
for i in range(100):
    lb1.insert(END, "List %d" %(i))

lb2 = Listbox(root, yscrollcommand = scrollbar1.set)
for j in range (100):
    lb2.insert(END, "List %d" %(j))

lb1.place(x = 0, y = 20)
lb2.place(x = 190, y = 20)

scrollbar.config(command = lb1.yview)
scrollbar1.config(command = lb2.yview)

root.mainloop()

This post has been edited by chan 06: 16 December 2013 - 12:53 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Problems with Tkinter (Scrollbar placing)

#2 chan 06   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 67
  • Joined: 07-October 12

Re: Problems with Tkinter (Scrollbar placing)

Posted 16 December 2013 - 03:38 AM

I solved it, I needed to place a two frames around my listbox. My frame would use place() while my listbox need to use pack(). By creating a frame it will adjust the height on scrollbar that would accommodate the height of your widget.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1