473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

results from query to textbox in GUI

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
1 2704
v13tn1g
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

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

Similar topics

2
by: Jeroen van vliet | last post by:
Hello How can i run a query from a mdb database and show it in a datagrid control when i put in a letter in a textbox? for instance. when i type the letter "A" in the textbox i want to run a...
1
by: Eva | last post by:
Hi I have 2 comboboxes on my form that gathers 2 parameters: The Caravan_Name and the caravan_Length. these 2 values that the user selects are placed into a stored procedure as parameters. The...
1
by: CapeCoder | last post by:
I'd like to use the Excel.WorksheetFunction library to compute median and percentiles in a user-defined function. I'd like to use the data from the calling report as the function argument. ...
3
by: DLN | last post by:
I want to create a form page that has a single field on it, say "last name", and when that last name is entered in, I want to click a button and have it bring up another page with the results. Any...
6
by: Jeremy | last post by:
I have a datasheet subform that is based off an ADO recordset. All is fine excpet the query results are displayed oddly. Rather than displaying the results as say 95.43, it displays it as...
2
by: Steven Smith | last post by:
Hi guys What I'm trying to do today is display the results from an SQL query on one table in a Datagrid I'm using the following code to query the table. \\\ Try If...
1
by: Ed244 | last post by:
Hi, I'm in the process of producing a database for a college project and have a slight problem I was wondering whether you could help me with. The area I'm having problems with takes a value...
4
by: lorirobn | last post by:
Hi, I have a report displaying items that are missing from a room. I created 2 queries, the first getting the items IN the room, and the second being an "unmatched" query that references the...
1
by: russot00 | last post by:
I have 3 drop down menus that are used in a search to locate restaurants in a db. All of the drop down menus function, a search can be submitted with any combination of drop downs and the results are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.