Need help sending text to a wxTextCtrl when a button is clicked.
Made a small gui trying to learn wxPython. It has two buttons,
menus and a TextCtrl (multiline). Have the menus and button events
working.
Have been able to get the button working on, to print Text to the
console screen when start App with the console. Cannot send to the
TextCtrl though.
Little info:
wxGlade made two classes in the generated file.
class MyNotebook(wxNotebook):
...(buttons and textctrl(readonly, multline))
class MyFrame(wxFrame):
...(menus)
The buttons and TextCtrl are in the Notebook class. Trying to keep the
commandline functionality of the program writing a gui for so want
to keep the Gui seperate form the program. So right now following
the example from: http://wiki.wxpython.org/index.cgi/OrganizingYourCode
where he is using a main.py to start the gui.
Perferably would like to send stdout to the TextCtrl (tried one tutorial
on wiki.wxpython.org for that an didn't work.) But if have to would
be able to have the program write to a file and send the file to TextCtrl.
Do you have any hints, ideas, better examples on the web.
Here is the total main.py script calling the Gui1.py generated file.
Main.py
···
***************************************************************
#!/usr/bin/python
from wxPython.wx import *
from Gui1 import *
ID_COMBO = wxNewId()
# First doing MyApp to just launch it. will add functionality later
class MyApp(wxApp):
def OnInit(self):
# Display the main frame of the App
frame = MyFrame(None,-1,"")
frame.Show(True)
#self.SetTopWindow(frame)
self.frame = frame
# Menu Events
EVT_MENU(self,ID_EXIT,self.MenuExit)
#EVT_MENU(self,frame.ID_ABOUT,self.MenuAbout)
# Adding a button that is the main window
EVT_BUTTON(self,ID_SHOW,self.onButtonShow)
return True
def MenuExit(self,event):
self.frame.Close(true)
def onButtonShow(self,event):
This is the section can't get working.
EVT_MENU sends it here when button pressed.
But can't make text go to the Gui TextCtrl.
def main():
app = MyApp(0)
app.MainLoop()
if __name__ == '__main__':
main()
***************************************************************
Thanks, Dave