Python Tutorials

How to Create Database Menu Driven Application with OOPS in Python Part – 3 0

How to Create Database Menu Driven Application with OOPS in Python Part – 3

Program 1 import MySQLdb class MyDataBase: def __init__(self): self.con=MySQLdb.Connect(host=”localhost”,user=”root”,password=”root”,database=”dataflair”) print(“Connection success”) def autoId(self): self.maxid=100 sql=”select max(eid) from employee” self.cur=self.con.cursor() self.cur.execute(sql) result=self.cur.fetchone() self.maxid=result[0] self.maxid=id=self.maxid+1 def insertData(self,empname,empdept,empsal): self.autoId() sql=”insert into employee values(‘%d’,’%s’,’%s’,’%d’)” value=(self.maxid,empname,empdept,empsal) self.cur=self.con.cursor() self.cur.execute(sql %...

How to use RadioButton in GUI Application in Python 0

How to use RadioButton in GUI Application in Python

Program 1 from tkinter import * class MyRadio: def __init__(self,myroot): self.mf=Frame(myroot,width=500,height=500,bg=’yellow’) self.mf.pack() self.mf.propagate(0) self.v=IntVar() self.rdm=Radiobutton(self.mf,text=”Male”,variable=self.v,value=1,font=(‘Arial,bold,10’),command=self.rdClick) self.rdf=Radiobutton(self.mf,text=”FeMale”,variable=self.v,value=2,font=(‘Arial,bold,10’),command=self.rdClick) self.lb1=Label(self.mf,text=”-“,font=(‘Arial,bold,10′)) Self.rdm.place Self.rdf.place self.lb1.place def rdClick(self): #print(self.v.get()) if(self.v.get()==1): self.lb1[“text”]=”Male Selected” self.mf[“bg”]=’cyan’ if(self.v.get()==2): self.lb1[“text”]=”FeMale Selected” self.mf[“bg”] = ‘green’ myroot=Tk()...

Python Program to Open Multiple Software Using GUI Application Tkinter 0

Python Program to Open Multiple Software Using GUI Application Tkinter

Program 1 from tkinter import * import tkinter.filedialog import os def opencalc(): os.system(“calc”) def openpaintb(): os.system(“mspaint”) def openword(): os.system(“start winword.exe”) def openexcel(): os.system(“start excel.exe”) def openpower(): os.system(“start powerpnt.exe”) def opennotepad(): os.system(“notepad”) def opendate(): os.system(“date”)...

Python Program to Create Save Dialog Window 0

Python Program to Create Save Dialog Window

Program 1 from tkinter import * import tkinter.filedialog as fd import tkinter.messagebox as msgbox def btnclick(choice): t=Text(myroot,width=100,height=100,fg=’red’) t.pack() if(choice==’new’): print(“This is New Option”) elif(choice==’save’): txtdata=str(t.get(1.0,END)) filename=fd.asksaveasfilename(parent=myroot,defaultextension=”*.txt”) f=open(filename,’w’) f.write(txtdata) f.close() elif(choice==’exit’): ch=msgbox.askyesno(‘exit’,”Are you sure want...

How to Open One Window from Another using Tkinter in Python 0

How to Open One Window from Another using Tkinter in Python

Program 1 from tkinter import * def btnclick(): subwindow=Toplevel(mainw) subwindow.geometry(‘200×100’) subwindow.title(“This is Sub Window”) subwindow.wm_iconbitmap(‘2.ico’) Label(subwindow, text=”This is sub Window Page”, fg=’green’).pack() subwindow.mainloop() mainw=Tk() mainw.geometry(‘300×300′) mainw.title(“This is Main Window”) Label(mainw,text=”This is Main Window Page”,fg=’Red’).pack()...

Python Program to Design a Notepad 0

Python Program to Design a Notepad

In the realm of Python practicality, our attention now turns to the development of a Notepad application using Tkinter, marking the beginning of a multi-part series. This endeavor presents an exciting opportunity for developers...