By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,932 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,932 IT Pros & Developers. It's quick & easy.

Combobox get() not returning selected value

P: 2
I'm trying to pass a name from a ComboBox to a MySQL search function, but no matter how I twist it, the get() always returns the first value in the combobox list, regardless of which name the user selects. Any ideas why?

ComboBox Window
Expand|Select|Wrap|Line Numbers
  1. import search
  2.  
  3. def match():
  4.     #Initialize
  5.     new2 = tk.Toplevel()
  6.     new2.title("Matching Students and Projects")
  7.     title = tk.Label(new2, text = "See Student/Project matches for:", font=("Arial", 12, "bold"))
  8.     title.grid(row=0, column=0, sticky=W)
  9.  
  10.     #Create drop-down list of students
  11.     students = ['student name', 'Student Name', 'Students Named']
  12.  
  13.     Pmw.initialise()
  14.     studentmenu = Pmw.ComboBox(new2, label_text='Choose a Student:', labelpos = 'nw', scrolledlist_items=students, selectioncommand=None, entryfield_value=students[0])
  15.     studentmenu.grid(row=1, column=0, sticky=W, padx=0, pady=5)
  16.  
  17.     #run the search
  18.     close = tk.Button(new2,text="Match",command=search.search(studentmenu))
  19.     close.grid(row=2, column=0)
  20.  
  21.     #Exit
  22.     close = tk.Button(new2,text="Close Form",command=new2.destroy)
  23.     close.grid(row=2, column=0, sticky=W)
  24.     new2.mainloop()
Beginning of Search function
Expand|Select|Wrap|Line Numbers
  1. def search(menu):
  2.     #Select the student
  3.     searchname = menu.get()
  4.     searchname = searchname.split()
  5.     print searchname
  6.     fname = searchname[0]
  7.     lname = searchname[1]
Jul 7 '09 #1
Share this Question
Share on Google+
1 Reply


P: 25
I would think it should be...

searchname = menu.getSelected()
Just a thought.
Jul 10 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.