~brian-sidebotham/wxwidgets-cmake/wxpython-2.9.4

« back to all changes in this revision

Viewing changes to wxPython/samples/wxPIA_book/Chapter-01/hello.py

  • Committer: Brian Sidebotham
  • Date: 2013-08-03 14:30:08 UTC
  • Revision ID: brian.sidebotham@gmail.com-20130803143008-c7806tkych1tp6fc
Initial import into Bazaar

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
"""Hello, wxPython! program."""
 
4
 
 
5
import wx
 
6
 
 
7
class Frame(wx.Frame):
 
8
    """Frame class that displays an image."""
 
9
 
 
10
    def __init__(self, image, parent=None, id=-1,
 
11
                 pos=wx.DefaultPosition, title='Hello, wxPython!'):
 
12
        """Create a Frame instance and display image."""
 
13
        temp = image.ConvertToBitmap()
 
14
        size = temp.GetWidth(), temp.GetHeight()
 
15
        wx.Frame.__init__(self, parent, id, title, pos, size)
 
16
        panel = wx.Panel(self)
 
17
        self.bmp = wx.StaticBitmap(parent=panel, bitmap=temp)
 
18
        self.SetClientSize(size)
 
19
 
 
20
class App(wx.App):
 
21
    """Application class."""
 
22
 
 
23
    def OnInit(self):
 
24
        image = wx.Image('wxPython.jpg', wx.BITMAP_TYPE_JPEG)
 
25
        self.frame = Frame(image)
 
26
        self.frame.Show()
 
27
        self.SetTopWindow(self.frame)
 
28
        return True
 
29
 
 
30
def main():
 
31
    app = App()
 
32
    app.MainLoop()
 
33
 
 
34
if __name__ == '__main__':
 
35
    main()
 
36