Help with wx.NoteBook Example listed in wxPy Wiki

"The curse of the black spot..." :wink:

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

Ā·Ā·Ā·

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&gt;\.

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.

--
Robin Dunn
Software Craftsman

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.

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.

Regards.

Ā·Ā·Ā·

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>.

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ā€¦ā€ :wink:

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

ā€“
Robin Dunn

Software Craftsman

http://wxPython.org

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.

Ā·Ā·Ā·

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&gt;&gt;\.
     >
     > 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..." :wink:

    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&gt;

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&gt;

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.

--
Robin Dunn
Software Craftsman

Aditya wrote:

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.

However, your screen shot does show us something that you didn't mention
before: your desktop background color is black. Thus, rather than being
a black square drawn on top of everything else, what's likely happening
here is that the background color is showing through. You could test
that theory by changing the background color temporarily.

My best guess is that there is a cursor bug in your display driver.
It's restoring the wrong location after your window is drawn. By any
chance, is this running in a VM, or a Remote Desktop session, or a
TeamViewer session, or a GotoMyPC session, or one of the VNC clones? If
so, try this on real hardware and I'll bet you $100 it goes away.

Ā·Ā·Ā·

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

I saw it on one of my Windows PC too, it's not the background showing through and has no discernible relationship with the cursor. It initially starts out at the frame's client area (0,0) position and then is shifted to the notebook's client area (0,0) after the initial layout.

My theory is that before everything is positioned and sized the panel, the notebook and all the page windows are stacked on top of each other at the frame's upper left corner and sized at about (20,20) with the first page on top and all the page windows are shown (but not visible because they are under the first page). When the notebook gets sized to fill the panel it hides the other page windows and resizes/repositions the first page window to be in the right place, but since it was on top before Windows thinks that the (20,20) in the upper left corner has already been painted and clips it out of the refresh region, but it either never was painted or something (perhaps the themed drawing of the notebook tabs) drew over that area before the page window was moved to the correct position.

We used to see something similar in the demo when adding/removing notebook pages when the current demo sample was changed. In that case some Freeze/Thaw calls took care of it

Ā·Ā·Ā·

On 11/21/12 9:26 AM, Tim Roberts wrote:

Aditya wrote:

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.

However, your screen shot does show us something that you didn't mention
before: your desktop background color is black. Thus, rather than being
a black square drawn on top of everything else, what's likely happening
here is that the background color is showing through. You could test
that theory by changing the background color temporarily.

--
Robin Dunn
Software Craftsman

First of all, extremely sorry for a late reply. My Internet Connection has been giving lots of problems for the last 2 days.

Now coming to the curse of the Black Spot. Itā€™s goneā€¦ The trick of refreshing the NoteBook by using wx.CallAfter(nb.Refresh) worked. Now, my 1st GUI App, which I am developing using that base code, looks pretty. Thanks for your help.

I would request you to update the code on that wiki providing the reasons thereof. Thank you once again.

Regards.

Ā·Ā·Ā·

On Wednesday, November 21, 2012 10:55:57 PM UTC+5:30, Robin Dunn wrote:

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

No my Desktop background wasnā€™t Black. I had edited the image so that the focus remains on the problem rather than the background. Neither am I running this in a VM or other VNC clones. Using the main Window 7 Desktop PC for this.

Do you still want to transfer $100 to my account. Let me know if you wish (or, has the offer expired in these last 2 days) :slight_smile:

Ā·Ā·Ā·

On Wednesday, November 21, 2012 10:56:37 PM UTC+5:30, Tim Roberts wrote:

Aditya wrote:

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.

However, your screen shot does show us something that you didnā€™t mention

before: your desktop background color is black. Thus, rather than being

a black square drawn on top of everything else, whatā€™s likely happening

here is that the background color is showing through. You could test

that theory by changing the background color temporarily.

My best guess is that there is a cursor bug in your display driver.
Itā€™s restoring the wrong location after your window is drawn. By any

chance, is this running in a VM, or a Remote Desktop session, or a

TeamViewer session, or a GotoMyPC session, or one of the VNC clones? If

so, try this on real hardware and Iā€™ll bet you $100 it goes away.

ā€“
Tim Roberts, ti...@probo.com

Providenza & Boekelheide, Inc.

Iā€™m sorry, but Iā€™m afraid you didnā€™t satisfy the pre-conditions ā€“
you were already running this on real hardware.
I do admit that my analysis was wrongā€¦

Ā·Ā·Ā·

Aditya wrote:

  On Wednesday, November 21, 2012 10:56:37 PM UTC+5:30, Tim Roberts

wrote:

    My best guess is that there is a cursor bug in your display

driver.

    It's restoring the wrong location after your window is drawn.

By any

    chance, is this running in a VM, or a Remote Desktop session, or

a

    TeamViewer session, or a GotoMyPC session, or one of the VNC

clones? If

    so, try this on real hardware and I'll bet you $100 it goes

away.

    No my Desktop background wasn't Black. I had edited the image

so that the focus remains on the problem rather than the
background. Neither am I running this in a VM or other VNC
clones. Using the main Window 7 Desktop PC for this.

    Do you still want to transfer $100 to my account. Let me know

if you wish (or, has the offer expired in these last 2 days) :slight_smile:

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com

I was getting weird black spots and rectangles on start-up of a Notebook-based GUI, calling wx.CallAfter(self.nb.Refresh) fixed the problem, albeit with some discernible flicker. I also tried using the WITā€™s Find button then clicked on the black areas, but the WIT just showed the Panel Iā€™d added to the Notebook (properly parented).

Using wx-3.0.1-msw-classic on WinXP

Ā·Ā·Ā·

On Wednesday, November 21, 2012 9:25:57 AM UTC-8, Robin Dunn wrote:

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.