Saturday, September 11, 2010

My first option menu written in Python 2.6

I am learning how to create option menus with Python. I made a very simple one that opens web pages.  This is just a learning excercise, and it is very simple. I have to start somewhere.

pages.  from Tkinter import *
import webbrowser
#My first OptionMenu widget written in Python 2.6

def OpenWeb():
    showWeb=theAction.get()
    if showWeb=='My blog':
       webbrowser.open('http://stevespythonprogramadventures.blogspot.com/')
    if showWeb=='open SNCO':
        webbrowser.open('http://www.snco.us/default.asp')
    if showWeb=='GISviewer':
        webbrowser.open('http://gis.snco.us/PublicGIS/')
  


root=Tk()

theAction=StringVar()
theAction.set(None)

OptionMenu(root,theAction,'My blog','open SNCO','GISviewer').pack()

abtn=Button(root, text='go!',command=OpenWeb)
abtn.pack()
      
root.mainloop()

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.