HT clear some wxPython fram?
Cliff Wells
logiplexsoftware at earthlink.net
Wed Jul 3 14:47:14 EDT 2002
On Wed, 03 Jul 2002 20:36:34 +0200
Klaus Reinhardt wrote:
> Am 03.07.02 20:06:07, schrieb Cliff Wells <logiplexsoftware at earthlink.net>:
> >> >> HOW I CAN CLEAR SOME FRAME?
> Hi
>
> 1.) Thank you very much, it's now working with
> the changes ### I made (s.b.)
> 2.) A further question: How can I change the font
> to equal spacing?
>
> tia K at Rdt
>
> >What you will want to do instead is something more like this:
> >
> >from wxPython.wx import *
> >
> >class MyPanel(wxPanel):
[snip]
> > def draw(self, dc):
> > dc.Clear()
font = wxFont(12, wxMODERN, wxNORMAL, wxNORMAL)
dc.SetFont(font)
[snip]
Notice that the font size is 12 (although this is rather arbitrary). If you
want a different font size, you'll also want to change the line spacing in
MyPanel.draw(). This being the case, I would recommend using an attribute to
MyPanel to keep track of the font size and adjusting the line spacing
accordingly:
class MyPanel(wxPanel):
def __init__(self, parent, fontsize = 12):
wxPanel.__init__(self, parent, -1)
self.SetBackgroundColour(wxWHITE)
self.text = []
self.fontsize = fontsize
EVT_PAINT(self, self.OnPaint)
def draw(self, dc):
dc.Clear()
font = wxFont(self.fontsize, wxMODERN, wxNORMAL, wxNORMAL)
dc.SetFont(font)
y = 0
for t in self.text:
dc.DrawText(t, 0, y)
y += self.fontsize + 2
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308
More information about the Python-list
mailing list