[wxPython] Strangeness in GetClientSize()

This is just a curiousity thing -- not really a problem, since I found
what I should have done . . . .

I'm taking a look at one of my older Python apps that use wxPython.
Before I have ran it exclusively on Windows, but (just for curiousity), I
have tried in on Linux. I've never had problems with it on Windows
before, but when I tried to run on Linux, I got this:

176 gideon:~/gfnr2lit > python gfnr2lit.py

Gtk-WARNING **: undefined symbol: gtk_style_apply_default_background
Traceback (most recent call last):
  File "gfnr2lit.py", line 428, in ?
    app = MainApp(0)
  File "/usr/local/lib/python2.1/site-packages/wxPython/wx.py", line 1677, in __init__
    _wxStart(self.OnInit)
  File "gfnr2lit.py", line 420, in OnInit
    frame = MainFrame(None,-1,"fnr2lit configuration")
  File "gfnr2lit.py", line 40, in __init__
    self.main = MainPanel(self)
  File "gfnr2lit.py", line 164, in __init__
    self.list = FileList(self)
  File "gfnr2lit.py", line 308, in __init__
    wxListCtrl.__init__(self,self.parent,listId, pos=wxPoint(sizer[0]/8-50,sizer[1]/8-30), style=wxLC_REPORT|wxSUNKEN_BORDER|wxLC_NO_HEADER)
  File "/usr/local/lib/python2.1/site-packages/wxPython/misc.py", line 57, in __getattr__
    raise AttributeError,name
AttributeError: __getitem__

I traced it down to how 'sizer' was declared. I assigned it like this:
        sizer = self.parent.parent.GetClientSize()

Now I know that I should use:
        sizer = self.parent.parent.GetClientSize()

So I changed it . . . and it worked.

So why is the behaviour different with GetClientSize() on Windows than on
Linux?? Just curious . . . I'm running wxPython 2.2.5 on both.

···

--
Mike Hostetler
thehaas@binary.net
http://www.binary.net/thehaas
GnuPG key: http://www.binary.net/thehaas/mikeh.gpg

"What good is having someone who can walk on water if you don't follow
in his footsteps?"

    wxListCtrl.__init__(self,self.parent,listId,

pos=wxPoint(sizer[0]/8-50,sizer[1]/8-30),
style=wxLC_REPORT|wxSUNKEN_BORDER|wxLC_NO_HEADER)

  File "/usr/local/lib/python2.1/site-packages/wxPython/misc.py", line 57,

in __getattr__

    raise AttributeError,name
AttributeError: __getitem__

Just as it says, the wxSize object doesn't have __getitem__, which it tries
to find because of your "sizer[0]"

I traced it down to how 'sizer' was declared. I assigned it like this:
        sizer = self.parent.parent.GetClientSize()

Now I know that I should use:
        sizer = self.parent.parent.GetClientSize()

What's the difference?

So I changed it . . . and it worked.

So why is the behaviour different with GetClientSize() on Windows than on
Linux?? Just curious . . . I'm running wxPython 2.2.5 on both.

Are you sure? wxSize in 2.3.x has __getitem__, in 2.2.x it doesn't.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

GetClientSize() returns an instance of wxSize. Use the "width" and "height"
attributes of this. The _getitem__method is used by Python classes when a
"subscripting" operation [index] is attempted on it... see Section 2 of the
Library Reference Manual...

Perhaps Robin would consider creative a GetClientSizeTuple() method to be in
line with GetSizeTuple() ?

Cheerio, Chris

···

-------------------------------------------------------------------------
Chris Fama <mailto:Chris.Fama@whollysnakes.com>
         or <mailto:Chris.Fama@uq.net.au>
Brisbane, Australia
Phone: (0/+61)(7) 3870 5639 {10am-10pm GMT+10 on both these numbers please}
Mobile: (0/+61)(400) 833 700
-------------------------------------------------------------------------
Business page: <http://whollysnakes.com>
Personal page: <http://uq.net.au/~zzcfama&gt;
-------------------------------------------------------------------------

----- Original Message -----
From: "Mike Hostetler" <thehaas@binary.net>
To: "wxpython-users" <wxpython-users@lists.wxwindows.org>
Sent: Friday, October 26, 2001 12:57 PM
Subject: [wxPython] Strangeness in GetClientSize()

This is just a curiousity thing -- not really a problem, since I found
what I should have done . . . .

I'm taking a look at one of my older Python apps that use wxPython.
Before I have ran it exclusively on Windows, but (just for curiousity), I
have tried in on Linux. I've never had problems with it on Windows
before, but when I tried to run on Linux, I got this:

176 gideon:~/gfnr2lit > python gfnr2lit.py

Gtk-WARNING **: undefined symbol: gtk_style_apply_default_background
Traceback (most recent call last):
  File "gfnr2lit.py", line 428, in ?
    app = MainApp(0)
  File "/usr/local/lib/python2.1/site-packages/wxPython/wx.py", line 1677,

in __init__

    _wxStart(self.OnInit)
  File "gfnr2lit.py", line 420, in OnInit
    frame = MainFrame(None,-1,"fnr2lit configuration")
  File "gfnr2lit.py", line 40, in __init__
    self.main = MainPanel(self)
  File "gfnr2lit.py", line 164, in __init__
    self.list = FileList(self)
  File "gfnr2lit.py", line 308, in __init__
    wxListCtrl.__init__(self,self.parent,listId,

pos=wxPoint(sizer[0]/8-50,sizer[1]/8-30),
style=wxLC_REPORT|wxSUNKEN_BORDER|wxLC_NO_HEADER)

  File "/usr/local/lib/python2.1/site-packages/wxPython/misc.py", line 57,

in __getattr__

    raise AttributeError,name
AttributeError: __getitem__

I traced it down to how 'sizer' was declared. I assigned it like this:
        sizer = self.parent.parent.GetClientSize()

Now I know that I should use:
        sizer = self.parent.parent.GetClientSize()

So I changed it . . . and it worked.

So why is the behaviour different with GetClientSize() on Windows than on
Linux?? Just curious . . . I'm running wxPython 2.2.5 on both.

--
Mike Hostetler
thehaas@binary.net
http://www.binary.net/thehaas
GnuPG key: http://www.binary.net/thehaas/mikeh.gpg

"What good is having someone who can walk on water if you don't follow
in his footsteps?"

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

Perhaps Robin would consider creative a GetClientSizeTuple() method to be

in

line with GetSizeTuple() ?

In 2.3 wxSize (and wxPoint, wxRect, etc.) can be used as a sequence since
they implement the __getitem__ method.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!