clearing selection in Tix.FileSelectBox

D

devnew

hello
i am creating a Tix.FileSelectBox to select some jpeg files
on clicking an OK button i wish to get the selected imagename as
string ,so i code like below


class TixGUI:
def __init__(self, parent):
....
self.imgsel=FileSelectBox(self.bgframe)
self.imgsel.configure(pattern="*.jp*")
self.imgsel.pack(side=LEFT)

self.okButton = Button(self.bgframe,text="OK")
self.okButton.bind("<Button-1>",self.okbuttonClick)
self.okButton.pack(side=LEFT )

def okbuttonClick(self,event):
self.cursel=self.imgsel.selection.cget("value")
print "selected image::",self.cursel

here if i select an imagefile say sh1.jpg and click ok..it will print
the imagefilename..BUT if i just select a folder next and don't choose
any imagefile ,it will still print the previous value of sh1.jpg..

i managed to set the selection to "" by adding a
self.imgsel.selection.__setitem__("value","")
to the end of okbuttonClick(self,event).. but i want to know if this
is the correct way .or is there another way to clear the selection?

thanx in adv
dn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top