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()
This is a personal record of my python programming experiences. It will allow me to see how I am progressing as I learn a new language.
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
- June (1)
- March (3)
- February (1)
- July (3)
- May (1)
- April (1)
- March (1)
- January (1)
- December (1)
- November (4)
- July (3)
- May (2)
- April (1)
- March (6)
- February (2)
- December (1)
- November (1)
- September (3)
- August (3)
- July (1)
- March (3)
- January (1)
- December (5)
- November (2)
- October (1)
- September (2)
- August (1)
- July (4)
- May (3)
- February (1)
- January (1)
- December (1)
- November (2)
- October (2)
- September (9)
- August (2)
- May (1)
- April (1)
- March (6)
- February (5)
- January (3)
- August (2)
No comments:
Post a Comment