You are generating more bar data every time there is a paint event, and the system will send one of those whenever it thinks that part of the window needs to be repainted. To get a better feel for what is happening comment out all your print statements and add "print len(BarData)" at the beginning of paintBox() and then try things like resizing the window or dragging other windows across it.
···
On 1/11/13 8:47 PM, shannon wrote:
Hi, I am new in python.
I was writing a simple program to generate 20 rectangle bars, but after
I run the application, it seems there are 40 bars generated.
Does anybody know how to solve this problem? I have attached the code.
Thanks, finally I figure out what happen to paint event:)every time I resize the window, the window will be repainted, since I call GenerateBarData() from paintBox(), so every time resize window there will be more 20 barsData generated.
···
On Saturday, January 12, 2013 10:44:55 PM UTC, Robin Dunn wrote:
On 1/11/13 8:47 PM, shannon wrote:
Hi, I am new in python.
I was writing a simple program to generate 20 rectangle bars, but after
I run the application, it seems there are 40 bars generated.
Does anybody know how to solve this problem? I have attached the code.
You are generating more bar data every time there is a paint event, and
the system will send one of those whenever it thinks that part of the
window needs to be repainted. To get a better feel for what is
happening comment out all your print statements and add “print
len(BarData)” at the beginning of paintBox() and then try things like
resizing the window or dragging other windows across it.