HT clear some wxPython fram?

Klaus Reinhardt K.Rdt at TU-Berlin.DE
Wed Jul 3 14:36:34 EDT 2002


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):
>    def __init__(self, parent):
>        wxPanel.__init__(self, parent, -1)
>        self.SetBackgroundColour(wxWHITE)
>        self.text = []
>        EVT_PAINT(self, self.OnPaint)
>        
>    def OnPaint(self, event):
>        dc = wxPaintDC(self)
>        self.draw(dc)
>
>    def write(self, text):
>        self.text.append(text)
>        if len(self.text) > 10:
>            del self.text[0]
>        dc = wxClientDC(self)
>        self.draw(dc)
>        
>    def draw(self, dc):
>        dc.Clear()
>        y = 0
>        for t in self.text:
>            dc.DrawText(t, 0, y)
>            y += 15
>    
>class MyFrame(wxFrame):
>    def __init__(self):
>        wxFrame.__init__(self, None, -1, "MyFrame")
>        self.panel = MyPanel(self)
>        self.timer = wxTimer(self, -1)
>        self.timer.Start(100)
>        EVT_TIMER(self, -1, self.OnTimer)
>        
>    def OnTimer(self, evt):
>        self.panel.write("hello")
###
          y=os.popen( 'netstat -a -n','r').read()
          self.panel.write("--------------------------------------------------------------")
          yy=y.splitlines()
          for i in yy: 
              if i[:5]=="  TCP":
	    ry=string.split(i)
	    self.panel.write("%5s %22s %22s %22s" % (ry[0],ry[1],ry[2],ry[3]))

###
>        
>    def OnClose(self,event):
>        self.timer.Stop()
>        self.Destroy()
>        
>class MyApp(wxApp):
>    def OnInit(self):
>        frame = MyFrame()
>        frame.Show(true)
>        return true
>
>
>app = MyApp()
>app.MainLoop()
>        
>
>Please realize that the apparent complexity of something so simple has more to
>do with the nature of GUI programming than with Python.
>
>-- 
>Cliff Wells, Software Engineer
>Logiplex Corporation (www.logiplex.net)
>(503) 978-6726 x308  (800) 735-0555 x308
>
---------------------------------------------------------------------
Hi

		K at Rdt
---------------------------------------------------------------------








More information about the Python-list mailing list