Setting the height of a scrollbar in Tkinter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Appu2008
    New Member
    • Dec 2007
    • 18

    Setting the height of a scrollbar in Tkinter

    HI,
    Iam creating a python application using Tkinter.
    Ia trying to attach a scrollbar to a listbox.
    Please tell me how can i set the height of the scrollbar to that of
    the listbox. Beacuse in the docs i found the fill=X
    and fill=Y options, but this is not i want.
    I want to limit the height of scrollbar to match the height of listbox.
    Code:
        listbox=Listbox(parentwnd,width=100,height=40)
        listbox.place(x=20,y=20)
        scroll1=Scrollbar(orient=VERTICAL,width=200)
        scroll2=Scrollbar()
        scroll1.place(x=610,y=20)
        listbox.config(yscrollcommand=scroll1.set)
        scroll1.config(command=listbox.yview)
        scroll1.set(20,200)
    Thanx
  • raubana
    New Member
    • Feb 2008
    • 55

    #2
    Um, to tell you the truth: I don't know anything about Tkinter.

    I do know that if you go to help() (after Tkintet is imported), you can look up
    a function you need help with. Try something like this:

    (1) call "help(NAME_OF_I MPORT)". A large amout of stuff may pop up. Just go to the top of it all and look for any other classes that may be in Tkinter.

    (2) Repeat untill you find your class. When you repeat, write it like this:
    ex: 'pygame.display '

    (3) When you find the class your looking for, type in the whole 'link'
    in help and it should tell you all of that classes commands.

    That should be helpfull! Good luck.

    Comment

    • mujtablue
      New Member
      • Aug 2022
      • 1

      #3
      Hello if you are using a vertical scrollbar:
      Code:
      scroll1=Scrollbar(orient='vertical')
      scroll1.place(x=1,y=1,height=100)
      and if you are using a horizontal scroll bar:
      Code:
      scroll2=Scrollbar(orient='horizontal')
      scroll2.place(x=1,y=200,width=100)
      so basically Scrollbar(orien t=VERTICAL/HORIZONTAL).pla ce(x=x,y=y,heig ht/width=amount)


      thats for place if you are using pack its like
      Code:
      scrollbar3=Scrollbar(master=None,orient=VERTICAL/HORIZONTAL).pack(ipadx/ipady=amount)

      Comment

      Working...