Commits

Mike Driscoll  committed 3f5ff00

added a bunch of wxPython examples

  • Participants
  • Parent commits c006e24

Comments (0)

Files changed (466)

File wxpython_by_example/AGW Series/email_popup_v3.py

+import wx
+
+import ToasterBox as TB
+
+class EmailPopup(wx.Frame):
+    
+    def __init__(self, parent, id=wx.ID_ANY, title="ToasterBox Demo",
+                 pos = wx.DefaultPosition, size=(400,550)):
+        wx.Frame.__init__(self, parent, id, title, pos, size)
+        panel = wx.Panel(self, wx.ID_ANY)
+##        btn = wx.Button(panel, wx.ID_ANY, 'Test')
+##        self.Bind(wx.EVT_BUTTON, self.onTest, btn)
+        self.onTest('')
+
+        self.Show()
+
+    def onTest(self, event):
+        
+        tbstyle = TB.TB_SIMPLE
+        windowstyle = TB.TB_CAPTION
+        closingstyle = TB.TB_ONTIME
+        
+        tb = TB.ToasterBox(self, tbstyle, windowstyle, closingstyle)
+        tb.SetTitle('New Mail')
+
+        message = '''
+        Blah blah blah
+        ipsum cumbers'
+        '''
+        tb.SetPopupText(message)
+        
+        tb.SetPopupSize((290, 90))  # x,y
+
+        # get display size
+        width, height = wx.GetDisplaySize()
+        posx = width-300
+        posy = height-125
+        tb.SetPopupPosition((posx, posy))
+        # 1 sec = 1000
+        tb.SetPopupPauseTime(10000) 
+        tb.SetPopupScrollSpeed(20)
+        tb.Play()
+
+def main():
+
+    app = wx.PySimpleApp()
+    frame = EmailPopup(None)
+    frame.Show()
+    app.MainLoop()
+
+
+if __name__ == "__main__":
+    main()

File wxpython_by_example/AGW Series/toaster.py

+# toaster.py
+
+import wx
+from wx.lib.agw import toasterbox as TB
+
+########################################################################
+class MainPanel(wx.Panel):
+    """"""
+
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        wx.Panel.__init__(self, parent, wx.ID_ANY)
+        btn = wx.Button(self, label="Open ToasterBox")
+        btn.Bind(wx.EVT_BUTTON, self.onButton)
+        
+    #----------------------------------------------------------------------
+    def onButton(self, event):
+        """
+        """
+        print "in onButton"
+        
+        tbstyle = TB.TB_SIMPLE
+        windowstyle = TB.DEFAULT_TB_STYLE
+        closingstyle = TB.TB_ONTIME
+    
+        tb = TB.ToasterBox(self, tbstyle, windowstyle, closingstyle)
+        
+        tb.SetPopupSize((100, 200))
+        tb.SetPopupPosition((300, 300))
+        
+        tb.SetPopupPauseTime(100)
+        tb.SetPopupScrollSpeed(8)
+        tb.SetPopupText("This is a test!")
+        tb.Play()
+        
+########################################################################
+class DemoFrame(wx.Frame):
+    """
+    Frame that holds all other widgets
+    """
+
+    #----------------------------------------------------------------------
+    def __init__(self):
+        """Constructor"""        
+        wx.Frame.__init__(self, None, wx.ID_ANY, 
+                          "ToasterBox Tutorial",
+                          size=(600,400)
+                          )
+        panel = MainPanel(self)        
+        self.Show()
+        
+#----------------------------------------------------------------------
+if __name__ == "__main__":
+    app = wx.PySimpleApp()
+    frame = DemoFrame()
+    app.MainLoop()

File wxpython_by_example/BoxSizers/expand_one_axis.py

+import wx
+
+# Expand on one axis
+# Show spacers example
+# show nested sizers
+
+'''
+(6:17:04 PM) RobinD: in box sizers wx.EXPAND works in the orientation 
+opposite of the sizers orientation (horizontal/vertical) while the 
+proportion controls the size in the same orientation as the sizer.
+
+(6:20:32 PM) RobinD: Perhaps a better way to say it:  In a box sizer 
+the proportion parameter controls the size of the item in the same 
+direction as the sizer's orientation, therefore the wx.EXPAND flag 
+works in the alternative direction.
+'''
+
+########################################################################
+class DemoFrame(wx.Frame):
+    """
+    Frame that holds all other widgets
+    """
+
+    #----------------------------------------------------------------------
+    def __init__(self):
+        """Constructor"""        
+        wx.Frame.__init__(self, None, wx.ID_ANY, 
+                          "BoxSizer Tutorial",
+                          size=(600,400)
+                          )
+        panel = wx.Panel(self)
+        
+        sizer = wx.BoxSizer(wx.VERTICAL)
+        txt = wx.TextCtrl(panel, value="")
+        sizer.Add(item=txt, proportion=0, flag=wx.EXPAND, border=5)
+        panel.SetSizer(sizer)
+        
+# Run the program
+if __name__ == "__main__":
+    app = wx.App(False)
+    frame = DemoFrame()
+    frame.Show()
+    app.MainLoop()
+

