473,396 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Listbox with scrollbar

Hi,
Iam using Python 2.5 and developing an application using Tkinter.
I want a listbox with scrollbar. I tried to combine both
but it gets filled in the entire screen.

Here is the code..

frm=Frame(root,height=400,width=400)
frm.pack()
scrollbar1=Scrollbar(frm)
scrollbar2=Scrollbar(frm)
scrollbar1.pack(side=RIGHT,fill=Y)
scrollbar2.pack(side=BOTTOM,fill=X)
listbox=Listbox(frm,width=400,height=400)
listbox.pack()
listbox.config(yscrollcommand=scrollbar1.set)
scrollbar1.config(command=listbox.yview)
listbox.config(xscrollcommand=scrollbar2.set)
scrollbar2.config(command=listbox.xview)

How to position this scrollbar in a particular
position??Also is there any table widget
in Tkinter that i can use in windows. I think tktable widget
works only for linux..
Pls help
Apr 25 '08 #1
2 2894
jlm699
314 100+
It would help us all a great deal if you could use CODE tags around your code to make it easier to read.
Please read the posting guidelines before posting, particularly the "How the ask a question" section.
Apr 25 '08 #2
woooee
43
I prefer to use the PMW extension to Tkinter. PMW has a scrolled listbox widget. This is something I had lying around.

In answer to your question, TableList will run on any OS that has TCL/Tk installed http://www.nemethi.de/
Expand|Select|Wrap|Line Numbers
  1. import Tkinter 
  2. import Pmw  
  3. class PMWListBox :
  4.    def __init__( self, list_in, min_width=300, min_height=350 ) :
  5.       self.top = Tkinter.Tk()       
  6.       self.top.geometry( "300x300+10+10" )   
  7.       self.top.minsize( min_width, min_height )
  8.       self.top.option_add('*Font', 'Fixed 14')
  9.       Pmw.initialise( fontScheme='default')
  10.       #---  exit button must be first----------------------
  11.       exit = Tkinter.Button(self.top, text='EXIT',
  12.                  command=self.top.quit, bg='lightblue', fg='yellow' )
  13.       exit.pack(fill="x", expand=1, side="bottom")
  14.       #----------------------------------------------------------------
  15.       scroll_box = Pmw.ScrolledListBox( self.top, \
  16.                           listbox_selectmode="SINGLE", \
  17.                           items=(list_in) )
  18.       scroll_box.pack(fill="both", expand=1, padx=5, pady=5, side="top" )
  19.       self.top.mainloop()
  20. ##=======================================
  21. if __name__ == "__main__" :
  22.     list_items=["First List Entry", "Second List Entry", \
  23.                "Third List Entry", \ 
  24.                "Fourth List Entry -- W I D E -- W  I  D  E", \
  25.                "Fifth List Entry", "Sixth Entry", "Seventh Entry" \
  26.                "Eighth Entry", "Ninth Entry", "Tenth Entry", \
  27.                "Entry # 11 Test", "Test for 12th Lit", \
  28.                "Thirteen", "Fourteen", "Fifteen"]
  29.     PM = PMWListBox( list_items )
Apr 25 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Brian | last post by:
Hi, All, I'm using MS.net 2003 and using a windows.forms.listbox control for my window application but I don't know why the Horizontal Scrollbar could NOT be shown even if I set...
3
by: Alan Lane | last post by:
Hello world: I have a Parent form with a combobox, where the user selects a Contract or Estimate number. Then, on a subform, I have a listbox that gets filled with the details of the selected...
2
by: carmen | last post by:
I need to have in a form a listbox with a big scrollbar (I'm working for a touchscreen). As the scrollbar that the listbox has is small, I put a listbox withou scroll and a scrollbar independent....
2
by: Paul_Madden via DotNetMonster.com | last post by:
I am handling the Listbox DrawItem event to enable the listbox strings to be displayed in different colours for easy reading. Have set ScrollAlwaysVisible and HorizontalScrollbar to true. I...
2
by: kurt sune | last post by:
How do I render the scrollbars by CSS in a listbox? I have understood that an asp listbox gets rendered as a select element. So I tried first by adding a style element: ..TA...
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
0
by: rn5a | last post by:
How do I make a ListBox display the horizontal scrollbar if the text of any of the items in the ListBox exceeds the width of the ListBox? Unlike the vertical scrollbar which gets displayed...
0
by: evan | last post by:
Hi, Is anyone able to give me an example on how to scroll the contents of a ListBox without forcing the user to click on the scroll up/down internal buttons? ============================== I...
0
by: LostInMd | last post by:
Hi All, I've got an owner drawn listBox where I draw and measure the items that I add to the listBox. For example, I have a listBox that can only display 10 characters on each horizontal line. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.