[Tutor] use of WxPython class, method, etc

dman dsh8290@rit.edu
Tue, 23 Oct 2001 09:01:54 -0400


On Tue, Oct 23, 2001 at 01:40:26PM +0700, Adinda-Praditya wrote:
| hi list,...
| 
| i'm newbie in python world, tried to use wxpython. i read
| the manual (wxPython-docs-*.tar.gz), i think it's for C++
| instead of python, (i don't know C++ :-(  )

Yeah, the underlying wxWindows library is implemented in C++ and those
people wrote most of the docs.  C++ and Python are very similar (at
least as far as the docs are concerned) and no one has spent the time
to rewrite them to be python-specific.  If you know C++ it isn't a
problem.  If not, well, ask when you have trouble and some people will
explain it.  There is also a mailing list dedicated to wxPython.

| it said :
| 
| wxStopWatch
| The wxStopWatch class allow you to measure time intervals.
| Include files
| <wx/timer.h>
| See also
| ::wxStartTimer, ::wxGetElapsedTime, wxTimer
| Members
| wxStopWatch::wxStopWatch
| wxStopWatch::Pause
| wxStopWatch::Start
| wxStopWatch::Resume
| wxStopWatch::Time
| wxStopWatch::wxStopWatch wxStopWatch()
| Constructor. This starts the stop watch.
| ---
| 
| still confuse using it.  what does wxStopWatch::Start  mean?

It means that there is a method called "Start" that is inside the
class called "wxStopWatch".  The double-colon is called the "scope
resolution operator".  The dot ( '.' ) operator in Python performs the
same functionality.  Ignore the "include files" section.  Also ignore
anything that talks about memory management (new/delete, etc) --
python takes care of that for you.

| i tried to make a stopwatch apps. what should i write?
| should i create panel first or not, how can i know that? I
| tried to use it in deferenct way, but i always get error.

(note : all untested, but should give the general idea)

import time
import wx

my_watch = wx.wxStopWatch()
time.sleep( 2 )
print my_watch.Time()
my_watch.Pause()
time.sleep( 2 )
print my_watch.Time()
my_watch.Resume()
time.sleep( 2 )
print my_watch.Time()


HTH,
-D