wxPython / sandbox / test_swfocus.py

import wx
print wx.version()

import os; print "PID:", os.getpid()



class TestPanel(wx.Panel):
    """
    For testing tabbing into a scrolled window
    """
    def __init__(self, *args, **kw):
        wx.Panel.__init__(self, *args, **kw)

        tc1 = wx.TextCtrl(self, -1, "one", size=(150,-1))
        
        sw = wx.ScrolledWindow(self, -1,   size=(150,150),
                               #style = wx.WANTS_CHARS|wx.BORDER
                               )
        sw.SetBackgroundColour("light blue")
        sw.SetVirtualSize((150,150))
        sw.SetScrollRate(5,5)
        
        tc2 = wx.TextCtrl(self, -1, "two", size=(150,-1))
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(tc1, 0, wx.ALL, 15)
        sizer.Add(sw, 0, wx.ALL, 15)
        sizer.Add(tc2, 0, wx.ALL, 15)

        self.SetSizer(sizer)

        sw.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
        sw.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)

    def OnSetFocus(self, evt):
        evt.Skip()
        print "OnSetFocus"
        
    def OnKillFocus(self, evt):
        evt.Skip()
        print "OnKillFocus"



app = wx.App(redirect=False)
frm = wx.Frame(None, title="Tab to ScrolledWindow")

pnl = TestPanel(frm)

pnl.Sizer.SetSizeHints(frm)
frm.Show()
app.MainLoop()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.