python 2.7 - messagebox getting looped -
i displaying message box on click of option menu when data not available , acquired. somehow whenever change content of option menu message box gets looped. like- first time vanishes when press ok. when change option again second time displays message box 2 times , third time 3 times. can tell me change in code?
#the function change option menu value def module_func(event): #declarations if(datetext.get()!="" , drivetext.get()!=""): global module_dir global selected_module modules['menu'].delete(0,end) select="-----select-----" modules['menu'].add_command(label=select, command=tk._setit(module,select)) module_dir in get_immediate_subdirectories(('%s\%s\%s')%(startpath,selected_shot,selected_fec)): module_dropdown.append(module_dir) modules['menu'].add_command(label=module_dir, command=tk._setit(module,module_dir)) module.trace('w',seteighttext) #think problem here else: errormsg("") def seteighttext(*args): #declarations if(os.path.exists(('%s\%s\%s\%s\%s')%(startpath,selected_shot,selected_fec,selected_module,chan))): #some operations else: tkmessagebox.showinfo("error","data @ given location not available.\n please wait until data acquired.") module=tk.stringvar(labelframe1) module.set("-----select-----") modules = tk.optionmenu(labelframe1, module, module_dropdown, command=module_func) modules.config(width=20, background="snow") modules.grid(row=8, column=2, sticky="w", padx=10, pady=5) modules.bind('<button-1>',module_func)
i think problem because of trace. don't know add instead of that.
Comments
Post a Comment