File wxpython_by_example/Dark Mode/darkMode.py

+# ------------------------------------------------------
+# darkMode.py
+#
+# Author: Mike Driscoll - mike@pythonlibrary.org 
+#
+# Usage: Import module and call the onDark method which
+#        will change all the widgets to a dark color
+#        and return a bool you can use to know whether
+#        whether dark mode is enabled
+#
+#        Requires you to pass in a parent widget and 
+#        a colour object
+# ------------------------------------------------------
+
+import wx
+try:
+    from ObjectListView import ObjectListView
+except:
+    ObjectListView = False
+
+#----------------------------------------------------------------------
+def getWidgets(parent):
+    """
+    Return a list of all the child widgets
+    """
+    items = [parent]
+    for item in parent.GetChildren():
+        items.append(item)
+        if hasattr(item, "GetChildren"):
+            for child in item.GetChildren():
+                items.append(child)
+    return items
+
+#----------------------------------------------------------------------
+def darkRowFormatter(listctrl, dark=False):
+    """
+    Toggles the rows in a ListCtrl or ObjectListView widget. 
+    Based loosely on the following documentation:
+    http://objectlistview.sourceforge.net/python/recipes.html#recipe-formatter
+    and http://objectlistview.sourceforge.net/python/cellEditing.html
+    """
+    
+    listItems = [listctrl.GetItem(i) for i in range(listctrl.GetItemCount())]
+    for index, item in enumerate(listItems):
+        if dark:
+            if index % 2:
+                item.SetBackgroundColour("Dark Grey")
+            else:
+                item.SetBackgroundColour("Light Grey")
+        else:
+            if index % 2:
+                item.SetBackgroundColour("Light Blue")
+            else:
+                item.SetBackgroundColour("Yellow")
+        listctrl.SetItem(item)
+
+#----------------------------------------------------------------------
+def darkMode(self, normalPanelColor):
+    """
+    Toggles dark mode
+    """
+    widgets = getWidgets(self)
+    panel = widgets[0]
+    if normalPanelColor == panel.GetBackgroundColour():
+        dark_mode = True
+    else:
+        dark_mode = False
+    for widget in widgets:
+        if dark_mode:
+            if isinstance(widget, ObjectListView) or isinstance(widget, wx.ListCtrl):
+                darkRowFormatter(widget, dark=True)
+            widget.SetBackgroundColour("Dark Grey")
+            widget.SetForegroundColour("White")
+        else:
+            if isinstance(widget, ObjectListView) or isinstance(widget, wx.ListCtrl):
+                darkRowFormatter(widget)
+                widget.SetBackgroundColour("White")
+                widget.SetForegroundColour("Black")
+                continue
+            widget.SetBackgroundColour(wx.NullColor)
+            widget.SetForegroundColour("Black")
+    self.Refresh()
+    return dark_mode

File wxpython_by_example/Dark Mode/listctrl_dark.py

+import wx
+import darkMode
+
+########################################################################
+class MyPanel(wx.Panel):
+    """"""
+ 
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        wx.Panel.__init__(self, parent)
+        self.defaultColor = self.GetBackgroundColour()
+ 
+        rows = [("Ford", "Taurus", "1996", "Blue"),
+                ("Nissan", "370Z", "2010", "Green"),
+                ("Porche", "911", "2009", "Red")
+                ]
+        self.list_ctrl = wx.ListCtrl(self, style=wx.LC_REPORT)
+ 
+        self.list_ctrl.InsertColumn(0, "Make")
+        self.list_ctrl.InsertColumn(1, "Model")
+        self.list_ctrl.InsertColumn(2, "Year")
+        self.list_ctrl.InsertColumn(3, "Color")
+ 
+        index = 0
+        for row in rows:
+            self.list_ctrl.InsertStringItem(index, row[0])
+            self.list_ctrl.SetStringItem(index, 1, row[1])
+            self.list_ctrl.SetStringItem(index, 2, row[2])
+            self.list_ctrl.SetStringItem(index, 3, row[3])
+            if index % 2:
+                self.list_ctrl.SetItemBackgroundColour(index, "white")
+            else:
+                self.list_ctrl.SetItemBackgroundColour(index, "yellow")
+            index += 1
+            
+        btn = wx.ToggleButton(self, label="Toggle Dark")
+        btn.Bind(wx.EVT_TOGGLEBUTTON, self.onToggleDark)
+        normalBtn = wx.Button(self, label="Test")
+ 
+        sizer = wx.BoxSizer(wx.VERTICAL)
+        sizer.Add(self.list_ctrl, 0, wx.ALL|wx.EXPAND, 5)
+        sizer.Add(btn, 0, wx.ALL, 5)
+        sizer.Add(normalBtn, 0, wx.ALL, 5)
+        self.SetSizer(sizer)
+        
+    #----------------------------------------------------------------------
+    def onToggleDark(self, event):
+        """"""
+        darkMode.darkMode(self, self.defaultColor)
+ 
+########################################################################
+class MyFrame(wx.Frame):
+    """"""
+ 
+    #----------------------------------------------------------------------
+    def __init__(self):
+        """Constructor"""
+        wx.Frame.__init__(self, None, wx.ID_ANY,
+                          "MvP ListCtrl Dark Mode Demo")
+        panel = MyPanel(self)
+        self.Show()
+ 
+#----------------------------------------------------------------------
+if __name__ == "__main__":
+    app = wx.App(False)
+    frame = MyFrame()
+    app.MainLoop()

