Below, I have a panel inside of a frame. Why am I not able to draw to the panel? I just get a plain white screen. If I get rid of the panel and draw directly to the frame...it works. any help would be appreciated.
import wx
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,'window',(200,200),(600,600))
self.Center()
self.panel=wx.Panel(self)
self.panel.SetBackgroundColour('white')
self.firstpoint=wx.Point(300,300)
self.secondpoint=wx.Point(400,400)
self.Bind(wx.EVT_PAINT,self.onPaint)
def onPaint(self,event):
dc=wx.PaintDC(self.panel)
dc.DrawLine(self.firstpoint.x,self.firstpoint.y,
self.secondpoint.x,self.secondpoint.y)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…