Hi everybody,
I have a wxMiniFrame with a wxTextCtrl in it, when I create the frame I want the text control to display the text without a selection and with the insertion point at the end of the string. But the #!=%6€ thing doesn't want to. Is there anybody out there who can spot what I'm missing?
This works as it should in OSX but in XP ( pro ), all text is selected ( and hightlighted ) when the textcontrol shows.
= ( .
from wxPython.wx import *
class MyMiniFrame(wxMiniFrame):
def __init__(self, parent, title, text = " ", pos=wxDefaultPosition, size=wxDefaultSize,
style=wxDEFAULT_FRAME_STYLE ):
self.parent = parent
wxMiniFrame.__init__(self, parent, -1, title, pos, size, style)
self.textCtrl = wxTextCtrl(self, -1, text , style=wxTE_MULTILINE)
self.textCtrl.SetInsertionPoint(0)
#self.textCtrl.SetSelection( self.textCtrl.GetLastPosition() - 1, self.textCtrl.GetLastPosition() )
sizer_1 = wxBoxSizer(wxVERTICAL)
sizer_1.Add(self.textCtrl, 1, wxEXPAND, 0)
self.SetAutoLayout(1)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
sizer_1.SetSizeHints(self)
self.Layout()
EVT_CLOSE(self, self.OnCloseWindow)
EVT_TEXT(self, self.textCtrl.GetId() , self.OnControlEnter )
EVT_KILL_FOCUS( self, self.test )
def test( self, event ):
self.textCtrl.SetFocus()
def OnControlEnter( self, event ):
if event.GetString() and event.GetString()[-1] == '\n':
#self.parent.setPostItText( self.textCtrl.GetValue()[:-1] )
print self.textCtrl.GetValue()
self.Destroy()
def OnCloseWindow(self, event):
#self.parent.setPostItText( self.textCtrl.GetValue() )
print self.textCtrl.GetValue()
self.Destroy()
class MyFrame(wxFrame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wxDEFAULT_FRAME_STYLE
wxFrame.__init__(self, *args, **kwds)
self.but = wxButton( self, 1003, "pop" )
EVT_BUTTON( self, self.but.GetId(), self.pop )
def pop( self, event ):
win = MyMiniFrame(self,
"",
"testing",
#pos=(250,250), size=(200,200),
style=wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ
)
win.SetSize((200, 200))
win.CenterOnParent(wxBOTH)
self.otherWin = win
win.Show(True)
# end of class MyFrame
class MyApp(wxApp):
def OnInit(self):
wxInitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
self.SetTopWindow(frame_1)
frame_1.Show(1)
return 1
# end of class MyApp
if __name__ == "__main__":
app = MyApp()
app.MainLoop()