EVT_MENU prob and wxTextCtrl question

I have 2 questions
1.the lines I've commented out don't work and I don't see the probleme
2.I want to create a function so I can save what I typed in in a file I know how to write to a file but I don't know what
variable the wxTextCtrl uses in other words what var do I have to write to the file ?
here is the code:

import sys, os
from wxPython.wx import *

ID_OPEN = 101
ID_SAVE = 102
ID_EXIT = 103

class main_window(wxFrame):
       def __init__(self, parent, id, title):
                 wxFrame.__init__(self, parent, -1, title, size = (500,500),style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
          
    self.CreateStatusBar()
    self.SetStatusText("small editor")
    
    M_file = wxMenu()
    M_file.Append(ID_OPEN,"&Open","Open a file")
    M_file.Append(ID_SAVE,"&Save","Save a file")
    M_file.Append(ID_EXIT,"&Quit","Quit this small editor")
    
    menuBar = wxMenuBar()
    menuBar.Append(M_file,"&File")
    self.SetMenuBar(menuBar)
    
    self.control = wxTextCtrl(self, -1, style=wxTE_MULTILINE)
               self.Show(true)
    
# EVT_MENU(self, ID_EXIT, self.TimeToQuit)

···

#
# def TimeToQuit(self, event):
# self.Close(true)
        
class App(wxApp):
         def OnInit(self):
             frame = main_window(None, -1, "wxPython: (A Demonstration)")
             frame.Show(true)
      self.SetTopWindow(frame)
             return true
app = App(0)
app.MainLoop()

With regard to question 1, your code works fine for me.
With regard to question 2, you need self.control.GetValue(). Since
you already know how to save to a file the following should get you
started:

import sys, os
from wxPython.wx import *

ID_OPEN = 101
ID_SAVE = 102
ID_EXIT = 103

class main_window(wxFrame):
    def __init__(self, parent, id, title):
        wxFrame.__init__(self, parent, -1, title,
                         size = (500,500),
                         style=wxDEFAULT_FRAME_STYLE|
                         wxNO_FULL_REPAINT_ON_RESIZE)
            
        self.CreateStatusBar()
        self.SetStatusText("small editor")
        
        M_file = wxMenu()
        M_file.Append(ID_OPEN,"&Open","Open a file")
        M_file.Append(ID_SAVE,"&Save","Save a file")
        M_file.Append(ID_EXIT,"&Quit","Quit this small editor")
        
        menuBar = wxMenuBar()
        menuBar.Append(M_file,"&File")
        self.SetMenuBar(menuBar)
        
        self.control = wxTextCtrl(self, -1, style=wxTE_MULTILINE)
        self.Show(true)
        
        EVT_MENU(self, ID_EXIT, self.TimeToQuit)
        EVT_MENU(self, ID_SAVE, self.TimeToSave)
                            
    def TimeToQuit(self, event):
        self.Close(true)

    def TimeToSave(self, event):
        # control.GetValue() returns the text in the wxTextCtrl
        print self.control.GetValue()
      
class App(wxApp):
    def OnInit(self):
        frame = main_window(None, -1, "wxPython: (A
Demonstration)")
        frame.Show(true)
        return true

app = App(0)
app.MainLoop()

···

--- Jonas Geiregat <kemu@sdf-eu.org> wrote:

I have 2 questions
1. the lines I've commented out don't work and I don't see the
probleme
2. I want to create a function so I can save what I typed in in a
file I know how to write to a file but I don't know what
variable the wxTextCtrl uses in other words what var do I have to
write to the file ?

=====
Donnal Walter
Arkansas Children's Hospital

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.

Donnal Walter wrote:

--- Jonas Geiregat wrote:
I have 2 questions
1. the lines I've commented out don't work and I don't see the
probleme
2. I want to create a function so I can save what I typed in in a
file I know how to write to a file but I don't know what
variable the wxTextCtrl uses in other words what var do I have to
write to the file ?

With regard to question 1, your code works fine for me.
With regard to question 2, you need self.control.GetValue(). Since
you already know how to save to a file the following should get you
started:
import sys, os
from wxPython.wx import *
ID_OPEN = 101
ID_SAVE = 102
ID_EXIT = 103
class main_window(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent, -1, title,
size = (500,500),
style=wxDEFAULT_FRAME_STYLE|
wxNO_FULL_REPAINT_ON_RESIZE)
self.CreateStatusBar()
self.SetStatusText("small editor")
M_file = wxMenu()
M_file.Append(ID_OPEN,"&Open","Open a file")
M_file.Append(ID_SAVE,"&Save","Save a file")
M_file.Append(ID_EXIT,"&Quit","Quit this small editor")
menuBar = wxMenuBar()
menuBar.Append(M_file,"&File")
self.SetMenuBar(menuBar)
self.control = wxTextCtrl(self, -1, style=wxTE_MULTILINE)
self.Show(true)
EVT_MENU(self, ID_EXIT, self.TimeToQuit)
EVT_MENU(self, ID_SAVE, self.TimeToSave)
def TimeToQuit(self, event):
self.Close(true)
def TimeToSave(self, event):
# control.GetValue() returns the text in the wxTextCtrl
print self.control.GetValue()
class App(wxApp):
def OnInit(self):
frame = main_window(None, -1, "wxPython: (A
Demonstration)")
frame.Show(true)
return true
app = App(0)
app.MainLoop()
=====
Donnal Walter
Arkansas Children's Hospital
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
---------------------------------------------------------------------
To unsubscribe, e-mail: For additional commands, e-mail:

if you comment out the 4lines I get this error

[kemu@localhost python-source]$ python test.py

File “”, line 29

def TimeToQuit(self, event):

                           ^

IndentationError: unindent does not match any outer indentation leve

···

kemu@sdf-eu.orghttp://mailplus.yahoo.comwxPython-users-unsubscribe@lists.wxwindows.orgwxPython-users-help@lists.wxwindows.org

I am unable to locate your specific problem, but Python is strict
about indentation levels, including spaces (not tabs). When you
comment out lines of code, you must make sure that the lines which
follow are indented *EXACTLY* the same as the previous lines in
that block of code, or the same as some previous block. Hope this
helps.

···

--- Jonas Geiregat <kemu@sdf-eu.org> wrote:

if you comment out the 4lines I get this error

[kemu@localhost python-source]$ python test.py
  File "<string>", line 29
    def TimeToQuit(self, event):
                               ^
IndentationError: unindent does not match any outer indentation
level

=====
Donnal Walter
Arkansas Children's Hospital

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.

Donnal Walter wrote:

--- Jonas Geiregat wrote:
I have 2 questions
1. the lines I've commented out don't work and I don't see the
probleme
2. I want to create a function so I can save what I typed in in a
file I know how to write to a file but I don't know what
variable the wxTextCtrl uses in other words what var do I have to
write to the file ?

With regard to question 1, your code works fine for me.
With regard to question 2, you need self.control.GetValue(). Since
you already know how to save to a file the following should get you
started:
import sys, os
from wxPython.wx import *
ID_OPEN = 101
ID_SAVE = 102
ID_EXIT = 103
class main_window(wxFrame):
def __init__(self, parent, id, title):
wxFrame.__init__(self, parent, -1, title,
size = (500,500),
style=wxDEFAULT_FRAME_STYLE|
wxNO_FULL_REPAINT_ON_RESIZE)
self.CreateStatusBar()
self.SetStatusText("small editor")
M_file = wxMenu()
M_file.Append(ID_OPEN,"&Open","Open a file")
M_file.Append(ID_SAVE,"&Save","Save a file")
M_file.Append(ID_EXIT,"&Quit","Quit this small editor")
menuBar = wxMenuBar()
menuBar.Append(M_file,"&File")
self.SetMenuBar(menuBar)
self.control = wxTextCtrl(self, -1, style=wxTE_MULTILINE)
self.Show(true)
EVT_MENU(self, ID_EXIT, self.TimeToQuit)
EVT_MENU(self, ID_SAVE, self.TimeToSave)
def TimeToQuit(self, event):
self.Close(true)
def TimeToSave(self, event):
# control.GetValue() returns the text in the wxTextCtrl
print self.control.GetValue()
class App(wxApp):
def OnInit(self):
frame = main_window(None, -1, "wxPython: (A
Demonstration)")
frame.Show(true)
return true
app = App(0)
app.MainLoop()
=====
Donnal Walter
Arkansas Children's Hospital
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
---------------------------------------------------------------------
To unsubscribe, e-mail: For additional commands, e-mail:

Is there a way to give the text a color ? or parts of a text

···

kemu@sdf-eu.orghttp://mailplus.yahoo.comwxPython-users-unsubscribe@lists.wxwindows.orgwxPython-users-help@lists.wxwindows.org

Go to the wxPython Demo and look for wxStyledTextCtrl under
"More Windows/Controls" in the navigation tree.

···

--- Jonas Geiregat <kemu@sdf-eu.org> wrote:

Is there a way to give the text a color ? or parts of a text

=====
Donnal Walter
Arkansas Children's Hospital

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.

wxTextCtrl has a special function just for saving its contents to a file
- saves a few lines of code.
Look it up in the wxWindows refference, i forgot what its called.