File wxpython_by_example/Dark Mode/listctrl_dark2.py

+import wx
+
+########################################################################
+class MyPanel(wx.Panel):
+    """"""
+ 
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        wx.Panel.__init__(self, parent)
+ 
+        rows = [("Ford", "Taurus", "1996", "Blue"),
+                ("Nissan", "370Z", "2010", "Green"),
+                ("Porche", "911", "2009", "Red")
+                ]
+        self.list_ctrl = wx.ListCtrl(self, style=wx.LC_REPORT)
+ 
+        self.list_ctrl.InsertColumn(0, "Make")
+        self.list_ctrl.InsertColumn(1, "Model")
+        self.list_ctrl.InsertColumn(2, "Year")
+        self.list_ctrl.InsertColumn(3, "Color")
+ 
+        index = 0
+        for row in rows:
+            self.list_ctrl.InsertStringItem(index, row[0])
+            self.list_ctrl.SetStringItem(index, 1, row[1])
+            self.list_ctrl.SetStringItem(index, 2, row[2])
+            self.list_ctrl.SetStringItem(index, 3, row[3])
+            if index % 2:
+                self.list_ctrl.SetItemBackgroundColour(index, "white")
+            else:
+                self.list_ctrl.SetItemBackgroundColour(index, "yellow")
+            index += 1
+            
+        btn = wx.ToggleButton(self, label="Toggle Dark")
+        btn.Bind(wx.EVT_TOGGLEBUTTON, self.onToggleDark)
+ 
+        sizer = wx.BoxSizer(wx.VERTICAL)
+        sizer.Add(self.list_ctrl, 0, wx.ALL|wx.EXPAND, 5)
+        sizer.Add(btn, 0, wx.ALL, 5)
+        self.SetSizer(sizer)
+        
+    #----------------------------------------------------------------------
+    def onToggleDark(self, event):
+        """"""
+        normalColor = wx.Colour(255, 255, 255, 255)
+        if normalColor == self.list_ctrl.GetBackgroundColour():
+            dark_mode = True
+            self.list_ctrl.SetBackgroundColour("Blue")
+        else:
+            dark_mode = False
+            self.list_ctrl.SetBackgroundColour("White")
+        listItems = [self.list_ctrl.GetItem(i) for i in range(self.list_ctrl.GetItemCount())]
+        for index, item in enumerate(listItems):
+            if dark_mode:
+                if index % 2:
+                    item.SetBackgroundColour("Dark Grey")
+                else:
+                    item.SetBackgroundColour("Light Grey")
+            else:
+                if index % 2:
+                    item.SetBackgroundColour("Light Blue")
+                else:
+                    item.SetBackgroundColour("Yellow")
+                    
+            self.list_ctrl.SetItem(item)
+        
+        self.Refresh()
+ 
+########################################################################
+class MyFrame(wx.Frame):
+    """"""
+ 
+    #----------------------------------------------------------------------
+    def __init__(self):
+        """Constructor"""
+        wx.Frame.__init__(self, None, wx.ID_ANY,
+                          "List Control w/ Alternate Colors")
+        panel = MyPanel(self)
+        self.Show()
+ 
+#----------------------------------------------------------------------
+if __name__ == "__main__":
+    app = wx.App(False)
+    frame = MyFrame()
+    app.MainLoop()

File wxpython_by_example/Dark Mode/olv-ex_dark.py

