Saturday, August 4, 2012

#I discovered the Tkinter Menu Widget! 
from Tkinter import *
import sqlite3
import webbrowser

def hello():
    print "Written by Steve Atchison 8/4/2012"

def mydb():#Create database and table
    conn=sqlite3.connect("deedinfo.db")
    cur=conn.cursor()
    cur.execute("CREATE TABLE IF NOT EXISTS deedtable(bookpage text,grantor text,grantee text, pin text,action text)")
    dbdialog()

def dbdialog():#Deed assitant dialog
    top=Toplevel(root)
    top.title('Deed assitant')
    top.geometry('200x120')
    top.config(bg='orange')

    btn1=Button(top,text="List Table",command=listtable)
    btn1.pack(padx=3,pady=3)
    
    btn2=Button(top,text="Enter data ",command=enterdata)
    btn2.pack(padx=3,pady=3)

    btn3=Button(top,text="List grantors",command=listgrantors)
    btn3.pack(padx=3,pady=3)

def listgrantors():
    conn=sqlite3.connect("deedinfo.db")
    cur=conn.cursor()
    therows = cur.execute("SELECT * FROM deedtable")
    for row in therows:
            print('---------------------')
            print row[1]  
    
def enterdata():
    bookpage=raw_input('Book and Page? ')
    grantor=raw_input('Grantor? ')
    grantee=raw_input('Grantee ? ')
    pin=raw_input('Parcel number? ')
    action=raw_input('Action? ')

    #Insert above data into database table.
    conn=sqlite3.connect("deedinfo.db")
    cur=conn.cursor()
    cur.execute("INSERT INTO deedtable VALUES(?,?,?,?,?)",([bookpage,grantor,grantee,pin,action]))
    conn.commit()
    listtable()

def listtable():
    conn=sqlite3.connect("deedinfo.db")
    cur=conn.cursor()
    therows = cur.execute("SELECT * FROM deedtable")
    for row in therows:
            print('---------------------')
            print row[0]
            print row[1]
            print row[2]
            print row[3]
            print row[4]
        
def findunknownside():
    knownside=raw_input("Known side? ")
    theacres=raw_input("Acres? ")
    acrestosqfeet= float(theacres)*43560
    unknownside= float(acrestosqfeet)/float(knownside)
    print("Unknown side = %.2f"% unknownside)
          
def sc():
    webbrowser.open('http://www.snco.us/')
    open
def myblog():
    webbrowser.open('http://stevespythonprogramadventures.blogspot.com/')
    open
    
root = Tk()
root.geometry('275x40')
root.config(bg='green')

menubar = Menu(root)

# create a pulldown menu, and add it to the menu bar
filemenu = Menu(menubar, tearoff=1)
filemenu.add_command(label="Deed assistant", command=mydb)
filemenu.add_command(label="Find unknown side ", command=findunknownside)
#filemenu.add_command(label="Save", command=hello)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="Tools", menu=filemenu)

# create more pulldown menus
editmenu = Menu(menubar, tearoff=1)
editmenu.add_command(label="Shawnee County", command=sc)
editmenu.add_command(label="My blog", command=myblog)
##editmenu.add_command(label="Paste", command=hello)
menubar.add_cascade(label="Web sites", menu=editmenu)

helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="About", command=hello)
menubar.add_cascade(label="Help", menu=helpmenu)

# display the menu
root.config(menu=menubar)
root.mainloop()

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.