girl scout badge

Raymond Hettinger vze4rx4y at verizon.net
Thu Jun 5 02:07:29 EDT 2003


"sam420" <WEBEXPERTS4 at YAHOO.COM> wrote in message
news:eb5e40b2.0306042028.635442d6 at posting.google.com...
> I'd like a simple python program to help organize my girl scout badge
> info. I want a GUI interface that would have different button for each
> badge, i.e., if I hit the communication button, the communication
> requirements would pop up. Or if I hit the weather badge button, the
> requirements for the weather badge would pop up. I'd like to start
> with 6 badges. I'll type the requirements in the data (?) file, but
> you would have to create the actual file and show me where to type the
> requirements in. Can anyone help? I am a newbie =)

The best way to start is to get your data file working before attempting
to build a GUI.  The shelve module is well suited to your needs because
it connects a keyword (like the name of the merit badge) to a record in
a file that has your data stored in some structure (like a list of
requirements).
It looks a bit like this:

>>> import shelve
>>> badgefile = shelve.open('badgefil.shl')
>>> badgefile['Communications'] = [
 'Develop a plan to teach a skill',
 'Choose a product or service and build a sales plan',
 'Show how to leave an effective recorded message or voice mail',
 'Write and give a five minute speech to a group',
 'Show how to introduce a speaker',
 'Attend a town meeting and report back to your troop',
 'Write a letter to the editor to express an opinion',
 'Create a autobiographic resume to apply for a job',
 'Find out about careers in communications' ]

Once your database is built and meaning your needs, attach it to a GUI.
Learning all of Tkinter can be daunting but it is not difficult to setup
buttons and to create list boxes.

Here's a simple example of using a Button:

import sys, Tkinter
Tkinter.Button('text'='Click here to Exit', command=sys.exit).pack()
Tkinter.mainloop()

Displaying the requirements in a listbox is also easy:

>>> import Tkinter
>>> req = Tkinter.Listbox()
>>> for line in badgefile['Communications']:
 req.insert(Tkinter.END, line)
>>> req.pack()

This should be enough to get you started.  It is not easy to setup
your first GUI, but the effort is worth it and it is a valuable skill
to have.

If you get stuck and would like some coaching, there is a
friendly group of experts at:
  tutor at python.org


Good luck, happy computing, happy scouting


Raymond Hettinger








More information about the Python-list mailing list