Simple logging app problems

Howdy. I'm starting to learn wxPython and this is my first post
here.

I've been using Boa Constructor and have been through the tutorial.
To learn how logging works I'm trying to create an app with a button
and a log window. I cobbled together the code below using code lifted
from the wxPython Demo app. When you run it you get a window with the
button and the log window pane at the bottom. I know the button event
is working because the print in the event handler generates output
each time I click it. However, the log window simply shows what is
behind the app and never updates. I'd appreciate any help and
explanation as to why it isn't working.

I see the problem as more of a wxPython question than a Boa
Constructor question, that's why I posted here.

Thanks!

···

**************************
file: log.py
*************************

#!/usr/bin/env python
#Boa:App:BoaApp

import wx

import log_frame1

modules ={u'log_frame1': [1, 'Main frame of Application',
u'log_frame1.py']}

class BoaApp(wx.App):
    def OnInit(self):
        self.main = log_frame1.create(None)
        self.main.Show()
        self.SetTopWindow(self.main)
        return True

def main():
    application = BoaApp(0)
    application.MainLoop()

if __name__ == '__main__':
    main()

*************************
file log_frame1.py
*************************

#Boa:Frame:Frame1

import wx
import wx.aui

def create(parent):
    return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1B_PUSHME,
] = [wx.NewId() for _init_ctrls in range(2)]

class Frame1(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
              pos=wx.Point(2525, 430), size=wx.Size(600, 400),
              style=wx.DEFAULT_FRAME_STYLE, title='Log')
        self.SetClientSize(wx.Size(592, 370))

        self.b_pushMe = wx.Button(id=wxID_FRAME1B_PUSHME, label='Push
Me',
              name='b_pushMe', parent=self, pos=wx.Point(208, 32),
              size=wx.Size(60, 20), style=0)
        self.b_pushMe.Bind(wx.EVT_BUTTON, self.OnB_pushMeButton,
              id=wxID_FRAME1B_PUSHME)

    def __init__(self, parent):
        self._init_ctrls(parent)
        self.mgr = wx.aui.AuiManager(self)

        # Use a panel under the AUI panes in order to work around a
        # bug on PPC Macs
        pnl = wx.Panel(self)
        self.pnl = pnl

        #topPanel = wx.Panel(self, -1)
        #bottomPanel = wx.Panel(self, -1)

        #self.mgr.AddPane(topPanel, wx.aui.AuiPaneInfo().Top())
        #self.mgr.AddPane(bottomPanel, wx.aui.AuiPaneInfo().Bottom())

        # Set up a log window
        self.log = wx.TextCtrl(pnl, -1,
                              style = wx.TE_MULTILINE|wx.TE_READONLY|
wx.HSCROLL)
        if wx.Platform == "__WXMAC__":
            self.log.MacCheckSpelling(False)

        # Set the wxWindows log target to be this textctrl
        wx.Log_SetActiveTarget(wx.LogTextCtrl(self.log))
        # But instead of the above we want to show how to use our own
wx.Log class
        #wx.Log_SetActiveTarget(MyLog(self.log))
        # for serious debugging
        #wx.Log_SetActiveTarget(wx.LogStderr())
        #wx.Log_SetTraceMask(wx.TraceMessages)

        self.mgr.AddPane(self.log,
                         wx.aui.AuiPaneInfo().
                         Bottom().BestSize((-1, 150)).
                         MinSize((-1, 60)).
                         #Floatable(ALLOW_AUI_FLOATING).FloatingSize
((500, 160)).
                         Floatable(True).FloatingSize((500, 160)).
                         Caption("Demo Log Messages").
                         CloseButton(False).
                         Name("LogWindow"))
        self.mgr.Update()

        self.b_pushMe.log = self.log

    def OnB_pushMeButton(self, event):
        print ("Hey!")
        self.log.write("You pushed me!")

xabiche wrote:

Howdy. I'm starting to learn wxPython and this is my first post
here.

I've been using Boa Constructor and have been through the tutorial.
To learn how logging works I'm trying to create an app with a button
and a log window. I cobbled together the code below using code lifted
from the wxPython Demo app. When you run it you get a window with the
button and the log window pane at the bottom. I know the button event
is working because the print in the event handler generates output
each time I click it. However, the log window simply shows what is
behind the app and never updates. I'd appreciate any help and
explanation as to why it isn't working.

I see the problem as more of a wxPython question than a Boa
Constructor question, that's why I posted here.

        pnl = wx.Panel(self)
        self.pnl = pnl

The problem is this panel. You use it as the parent of the textctrl but there is nothing to manage the size or position of the panel, so it will stay at its small default size, and thus clips the view of the text ctrl. Get rid of this panel and use self for the parent of the textctrl and it will work better.

BTW, you'll be better off not trying to use AUI in your beginning programs. It's quite an advanced topic. Get to know the basics first, and if you really want to learn, get to know them without a code generator doing the work for you.

···

--
Robin Dunn
Software Craftsman

I thought I had replied to this... ?

Anyways, thanks for the help. That fixed it.

This was just a experiment to see how easy it is to generate a GUI
simply by jumping in and doing it. I'll definitely do some
development w/o the AUI or code generator to get better training on
the tech.

Thanks.