Thursday, February 5, 2015

I improved on my letter writing program!

#Written by Steve Atchison 6/5/2013 for Shawnee County
import datetime
from Tkinter import *

def cleargui():
    ent1.delete(0,END)
    deednum.delete(0,END)
    textwin.delete("1.0",END)
    textwin.insert("0.1","Please close GUI to create letter.")
           
#GET DATA FROM GUI
def getdatafromgui():
    notes = textwin.get('1.0',END)#GET TEXT FROM THE TEXT WINDOW
    
    print("\n")
    #SELECT A PARCEL FROM THE OWNER LAYER FIRST BEFORE USING THIS SCRIPT.
    for row in arcpy.SearchCursor("Owners"):
        grantor= ent1.get()
        owner = row.getValue('ONAME')
        mailaddress = row.getValue('MAILADDRESS')
        mailaddress2 = row.getValue('MAILADDRESS2')
        #deed= row.getValue('DBOOKPAGE')

        deed=deednum.get()
        today=datetime.date.today()
        parcelid=row.getValue('PID')
    
#THIS IS WHERE THE SAVE LETTER TO FILE STARTS.
       
    
    f = open(r"G:\GIS and Mapping\TitleLetters\theletter.txt",'w')
    
    getdatafromgui() #Gets data from the GUI  
             
    
    f.write('''




                                                    Shawnee County Appraiser/GIS Department
                                                    1515 NW Saline, Suite 100
                                                    Topeka KS 66618

                                                    '''+"\n")


    f.write("    "+today.strftime("%m/%d/%y"+"\n")+"\n"+"\n"+"\n")

    f.write("    "+str(owner)+"\n")
    f.write("    "+str(mailaddress)+"\n")
    f.write("    "+str(mailaddress2)+ "\n"+"\n"+"\n")



   

    f.write('    '+'Dear '+ str(owner)+'\n')

    f.write('''




    Recently we processed a recorded deed %s that was filed with the Shawnee County
    Register of Deeds Office.  You are being sent this letter to acknowledge what properties
    were affected and what the actions the GIS (Geographic Information Systems) department
    did according to that filed deed.

    Please note below are the actions the GIS Department used in processing %s

    Name NOT Changed from %s to %s

    %s : %s




    Respectfully,    

    Shawnee County Mapping Department/Appraisers  (785)251-6049 ''' %(deed,deed,owner,grantor,parcelid,notes))

    #f.write("\n"+"-------------------------------------------------------------------------------------------------"+"\n")
    cleargui()

root = Tk()
root.config(bg='blue')
root.geometry('700x400')

btn1=Button(root,text='Add to letter',command = write_letter)
btn1.pack()
lbl=Label(root,text="GRANTEE").pack()
ent1 = Entry(root, width =80)
ent1.pack()
lbl2=Label(root,text="Deed number ")
lbl2.pack()
deednum=Entry(root)
deednum.pack()

lbl2=Label(root,text="Actions taken").pack()
textwin=Text(root,width=800,height=26,background='white')
textwin.pack(padx=5,pady=5)

root.mainloop()

#Select a parcel from the owner layer before running this script.

#A layer named "Owner" needs to be present in the table of contents    

#Letter will be created when GUI is closed: Copy and paste into Word. 

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.