[wxPython] Getting a DC on a button?

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

[wxPython] Getting a DC on a button?

andy-224
wxGTK 2.1 snap 9
wxPython 2.1b3

I have a class that inherits from wxButton.  I'm capturing OnClick events
via the EVT_BUTTON() callback.  In my OnClick() I want to get a DC for the
button and draw on it.  I call dc = wxWindowDC(self); and python
immediately coredumps.  Creating a wxClientDC() also coredumps python.
How do I go about getting a DC so that I can draw on my button?

            &y

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Getting a DC on a button?

Robin Dunn
>
> I have a class that inherits from wxButton.  I'm capturing OnClick events
> via the EVT_BUTTON() callback.  In my OnClick() I want to get a DC for the
> button and draw on it.  I call dc = wxWindowDC(self); and python
> immediately coredumps.  Creating a wxClientDC() also coredumps python.
> How do I go about getting a DC so that I can draw on my button?
>

The debugging version of wxGTK has an assert that gets triggered:  "DC needs
a widget"

I'll ask about this on wxwin-developers.  Incedentally, it works okay on
wxMSW although the button is repainted loosing my lines as soon as the focus
moves:

        size = self.testBtn.GetSize()
        dc = wxClientDC(self.testBtn)
        dc.DrawLine(0,0, size.width, size.height)
        dc.DrawLine(0,size.height, size.width, 0)

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users