This page is just a placeholder. Feel free to start editing and adding information about PythonCard from the perspective of a Visual Basic user. - KEA 2002-04-22
Introduction
Benefits
The biggest benefit of using PythonCard instead of Visual Basic is that you get to use Python as the programming language instead of Basic and leverage the large set of Python Standard Libraries. Probably the second biggest benefit is being able to run your program on Linux and OS X in addition to Windows.
Status
See the vb2py section below for the status of a project to convert existing Visual Basic programs to PythonCard.
Standalone Applications
You can build standalone EXEs using py2exe and Gordon McMillan's installer. The resulting package will allow an application to be installed on a users machine without needing to install Python, wxPython or PythonCard. The packages are self-contained, so you don't have to worry about DLL conflicts in the System folder either. There are example scripts included with the minimal sample for building standalones.
win32 and win32com
Utilizing Mark Hammond's win32 code it is possible to create ActiveX (COM) servers and access existing COM components and other win32 services such as the registry. wxPython already includes wrappers for the Internet Explorer (IE) WebBrowser control and Adobe Acrobat Reader control.
win32com entries in the Python Cookbook
win32 entries in the Python Cookbook
Component Names
All components such as Buttons, TextFields, and Lists in PythonCard have a unique name used to reference the component from different parts of a program.
Event handlers
An event handler in Visual Basic looks something like this.
Private Sub Command1_Click()
Command1.Caption = "hello"
End SubAssuming you had a button named 'Command1' in PythonCard, the handler would look like this if you wanted to use the target of the event to make the change.
def on_Command1_mouseClick(self, event):
event.target.label = "hello"You could also access the Command1 Button this way.
def on_Command1_mouseClick(self, event):
self.components.Command1.label = "hello"
Layout
Component layout in PythonCard is done using the resourceEditor sample.
Layout translator
Since the .frm layout descriptions are structured, it would be nice to have a .frm to PythonCard resource format translator. The different scale options supported by VB would need to be handled. Here's a portion of a VB .frm file
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "SearchExplorer"
ClientHeight = 4860
ClientLeft = 45
ClientTop = 615
ClientWidth = 7845
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4860
ScaleWidth = 7845
Begin VB.TextBox Text1
Height = 285
Left = 0
MaxLength = 200
TabIndex = 0
Top = 0
Width = 6495
End
Begin VB.CommandButton Command2
Caption = "Remove Search"
Height = 375
Left = 3360
TabIndex = 7
TabStop = 0 'False
Top = 4320
Width = 1455
End
vb2py
Paul Paterson has announced the first release of vb2py.
"vb2py is a toolkit to aid in the conversion of Visual Basic projects to Python (using PythonCard). The conversion will eventually include both forms and code (modules and classes). Version 0.1 is mainly a form layout converter to PythonCard with a very simplistic code translation. The project roadmap shows the project's development timeline.
Converting VB to Python turns your VB projects into cross platform developments and allows full access to all Python's extensive library of modules."
