473,792 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox with scrollbar

18 New Member
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,widt h=400)
frm.pack()
scrollbar1=Scro llbar(frm)
scrollbar2=Scro llbar(frm)
scrollbar1.pack (side=RIGHT,fil l=Y)
scrollbar2.pack (side=BOTTOM,fi ll=X)
listbox=Listbox (frm,width=400, height=400)
listbox.pack()
listbox.config( yscrollcommand= scrollbar1.set)
scrollbar1.conf ig(command=list box.yview)
listbox.config( xscrollcommand= scrollbar2.set)
scrollbar2.conf ig(command=list box.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 2919
jlm699
314 Contributor
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 New Member
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
540
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 HorizontalScrollbar = true. The text info in listbox already beyond its right edge. How can I see the hidden part info in listbox? here is a part of codes. ListBox.ValueMember = XX ListBox.DisplayMember = XXXX
3
5309
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 Contract. The subform listbox shows 21 rows. That has been fine, but now we are starting to get some Contracts or Estimates with more than 21 items.
2
3676
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. How could I associate the two controls to work as if they where only one? Thank you for your help Carmen
2
8892
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 Anchor the listbox T, L, R, B on the parent form The string items held within the listbox are quite big, much longer than could be displayed within the Listbox display area.
2
10659
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 {scrollbar-3dlight-color:aqua; scrollbar-arrow-color:fuchsia; scrollbar-base-color:fuchsia;
3
4300
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: self.fonts=list(tkFont.families()) self.fonts.sort() for item in self.fonts: self.fontlist.insert(END, item) #self.fontlist is the
0
1570
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 automatically if the number of items in the ListBox exceed the height of the ListBox, the horizontal scrollbar doesn't get displayed automatically when the text of any of the items in the ListBox exceeds the width of the ListBox!
0
2363
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 am wanting to draw my own non-client area (including the scrollbar). I have had the following ideas but each idea has failed:
0
2691
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. The majority of my items contain much more than 10 characters and thus the reason for my use of owner drawn listBoxes - I do not want to use a horizontal scrollbar, instead I want the text of each item to wrap onto multiple lines. I do use a...
0
9670
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.