+from ObjectListView import ObjectListView, ColumnDefn
+import darkMode
+import wx
+
+########################################################################
+class Book(object):
+    """
+    Book model for ObjectListView
+    """
+    #----------------------------------------------------------------------
+    def __init__(self, title, author, isbn, mfg):
+        self.isbn = isbn
+        self.author = author
+        self.mfg = mfg       
+        self.title = title
+    
+########################################################################
+class MainPanel(wx.Panel):
+    
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
+        self.defaultColor = self.GetBackgroundColour()
+        self.products = [Book("wxPython in Action", "Robin Dunn",
+                              "1932394621", "Manning"),
+                         Book("Hello World", "Warren and Carter Sande",
+                              "1933988495", "Manning")
+                         ]
+
+        self.dataOlv = ObjectListView(self, wx.ID_ANY, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
+        self.setBooks()
+
+        # Allow the cell values to be edited when double-clicked
+        self.dataOlv.cellEditMode = ObjectListView.CELLEDIT_SINGLECLICK
+        
+        btn = wx.ToggleButton(self, label="Toggle Dark")
+        btn.Bind(wx.EVT_TOGGLEBUTTON, self.onToggleDark)
+
+        # Create some sizers
+        mainSizer = wx.BoxSizer(wx.VERTICAL)
+
+        mainSizer.Add(self.dataOlv, 1, wx.ALL|wx.EXPAND, 5)
+        mainSizer.Add(btn, 0, wx.ALL, 5)
+        self.SetSizer(mainSizer)
+
+    #----------------------------------------------------------------------
+    def setBooks(self):
+        self.dataOlv.SetColumns([
+            ColumnDefn("Title", "left", 120, "title"),
+            ColumnDefn("Author", "left", 100, "author"),
+            ColumnDefn("ISBN", "right", 100, "isbn"),            
+            ColumnDefn("Mfg", "left", 80, "mfg")
+        ])
+        self.dataOlv.SetObjects(self.products)
+            
+    #----------------------------------------------------------------------
+    def onToggleDark(self, event):
+        """"""
+        darkMode.darkMode(self, self.defaultColor)
+        
+########################################################################
+class MainFrame(wx.Frame):
+    
+    #----------------------------------------------------------------------
+    def __init__(self):
+        wx.Frame.__init__(self, parent=None, id=wx.ID_ANY, 
+                          title="MvP OLV Dark Mode Demo")
+        panel = MainPanel(self)
+
+class GenApp(wx.App):
+    
+    #----------------------------------------------------------------------
+    def __init__(self, redirect=False, filename=None):
+        wx.App.__init__(self, redirect, filename)
+
+    #----------------------------------------------------------------------
+    def OnInit(self):
+        # create frame here
+        frame = MainFrame()
+        frame.Show()
+        return True
+    
+#----------------------------------------------------------------------
+def main():
+    app = GenApp()
+    app.MainLoop()
+    
+#----------------------------------------------------------------------
+if __name__ == "__main__":
+    main()

File wxpython_by_example/Drawing/animate.py

+# http://stackoverflow.com/questions/7684934/wxpython-using-wxtimer-my-box-doesnt-move/7688020#7688020
+import wx
+
+WHITE_COLOR = (255,255,255)
+
+class AnimationPanel(wx.Panel):
+
+    def __init__(self, parent):
+        wx.Panel.__init__(self, parent)
+        self.boxParameters = [10,10,60,60]
+        self.SetBackgroundColour(wx.Colour(*WHITE_COLOR))
+        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        self.timer = wx.Timer(self)
+        
+        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
+        self.timer.Start(100)
+
+    def OnPaint(self, event):
+        dc = wx.PaintDC(self)
+        self.paintBox(dc)
+
+    def OnTimer(self, event):
+        self.boxParameters[0] += 3
+        print self.boxParameters
+        self.Refresh()
+        
+    def paintBox(self, dc):
+        dc.SetBrush(wx.Brush("blue"))
+        dc.DrawRectangle(*self.boxParameters)
+
+class MainFrame(wx.Frame):
+
+    def __init__(self):
+        wx.Frame.__init__(self, None, title="Box with far and back movement", size=(300,200))
+        AnimationPanel(self)
+
+if __name__ == "__main__":
+    app = wx.PySimpleApp()
+    frame = MainFrame()
+    frame.Show(True)
+    app.MainLoop()

File wxpython_by_example/Drawing/draw_circle.py

+import wx
+
+########################################################################
+class MyPanel(wx.Panel):
+    """"""
+
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        wx.Panel.__init__(self, parent)
+        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        
+    #----------------------------------------------------------------------
+    def OnPaint(self, event):
+        """"""
+        pdc = wx.PaintDC(self)
+        try:
+            dc = wx.GCDC(pdc)
+        except:
+            dc = pdc
+            
+        brushclr = wx.Colour(red=178, green=34, blue=34, alpha=128)
+        dc.SetBrush(wx.Brush(brushclr))
+        dc.DrawCircle(x=50, y=50, radius=25)
+        
+#----------------------------------------------------------------------
+if __name__ == "__main__":
+    app = wx.App(False)
+    frame = wx.Frame(None, title="Test")
+    panel = MyPanel(frame)
+    frame.Show()
+    app.MainLoop()

File wxpython_by_example/Drawing/draw_circle_key.py

+import wx
+
+########################################################################
+class MyPanel(wx.Panel):
+    """"""
+
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        wx.Panel.__init__(self, parent)
+        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        self.Bind(wx.EVT_KEY_DOWN, self.onKey)
+        
+    #----------------------------------------------------------------------
+    def onKey(self, event):
+        """"""
+        print "you pressed something!"
+        
+    #----------------------------------------------------------------------
+    def OnPaint(self, event):
+        """"""
+        pdc = wx.PaintDC(self)
+        try:
+            dc = wx.GCDC(pdc)
+        except:
+            dc = pdc
+            
+        brushclr = wx.Colour(red=178, green=34, blue=34, alpha=128)
+        dc.SetBrush(wx.Brush(brushclr))
+        dc.DrawCircle(x=50, y=50, radius=25)
+        
+#----------------------------------------------------------------------
+if __name__ == "__main__":
+    app = wx.App(False)
+    frame = wx.Frame(None, title="Test")
+    panel = MyPanel(frame)
+    frame.Show()
+    app.MainLoop()

File wxpython_by_example/Drawing/draw_rect.py

+import wx
+
+########################################################################
+class MyPanel(wx.Panel):
+    """"""
+
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        wx.Panel.__init__(self, parent)
+        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        
+    #----------------------------------------------------------------------
+    def OnPaint(self, event):
+        """"""
+        pdc = wx.PaintDC(self)
+        try:
+            dc = wx.GCDC(pdc)
+        except:
+            dc = pdc
+            
+        w, h = self.GetSizeTuple()
+        w = w - 10
+        h = h - 10
+                
+        dc.DrawRectangle(x=5, y=5, width=w, height=h)
+        
+        
+        
+#----------------------------------------------------------------------
+if __name__ == "__main__":
+    app = wx.App(False)
+    frame = wx.Frame(None, title="Test", style=wx.DEFAULT_FRAME_STYLE|wx.FULL_REPAINT_ON_RESIZE)
+    panel = MyPanel(frame)
+    frame.Show()
+    app.MainLoop()

File wxpython_by_example/Drawing/draw_rect2.py

+# helped by r4z
+import wx
+
+########################################################################
+class MyPanel(wx.Panel):
+    """"""
+
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        wx.Panel.__init__(self, parent)
+        self.Bind(wx.EVT_PAINT, self.OnPaint)
+
+    #----------------------------------------------------------------------
+    def OnPaint(self, event):
+        """"""
+        pdc = wx.PaintDC(self)
+        try:
+            dc = wx.GCDC(pdc)
+        except:
+            dc = pdc
+
+        w, h = self.GetSizeTuple()
+        w = w - 10
+        h = h - 10
+
+        dc.Clear()
+        dc.DrawRectangle(x=5, y=5, width=w, height=h)
+
+
+#----------------------------------------------------------------------
+def OnSize(event):
+    event.EventObject.Refresh()
+    event.Skip()
+
+
+if __name__ == "__main__":
+    app = wx.App(False)
+    frame = wx.Frame(None, title="Test")
+    panel = MyPanel(frame)
+    frame.Bind(wx.EVT_SIZE, OnSize)
+    frame.Show()
+    app.MainLoop()

File wxpython_by_example/Drawing/drawing_pens.py

+import wx
+
+########################################################################
+class MyPanel(wx.Panel):
+    """"""
+
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        wx.Panel.__init__(self, parent)
+        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        
+    #----------------------------------------------------------------------
+    def OnPaint(self, event):
+        """"""
+        pdc = wx.PaintDC(self)
+        try:
+            dc = wx.GCDC(pdc)
+        except:
+            dc = pdc
+            
+        penclr = wx.Colour(red=35, green=142, blue=35, alpha=128)
+        # style list http://docs.wxwidgets.org/stable/wx_wxpen.html
+        pen_styles = [("wx.SOLID", wx.SOLID), ("wx.DOT", wx.DOT),
+                      ("wx.LONG_DASH", wx.LONG_DASH), 
+                      ("wx.SHORT_DASH", wx.SHORT_DASH), 
+                      ("wx.DOT_DASH", wx.DOT_DASH),
+                      ("wx.BDIAGONAL_HATCH", wx.BDIAGONAL_HATCH),
+                      ("wx.CROSSDIAG_HATCH", wx.CROSSDIAG_HATCH),
+                      ("wx.FDIAGONAL_HATCH", wx.FDIAGONAL_HATCH),
+                      ("wx.CROSS_HATCH", wx.CROSS_HATCH),
+                      ("wx.HORIZONTAL_HATCH", wx.HORIZONTAL_HATCH),
+                      ("wx.VERTICAL_HATCH", wx.VERTICAL_HATCH)]
+        pos = 5
+        for style_name, style in pen_styles:
+            pen = wx.Pen(penclr, 8, style=style)
+            dc.SetPen(pen)
+            dc.DrawLine(5, pos, 100, pos)
+            dc.DrawText(style_name, 125, pos-5)
+            pos += 25
+##        dc.DrawCircle(x=150, y=150, radius=125)
+##        dc.DrawText("Test", x=175, y=150) # dc.SetFont, dc.SetTextBackground, dc.SetTextForeground
+        
+#----------------------------------------------------------------------
+if __name__ == "__main__":
+    app = wx.App(False)
+    frame = wx.Frame(None, title="Test")
+    panel = MyPanel(frame)
+    frame.Show()
+    app.MainLoop()

File wxpython_by_example/Html Help/doc-0003.htm

+
+This is only a test
+
+Here is a link to another <A HREF="doc-0004.htm">page</A>

File wxpython_by_example/Html Help/doc-0004.htm

+
+This is page #2!

File wxpython_by_example/Html Help/htmlExample.py

+# http://www.helpblocks.com/
+
+import wx
+from wx.html import HtmlWindow
+
+########################################################################
+class MyFrame(wx.Frame):
+    """"""
+
+    #----------------------------------------------------------------------
+    def __init__(self):
+        """Constructor"""
+        wx.Frame.__init__(self, None, title="Html Help Test")
+        panel = wx.Panel(self)
+        
+        htmlWin = HtmlWindow(panel)
+        htmlWin.LoadPage("doc-0003.htm")
+        
+        sizer = wx.BoxSizer(wx.VERTICAL)
+        sizer.Add(htmlWin, 1, wx.ALL | wx.EXPAND, 5)
+        panel.SetSizer(sizer)
+        self.Show()
+        
+if __name__ == "__main__":
+    app = wx.App(False)
+    frame = MyFrame()
+    app.MainLoop()
+    

File wxpython_by_example/Html Help/makoHtmlExample.py

+from mako.template import Template
+from mako.lookup import TemplateLookup
+
+p = r'C:\Users\mld.MCIS\Documents\Dropbox\Scripts\wx tutorials\Html Help\templates'
+mylookup = TemplateLookup(directories=[p])
+mytemplate = mylookup.get_template("index.mako")
+html = mytemplate.render()
+print html
+
+f = file('test.html', 'w')
+f.write(html)
+f.close()

File wxpython_by_example/Html Help/templates/index.mako

+<%inherit file="master.mako"/>
+
+<%def name="title()">
+  Welcome to wxPython Help
+</%def>
+
+<%def name="content()">
+  Welcome to the wxPython help page where you can learn all kinds of wxPython information!
+</%def>

File wxpython_by_example/Html Help/templates/master.mako

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+    <title>${self.title()}</title>
+</head>
+
+<body>
+    ${self.content()}
+</body>
+
+<%def name="content()">
+</%def>
+
+<%def name="title()">  </%def>
+</html>

File wxpython_by_example/Html Help/test.html

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+    <title>
+  Welcome to wxPython Help
+</title>
+</head>
+
+<body>
+    
+  Welcome to the wxPython help page where you can learn all kinds of wxPython information!
+
+</body>
+
+
+
+
+</html>

File wxpython_by_example/Notebooks-agw/Notebooks-agw.tar

Binary file added.

File wxpython_by_example/Notebooks-agw/Notebooks-agw.zip

Binary file added.

File wxpython_by_example/Notebooks-agw/agwAUINBookFeaturesDemo.py

+#----------------------------------------------------------------------
+# agwAUINBookFeaturesDemo.py
+#
+# Created: December 2009
+#
+# Author: Mike Driscoll - mike@pythonlibrary.org
+#
+# Note: Some code comes from the wxPython demo
+#
+#----------------------------------------------------------------------
+
+import panelOne, panelTwo, panelThree
+import wx
+import wx.lib.agw.aui as aui
+
+ID_NotebookArtGloss = 0
+ID_NotebookArtSimple = 1
+ID_NotebookArtVC71 = 2
+ID_NotebookArtFF2 = 3
+ID_NotebookArtVC8 = 4
+ID_NotebookArtChrome = 5
+
+########################################################################
+class AUIManager(aui.AuiManager):
+    """
+    AUI Manager class
+    """
+
+    #----------------------------------------------------------------------
+    def __init__(self, managed_window):
+        """Constructor"""
+        aui.AuiManager.__init__(self)
+        self.SetManagedWindow(managed_window)
+
+########################################################################
+class AUINotebook(aui.AuiNotebook):
+    """
+    AUI Notebook class
+    """
+
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        aui.AuiNotebook.__init__(self, parent=parent)
+        self.default_style = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER
+        self.SetWindowStyleFlag(self.default_style)
+
+        # add some pages to the notebook
+        pages = [panelOne, panelTwo, panelThree]
+
+        x = 1
+        for page in pages:
+            label = "Tab #%i" % x
+            tab = page.TabPanel(self)
+            self.AddPage(tab, label, False)
+            x += 1
+
+########################################################################
+class DemoFrame(wx.Frame):
+    """
+    wx.Frame class
+    """
+    #----------------------------------------------------------------------
+    def __init__(self):
+        """Constructor"""
+        title = "AGW AUI Notebook Feature Tutorial"
+        wx.Frame.__init__(self, None, wx.ID_ANY, 
+                          title=title, size=(600,400))
+        self.themeDict = {"Glossy Theme (Default)":0,
+                          "Simple Theme":1,
+                          "VC71 Theme":2,
+                          "Firefox 2 Theme":3,
+                          "VC8 Theme":4,
+                          "Chrome Theme":5,
+                          }
+
+        # create the AUI manager
+        self.aui_mgr = AUIManager(self)
+
+        # create the AUI Notebook
+        self.notebook = AUINotebook(self)
+        
+        self._notebook_style = self.notebook.default_style
+                
+        # add notebook to AUI manager
+        self.aui_mgr.AddPane(self.notebook, 
+                             aui.AuiPaneInfo().Name("notebook_content").
+                             CenterPane().PaneBorder(False)) 
+        self.aui_mgr.Update()
+        
+        # create menu and tool bars
+        self.createMenu()
+        self.createTB()
+        
+    #----------------------------------------------------------------------
+    def createMenu(self):
+        """
+        Create the menu
+        """
+        def doBind(item, handler):
+            """ Create menu events. """
+            self.Bind(wx.EVT_MENU, handler, item)
+        
+        menubar = wx.MenuBar()
+        
+        fileMenu = wx.Menu()
+        
+        doBind( fileMenu.Append(wx.ID_ANY, "&Exit\tAlt+F4", 
+                                "Exit Program"),self.onExit)
+        
+        optionsMenu = wx.Menu()
+        
+        doBind( optionsMenu.Append(wx.ID_ANY, 
+                                   "Disable Current Tab"),
+                self.onDisableTab)
+        
+        # add the menus to the menubar
+        menubar.Append(fileMenu, "File")
+        menubar.Append(optionsMenu, "Options")
+        
+        self.SetMenuBar(menubar)
+        
+    #----------------------------------------------------------------------
+    def createTB(self):
+        """
+        Create the toolbar
+        """
+        TBFLAGS = ( wx.TB_HORIZONTAL
+                    | wx.NO_BORDER
+                    | wx.TB_FLAT )
+        tb = self.CreateToolBar(TBFLAGS)
+        keys = self.themeDict.keys()
+        keys.sort()
+        choices = keys
+        cb = wx.ComboBox(tb, wx.ID_ANY, "Glossy Theme (Default)", 
+                         choices=choices,
+                         size=wx.DefaultSize,
+                         style=wx.CB_DROPDOWN)
+        cb.Bind(wx.EVT_COMBOBOX, self.onChangeTheme)
+        tb.AddControl(cb)
+        tb.AddSeparator()
+        
+        self.closeChoices = ["No Close Button", "Close Button At Right",
+                             "Close Button On All Tabs",
+                             "Close Button On Active Tab"]
+        cb = wx.ComboBox(tb, wx.ID_ANY, 
+                         self.closeChoices[3],
+                         choices=self.closeChoices,
+                         size=wx.DefaultSize, 
+                         style=wx.CB_DROPDOWN)
+        cb.Bind(wx.EVT_COMBOBOX, self.onChangeTabClose)
+        tb.AddControl(cb)
+        
+        tb.Realize()
+        
+    #----------------------------------------------------------------------
+    def onChangeTabClose(self, event):
+        """
+        Change how the close button behaves on a tab
+        
+        Note: Based partially on the agw AUI demo
+        """
+        choice = event.GetString()        
+        self._notebook_style &= ~(aui.AUI_NB_CLOSE_BUTTON |
+                                 aui.AUI_NB_CLOSE_ON_ACTIVE_TAB |
+                                 aui.AUI_NB_CLOSE_ON_ALL_TABS)
+        
+        # note that this close button doesn't work for some reason
+        if choice == "Close Button At Right":
+            self._notebook_style ^= aui.AUI_NB_CLOSE_BUTTON 
+        elif choice == "Close Button On All Tabs":
+            self._notebook_style ^= aui.AUI_NB_CLOSE_ON_ALL_TABS 
+        elif choice == "Close Button On Active Tab":
+            self._notebook_style ^= aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
+            
+        self.notebook.SetWindowStyleFlag(self._notebook_style)
+        self.notebook.Refresh()
+        self.notebook.Update()
+        
+    #----------------------------------------------------------------------
+    def onChangeTheme(self, event):
+        """
+        Changes the notebook's theme
+        
+        Note: Based partially on the agw AUI demo
+        """
+        evId = self.themeDict[event.GetString()]
+        all_panes = self.aui_mgr.GetAllPanes()
+        
+        for pane in all_panes:
+
+            if isinstance(pane.window, aui.AuiNotebook):
+                nb = pane.window
+
+                if evId == ID_NotebookArtGloss:
+                
+                    nb.SetArtProvider(aui.AuiDefaultTabArt())
+                    
+                elif evId == ID_NotebookArtSimple:
+                    nb.SetArtProvider(aui.AuiSimpleTabArt())
+                    
+                elif evId == ID_NotebookArtVC71:
+                    nb.SetArtProvider(aui.VC71TabArt())
+                    
+                elif evId == ID_NotebookArtFF2:
+                    nb.SetArtProvider(aui.FF2TabArt())
+                    
+                elif evId == ID_NotebookArtVC8:
+                    nb.SetArtProvider(aui.VC8TabArt())
+                    
+                elif evId == ID_NotebookArtChrome:
+                    nb.SetArtProvider(aui.ChromeTabArt())
+                    
+                nb.Refresh()
+                nb.Update()
+                
+    #----------------------------------------------------------------------
+    def onDisableTab(self, event):
+        """
+        Disables the current tab
+        """
+        page = self.notebook.GetCurrentPage()
+        page_idx = self.notebook.GetPageIndex(page)
+        
+        self.notebook.EnableTab(page_idx, False)
+        self.notebook.AdvanceSelection()
+        
+    #----------------------------------------------------------------------
+    def onExit(self, event):
+        """
+        Close the demo
+        """
+        self.Close()
+        
+
+#----------------------------------------------------------------------
+if __name__ == "__main__":
+    app = wx.PySimpleApp()
+    frame = DemoFrame()
+    frame.Show()
+    app.MainLoop()

File wxpython_by_example/Notebooks-agw/agwAUINotebookDemo.py

+#----------------------------------------------------------------------
+# agwAUINotebook.py
+#
+# Created: December 2009
+#
+# Author: Mike Driscoll - mike@pythonlibrary.org
+#
+# Note: Some code comes from the wxPython demo
+#
+#----------------------------------------------------------------------
+
+
+import wx
+import wx.lib.agw.aui as aui 
+
+########################################################################
+class TabPanelOne(wx.Panel):
+    """
+    A simple wx.Panel class
+    """
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """"""
+        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)
+        
+        izer = wx.BoxSizer(wx.VERTICAL)
+        txtOne = wx.TextCtrl(self, wx.ID_ANY, "")
+        txtTwo = wx.TextCtrl(self, wx.ID_ANY, "")
+        
+        sizer = wx.BoxSizer(wx.VERTICAL)
+        sizer.Add(txtOne, 0, wx.ALL, 5)
+        sizer.Add(txtTwo, 0, wx.ALL, 5)
+        
+        self.SetSizer(sizer)
+        
+########################################################################
+class DemoFrame(wx.Frame):
+    """
+    wx.Frame class
+    """
+    
+    #----------------------------------------------------------------------
+    def __init__(self):
+        wx.Frame.__init__(self, None, wx.ID_ANY, 
+                          "AGW AUI Notebook Tutorial",
+                          size=(600,400))
+ 
+        self._mgr = aui.AuiManager()
+        
+        # tell AuiManager to manage this frame
+        self._mgr.SetManagedWindow(self)
+                
+        notebook = aui.AuiNotebook(self)
+        panelOne = TabPanelOne(notebook)
+        panelTwo = TabPanelOne(notebook)
+        
+        notebook.AddPage(panelOne, "PanelOne", False)
+        notebook.AddPage(panelTwo, "PanelTwo", False)
+        
+        self._mgr.AddPane(notebook, 
+                          aui.AuiPaneInfo().Name("notebook_content").
+                          CenterPane().PaneBorder(False)) 
+        self._mgr.Update()
+        #notebook.EnableTab(1, False)
+        
+ #----------------------------------------------------------------------
+# Run the program
+if __name__ == "__main__":
+    app = wx.PySimpleApp()
+    frame = DemoFrame()
+    frame.Show()
+    app.MainLoop()

