Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def simpleMode():
- list = [] # used to store all the variables that are created, this will be a 2d array
- simpleButton.grid_forget()
- advancedButton.grid_forget()
- # This function builds the SQL statement based on what the user ticked in checkboxes
- def getInput():
- SQL = "" # this will be the sql statement
- for obj in list: # for every array in the 2d array 'list'
- a = obj[0] # will get the IntVar() object from the array
- if a.get() == 1: # if IntVar() is equal to 1, meaning if the checkbox was checked
- SQL = SQL + obj[1].replace(' ', '') + "," #adds the field to the sql statement to search for
- SQL = SQL[:-1] # this will remove the last character in the string, (comma)
- SQL = SQL + " FROM " + tableOption # this is to tell what table we should get these fields from
- getSQLResult(SQL) #calls the getSQLResult function
- def getTable():
- def createList(fields):
- for v in range(len(fields)):
- tempL = [] # sets 'tempL' array as empty
- tempL.append(IntVar()) # adds the object IntVar() to 'tempL'
- tempL.append(fields[v]) # adds the field name to the array
- checkboxObject = Checkbutton(inputCanvas, text = fields[v], variable = tempL[0]) # creates a checkbox object, with its name being the field name
- checkboxObject.grid(row = v+1, column = 0, sticky = W) # puts this on the canvas
- tempL.append(checkboxObject) # adds this checkbox object to the 'tempL' array
- list.append(tempL) # adds this array to the 'list' array made at the beginning of this function
- global tableOption
- tableOption = selectTable.get()
- for widget in inputCanvas.winfo_children():
- widget.destroy()
- Label(inputCanvas, text = "Enter the fields you want to get").grid(row = 0, column = 0, sticky = W)
- if tableOption == "Students":
- createList(studentFields)
- if tableOption == "Courses":
- createList(courseFields)
- if tableOption == "Info":
- createList(intersectFields)
- Button(inputCanvas, text = "Search", command = getInput).grid(row = 0, column = 1, sticky = W)
- Label(inputCanvas, text = "Which table would you like to get data from?").grid(row = 0, column = 0, sticky = W)
- selectTable = ttk.Combobox(inputCanvas, values = ["Students", "Courses", "Info"], state = "readonly")
- selectTable.grid(row = 0, column = 1, sticky = W)
- Button(inputCanvas, text = "Next", command = getTable).grid(row = 0, column = 2, sticky = W)
- inputCanvas.grid(row = 0, column = 0, sticky = W)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement