Mac wx.SetTitle problem

In a wxPython application, which i am porting to Mac OSX, I set title of app frame every 500msec in update UI event, and due to that all the panels and windows are refreshed. That seems strange to me and almost halts my application which has many custom drawn controls and screens.

I wanted to know what could be the reason behind it, is it normal for MAC( bug?)

Here is a self-constrained script which replicates the scenario using timers. It keeps on printing “on paint” every 500ms because in timer I set title every 500ms.

import wx

app = wx.PySimpleApp()

frame = wx.Frame(None, title=“BasePainter
Test”)

painter = wx.Panel(frame)

def onPaint(event):

dc = wx.PaintDC(painter)

print “onPaint”

painter.Bind(wx.EVT_PAINT, onPaint)

def loop():

frame.SetTitle(frame.GetTitle())

wx.CallLater(500, loop)

loop()

frame.Show(True)

app.SetTopWindow(frame)

app.MainLoop()

My system details:

sys.version

‘2.5 (r25:51918, Sep 19
2006, 08:49:13) \n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]’

wx.VERSION

(2, 8, 10, 1, ‘’)

os.uname()

(‘Darwin’, ‘agyeys-mac-mini.local’, ‘9.8.0’, ‘Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386’, ‘i386’)

rgds

Anurag

···

Your Mail works best with the New Yahoo Optimized IE8. Get it NOW!.

1) Why are you setting the title of the frame repeatedly to the same
title?
2) Even if there is a valid reason (which I doubt), updating it faster
than the eye can see is not a good idea

···

On Mar 5, 2:23 am, anurag uniyal <anuraguni...@yahoo.com> wrote:

In a wxPython application, which i am porting to Mac OSX, I set title of app frame every 500msec in update UI event, and due to that all the panels and windows are refreshed. That seems strange to me and almost halts my application which has many custom drawn controls and screens.

I wanted to know what could be the reason behind it, is it normal for MAC( bug?)

Here is a self-constrained script which replicates the scenario using timers. It keeps on printing "on paint" every 500ms because in timer I set title every 500ms.

import wx

app = wx\.PySimpleApp\(\)
frame = wx\.Frame\(None, title=&quot;BasePainter Test&quot;\)
painter = wx\.Panel\(frame\)

def onPaint\(event\):
    dc = wx\.PaintDC\(painter\)
    print &quot;onPaint&quot;

painter\.Bind\(wx\.EVT\_PAINT, onPaint\)

def loop\(\):
    frame\.SetTitle\(frame\.GetTitle\(\)\)
    wx\.CallLater\(500, loop\)
loop\(\)

frame\.Show\(True\)
app\.SetTopWindow\(frame\)
app\.MainLoop\(\)

My system details:

&gt;&gt;&gt; sys\.version
&#39;2\.5 \(r25:51918, Sep 19 2006, 08:49:13\) \\n\[GCC 4\.0\.1 \(Apple Computer, Inc\. build 5341\)\]&#39;
&gt;&gt;&gt; wx\.VERSION
\(2, 8, 10, 1, &#39;&#39;\)
&gt;&gt;&gt; os\.uname\(\)
\(&#39;Darwin&#39;, &#39;agyeys\-mac\-mini\.local&#39;, &#39;9\.8\.0&#39;, &#39;Darwin Kernel Version 9\.8\.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu\-1228\.15\.4\~1/RELEASE\_I386&#39;, &#39;i386&#39;\)

rgds
Anurag

  Your Mail works best with the New Yahoo Optimized IE8\. Get it NOW\!http://downloads.yahoo.com/in/internetexplorer/

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

this is just a self contained example to show the problem.
In real case, i only update title periodically on UPDATE_UI event e.g.
when user modifies document I set title with '*'
so I have workarounds but the question here is

is this a bug? or some deep reason behind it which I fail to
understand

···

On Mar 5, 8:51 pm, Mike Driscoll <kyoso...@gmail.com> wrote:

On Mar 5, 2:23 am, anurag uniyal <anuraguni...@yahoo.com> wrote:

> In a wxPython application, which i am porting to Mac OSX, I set title of app frame every 500msec in update UI event, and due to that all the panels and windows are refreshed. That seems strange to me and almost halts my application which has many custom drawn controls and screens.

> I wanted to know what could be the reason behind it, is it normal for MAC( bug?)

> Here is a self-constrained script which replicates the scenario using timers. It keeps on printing "on paint" every 500ms because in timer I set title every 500ms.

> import wx

> app = wx.PySimpleApp()
> frame = wx.Frame(None, title="BasePainter Test")
> painter = wx.Panel(frame)

> def onPaint(event):
> dc = wx.PaintDC(painter)
> print "onPaint"

> painter.Bind(wx.EVT_PAINT, onPaint)

> def loop():
> frame.SetTitle(frame.GetTitle())
> wx.CallLater(500, loop)
> loop()

> frame.Show(True)
> app.SetTopWindow(frame)
> app.MainLoop()

> My system details:

> >>> sys.version
> '2.5 (r25:51918, Sep 19 2006, 08:49:13) \n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]'
> >>> wx.VERSION
> (2, 8, 10, 1, '')
> >>> os.uname()
> ('Darwin', 'agyeys-mac-mini.local', '9.8.0', 'Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386', 'i386')

> rgds
> Anurag

> Your Mail works best with the New Yahoo Optimized IE8. Get it NOW!Yahooist Teil der Yahoo Markenfamilie

1) Why are you setting the title of the frame repeatedly to the same
title?
2) Even if there is a valid reason (which I doubt), updating it faster
than the eye can see is not a good idea

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Hi Anurag,

