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

results from query to textbox in GUI

P: 31
so basically..what i have done is created a database, populated it and call that database from the GUI. When a user searches something in the database through the GUI, the result of the query displays next to the entry field. However, I need to display the results in a text field, for such instances where the results is really long. How do i do that?

Expand|Select|Wrap|Line Numbers
  1. from Tkinter import *
  2. import analyse
  3.  
  4.  
  5.  
  6. def quit(window):
  7.     window.destroy()    
  8.  
  9. def query1(db, entry, text_box):
  10.     text_box.insert(END, str(var.set(analyse.component_by_brand(db, entry.get()))))
  11.     #var.set(analyse.component_by_brand(db, entry.get()))
  12.  
  13.  
  14. def query2(db, entry, var):
  15.     var.set(analyse.price_with_serial(db, entry.get()))
  16.  
  17.  
  18. def query3(db, entry1, entry2, var):
  19.     var.set(analyse.type_with_both(db, entry1.get(), entry2.get()))
  20.  
  21.  
  22. def run_analyse(db):
  23.     window = Tk()
  24.  
  25.     frame = Frame(window)
  26.     frame.pack()
  27.  
  28.  
  29.     window.title(" Hardware Components")
  30.     q1_prompt = Label(frame, text="Enter a Brand:")
  31.     q1_prompt.grid(row=0, column=0)
  32.     q1_data = Entry(frame)
  33.     q1_data.grid(row=0, column=1)
  34.     q1_command = lambda : query1(db, q1_data, q1_var)
  35.     q1_button = Button(frame, text="Search for Type", command=q1_command)
  36.     q1_button.grid(row=0, column=2)
  37.  
  38.     q1_var = StringVar()
  39.     q1_result = Label(frame, textvariable=q1_var)
  40.     q1_result.grid(row=0, column=3)               
  41.  
  42.     blank = Label(frame, text="")
  43.     blank.grid(row=1, columnspan=4)
  44.  
  45.     q2_prompt = Label(frame, text="Enter the Serial Number:")
  46.     q2_prompt.grid(row=2, column=0)
  47.     q2_data = Entry(frame)
  48.     q2_data.grid(row=2, column=1)
  49.     q2_command = lambda : query2(db, q2_data, q2_var)
  50.     q2_button = Button(frame, text="Search for price", command=q2_command)
  51.     q2_button.grid(row=2, column=2)
  52.     q2_var = StringVar()
  53.     q2_result = Label(frame, textvariable=q2_var)
  54.     q2_result.grid(row=2, column=3)                   
  55.  
  56.     blank2 = Label(frame, text="")
  57.     blank2.grid(row=3, columnspan=4)
  58.  
  59.     q3_prompt = Label(frame, text="Enter the first part of the component:")
  60.     q3_prompt.grid(row=4, column=0)
  61.     q3_data = Entry(frame)
  62.     q3_data.grid(row=4, column=1)   
  63.     q3_prompt2 = Label(frame, text="Enter the second part of the component:")
  64.     q3_prompt2.grid(row=5, column=0)
  65.     q3_data2 = Entry(frame)
  66.     q3_data2.grid(row=5, column=1)
  67.     q3_command = lambda : query3(db, q3_data, q3_data2, q3_var)
  68.     q3_button = Button(frame, text="Search for Name", command=q3_command)
  69.     q3_button.grid(row=5, column=2)
  70.     q3_var = StringVar()
  71.     q3_result = Label(frame, textvariable=q3_var)
  72.     q3_result.grid(row=5, column=3) 
  73.  
  74.     def text_box():
  75.         w = Text(frame)
  76.         w.grid(row=0,column=4, rowspan=13)
  77.  
  78.     quit_button = lambda : quit(window)
  79.     b2 = Button(frame, text = "Quit", command = quit_button)
  80.     b2.grid(row=6, column=1)
  81.  
  82.     window.mainloop()
Apr 3 '09 #1
Share this Question
Share on Google+
1 Reply


P: 31
as you can see from my query1 function i tried the insert it into a text field but it wont work
Apr 3 '09 #2

Post your reply

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