def MakeTextFrame(type = "Expando"): f = wx.Frame(None, -1, title=type) if type == "Expando": tc = ExpandoTextCtrl(f,-1) else: tc = wx.TextCtrl(f,-1,style = wx.TE_RICH2 | wx.TE_MULTILINE | wx.TE_NO_VSCROLL) tc.ShowScrollbar(wx.VERTICAL, False) def OnKey(event): event.Skip() line = tc.PositionToXY(tc.GetInsertionPoint())[2] scrollPos = tc.GetScrollPos(wx.VERTICAL) print line, scrollPos def OnLayoutneeded(event): event.Skip() f.Fit() def OnKeyDownStripNewlineModifiers(event): if event.KeyCode == wx.WXK_RETURN and event.Modifiers: e = wx.KeyEvent(wx.EVT_CHAR) e.m_keyCode = event.m_keyCode e.m_rawCode = event.m_rawCode e.m_rawFlags = event.m_rawFlags e.m_scanCode = event.m_scanCode e.m_controlDown = False e.m_altDown = False e.m_metaDown = False e.m_shiftDown = False tc.WriteText('\n') tc.ProcessEvent(e) else: event.Skip() tc.Bind(wx.EVT_KEY_DOWN, OnKeyDownStripNewlineModifiers) tc.Bind(wx.EVT_KEY_DOWN, OnKey) tc.Bind(EVT_ETC_LAYOUT_NEEDED, OnLayoutneeded) if type == "Expando": tc.SetMaxHeight(100) f.Show() f.Layout()
def __init__(self, parent, style = 0, value = '', multiFormat = True, format = None, validator = wx.DefaultValidator): ExpandoTextCtrl.__init__(self, parent, wx.ID_ANY, value, wx.DefaultPosition, wx.DefaultSize, style | formattedstyle, validator, value) FormattingInterface.__init__(self, multiFormat, format)
def __init__(self, parent, style = 0, value = '', validator = wx.DefaultValidator): ExpandoTextCtrl.__init__(self, parent, wx.ID_ANY, value, wx.DefaultPosition, wx.DefaultSize, style, validator, value) SpellCheckTextCtrlMixin.__init__(self)
def __init__(self, *a, **k): ExpandoTextCtrl.__init__(self, *a, **k)
def NewInput(): f = wx.Frame(None) f.Sizer = wx.BoxSizer(wx.VERTICAL) font = wx.Font(22, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, True, "Comic Sans MS") textattr = wx.TextAttr(wx.Color(255, 0, 255), wx.Color(0, 255, 255), font) #font = FontFromFacename('Arial') #font.SetPointSize(10) #textattr = wx.TextAttr(wx.Color(255,0,255), wx.WHITE, font) #@UndefinedVariable output = wx.TextCtrl(f, -1, style=wx.TE_READONLY | wx.TE_MULTILINE) output.SetMinSize(wx.Size(200, 200)) f.Sizer.Add(output, 1, wx.EXPAND) # fo = {'default': False, # 'italic': True} input = ExpandoTextCtrl(f, wx.ID_ANY) input.SetStyle(0, 0, textattr) #input = FormattedExpandoTextCtrl(f, multiFormat = True, format = textattr) #input = FormattedInput(f, multiFormat = True, format = textattr)#, formatOptions = fo) def OnExpandEvent(event): try: height = (input.fbar.Size.height if input.FormattingBarIsShown() else 0) + input.tc.MinSize.height except: height = input.MinSize.height input.MinSize = wx.Size(-1, height) f.Fit() def OnEnterKey(event): if event.KeyCode in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER ) and event.Modifiers == wx.MOD_SHIFT: try: output.Value = input.tc.GetRTF() except: output.Value = input.GetRTF() input.Clear() return event.Skip() input.Bind(EVT_ETC_LAYOUT_NEEDED, OnExpandEvent) try: input.tc.Bind(wx.EVT_KEY_DOWN, OnEnterKey) except: input.Bind(wx.EVT_KEY_DOWN, OnEnterKey) f.Sizer.Add(input, 0, wx.EXPAND) f.MinSize = f.BestSize f.Show() f.Fit() input.SetFocus()