Hi Guys,
First off, I am new to Python and coding. I do apologise if this question has already been asked. I have searched the forum board and was unable to find a thread that gave me the answer I'm looking for.
Currently writing a small bit of code that will simply query a CSV file for lets say a 'Serial Number'. I have programmed a button that will grab text that is entered in an 'input box' for the user. I now would like to use that entered text to search/query a csv file. I am stuck :(
sorry for being a noob but as mentioned - I am learning and new to Python.
I noticed I may have not explained myself properly on what I would like to achieve.
First off, I am new to Python and coding. I do apologise if this question has already been asked. I have searched the forum board and was unable to find a thread that gave me the answer I'm looking for.
Currently writing a small bit of code that will simply query a CSV file for lets say a 'Serial Number'. I have programmed a button that will grab text that is entered in an 'input box' for the user. I now would like to use that entered text to search/query a csv file. I am stuck :(

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import tkinter as tk import requests import csv root = tk.Tk() #defining canvas size HEIGHT = 600 WIDTH = 800 #defined variables def get_serial(entry): print ( "Serial Number Has Been Entered:" , entry) # # with open('testdb.csv') as csvfile: # readCSV = csv.reader(csvfile, delimiter=',') canvas = tk.Canvas(root, height = HEIGHT, width = WIDTH) canvas.pack() #defining the background image background_image = tk.PhotoImage( file = 'background.png' ) background_label = tk.Label(root, image = background_image) background_label.place(relwidth = 1 , relheight = 1 ) #defining frame position, color and size frame = tk.Frame(root, bg = 'light grey' ) frame.place(relx = 0.20 , rely = 0.20 , relwidth = 0.6 , relheight = 0.6 ) #defining button position and color button = tk.Button(frame, text = "Locate Device" , bg = 'green' , command = lambda : get_serial(entry.get())) button.place(relx = 0.25 , rely = 0.8 , relwidth = 0.50 , relheight = 0.10 ) #Welcome Screen to db Search label = tk.Label(frame, text = "Welcome to Db Search v1.0 \n written using Python" , bg = 'red' ) label.place(relx = 0.25 , rely = 0.05 , relwidth = 0.50 , relheight = 0.1 ) #defining label for searching the serial number label = tk.Label(frame, text = "Please Enter the Serial Number" ) label.place(relx = 0.25 , rely = 0.25 , relwidth = 0.50 , relheight = 0.05 ) #entry field for Searching via Serial number entry = tk.Entry(frame, bg = 'dark grey' ) entry.place(relx = 0.25 , rely = 0.30 , relwidth = 0.50 , relheight = 0.05 ) root.mainloop() |
I noticed I may have not explained myself properly on what I would like to achieve.
- User inputs 'serial number'
- Serial number is then queried against CSV file 'testdb.csv'
- Then returns the finding in a text box along with its location and model etc.