Keep It Simple with PythonCard.notes

Thursday, March 24, 2005

TITLE OF PAPER: Keep It Simple with PythonCard
PRESENTED BY: Kevin Altis (

DATE: Wednesday, March 24, 2005
LOCATION: GWU Cafritz Conference Center, Marvin Theatre

{If you've contributed, add your name, e-mail & URL at the bottom}

Let's jump off the cliff and see if the parachute opens...
    [i.e. demo mostly, few slides]

What Python isn't: Hypercard
    More like VB, not designed to support big complicated projects or teams

PythonCard 2.0 could be more like HyperCard, goals not frozen yet

Demo --
    PyCard now has GUI templet library!
    Simple application
        [...although there is a sample MP3 player app]
    Choose a template
    [running on Mac to make things more interesting :-)]
    This creates an empty but runnable application
    Need text input fields (for mortgage calculator)
    [Shows creating a text input feild then editing it]
    Everything in pyCard uses names identifiers
        Static text items for labels
    GUI construction by item property edit, then drop & drag in GUI window
    [Shows using resource editor to change properties]
    [Shows align components to grid]    
    Run again: can type, tab between fields
        Still doesn't do anything, but layout is done    
    [Shows creating a button]
    Need code to make it work
        Code file created automatically with template
        Need to add event handler to make it do something
    [Shows adding event handler: named for button ID + event name (?)]
        def on_calculate_mouseClick(self, event):
            self.components.result.text = "hello pycon"
    [Now it actually does something]
    Code editor and shell window is PyCrust (comes with wx)
        Supports code completion, tooltips with method doc
    [Tests calculation code in shell -- using downloaded "pyfi" library]
    [Add to our code]
        def on_calculate_mouseClick(self, event):
            c = self.components
            amount = int(c.amount.text)
            rate = float(c.rate.text)
            payment15 = pyfi.amortization(amount, rate, 12, 13*15) ## 13? 12?
            self.components.result.text = str(payment15)
    Note controls are referenced by self.components.<identifier>
    It works! (applause)
    on_initialize will run after everything starts up
        Values in text items retained from previous run (?)
    [Shows app running with message watcher window -- displays all events
    [Shows live runtime changing of the application]
    [Copies code from Mac to Windows (under Virtual PC)]
        -- it just runs!  (oohs, applause)

    Pycard comes with 50+ samples, there's a samples launcher, shows code
    [Shows "Spirograph" sample app -- all written in Python, updates on the fly. So there.]

Q: Automated layout (as opposed to grid spacing in GUI)?
A: Built on wxPython, so sizers are available. Everything in GUI is static placement, but you can import any wxPython widget.

Q: If you were putting in a sizer, do you put sizing info in the init call?
A: Call from on_initialization() method. Turtle sample does this.

Q: Is there an HTML display window?
A: ActiveX wrappers for IE, Flash, ... but this is Windows only. It also
    includes the standard (very simple) HTML control from wxWidgets.

Q: What do you use to render html, what version, does it support CSS?
A: its the version built into wx, so no, unless you use the ActiveX

Q: Upgrade path for going deeper into wxPython?
A: All our classes subclass wxPython classes (and simplify them). e.g. we only
    wrap the "useful" wxApplication methods. All our methods use
    underscore_names instead of CamelCase.

Q: Back patting about the tool, good mailing list, productive tool. Resulting
    application is stable and does what it's supposed to do. Please show off
    what the resource code looks like. [Shows]
A: Resource file is basically just dictionaries and lists in standard
    Python syntax.

    Release 1.0 this year (waiting on wx 2.6)
    Open Space 4-4:30 today Room 310

Mailing list is on main site

REFERENCES: {as documents / sites are referenced add them below}

Kevin: "We'll put in $100,000 for a house..." Audience: "Where are you from?"

CONTRIBUTORS: {add your name, e-mail address and URL below}
Russell Finn <>
Andy Wright <>
Nate Silva <>
Linden Wright <>

E-MAIL BOUNCEBACK: {add your e-mail address separated by commas }

A headline (like a field in a database) will be CAPITALISED
    This differentiates from the text that follows
A variable that you can change will be surrounded by _underscores_
    Spaces in variables are also replaced with under_scores
    This allows people to select the whole variable with a simple double-click
A tool-tip is lower case and surrounded by {curly brackets / parentheses}
    These supply helpful contextual information.

Copyright shared between all the participants unless otherwise stated...