On 10/11/2011 8:35 AM, Ed Leafe wrote:
> On Oct 11, 2011, at 1:24 AM, Adam wrote:
>
>> I'm a beginner to Dabo and programming in general, so I have no idea
>> what's happening here. Basically, I have a window displaying a dBitmap
>> control on the left to be manipulated, and some controls on the right.
>> This screenshot shows the state of the window before pressing the "Run"
>> button, as well as the code that is executed upon hitting the button:
>>
>> http://img198.imageshack.us/img198/2914/beforeix.png
>>
>> At this point the only effect of the button should be to track whether
>> it is 'running' or 'paused,' and to change the caption of the button to
>> reflect this toggling between states.
>>
>> The toggling behavior works, but with an undesired side effect of
>> erasing most of the bitmap:
>>
>> http://img59.imageshack.us/img59/7015/afters.png
>>
>> Attempting to refresh() or redraw() the dBitmap after the button press
>> has no effect. I notice that the bitmap below the button remains
>> visible, so I imagine this is a clue. bringToFront() or sendToBack()
>> don't make any difference.
>>
>> Any idea what's causing this, if there's a simple fix, or will I have to
>> rebuild the bitmap every time this happens?
> First off, can you post your system info? From any Dabo app, go to the
> Help/About menu, and the dialog that appears will have a button that will
> copy the info to the clipboard, where you can paste it in your reply.
>
> Second, how are you creating the dBitmap? I just tried running a Class
> Designer session, and noticed that dBitmap isn't very well supported: the
> Picture property isn't exposed! I think that's because normally a dImage
> control is used for displaying images, whether they are BMPs, JPGs, or
> whatever.
>
>
>
> -- Ed Leafe
>
System info:
Platform: GTK
Python Version: 2.7.1+ on linux2
Dabo Version: Version 0.9.3; Revision ~6865
UI Version: 2.8.11.0 on wxGTK (gtk2)
Maybe I should be using dImage instead of dBitmap. I am creating the
bitmap as a numpy array and then converting to a wxBitmap object:
def arrayToBitmap(self, array):
width = len(array[0])
height = len(array)
image = wx.EmptyImage(width,height)
image.SetData(array.tostring())
image.Rescale(width*10,height*10)
wxBitmap = image.ConvertToBitmap()
return wxBitmap
Then using dBitmap.drawBitmap(wxBitmap) to set the control. Maybe you
can suggest a better way than having to do this every time I want to
update the image. I would like to be able to manipulate the array and
have the bitmap update accordingly, but I don't know if there's a more
direct way to do that.
Also, a little off topic, but the intended purpose of the Run/Pause
button is to start or stop an ongoing process (the blocks in the bitmap
should move around and interact according to some rules, etc.). I am
wondering now how to achieve this, since if I put it in its own loop I
think this will arrest the main loop and render the controls inactive
until the inner loop stops (which should only be when the button is
pushed). Do I need to look into threading, or is there a way to merge
this into the main loop so the controls will still work?
Thanks,
Adam
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]