Question on using the mouse in scrolled list applications
mongo57a at comcast.net
mongo57a at comcast.net
Thu Oct 10 15:23:07 EDT 2002
Hi all!
What I want to do is use a button to capture the position/value of the
selected item in a scrolled list. So the user selects the item in the list
with a single click of the left mouse button and then clicks a button.
Should be easy - I'm just not getting it......
Created a class (ScrolledList) for a scrolled list which works fine. Created
another class (aaaaa) which populates the list - and it works fine. Created
a handler under ScrolledList (handleList) which should trap the results of
the bind (makeWidgets). Right now, all I'm trying to do is just print out
the value (just testing..) - but my logic is incorrect (actually, I think
that the logic may be correct - it's just in the wrong place...).
class ScrolledList(Frame):
def __init__(self, options, parent=None):
........
self.makeWidgets(options)
def handleList(self, event):
index = self.listbox.curselection()
label = self.listbox.get(index) # fetch selection
text
print "label is ", label
def makeWidgets(self, options):
.........
list.bind('<Button-1>', self.handleList) # set event
handler
Class aaaaa
def update_strategy_code(self):
..........
ScrolledList(options)
Button(self, text='Update',
command=self.edit_strategy_code).pack(side=LEFT)
def edit_strategy_code(self):
label=self.listbox.get(ACTIVE)
print 'info2=',label
Also, how do I make the mouse appear essentially as it does in an MS
environment - namely, the ability to select a range of items using the shift
key in combination with the mouse and the cntl key in combination with the
mouse for the same application?
TIA
-Andy
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
More information about the Python-list
mailing list