[wxPython-users] Opening a frame from ListCtrl item in Mac OS X

roee88 shlomo roee88 at gmail.com
Sun Nov 5 08:49:42 PST 2006


Skipped content of type multipart/alternative-------------- next part -----=
---------
import wx

class MyList(wx.ListCtrl):
    def __init__(self, parent):
        wx.ListCtrl.__init__(self, parent, -1, style =3D wx.LC_REPORT|wx.LC=
_VRULES|wx.CLIP_CHILDREN|wx.STATIC_BORDER)
        self.InsertColumn(0, "COLUMN1",wx.LIST_FORMAT_LEFT, 300)
        self.InsertStringItem(0, "Activate me")
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnActivate)

    def OnActivate(self, event):
        NewFrame(self)
        =

class MyPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)
        box =3D wx.BoxSizer(wx.HORIZONTAL)
        self.list  =3D MyList(self)
        box.Add(self.list, 1, wx.EXPAND)
        self.SetSizerAndFit(box)

class MyFrame(wx.Frame):
    def __init__(self):
        """
        Main frame, contains the panel and the list
        """
        wx.Frame.__init__(self, None,-1)
        panel =3D MyPanel(self)
        self.Show()

class NewFrame(wx.Frame):
    def __init__(self, parent):
        """
        A new frame that opens when activating a list item
        Appears in Background under Mac OS X
        """
        #wx.Frame.__init__(self, parent,-1) ## Doesn't work either
        wx.Frame.__init__(self, None,-1)
        p =3D wx.Panel(self)
        wx.StaticText(p, -1, " Where am I?\n Background or Foreground?")
        self.Show()

if __name__ =3D=3D '__main__':
    app =3D wx.App("")
    frame =3D MyFrame()
    app.MainLoop()
   =20


More information about the wxpython-users mailing list