No error, application does not load

I invoke the main module and the shell prompt is immediately returned. No
errors, no application GUI displayed.

   My web searches found nothing specific for wxPython applications failing
to load.

   Where do I start looking for the reason? Stepping through the main module
with winpdb? Or, are there diagnostics I can put in the main frame or
notebook class to show me where the failure lies?

   This is a new situation for me. I need to learn how to respond.

Rich

Generated an error: SetSizeHints() needs to be overloaded:

$ ./openEDMS.py Traceback (most recent call last):
   File "./openEDMS.py", line 292, in <module>
     top = MainFrame('openEDMS')
   File "./openEDMS.py", line 27, in __init__
     self.SetSizeHints(self, minsize=wx.Size(300,200), maxSize=wx.Size(900,700), incSize=wx.Size(50,50))
TypeError: TopLevelWindow.SetSizeHints(): arguments did not match any overloaded call:
   overload 1: argument 1 has unexpected type 'MainFrame'
   overload 2: argument 1 has unexpected type 'MainFrame'

   How do I write a matching overloaded call? If the wx.Frame API methods
section has the answer I'm not seeing it.

Rich

···

On Tue, 24 Apr 2018, Rich Shepard wrote:

I invoke the main module and the shell prompt is immediately returned. No
errors, no application GUI displayed.

Rich Shepard wrote:

Generated an error: SetSizeHints() needs to be overloaded:

$ ./openEDMS.py Traceback (most recent call last):
File "./openEDMS.py", line 292, in <module>
top = MainFrame('openEDMS')
File "./openEDMS.py", line 27, in __init__
self.SetSizeHints(self, minsize=wx.Size(300,200),
maxSize=wx.Size(900,700), incSize=wx.Size(50,50))
TypeError: TopLevelWindow.SetSizeHints(): arguments did not match any
overloaded call:
overload 1: argument 1 has unexpected type 'MainFrame'
overload 2: argument 1 has unexpected type 'MainFrame'

How do I write a matching overloaded call? If the wx.Frame API methods
section has the answer I'm not seeing it.

You do not need to pass "self" as the first parameter. This is a Python
weirdness. When you write:
self.SetSizeHints( x, y, z )
that is the same as writing:
wx.Window.SetSizeHints( self, x, y, z )
so "self" is automatically passed as the first parameter.

Personally, I would call that a documentation bug, but it's not one that
can be easily corrected. For now, just know that when you see "self" as
the first parameter, you can satisfy that by calling it as a method on
the object.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Tim,

   Thanks for the lesson.

   Removing the prepended 'self.' still leaves an issue with the function:

$ ./openEDMS.py Traceback (most recent call last):
   File "./openEDMS.py", line 292, in <module>
     top = MainFrame('openEDMS')
   File "./openEDMS.py", line 27, in __init__
     SetSizeHints(self, minsize=wx.Size(300,200), maxSize=wx.Size(900,700), incSize=wx.Size(50,50))
NameError: name 'SetSizeHints' is not defined

   My understanding is that SetSizeHints() is supposed to provide initial
minimal and maximal size for the main frame. I thought the initial frame
size was provided in the wx.Frame() __init__; e.g.,

def __init__(self, parent, id=wx.ID_ANY, title="openEDMS",
                           size=wx.Size(700,400), style=wx.DEFAULT_FRAME_STYLE|
                           wx.TAB_TRAVERSAL, name = "MainFrame"):

   When I comment out that line there is neither an error traceback nor
display of the frame. There is no sizer in this class, only a status bar and
menus.

   I wonder if this wxFormBuilder-generated code is missing something. I can
send the entire 9k module (as an attachment) to the list or you for review.

Rich

···

On Tue, 24 Apr 2018, Tim Roberts wrote:

You do not need to pass "self" as the first parameter. This is a Python
weirdness. When you write:
self.SetSizeHints( x, y, z )
that is the same as writing:
wx.Window.SetSizeHints( self, x, y, z )
so "self" is automatically passed as the first parameter.

Personally, I would call that a documentation bug, but it's not one that
can be easily corrected. For now, just know that when you see "self" as
the first parameter, you can satisfy that by calling it as a method on the
object.

You removed the wrong ‘self’. Try this:

self.SetSizeHints(minsize=wx.Size(300,200), maxSize=wx.Size(900,700), incSize=wx.Size(50,50))

In general terms,

obj.methodName()

means that you want to call the method called methodName which is bound to obj, and obj will be received in the methodName method as the first parameter.

···

On Tuesday, April 24, 2018 at 11:55:05 AM UTC-7, Rich wrote:

Removing the prepended ‘self.’ still leaves an issue with the function:

$ ./openEDMS.py
Traceback (most recent call last):

File “./openEDMS.py”, line 292, in

 top = MainFrame('openEDMS')

File “./openEDMS.py”, line 27, in init

 SetSizeHints(self, minsize=wx.Size(300,200), maxSize=wx.Size(900,700), incSize=wx.Size(50,50))

NameError: name ‘SetSizeHints’ is not defined

Robin

You want to call the SetSizeHints() method of the instance of the top-level window, for example:

class MyFrame(wx.Frame):

def init(self, parent, size=(700, 400), style=wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL):
wx.Frame.init(self, parent, wx.ID_ANY, size=size, style=style, title=“openEDMS”, name=“MainFrame”)

self.SetSizeHints(minSize=(300, 200), maxSize=(900, 700), incSize=(50, 50))

I think what Tim was saying was that this gets translated internally to “wxFrameInstance.SetSizeHints(self, …)” so that the counting of arguments in the exception appears to be off by 1. But that is not something you should generally do yourself…