File wxpython_by_example/Notebooks-agw/blankFlatnotebookDemo.py

+#----------------------------------------------------------------------
+# flatnotebookDemo.py
+#
+# Created: 12-04-2009
+#
+# Author: Mike Driscoll  
+#
+# Email:  mike@pythonlibrary.org
+#----------------------------------------------------------------------
+
+import panelOne, panelTwo, panelThree
+import random
+import wx
+import wx.lib.agw.flatnotebook as fnb
+
+########################################################################
+class FlatNotebookDemo(fnb.FlatNotebook):
+    """
+    Flatnotebook class
+    """
+    #----------------------------------------------------------------------
+    def __init__(self, parent):
+        """Constructor"""
+        fnb.FlatNotebook.__init__(self, parent, wx.ID_ANY)
+        
+########################################################################
+class DemoFrame(wx.Frame):
+    """
+    Frame that holds all other widgets
+    """
+
+    #----------------------------------------------------------------------
+    def __init__(self, title="FlatNotebook Add/Remove Page Tutorial"):
+        """Constructor"""        
+        wx.Frame.__init__(self, None, wx.ID_ANY, 
+                          title=title,
+                          size=(600,400)
+                          )
+        self._newPageCounter = 0
+        panel = wx.Panel(self)
+        self.createRightClickMenu()
+        
+        # create some widgets
+        self.notebook = FlatNotebookDemo(panel)
+        addPageBtn = wx.Button(panel, label="Add Page")
+        addPageBtn.Bind(wx.EVT_BUTTON, self.onAddPage)
+        removePageBtn = wx.Button(panel, label="Remove Page")
+        removePageBtn.Bind(wx.EVT_BUTTON, self.onDeletePage)
+        self.notebook.SetRightClickMenu(self._rmenu)
+        
+        # create some sizers
+        sizer = wx.BoxSizer(wx.VERTICAL)
+        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
+        
+        # layout the widgets
+        sizer.Add(self.notebook, 1, wx.ALL|wx.EXPAND, 5)
+        btnSizer.Add(addPageBtn, 0, wx.ALL, 5)
+        btnSizer.Add(removePageBtn, 0, wx.ALL, 5)
+        sizer.Add(btnSizer)
+        panel.SetSizer(sizer)
+        self.Layout()
+        
+        self.Show()
+        
+    #----------------------------------------------------------------------
+    def createRightClickMenu(self):
+        """
+        Based on method from flatnotebook demo
+        """
+        self._rmenu = wx.Menu()
+        item = wx.MenuItem(self._rmenu, wx.ID_ANY, 
+                           "Close Tab\tCtrl+F4", 
+                           "Close Tab")
+        self.Bind(wx.EVT_MENU, self.onDeletePage, item)
+        self._rmenu.AppendItem(item)
+        
+    #----------------------------------------------------------------------
+    def onAddPage(self, event):
+        """
+        This method is based on the flatnotebook demo
+        
+        It adds a new page to the notebook
+        """
+        caption = "New Page Added #" + str(self._newPageCounter)
+        self.Freeze()
+
+        self.notebook.AddPage(self.createPage(caption), caption, True)
+        self.Thaw()
+        self._newPageCounter = self._newPageCounter + 1
+        
+    #----------------------------------------------------------------------