this is just a self contained example to show the problem.
In real case, i only update title periodically on UPDATE_UI event e.g.
when user modifies document I set title with '*'
so I have workarounds but the question here is

is this a bug? or some deep reason behind it which I fail to
understand

It's a bug. Since the API for changing a control's label and a Frame's title are the same on Mac (for Carbon at least), the Frame code just calls wx.Window.SetLabel. SetLabel, though, calls Refresh() on the control, which makes sense for a wx.Window but is probably not necessary or useful for a Frame.

However, I'm surprised a Refresh() would grind your application to a halt. Are you using wx.BufferedPaintDC or doing drawing during a repaint using wx.ClientDC?

Regards,

Kevin

···

On Mar 5, 2010, at 8:23 AM, anuraguniyal@yahoo.com wrote:

On Mar 5, 8:51 pm, Mike Driscoll <kyoso...@gmail.com> wrote:

On Mar 5, 2:23 am, anurag uniyal <anuraguni...@yahoo.com> wrote:

In a wxPython application, which i am porting to Mac OSX, I set title of app frame every 500msec in update UI event, and due to that all the panels and windows are refreshed. That seems strange to me and almost halts my application which has many custom drawn controls and screens.

I wanted to know what could be the reason behind it, is it normal for MAC( bug?)

Here is a self-constrained script which replicates the scenario using timers. It keeps on printing "on paint" every 500ms because in timer I set title every 500ms.

    import wx

    app = wx.PySimpleApp()
    frame = wx.Frame(None, title="BasePainter Test")
    painter = wx.Panel(frame)

    def onPaint(event):
        dc = wx.PaintDC(painter)
        print "onPaint"

    painter.Bind(wx.EVT_PAINT, onPaint)

    def loop():
        frame.SetTitle(frame.GetTitle())
        wx.CallLater(500, loop)
    loop()

    frame.Show(True)
    app.SetTopWindow(frame)
    app.MainLoop()

My system details:

    >>> sys.version
    '2.5 (r25:51918, Sep 19 2006, 08:49:13) \n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]'
    >>> wx.VERSION
    (2, 8, 10, 1, '')
    >>> os.uname()
    ('Darwin', 'agyeys-mac-mini.local', '9.8.0', 'Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386', 'i386')

rgds
Anurag

      Your Mail works best with the New Yahoo Optimized IE8. Get it NOW!Yahooist Teil der Yahoo Markenfamilie

1) Why are you setting the title of the frame repeatedly to the same
title?
2) Even if there is a valid reason (which I doubt), updating it faster
than the eye can see is not a good idea

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Thanks Kevin, may be I exaggerated a bit :), its not halting but my
render speed becomes too low on MAC e.g. on windows i have 32 FPS and
on MAC 11 FPS(to user it seems moving widgets around is cumbersome),
and yes i do drawing on memory dc and i have many custom controls,
though as i said earlier I have fixed it for now by first checking if
title really needs to be changed
i thought internally wxFrame must be doing that.

