Hello all,
I have problem with wx.richtext
I cannot make it start new line at hitting return key! How can I do it so that I can use Align left and right

Here is a code

# Text area
        self.textarea = rt.RichTextCtrl(epanel, style=wx.VSCROLL|wx.HSCROLL|wx.NO_BORDER )

What happens now when you hit return?

Oh and for the algin left and right just bind something to this code:

#to align left
self.textarea.ApplyAlignmentToSelection(rt.TEXT_ALIGNMENT_LEFT)
#to align right
self.textarea.ApplyAlignmentToSelection(rt.TEXT_ALIGNMENT_RIGHT)

Hope that helps

What happens now when you hit return?

Nothing happens, it is until you the characters fill the first line then it starts a new line. I dont know why it doesn't start new line at hitting return key! Is there option missing in style? I know text ctle have TE_MULTILINE, and i've tried to insert without effect :(

Oh and for the algin left and right just bind something to this code:

#to align left
self.textarea.ApplyAlignmentToSelection(rt.TEXT_ALIGNMENT_LEFT)
#to align right
self.textarea.ApplyAlignmentToSelection(rt.TEXT_ALIGNMENT_RIGHT)

Hope that helps

With that i have no problem, but since it cannot start new line then there is no alignment!

Could you post your code please. I made myself a wx.RichText based frame and it works no problems so maybe we would have more chance solving the problem with a bit of code to work with.

Code is getting bigger. But what I think is ; something is missing in the way I initialize the textarea in my code, I mean something like TE_MULTILINE is missing. The rest of code contains string manipulations and other widgets/toolbars that have nothing to do with the problem

perhaps you could bind it to an event so when you press enter it does something like this:

def enter(self,event):
    text = self.textarea.GetValue()
    self.textarea.SetValue(text+'\n')

But maybe to get it to process the enter button you have to add the style wx.PROCESS_ENTER and then bind it:

self.textarea.Bind(wx.EVT_TEXT_ENTER,self.enter)

Hope that works, tell me how it goes.

This article has been dead for over six months. Start a new discussion instead.