nice to meet you. I have a some problem about using wxpython. That's I can't control cursor of TextCtrl Function. That is my wxpython code.
#!/usr/bin/python
import wx
def get_main_screen_text():
text = "\n [Anyfusion Monitoring System]\n\n"
return text
class Tom(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(400, 420))
panel = wx.Panel(self, -1)
vbox = wx.BoxSizer(wx.HORIZONTAL)
vbox1 = wx.BoxSizer(wx.VERTICAL)
vbox2 = wx.BoxSizer(wx.VERTICAL)
self.message = get_main_screen_text()
self.write = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE, value=self.message)
System_Checkup = wx.Button(panel, 1, label='System_Checkup')
Open_the_Web = wx.Button(panel, 1, label=' Open_the_Web ')
Help_Desk = wx.Button(panel, 1, label=' Help_Desk ')
Exit = wx.Button(panel, 1, label=' Exit ')
vbox1.Add(self.write, 1, wx.EXPAND | wx.TOP | wx.RIGHT | wx.LEFT | wx.BOTTOM, 15)
vbox2.Add(System_Checkup, 0, wx.TOP | wx.TOP | wx.RIGHT, 15)
vbox2.Add(Open_the_Web, 0, wx.TOP | wx.RIGHT, 15)
vbox2.Add(Help_Desk, 0, wx.TOP, 230)
vbox2.Add(Exit, 0, wx.TOP | wx.RIGHT, 15)
vbox.Add(vbox1, 1, wx.EXPAND)
vbox.Add(vbox2, 0, wx.TOP)
self.Bind(wx.EVT_BUTTON, self.EventHandler, id=1)
panel.SetSizer(vbox)
self.Centre()
def EventHandler(self, event):
b=event.GetEventObject().GetLabel()
if b.endswith('System_Checkup'):
self.message = self.message+"\nABC"
self.write.SetValue(self.message)
self.write.SetEditable(False)
self.write.SetScrollPos(wx.VERTICAL,0)
self.write.SetInsertionPoint(0)
self.write.Refresh()
class MyApp(wx.App):
def OnInit(self):
frame = Tom(None, -1, 'Tom')
frame.ShowModal()
frame.Destroy()
return True
if __name__ == "__main__":
app = MyApp()
app.MainLoop()
I want to locate my cursor to end of text. But my program didn't work it. The capture of my wxpython program below.
Next capture is a expected result of wxpython program.
Thanks you so much. I want to solve this problem as soon as possible.. thanks..
Use SetInsertionPointEnd
#!/usr/bin/python
import wx
def get_main_screen_text():
text = "\n [Anyfusion Monitoring System]\n\n"
return text
class Tom(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(400, 420))
panel = wx.Panel(self, -1)
vbox = wx.BoxSizer(wx.HORIZONTAL)
vbox1 = wx.BoxSizer(wx.VERTICAL)
vbox2 = wx.BoxSizer(wx.VERTICAL)
self.message = get_main_screen_text()
self.write = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE, value=self.message)
System_Checkup = wx.Button(panel, 1, label='System_Checkup')
Open_the_Web = wx.Button(panel, 1, label=' Open_the_Web ')
Help_Desk = wx.Button(panel, 1, label=' Help_Desk ')
Exit = wx.Button(panel, 1, label=' Exit ')
vbox1.Add(self.write, 1, wx.EXPAND | wx.TOP | wx.RIGHT | wx.LEFT | wx.BOTTOM, 15)
vbox2.Add(System_Checkup, 0, wx.TOP | wx.TOP | wx.RIGHT, 15)
vbox2.Add(Open_the_Web, 0, wx.TOP | wx.RIGHT, 15)
vbox2.Add(Help_Desk, 0, wx.TOP, 230)
vbox2.Add(Exit, 0, wx.TOP | wx.RIGHT, 15)
vbox.Add(vbox1, 1, wx.EXPAND)
vbox.Add(vbox2, 0, wx.TOP)
self.Bind(wx.EVT_BUTTON, self.EventHandler, id=1)
panel.SetSizer(vbox)
self.Centre()
def EventHandler(self, event):
b=event.GetEventObject().GetLabel()
if b.endswith('System_Checkup'):
self.message = self.message+"\nABC"
self.write.SetValue(self.message)
self.write.SetEditable(False)
self.write.SetScrollPos(wx.VERTICAL,0)
self.write.SetFocus()
self.write.SetInsertionPointEnd()
self.write.Refresh()
class MyApp(wx.App):
def OnInit(self):
frame = Tom(None, -1, 'Tom')
frame.ShowModal()
frame.Destroy()
return True
if __name__ == "__main__":
app = MyApp()
app.MainLoop()