1
1
Aaron Stevens
13 April 2009
CS108 Lecture 29: GUI: PythonCard Basic Input/Output Widgets
2
Overview/Questions How do we start create a custom GUI dialog? - - PDF document
CS108 Lecture 29: GUI: PythonCard Basic Input/Output Widgets Aaron Stevens 13 April 2009 1 Overview/Questions How do we start create a custom GUI dialog? Using the PythonCard LayoutEditor. How do we specify input/output widgets?
1
2
3
Start / Programs / PythonCard / Layout Editor
PythonCard/tools/resourceEditor/layoutEditor.py
4
5
6
7
8
9
This webpage has a list of naming conventions to follow: http://www.cs.bu.edu/courses/cs108/gui_naming_conventions.html
10
11
12
13
http://pythoncard.sourceforge.net/framework/events_and_handlers.html
14
def on_btnIncrement_mouseClick(self,event): # handler code here…
15
def on_btnIncrement_mouseClick(self,event): count = int(self.components.txtCounter.text) count = count + 1 self.components.txtCounter.text = str(count) def on_btnDecrement_mouseClick(self,event): count = int(self.components.txtCounter.text) count = count - 1 self.components.txtCounter.text = str(count) def on_btnReset_mouseClick(self,event): self.components.txtCounter.text = "42"
16
17
http://pythoncard.sourceforge.net/framework/components.html
18
def debugComponentsAndAttributes(self): for component in self.components.iterkeys(): # self.components is a dictionary (and also an object) print component, "->", type(self.components[component]) attributes = dir(type(self.components[component])) for attr in attributes: if attr[0] >= 'a': # only print lower case names print "\t",attr print
19
20
21
22
<site-packages>/PythonCard/tools/resourceEditor/
#! /bin/sh # # A quick shell script to launch the PythonCard Layout Editor # python /Users/azs/code/python/lib/PythonCard- 0.8.2/tools/resourceEditor/layoutEditor.py