Python Tutorials

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

Program 1 from tkinter import * import tkinter.messagebox as msgbox import tkinter.filedialog as fd def menuclick(choice): textbox = Text(myroot, width=1200, height=500, font=(‘Arial’, 15, ‘bold’),wrap=WORD) if(choice==’new’): textbox.pack() elif(choice==’newwindow’): filename = fd.askopenfilename(parent=myroot, title=’open file window’,filetypes=((“Text File”,...

How to Create Table in Python GUI Application with Tkinter 0

How to Create Table in Python GUI Application with Tkinter

Program 1 from tkinter import * class Mytable: def __init__(self,myroot): for i in range(5): for j in range(4): self.e=Entry(myroot,width=20,fg=’blue’,font=(‘Arial,13,”bold’)) self.e.grid(row=i,column=j) self.e.insert(END,mylist[i][j]) mylist=[(‘Emp No’,’Emp Name’,’Salary’,’Department’),(101,’Ashok Sharma’,80000,’CSE’),(102,’Rajesh Mishra’,23000,’IT’),(103,’Vishal Verma’,13000,’IT’),(103,’Vishal Verma’,13000,’IT’),(103,’Vishal Verma’,13000,’IT’)] myroot=Tk() myroot.geometry(‘700×500’) myroot.title(“Table Demo Application”)...

Python Program on GUI Applications with PDBC 0

Python Program on GUI Applications with PDBC

Program 1 from tkinter import * import MySQLdb def saveData(event): con=MySQLdb.Connect(host=”localhost”,user=”root”,password=”root”,database=”dataflair”) sql=”insert into employee values(‘%d’,’%s’,’%s’,’%d’)” cur=con.cursor() value=(int(txtid.get()),txtname.get(),txtdept.get(),int(txtsal.get())) cur.execute(sql % value) con.commit() print(“record inserted: “,cur.rowcount) con.close() print(“Connection close”) txtname.insert(0,”Hi Friend”) myroot=Tk() myroot.geometry(‘600×600’) myroot.maxsize(600,600) myroot.minsize(600,600) myroot.title(“Employee...

How to Auto Generate Code in Python OOPS with PDBC 0

How to Auto Generate Code in Python OOPS with PDBC

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 %...