-
- class StyledTextApp(wx.App):
- def OnInit(self):
- self.frame = StcFrame(None, title="Custom Lexer")
- self.frame.Show()
- return True
-
- class StcFrame(wx.Frame):
- """Main application window"""
- def __init__(self, parent, *args, **kwargs):
- super(StcFrame, self).__init__(parent,
- *args,
- **kwargs)
-
- self.panel = TestPanel(self)
-
-
- class TestPanel(wx.Panel):
- def __init__(self, parent):
- wx.Panel.__init__(self, parent, -1)
-
- self.Autosizer = wx.FlexGridSizer(rows=1, cols=2, hgap = -190, vgap = -1)
- self.Autosizer.SetFlexibleDirection(wx.VERTICAL)
- self.Autosizer.AddGrowableCol(1, 1) # 2 col
- self.SetSizer(self.Autosizer)
- self.Fit()
-
- class STC(st.StyledTextCtrl):
- def __init__(self, *args, **kwargs):
- super(STC, self).__init__(*args, **kwargs)
-
- self.InitUI()
-
- def InitUI(self):
- self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
-
- def OnRightDown(self, e):
- self.PopupMenu(MyPopupMenu(self), e.GetPosition())
-
-
- class MyPopupMenu(wx.Menu):
-
- def __init__(self, parent):
- super(MyPopupMenu, self).__init__()
-
- self.parent = parent
-
- mmi = wx.MenuItem(self, wx.NewId(), 'Remove')
- self.AppendItem(mmi)
- self.Bind(wx.EVT_MENU, self.OnMinimize, mmi)
-
- def OnMinimize(self, e):
- StcFrame.panel.Autosizer.Remove(self) <------------------------------------------------------ this part is what I concern!
-
- def OnClose(self, e):
-
-
- if __name__ == '__main__':
- app = StyledTextApp(False)
- app.MainLoop()
-