[wxPython-users] Help drawing on a button
Christopher Barker
Chris.Barker at noaa.gov
Thu Jan 31 13:49:09 PST 2008
Assaf Tal wrote:
> Added note: just updated to wxPython 2.8.7.1 <http://2.8.7.1>, didn't
> change anything.
very weird -- I don't see anything wring with that code. Could you
describe the symptoms again?
Also, just for the heck of it, try doing the same thing, but loading the
bitmap from a file, instead of drawing it.
And make sure this is the code you're running:
#!/usr/bin/env python
import wx
class MyFrame(wx.Frame):
def __init__(self, parent = None, id = -1, pos = (10,10), title =
"HelloWorld", size = (800,600)):
wx.Frame.__init__(self, parent,id,title, pos, size)
self.pnl = wx.Panel(self)
self.pnl.SetBackgroundColour("blue")
self.btn1 = wx.BitmapButton(self.pnl, pos = (50,50),
size=(300,400))
self.buffer = wx.EmptyBitmap(300,400)
dc = wx.MemoryDC()
dc.SelectObject(self.buffer)
dc.SetPen(wx.Pen("green",1))
dc.Clear()
dc.DrawLine(1,1,200,200)
self.btn1.SetBitmapLabel(self.buffer)
class App(wx.App):
def OnInit(self):
self.frame = MyFrame()
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main():
app = App(False)
app.MainLoop()
if __name__ == '__main__':
main()
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the wxpython-users
mailing list