On 11/21/12 3:06 AM, Aditya wrote:
On Wednesday, November 21, 2012 12:20:21 AM UTC+5:30, Robin Dunn wrote:
On 11/19/12 3:17 AM, Aditya wrote:
> Hello World,
>
> I am pretty new to Programming. I was going through the example of
> wx.NoteBook as listed over here at wxPy Wiki
> <[http://wiki.wxpython.org/Simple%20wx.Notebook%20Example](http://wiki.wxpython.org/Simple%20wx.Notebook%20Example)
<[http://wiki.wxpython.org/Simple%20wx.Notebook%20Example](http://wiki.wxpython.org/Simple%20wx.Notebook%20Example)>>.
>
> However, when I run this code:
>
> * a small Black Square
> * appears on Top-Left
> * of Page 1 of the App.
>
> This Black Spot goes away once I navigate to other pages and come
back
> to Page 1. I am using this example code to develop my first GUI
> Application and this 'out-of-order-Black-Spot' is irking me for
last 3 days.
>
> Following is the snapshot of the App. I have used the code 'as is'
> listed on that Wiki page.
"The curse of the black spot..." ;-)
Things like that usually mean that there is some other window there,
perhaps one that is not parented properly, or that hasn't been added to
a sizer, etc. For example if one of the page panels was made a
child of
the frame instead of the notebook, then it could manifest like that.
One way to figure it out would be to use the WIT. Once you've added it
to your program you can click on the Find button and then on the black
spot, and it should then be able to find that widget in the tree and
highlight it. If you can't tell from that where it is coming from then
you can assign names to the widgets (in their __init__ or by calling
SetName) and then the names will be displayed in the widget tree in the
WIT. [http://wiki.wxpython.org/Widget_Inspection_Tool](http://wiki.wxpython.org/Widget_Inspection_Tool)
<[http://wiki.wxpython.org/Widget_Inspection_Tool](http://wiki.wxpython.org/Widget_Inspection_Tool)>
Hi Robin,
Thanks for your time. As you suggested, I have added WIT into the code.
However, I still canāt figure out the problem. Everything seems well
parented to me and Sizers seem to be used appropriately. Following is
the snapshot of what WIT shows when I use its Find feature.
<http://i.imgur.com/CK1bQ.png>
I should also let you know, that if I remove Page1 from the code
completely; ie; if I comment out Line 33 and Line 38 of the code listed
on the wiki; then this Black Spot appears on Page 2. And disappears once
I navigate to other pages.
Similarly, if I make any of the pages as Default; ie; if I make Page 3
as default by modifying Line 40 as:
nb.AddPage(page3, āPage 3ā, select=True)
Then, Black Spot appears in Page3 and disappears once I start navigating.
In Short, this Spot appears on the Page that is first displayed by the
app and disappears once we navigate to other Pages.
Ok, the other possibility is that it is simply a refresh glitch where
Windows thinks that that square has already been drawn and so itās
excluded from the initial paint event. That can sometimes happen when
windows are first being created and shuffled around by the initial
layout. Try adding āwx.CallAfter(nb.Refresh)ā to the end of
MainFrame.init. That will cause an extra paint event to be
delivered to the notebook and its visible children right after the
MainLoop starts.
ā
Robin Dunn
Software Craftsman
http://wxPython.org