Posts

Insert And Retrieve Images From SQlite Database using Tkinter and Python

Image
Insert And Retrieve Images From SQlite Database using Tkinter and Python Firstly need to create database  import sqlite3 conn = sqlite3.connect('test8.db')  conn.execute('''CREATE TABLE PHOTO          (ID INT PRIMARY KEY     NOT NULL,          IMAGE           BLOB   NOT NULL,                     );''')    conn.close() Secondly Inserting Method import sqlite3 conn = sqlite3.connect('test8.db') image = open("Home.png","rb")  ////IMAGE FILE TO UPLOAD conn.execute('INSERT INTO PHOTO (ID,IMAGE) VALUES(1,?)',[sqlite3.Binary(image.read())]) conn.commit() conn.close() Retrieve Images From Database Using Tkinter import sqlite3 from tkinter import * root = Tk() root.geometry('300x400') conn = sqlite3.connect('test8.db') cursor = conn.cursor() cursor = conn.execute("""SELECT * FROM PHOTO WHERE ID = 3 """...

Python Tutorial Gui Tkinter Display Data As Text

Image
Displaying data on Tkinter Window from Database  Using the widget  label.config() Example Code: from tkinter import * import sqlite3 root = Tk() root.geometry("200x200") conn = sqlite3.connect('test1.db') def showdata():    cursor = conn.execute("SELECT id, name, address, salary from COMPANY")    for row in cursor:       l1 = Label(root, text="result")       l1.pack()       l1.config(text=row) b1 = Button(root,text="submit",command=showdata) b1.pack() root.mainloop()

Currency Converter Code Python Tkinter Gui

Image
  Window Creation from tkinter import * root = Tk() root.geometry("320x300") root.title("currency converter") i= PhotoImage(file='') root.iconphoto(False,i) root['bg'] ='#f09942' Widgets Using Entry Button & Label lab = Label(root,text="Currency Converter",relief="raised",borderwidth=2,font= ('Garamond',25),bg='#f09942',padx=20,pady=10) lab.pack(padx=10,pady=10) lab_1 =Label(root,text="USD",font= ('Garamond',25),bg='#f09942') lab_1.pack(padx=2,pady=2) en = Entry(root,highlightthickness=1, width=30) en.pack(padx=2,pady=2) bt = Button(root,text="TO",command=convert,width=10) bt.pack(padx=2,pady=2) lab_2=Label(root,text="INR",font= ('Garamond',25),bg='#f09942') lab_2.pack(padx=2,pady=2) en_1=Entry(root,highlightthickness=1, width=30) en_1.pack(padx=2,pady=2) Button Code (Conversion Method)  [Button,command= convert] def convert():     en_1.delet...

Registration Form Python Tkinter GUI Project

Importing Files import tkinter from tkinter import * Initializing Window top=Tk() Declaring Variables name_var = StringVar() email_var = StringVar() pass_var  = StringVar() Function to view Output def submit ():     name = name_var.get()     e= email_var.get()     p = pass_var.get()     print ( "the name is " + name)     print ( "email address is :" + e)     print ( "password is: " + p) Label Function nme = Label(top , text = "name" ).place( x = 30 , y = 50 ) email = Label(top , text = "email" ).place( x = 30 , y = 90 ) password = Label(top , text = "password" ).place( x = 30 , y = 130 ) Button Function sbmitbtn = Button(top , text = "submit" , activebackground = "pink" , activeforeground = "blue" , command =submit).place( x = 30 , y = 170 )  Entry Function   e1 = Entry(top , textvariable =name_var).place( x = 80 , y = 50 ) e2 = Entry(top , textvariable =email_var).pla...