I will file a bug for this.

···

On Mar 5, 9:53 pm, Kevin Ollivier <kevin-li...@theolliviers.com> wrote:

Hi Anurag,

On Mar 5, 2010, at 8:23 AM, anuraguni...@yahoo.com wrote:

> this is just a self contained example to show the problem.
> In real case, i only update title periodically on UPDATE_UI event e.g.
> when user modifies document I set title with '*'
> so I have workarounds but the question here is

> is this a bug? or some deep reason behind it which I fail to
> understand

It's a bug. Since the API for changing a control's label and a Frame's title are the same on Mac (for Carbon at least), the Frame code just calls wx.Window.SetLabel. SetLabel, though, calls Refresh() on the control, which makes sense for a wx.Window but is probably not necessary or useful for a Frame.

However, I'm surprised a Refresh() would grind your application to a halt. Are you using wx.BufferedPaintDC or doing drawing during a repaint using wx.ClientDC?

Regards,

Kevin

> On Mar 5, 8:51 pm, Mike Driscoll <kyoso...@gmail.com> wrote:
>> On Mar 5, 2:23 am, anurag uniyal <anuraguni...@yahoo.com> wrote:

>>> In a wxPython application, which i am porting to Mac OSX, I set title of app frame every 500msec in update UI event, and due to that all the panels and windows are refreshed. That seems strange to me and almost halts my application which has many custom drawn controls and screens.

>>> I wanted to know what could be the reason behind it, is it normal for MAC( bug?)

>>> Here is a self-constrained script which replicates the scenario using timers. It keeps on printing "on paint" every 500ms because in timer I set title every 500ms.

>>> import wx

>>> app = wx.PySimpleApp()
>>> frame = wx.Frame(None, title="BasePainter Test")
>>> painter = wx.Panel(frame)

>>> def onPaint(event):
>>> dc = wx.PaintDC(painter)
>>> print "onPaint"

>>> painter.Bind(wx.EVT_PAINT, onPaint)

>>> def loop():
>>> frame.SetTitle(frame.GetTitle())
>>> wx.CallLater(500, loop)
>>> loop()

>>> frame.Show(True)
>>> app.SetTopWindow(frame)
>>> app.MainLoop()

>>> My system details:

>>> >>> sys.version
>>> '2.5 (r25:51918, Sep 19 2006, 08:49:13) \n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]'
>>> >>> wx.VERSION
>>> (2, 8, 10, 1, '')
>>> >>> os.uname()
>>> ('Darwin', 'agyeys-mac-mini.local', '9.8.0', 'Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386', 'i386')

>>> rgds
>>> Anurag

>>> Your Mail works best with the New Yahoo Optimized IE8. Get it NOW!Yahooist Teil der Yahoo Markenfamilie

>> 1) Why are you setting the title of the frame repeatedly to the same
>> title?
>> 2) Even if there is a valid reason (which I doubt), updating it faster
>> than the eye can see is not a good idea

>> -------------------
>> Mike Driscoll

>> Blog: http://blog.pythonlibrary.org

> --
> To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
> or visithttp://groups.google.com/group/wxPython-users?hl=en

Hi Anurag,

Thanks Kevin, may be I exaggerated a bit :), its not halting but my
render speed becomes too low on MAC e.g. on windows i have 32 FPS and
on MAC 11 FPS(to user it seems moving widgets around is cumbersome),
and yes i do drawing on memory dc and i have many custom controls,
though as i said earlier I have fixed it for now by first checking if
title really needs to be changed
i thought internally wxFrame must be doing that.

I will file a bug for this.

Yes, it is a bug, and I'll see about fixing it for trunk, but I suspect it's not the main cause of your performance problems, it just makes them more visible. If you're using wx.BufferedPaintDC or wx.MemoryDC to avoid flicker, don't. Use wx.AutoBufferedPaintDC instead, which only double-buffers on Windows because it happens internally on Mac and GTK. The Mac window manager protects against things like flicker itself, so a lot of the tricks developers use to get drawing working properly on Windows are unnecessary on Mac, and using them just hurts the performance of your app, sometimes a great deal.

