how do I start PyCrust?

7stud bbxx789_05ss at yahoo.com
Tue Jun 5 22:29:51 PDT 2007


Robin Dunn <robin <at> alldunn.com> writes:
> For pywrap to work you need to not automatically create the app and run 
> the MainLoop when the module is imported.  Try it like this:
> 
> import wx
> 
> class MyFrame(wx.Frame):
>      pass
> 
> class MyApp(wx.App):
>      def OnInit(self):
>          self.frame = MyFrame(None, -1, "Test")
>          self.frame.Show()
>          self.SetTopWindow(self.frame)
>          return True
> 
> if __name__ == '__main__':
>      app = MyApp()
>      app.MainLoop()
> 
> This way pywrap can import the module and then create the instance of 
> the application object itself.  It also calls MainLoop.
> 

When I added the "if __name__" guard, the pycrust window was now the
first window displayed.  Then I entered the following into pycrust:

PyCrust 0.9.5 - The Flakiest Python Shell
Python 2.4.4 (#1, Oct 18 2006, 10:34:39) 
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> app.frame.panel = wx.Panel(parent=app.frame)
>>> app.frame.panel.SetBackgroundColour("blue")
True
>>> app.frame.panel.Refresh()
>>> app.frame.panel.ClearBackground()
>>> 

However, neither Refresh() nor ClearBackground() succeeded in 
repainting the panel blue.  I also tried Refresh() on the frame, and that 
didn't work either.  So the "if __name__" guard didn't solve the 
painting problem.

If I manually resize the window, then it repaints itself in blue.  
Thereafter, if I use SetBackgroundColour() in pycrust to change
the panel color from blue to black, the panel changes immediately
without needing to call Refresh().  


mac os 10.4.7








More information about the wxpython-users mailing list