And the exception that proves this rule turns out to be right there in the call to wx.Frame.init(). This does include self as the first argument as it is calling the __init__ method of the parent class to initialize the instance. To be sure, that could have been written as

super(MyFrame, self).init(parent, wx.ID_ANY, size=size, …)

but I’m not sure that helps the discussion here. The point is that you need to initialize the instance of the object, then use self as the reference to the instance and call its methods with self.DoSomethingGreat.

···

On Tue, Apr 24, 2018 at 1:55 PM, Rich Shepard rshepard@appl-ecosys.com wrote:

On Tue, 24 Apr 2018, Tim Roberts wrote:

You do not need to pass “self” as the first parameter. This is a Python

weirdness. When you write:

self.SetSizeHints( x, y, z )

that is the same as writing:

wx.Window.SetSizeHints( self, x, y, z )

so “self” is automatically passed as the first parameter.

Personally, I would call that a documentation bug, but it’s not one that

can be easily corrected. For now, just know that when you see “self” as

the first parameter, you can satisfy that by calling it as a method on the

object.

Tim,

Thanks for the lesson.

Removing the prepended ‘self.’ still leaves an issue with the function:

$ ./openEDMS.py Traceback (most recent call last):

File “./openEDMS.py”, line 292, in

top = MainFrame('openEDMS')

File “./openEDMS.py”, line 27, in init

SetSizeHints(self, minsize=wx.Size(300,200), maxSize=wx.Size(900,700), incSize=wx.Size(50,50))

NameError: name ‘SetSizeHints’ is not defined

My understanding is that SetSizeHints() is supposed to provide initial

minimal and maximal size for the main frame. I thought the initial frame

size was provided in the wx.Frame() init; e.g.,

def init(self, parent, id=wx.ID_ANY, title=“openEDMS”,

                      size=wx.Size(700,400), style=wx.DEFAULT_FRAME_STYLE|

                      wx.TAB_TRAVERSAL, name = "MainFrame"):

When I comment out that line there is neither an error traceback nor

display of the frame. There is no sizer in this class, only a status bar and

menus.

I wonder if this wxFormBuilder-generated code is missing something. I can

send the entire 9k module (as an attachment) to the list or you for review.

Rich

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You removed the wrong 'self'.

Robin,

   Thank you. I missed that and should have known better.

Try this:
  self.SetSizeHints(minsize=wx.Size(300,200), maxSize=wx.Size(900,700),
incSize=wx.Size(50,50))

   This should be self.SetSizeHints(minSize...), but now the loading attempt
segfaults:

$ ./openEDMS.py

(openEDMS.py:14426): Gtk-CRITICAL **: gtk_widget_get_display: assertion
'GTK_IS_WIDGET (widget)' failed Segmentation fault

   Installed here I have:

gtk+2-2.24.31-i586-1_slack14.2
gtk+3-3.18.9-i586-1
gtk-xfce-engine-2.10.1-i586-2
gtkhtml-4.10.0-i586-1_SBo
gtkmm-2.24.4-i486-1_SBo
gtkmm2-2.24.4-i586-1
gtkmm3-3.18.1-i586-1
gtkspell-2.0.16-i586-3
libgtkhtml-2.11.1-i486-2
oxygen-gtk2-1.4.6-i586-2
pygtk-2.24.0-i586-2
webkit2gtk-2.20.1-i586-1_SBo
webkitgtk-2.4.11-i586-1_SBo
and
wxGTK3-3.0.4-i586-1_SBo

   What might I be missing?

Best regards,

Rich

···

On Tue, 24 Apr 2018, Robin Dunn wrote:

Matt,

   This is another instance where wxFormBuilder's code sent me off in the
wrong direction. My class initiation is not followed by a wx.Frame instance:

def __init__(self, parent, id=wx.ID_ANY, title="openEDMS",
                           size=wx.Size(700,400), style=wx.DEFAULT_FRAME_STYLE|
                           wx.TAB_TRAVERSAL, name = "MainFrame"):
         super().__init__()

         self.SetSizeHints(minSize=wx.Size(300,200),
               maxSize=wx.Size(900,700), incSize=wx.Size(50,50))

   I'll fix this now.

Many thanks,

Rich

···

On Tue, 24 Apr 2018, Matt Newville wrote:

You want to call the SetSizeHints() method of the instance of the top-level
window, for example:

class MyFrame(wx.Frame):
   def __init__(self, parent, size=(700, 400),
style=wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL):
        wx.Frame.__init__(self, parent, wx.ID_ANY, size=size, style=style,
title="openEDMS", name="MainFrame")

        self.SetSizeHints(minSize=(300, 200), maxSize=(900, 700),
incSize=(50, 50))

Rich Shepard wrote:

···

On Tue, 24 Apr 2018, Matt Newville wrote:

This is another instance where wxFormBuilder's code sent me off in the
wrong direction. My class initiation is not followed by a wx.Frame
instance:

def __init__(self, parent, id=wx.ID_ANY, title="openEDMS",
size=wx.Size(700,400),
style=wx.DEFAULT_FRAME_STYLE|
wx.TAB_TRAVERSAL, name = "MainFrame"):
super().__init__()

    self\.SetSizeHints\(minSize=wx\.Size\(300,200\),
              maxSize=wx\.Size\(900,700\), incSize=wx\.Size\(50,50\)\)

Not so, actually. If your class is derived from wx.Frame, then "super"
is just an alias for wx.Frame. This should work.

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.