Problem with TextCtrl subclass

Hi,
I created a subclass of textctrl to capture AppendText() and print to
a file then call super.AppendText(). Everything seems to be working
fine except for when i call super's AppendText the display does not
print new lines it prints a little square or box instead. Anyone have
an idea why?

We can probably guess, but without a running sample to test we have no solid idea what your AppendText is doing nor how it is doing it. MakingSampleApps - wxPyWiki

···

On 2/17/11 8:30 AM, Daniel wrote:

Hi,
I created a subclass of textctrl to capture AppendText() and print to
a file then call super.AppendText(). Everything seems to be working
fine except for when i call super's AppendText the display does not
print new lines it prints a little square or box instead. Anyone have
an idea why?

--
Robin Dunn
Software Craftsman

I found out what the problem was, it was a really dumb but hard to
catch mistake. Here is my code:

import wx
class logger(wx.TextCtrl):
    def __init__(self, parent, style):
        wx.TextCtrl.__init__(self, parent, style=style)

    def AppendText(self, txt):
        super(logger, self).AppendText(txt)

class ExamplePanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.logger = logger(self,style=wx.TE_MULTILINE |
wx.TE_READONLY)

        self.logger.AppendText("Hello\n")
        self.logger.AppendText("Bye\n")

    def prints(self, txt):
        self.logger.AppendText(txt)
try:
    app = wx.App(False)
    frame = wx.Frame(None, size=(650,400))
    panel = ExamplePanel(frame)
    frame.Show()
    app.MainLoop()
finally:
    del app

The problem turned out to be that I had the line:
    wx.TextCtrl.__init__(self, parent, style)
instead of:
    wx.TextCtrl.__init__(self, parent, style=style)

And that made all the difference. Thanks for your help though

···

On Feb 17, 10:58 am, Robin Dunn <ro...@alldunn.com> wrote:

On 2/17/11 8:30 AM, Daniel wrote:

> Hi,
> I created a subclass of textctrl to capture AppendText() and print to
> a file then call super.AppendText(). Everything seems to be working
> fine except for when i call super's AppendText the display does not
> print new lines it prints a little square or box instead. Anyone have
> an idea why?

We can probably guess, but without a running sample to test we have no
solid idea what your AppendText is doing nor how it is doing it.MakingSampleApps - wxPyWiki

--
Robin Dunn
Software Craftsmanhttp://wxPython.org