Saturday, August 22, 2009

This is a program that I use at work. It makes my life a lot easier. I shared it with my co-workers too. Its a simple converter tool. I wrote it at home, and then emailed it to my workplace. When I paste this into my blog, it removes the indentation. Very annoying. Python requires indentation in its blocks of code.

#Written by Steve Atchison April 6 2009
from Tkinter import *
import webbrowser
import tkSimpleDialog

def ConvertChains(): #Function to convert Chains to feet
chains = tkSimpleDialog.askstring('Chain converter','Enter Chains ')
print( chains, 'chains = ',round((float(chains) * 66),2),'ft')

def ConvertRods(): #Function to convert rods to feet
theRods = tkSimpleDialog.askstring('Rod converter','Enter rods ')
print( theRods, 'Rods =',round(( float(theRods) * 16.5),2), 'ft')

def unknownside(): #Function to calculate unkown side of a parcel
knownSide = tkSimpleDialog.askstring('Enter known side','known side?')
acres = tkSimpleDialog.askstring('Enter acres','Acres?')
print( 'Unknown side = ', round((float(acres)* 43560) /float(knownSide),2), " ft")

def SncoWeb():
webbrowser.open('http://www.snco.us/')
open

#Create buttons then pack them into a window
root = Tk()
#aName = tkSimpleDialog.askstring('the title','enter text',)
ConChains = Button(root,text='Convert Chains', command = ConvertChains)
ConRods = Button(root,text='Convert Rods ', command = ConvertRods)
FindUnknown = Button(root, text="Unknown Side ", command=unknownside)
SNCO = Button(root, text='Open SNCO', command = SncoWeb)

SNCO.pack()
ConChains.pack()
ConRods.pack()
FindUnknown.pack()
#exitbutton.pack()

root.mainloop()

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.