Regards,

Kevin

···

On Mar 5, 2010, at 6:45 PM, anuraguniyal@yahoo.com wrote:

On Mar 5, 9:53 pm, Kevin Ollivier <kevin-li...@theolliviers.com> > wrote:

Hi Anurag,

On Mar 5, 2010, at 8:23 AM, anuraguni...@yahoo.com wrote:

this is just a self contained example to show the problem.
In real case, i only update title periodically on UPDATE_UI event e.g.
when user modifies document I set title with '*'
so I have workarounds but the question here is

is this a bug? or some deep reason behind it which I fail to
understand

It's a bug. Since the API for changing a control's label and a Frame's title are the same on Mac (for Carbon at least), the Frame code just calls wx.Window.SetLabel. SetLabel, though, calls Refresh() on the control, which makes sense for a wx.Window but is probably not necessary or useful for a Frame.

However, I'm surprised a Refresh() would grind your application to a halt. Are you using wx.BufferedPaintDC or doing drawing during a repaint using wx.ClientDC?

Regards,

Kevin

On Mar 5, 8:51 pm, Mike Driscoll <kyoso...@gmail.com> wrote:

On Mar 5, 2:23 am, anurag uniyal <anuraguni...@yahoo.com> wrote:

In a wxPython application, which i am porting to Mac OSX, I set title of app frame every 500msec in update UI event, and due to that all the panels and windows are refreshed. That seems strange to me and almost halts my application which has many custom drawn controls and screens.

I wanted to know what could be the reason behind it, is it normal for MAC( bug?)

Here is a self-constrained script which replicates the scenario using timers. It keeps on printing "on paint" every 500ms because in timer I set title every 500ms.

    import wx

    app = wx.PySimpleApp()
    frame = wx.Frame(None, title="BasePainter Test")
    painter = wx.Panel(frame)

    def onPaint(event):
        dc = wx.PaintDC(painter)
        print "onPaint"

    painter.Bind(wx.EVT_PAINT, onPaint)

    def loop():
        frame.SetTitle(frame.GetTitle())
        wx.CallLater(500, loop)
    loop()

    frame.Show(True)
    app.SetTopWindow(frame)
    app.MainLoop()

My system details:

    >>> sys.version
    '2.5 (r25:51918, Sep 19 2006, 08:49:13) \n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]'
    >>> wx.VERSION
    (2, 8, 10, 1, '')
    >>> os.uname()
    ('Darwin', 'agyeys-mac-mini.local', '9.8.0', 'Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386', 'i386')

rgds
Anurag

      Your Mail works best with the New Yahoo Optimized IE8. Get it NOW!Yahooist Teil der Yahoo Markenfamilie

1) Why are you setting the title of the frame repeatedly to the same
title?
2) Even if there is a valid reason (which I doubt), updating it faster
than the eye can see is not a good idea

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visithttp://groups.google.com/group/wxPython-users?hl=en

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Does the value of the title actually change that often? If not then you can probably improve things a lot if you only call SetTitle when the text actually needs to change.

  if newTitle != self.GetTitle():
    self.SetTitle(newTitle)

···

On 3/5/10 12:23 AM, anurag uniyal wrote:

In a wxPython application, which i am porting to Mac OSX, I set title of
app frame every 500msec in update UI event, and due to that all the
panels and windows are refreshed.

--
Robin Dunn
Software Craftsman

Yes thanks, I am already doing that, but sometime title does change
rapidly e.g user doing undo/redo, typing, deleting

···

On Mar 6, 12:59 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 3/5/10 12:23 AM,anuraguniyal wrote:

> In awxPythonapplication, which i am porting toMacOSX, I set title of
> appframeevery 500msec in update UI event, and due to that all the
> panels and windows are refreshed.

Does the value of the title actually change that often? If not then you
can probably improve things a lot if you only callSetTitlewhen the
text actually needs to change.

    if newTitle \!= self\.GetTitle\(\):
            self\.SetTitle\(newTitle\)

--
Robin Dunn
Software Craftsmanhttp://wxPython.org