Hello and happy new year,
i'm trying to build a user interface and have a problem with the Tix.ScrolledListbox. (Python 2.6.5, Tix 8.4.3, Windows XP)
I wanted to use it to show items of varying number, depending on a previous choice made by the user.
It's a GIS thing: the user picks a layer from a ComboBox, presses a button and the Listbox shows all fieldnames retrieved from the attribute table. So for some layers there are 5, for others 30 fields. In principle it works.
But the scrollbar next to the listbox remains grey with no function.
In a small test snippet, where, after pressing a button, a random (0..100) number of items is shown in the listbox the scrollbar works.
I have no idea. Anybody had this before?
Edit: The following samplecode shows a not scrollable scrolledListbox when arcpy is imported
import Tix
import random
import arcpy
class SampleApp(object):
def __init__(self):
self.window = Tix.Tk()
#listbox
self.lbx = Tix.ScrolledListBox(self.window, width = 30)
self.lbx.listbox.insert(Tix.END, " ")
self.lbx.listbox.bind("<<ListboxSelect>>", self.Choose)
#button to generate new list
self.btn = Tix.Button(self.window, text = "new list",
command = self.NewList)
#label shows chosen list item
self.lbl = Tix.Label(self.window, text = " ", bg = "white")
#pack
self.btn.pack(pady = 10)
self.lbx.pack(side="top", fill="both", expand=True, pady = 10)
self.lbl.pack(pady = 10)
self.window.mainloop()
#function to generate new listbox items on button command
def NewList(self):
self.lbx.listbox.delete(0, Tix.END)
r = random.randint(1, 30)
for i in range(r):
self.lbx.listbox.insert(Tix.END, i)
#event to show selected item in label
def Choose(self, event):
widget = event.widget
selection = widget.curselection()
value = widget.get(selection[0])
self.lbl.config(text = value)
sa = SampleApp()