Boa Custom Class problems

Hi guys im newbie. Im using Boa v0.2.3 with wxPython
2.4 for Python 2.3.

I wanna customize the status bar & using the code from
the demo (with the timer things).

So I made a module(CustomStatusBar.py):

from wxPython.wx import *
import time

class CustomStatusBar(wxStatusBar):
    def __init__(self, parent, id):
        wxStatusBar.__init__(self, parent, id)
        self.SetFieldsCount(2)
        
        self.SetStatusText(text='Skor Kardiovaskular
Jakarta')
        
        self.timer = wxPyTimer(self.Notify)
        self.timer.Start(1000)
        self.Notify()
        
        self.SetStatusWidths([-1, -1])
        
    def Notify(self):
        t = time.localtime(time.time())
        st = time.strftime("%d-%b-%Y %I:%M:%S", t)
        self.SetStatusText(st, 1)

and Change on my Main (wxFrame):

1. import CustomStatusBar

2. Adding "wxID_MAINMENUSTATUSBAR1," to map(lambda
_init_ctrls:... & increase the range

3. Add "_custom_classes = {'wxStatusBar':
['CustomStatusBar.CustomStatusBar']}" right below the
"class mainMenu(wxFrame):"

4. And finally adding:

self.statusBar1 =
CustomStatusBar.CustomStatusBar(self, id =
wxID_MAINMENUSTATUSBAR1)
self.statusBar1.SetPosition(wxPoint(0, 547))
self.statusBar1.SetSize(wxSize(780, 20))
self.SetStatusBar(self.statusBar1)

When I ran this things it works, but when I got back
to the Boa & tried to open the designer I always got
this:
"""
The following lines were not used by the Designer and
will be lost:
self.statusBar1 =
CustomStatusBar.CustomStatusBar(self,
id = wxID_MAINMENUSTATUSBAR1)

There were unprocessed lines in the source code of
method: _init_ctrls
If this was unexpected, it is advised that you cancel
this Designer session and correct the problem before
continuing.
"""

And my scripts on number 4 (above) its GONE!

Can anyone help me with these?

Thanx

Danu

···

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

Hi Danu,

Creating and using custom classes is discussed in detail in the Boa
docs, see Docs/boa/apphelp/MixingSource.html

The first problem is that the constructor signature should be the
same as the wxPython version.
The easiest way to do this is e.g.

  class CustomStatusBar(wxStatusBar):
      def __init__(self, *args, **kwargs):
          wxStatusBar.__init__(self, *args, **kwargs)

          ...

Next, you should import and use the custom class directly in the
global scope, e.g.

from CustomStatusBar import CustomStatusBar

And finally, you don't have to edit the generated source by hand
to create the custom statusbar class.
Just create a normal statusbar in the Designer and change it's
Class property in the Inspector to CustomStatusBar.

Hope that solves it,
Riaan.

danu kusmana wrote:

···

Hi guys im newbie. Im using Boa v0.2.3 with wxPython
2.4 for Python 2.3.
I wanna customize the status bar & using the code from
the demo (with the timer things).

So I made a module(CustomStatusBar.py):

from wxPython.wx import *
import time

class CustomStatusBar(wxStatusBar):
    def __init__(self, parent, id):
        wxStatusBar.__init__(self, parent, id)
        self.SetFieldsCount(2)
                self.SetStatusText(text='Skor Kardiovaskular
Jakarta')
                self.timer = wxPyTimer(self.Notify)
        self.timer.Start(1000)
        self.Notify()
                self.SetStatusWidths([-1, -1])
            def Notify(self):
        t = time.localtime(time.time())
        st = time.strftime("%d-%b-%Y %I:%M:%S", t)
        self.SetStatusText(st, 1)

and Change on my Main (wxFrame):

1. import CustomStatusBar

2. Adding "wxID_MAINMENUSTATUSBAR1," to map(lambda
_init_ctrls:... & increase the range

3. Add "_custom_classes = {'wxStatusBar':
['CustomStatusBar.CustomStatusBar']}" right below the
"class mainMenu(wxFrame):"

4. And finally adding:

self.statusBar1 =
CustomStatusBar.CustomStatusBar(self, id =
wxID_MAINMENUSTATUSBAR1)
self.statusBar1.SetPosition(wxPoint(0, 547))
self.statusBar1.SetSize(wxSize(780, 20))
self.SetStatusBar(self.statusBar1)

When I ran this things it works, but when I got back
to the Boa & tried to open the designer I always got
this:
"""
The following lines were not used by the Designer and
will be lost:
self.statusBar1 =
CustomStatusBar.CustomStatusBar(self,
id = wxID_MAINMENUSTATUSBAR1)

There were unprocessed lines in the source code of
method: _init_ctrls
If this was unexpected, it is advised that you cancel
this Designer session and correct the problem before
continuing.
"""

And my scripts on number 4 (above) its GONE!

Can anyone help me with these?

Thanx

Danu

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

I finally made up using:

class CustomStatusBar(wxStatusBar):
    def __init__(self, parent):

in wxFrame:

from CustomStatusBar import CustomStatusBar

class mainMenu(wxFrame):
    _custom_classes = {'wxStatusBar':
['CustomStatusBar']}

    def _init_ctrls(self, prnt):

        self.statusBar1 = CustomStatusBar(parent=self)

Thanx

danu

···

--- Riaan Booysen <riaan@e.co.za> wrote:

Hi Danu,

Creating and using custom classes is discussed in
detail in the Boa
docs, see Docs/boa/apphelp/MixingSource.html

The first problem is that the constructor signature
should be the
same as the wxPython version.
The easiest way to do this is e.g.

  class CustomStatusBar(wxStatusBar):
      def __init__(self, *args, **kwargs):
          wxStatusBar.__init__(self, *args,
**kwargs)

          ...

Next, you should import and use the custom class
directly in the
global scope, e.g.

from CustomStatusBar import CustomStatusBar

And finally, you don't have to edit the generated
source by hand
to create the custom statusbar class.
Just create a normal statusbar in the Designer and
change it's
Class property in the Inspector to CustomStatusBar.

Hope that solves it,
Riaan.

danu kusmana wrote:
> Hi guys im newbie. Im using Boa v0.2.3 with
wxPython
> 2.4 for Python 2.3.
>
> I wanna customize the status bar & using the code
from
> the demo (with the timer things).
>
> So I made a module(CustomStatusBar.py):
>
> from wxPython.wx import *
> import time
>
> class CustomStatusBar(wxStatusBar):
> def __init__(self, parent, id):
> wxStatusBar.__init__(self, parent, id)
> self.SetFieldsCount(2)
>
> self.SetStatusText(text='Skor
Kardiovaskular
> Jakarta')
>
> self.timer = wxPyTimer(self.Notify)
> self.timer.Start(1000)
> self.Notify()
>
> self.SetStatusWidths([-1, -1])
>
> def Notify(self):
> t = time.localtime(time.time())
> st = time.strftime("%d-%b-%Y %I:%M:%S",
t)
> self.SetStatusText(st, 1)
>
> and Change on my Main (wxFrame):
>
> 1. import CustomStatusBar
>
> 2. Adding "wxID_MAINMENUSTATUSBAR1," to map(lambda
> _init_ctrls:... & increase the range
>
> 3. Add "_custom_classes = {'wxStatusBar':
> ['CustomStatusBar.CustomStatusBar']}" right below
the
> "class mainMenu(wxFrame):"
>
> 4. And finally adding:
>
> self.statusBar1 =
> CustomStatusBar.CustomStatusBar(self, id =
> wxID_MAINMENUSTATUSBAR1)
> self.statusBar1.SetPosition(wxPoint(0, 547))
> self.statusBar1.SetSize(wxSize(780, 20))
> self.SetStatusBar(self.statusBar1)
>
> When I ran this things it works, but when I got
back
> to the Boa & tried to open the designer I always
got
> this:
> """
> The following lines were not used by the Designer
and
> will be lost:
> self.statusBar1 =
> CustomStatusBar.CustomStatusBar(self,
> id = wxID_MAINMENUSTATUSBAR1)
>
> There were unprocessed lines in the source code of
> method: _init_ctrls
> If this was unexpected, it is advised that you
cancel
> this Designer session and correct the problem
before
> continuing.
> """
>
> And my scripts on number 4 (above) its GONE!
>
> Can anyone help me with these?
>
> Thanx
>
> Danu
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync
to Outlook(TM).
> http://calendar.yahoo.com
>
>

---------------------------------------------------------------------

> To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwindows.org
> For additional commands, e-mail:
wxPython-users-help@lists.wxwindows.org
>
>

---------------------------------------------------------------------

To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwindows.org

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com