Oddness with wxNotebook

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Oddness with wxNotebook

floatingshed

I have this very basic code:

import wx


class MyMultiDlg(wx.Dialog):
   
def __init__(self, parent):
        wx
.Dialog.__init__(self, parent, -1, '', style=wx.DEFAULT_DIALOG_STYLE, size=(650,350))

       
       
        p
= wx.Panel(self)
       
self.nb = wx.Notebook(p)

       
self.nb.AddPage(test(self.nb), "one")
       
self.nb.AddPage(test2(self.nb), "two")
       

        sizer
= wx.BoxSizer()
        sizer
.Add(self.nb, 1, wx.EXPAND)
        p
.SetSizer(sizer)

       
class test(wx.Panel):
   
def __init__(self, parent):
        wx
.Panel.__init__(self, parent)
       
       
class test2(wx.Panel):
   
def __init__(self, parent):
        wx
.Panel.__init__(self, parent)

       
#----------------------------------------------------------------------
class MyApp(wx.App):
   
def OnInit(self):
        dlg
= MyMultiDlg(None)
        dlg
.ShowModal()
        dlg
.Destroy()
       
return True
if __name__ == "__main__":
    myapp
= MyApp(redirect=False)
    myapp
.MainLoop()

It generates a two page notebook but page one has a small black square top left, this is even visible in the official demo. Any ideas what is going on?
The square vanishes when changing pages and doesn't return until next run.
(Python3.6, wxpython 4.0.0b2, windows10)
Thanks.



--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Oddness with wxNotebook

Tim Roberts
[hidden email] wrote:
>
> I have this very basic code:
> ...
> It generates a two page notebook but page one has a small black square
> top left, this is even visible in the official demo. Any ideas what is
> going on?
> The square vanishes when changing pages and doesn't return until next run.
> (Python3.6, wxpython 4.0.0b2, windows10)

Yes, this is some kind of a bug in the notebook code that has been
around for a long time.  It's not a real window, and it's not the
background showing through.  Here's a thread from 2012 that talks about
the same issue, and my harebrained theory on what causes it:
    https://groups.google.com/forum/#!topic/wxpython-users/bdh7xxYMxho

The workaround is to force a refresh by adding this to your dialog's
__init__:
    wx.CallAfter( self.nb.Refresh )

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Oddness with wxNotebook

floatingshed
Thanks Tim, the workaround tidied it up nicely.

On Monday, December 18, 2017 at 7:24:34 PM UTC, Tim Roberts wrote:
<a href="javascript:" target="_blank" gdf-obfuscated-mailto="_NgRY3R-AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">floati...@... wrote:
>
> I have this very basic code:
> ...
> It generates a two page notebook but page one has a small black square
> top left, this is even visible in the official demo. Any ideas what is
> going on?
> The square vanishes when changing pages and doesn't return until next run.
> (Python3.6, wxpython 4.0.0b2, windows10)

Yes, this is some kind of a bug in the notebook code that has been
around for a long time.  It's not a real window, and it's not the
background showing through.  Here's a thread from 2012 that talks about
the same issue, and my harebrained theory on what causes it:
    <a href="https://groups.google.com/forum/#!topic/wxpython-users/bdh7xxYMxho" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/forum/#!topic/wxpython-users/bdh7xxYMxho&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/forum/#!topic/wxpython-users/bdh7xxYMxho&#39;;return true;">https://groups.google.com/forum/#!topic/wxpython-users/bdh7xxYMxho

The workaround is to force a refresh by adding this to your dialog's
__init__:
    wx.CallAfter( self.nb.Refresh )

--
Tim Roberts, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="_NgRY3R-AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ti...@...
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.