Re: [wxPython-users] Basics of drawing on a wx.Panel
by Vladimir Ignatov other posts by this author
Dec 11 2004 7:19PM messages near this date
Re: [wxPython-users] Basics of drawing on a wx.Panel
|
Re: [wxPython-users] Problem in opening a file from open dialog
Hi Peter,
You draw on hidden panel. Look where is your frame.Show() located. And you
don't need self.Refresh()
BTW drawing on top of panel is IMHO a bad idea. wxPanel is kind of
"container" for holing other controls and does not supposed for drawing
works. wxPanel has it's own paint routine. Of course you can draw on top of
it once or several times. But every panel.Refresh(), updating or resizing
will erase your painting. If you need custom drawing - use wxWindow
(wx.ScrolledWindow) or such.
Vladimir Ignatov,
KMI Software
----- Original Message -----
From: <pit.grinja@[...].de>
To: <wxpython-users@[...].org>
Sent: Saturday, December 11, 2004 4:25 PM
Subject: [wxPython-users] Basics of drawing on a wx.Panel
> Hello,
> I have recently started to explore the wxPython opportunities to generate
> small graphics. As a very first example, I wrote the following:
> import wx
> #____________________________
>
> class MainWindow(wx.Frame):
> def __init__(self,parent,id,title):
> wx.Frame.__init__(self,parent,-1, title,
> style=wx.DEFAULT_FRAME_STYLE)
> self.panel = wx.Panel(self,-1)
> self.sizer = wx.BoxSizer(wx.HORIZONTAL)
> self.sizer.Add(self.panel,1,wx.ALL)
> self.SetSize(wx.Size(400,400))
> self.SetSizer(self.sizer)
> self.SetAutoLayout(True)
> self.sizer.Fit(self)
> dc = wx.ClientDC(self.panel)
> dc.BeginDrawing()
> dc.SetPen(wx.Pen(wx.RED,20))
> dc.DrawLine(5,200,50,300)
> dc.EndDrawing()
> self.Refresh()
>
>
> app = wx.PySimpleApp()
> frame = MainWindow(None, -1, "Draw Demo")
> frame.Show(True)
> app.MainLoop()
>
> But I cannot see the expected line. What have I missed?
> Many thanks in advance for your help
> Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@[...].org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Thread:
Robin Dunn
Vladimir Ignatov
|