hi,
im trying to do something like the following:

text_area = wx.TextCtrl(self.panel, -1, style=wx.MULTILINE)
a = (all the text in the text control window)

I can't get my head around how to define the text with wxpython, how should I go about this?

umm something along the lines of a = getvalue(textarea)

not completely sure of the syntax but its along those lines. sorry i could be of more help
maybe...

a = self.GetValue(text_area)

Edited 6 Years Ago by Archenemie: n/a

Here would be simple example ...

# explore wxPython wx.Frame with
# a wx.TextCtrl to enter some text
# a wx.Button to start process action
# a wx.StaticText to display the result

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle):
        wx.Frame.__init__(self, parent, -1, mytitle)
        self.SetBackgroundColour("yellow")

        # create some widgets
        self.edit = wx.TextCtrl(self, -1, value="", size=(350, 50),
            style=wx.TE_MULTILINE)
        self.button = wx.Button(self, -1, label="Press to process")
        self.label = wx.StaticText(self, -1, size=(350, 90))

        # stack the widgets vertically
        myflag = wx.ALL|wx.EXPAND
        sizer_v = wx.BoxSizer(wx.VERTICAL)
        sizer_v.Add(self.edit, flag=myflag, border=10)
        sizer_v.Add(self.button, flag=myflag, border=10)
        sizer_v.Add(self.label, flag=myflag, border=10)
        # make the frame fit all the widgets
        self.SetSizerAndFit(sizer_v)

        # bind button mouse click event to an action
        self.button.Bind(wx.EVT_BUTTON, self.onAction)
        
    def onAction(self, event):
        """
        get the text from edit, process it and display in label
        """
        text = self.edit.GetValue()
        # optional text processing
        if not text:
            text = "any text entered would look like this"
        text = text.upper()
        self.label.SetLabel(text)


app = wx.App(0)
# create a MyFrame instance and show the frame
MyFrame(None, "enter some text and process it").Show()
app.MainLoop()
This article has been dead for over six months. Start a new discussion instead.