i am developing a dictionary app with tkinter. i have some words and their meanings stored in sqlite database in which one of the word is written like "XML", "Access". Now, whenever i input a word like (xml or Xml or ACCESS or access) in entry widget and click the search button, it says "word not found". i want the word to ignore any case sensitivity. i want the meaning of a word to show up whether i type the word like "xml" or "Xml" or "ACCESS" or "access"
import tkinter as tk
import sqlite3
from tkinter import messagebox
from ttkthemes import ThemedStyle
from tkinter import ttk
from PIL import ImageTk, Image
import os
import sys
########### DEF FOR SEARCH #######
def search(event=''):
if getattr(sys, 'frozen', False):
data_folder=sys._MEIPASS
else:
data_folder=os.getcwd()
conn = sqlite3.connect(os.path.join(data_folder,'GI_DICTION4.db'))
cur = conn.cursor()
tex.delete(1.0, "end")
data = v.get().swapcase()
cur.execute("SELECT Meaning FROM Tables2 WHERE Words= ?", (data.swapcase(),))
var = cur.fetchall()
if var:
tex.insert("end", var[0]) # accessing the meaning
else:
tex.insert("end","Word not found")
def refresh():
entry.delete(0, "end")
tex.delete(1.0, "end")
def fetch_data(word):
if getattr(sys, 'frozen', False):
data_folder=sys._MEIPASS
else:
data_folder=os.getcwd()
conn = sqlite3.connect(os.path.join(data_folder,'GI_DICTION4.db'))
cur = conn.cursor()
cur.execute("select Words from Tables2 where Words like ? || '%'", (word,))
allw = cur.fetchall()
return allw
def on_key_release(event):
qword = event.widget.get()
allw = fetch_data(qword)
listbox.delete(0, tk.END)
for w in allw:
listbox.insert(tk.END, w[0])
def on_select(event):
entry.delete(0, tk.END)
entry.insert(0, event.widget.selection_get())
########## GUI DESIGN ##############