help with TixComboBox usage in python

kalyan.abbaraju at gmail.com kalyan.abbaraju at gmail.com
Sun Aug 14 15:30:37 CEST 2005


 Hi,

I have to write a code in which based on a user selection in a combo
box, pages in NoteBook should be automatically added or deleted.

So, I have the following class.
class myActionsDialog:
def __init__ (self, top):

self.ActionsWidget = dict()
self.sd=None

self.ActionsWidget['Label'] = Label (text="My Actions")
top.configure(labelwidget=self.ActionsWidget['Label'])
self.actionChoice=Tix.StringVar()

self.ActionsWidget['Choice'] = Tix.ComboBox(top,
label="Pre-defined Actions: ", dropdown=1,
command=self.select_action, editable=1,
variable=self.actionChoice,
options='listbox.height 6 label.width 20 label.anchor e')
self.ActionsWidget['Choice'].configure(command=self.select_action)

self.ActionsWidget['Choice'].grid(row=1, column=0,sticky=NW)
self.ActionsWidget['CustomAction']=Frame(top)
self.ActionsWidget['CustomAction'].grid(row=2, column=0,sticky=NW+SE)
self.ActionsWidget['CustomAction'].configure(borderwidth=1,highlightthickness=1,
highlightcolor="blue", relief=GROOVE)

self.ActionsWidget['NoteBook'] =
Tix.NoteBook(self.ActionsWidget['CustomAction'])
self.ActionsWidget['NoteBook'].grid(row=0, column=0,sticky=NW+SE)
self.ActionsWidget['NoteBook'].configure(height=400, width=600)
self.ActionsWidget['NBFrame'] =
self.ActionsWidget['NoteBook'].subwidget_list["nbframe"]
self.ActionsWidget['NBFrame'].configure(relief="raised", tabpadx="8")
self.ANbook = self.ActionsWidget['NoteBook']

def add_Actions(self, toptions):
"""Usage: options = {'text':'Plain Text', 'html':'Plain Html'}
add_Actions(options)"""
print "add_Actions=", toptions
for eachOpt in toptions:
print eachOpt
self.ActionsWidget['Choice'].insert(Tix.END, eachOpt)

def add_page (self, name, text, mark):
print "add_page=", name, text, mark
self.ANbook.add(name, label=text, underline=mark, anchor="center")

def delete_page (self, name):
print "delete_page=", name
self.ANbook.delete(name)

def select_action(self,event):
print "myActionsDialog::select_action=", self.actionChoice.get(), ";"
print "select_action=", event, ";"

if self.sd != None:
print "Deleting the previous pages..."
self.sd.del_pages()
if self.actionChoice.get() == 'Send Events':
print "Found Send Events"
self.sd=mySendAlarmDialog(self)
elif self.actionChoice.get() == 'Alarm Upload':
print "Found Alarm Upload"
print "Seems alarm Upload is found"
self.sd=None

But my problem is select_action is not executing when ever user changes
his selection.

my Current widget layout is something like this now.
--------------------------------------------------
| pre-defined Actions: <action combo box> |
---------------------------------------------------
| Tix.NoteBook |
---------------------------------------------------
Tix.NoteBook pages should be changed dynamically based on the user
selection in <action combo box>
So, I have a doubt where this really works? or should I have to add a
new buttion called "Update NoteBook" and whenever user clicks this
button then the Notebook wiget changes. Question

New UI:

---------------------------------------------------------------------------
| pre-defined Actions: <action combo box> | Update NoteBook |
---------------------------------------------------------------------------
| Tix.NoteBook |
---------------------------------------------------------------------------

or please let me know if we have any better widgets to handle this
behaviour.

Thanks in advance

Regards
Kalyan




More information about the Python-list mailing list