if __name__ == '__main__':
edms = wx.App()
top = main_frame('openEDMS')
top = Show()
edms.MainLoop()
and Python3 tells me there's a error on the first 'top = ' line:
Traceback (most recent call last):
File "./openEDMS.py", line 297, in <module>
top = main_frame('openEDMS')
NameError: name 'main_frame' is not defined
When I read about wx.Frame I see that the name parameter is the internal
reference name for the class so I thought the above was correct. When I
replace the name with the class name I get a different error:
Traceback (most recent call last):
File "./openEDMS.py", line 296, in <module>
top = MainFrame('openEDMS')
TypeError: __init__() missing 1 required positional argument: 'title'
I've looked at the 4.0.1 demo, a couple of tutorials, and the 4.0.2a API
at <https://wxpython.org/Phoenix/docs/html/wx.Frame.html> yet still do not
see my error. I need to learn what I've done incorrectly between the
wx.Frame initialization and referencing it so the module runs.
if __name__ == '__main__':
edms = wx.App()
top = main_frame('openEDMS')
top = Show()
edms.MainLoop()
and Python3 tells me there's a error on the first 'top = ' line:
Traceback (most recent call last):
File "./openEDMS.py", line 297, in <module>
top = main_frame('openEDMS')
NameError: name 'main_frame' is not defined
Your class is named MainFrame not main_frame.
When I read about wx.Frame I see that the name parameter is the internal
reference name for the class so I thought the above was correct. When I
replace the name with the class name I get a different error:
Traceback (most recent call last):
File "./openEDMS.py", line 296, in <module>
top = MainFrame('openEDMS')
TypeError: __init__() missing 1 required positional argument: 'title'
I've looked at the 4.0.1 demo, a couple of tutorials, and the 4.0.2a API
at <https://wxpython.org/Phoenix/docs/html/wx.Frame.html> yet still do not
see my error. I need to learn what I've done incorrectly between the
wx.Frame initialization and referencing it so the module runs.
The TypeError is telling you the problem. Your class MainFrame takes two arguments in its __init__ method, parent and title. You've only passed one argument.
I thought the reference should be to the class name, not the internal
name. Thanks for confirming this.
The TypeError is telling you the problem. Your class MainFrame takes two
arguments in its __init__ method, parent and title. You've only passed one
argument.
Then I'm not seeing the type error. The class __init__ method specifies
the title:
When you are calling MainFrame() you are instantiating a class, which will call the __init__ method. You are only passing a single parameter to MainFrame() but you have defined MainFrame's __init__ to have two parameters, parent and title. You have to pass both.
You might want to brush up on Python classes here:
See the documentation about the __init__ method.
···
On Wed, 25 Apr 2018, Rich Shepard wrote:
The TypeError is telling you the problem. Your class MainFrame takes two
arguments in its __init__ method, parent and title. You've only passed one
argument.
Then I'm not seeing the type error. The class __init__ method specifies
the title:
edms = wx.App()
top = main_frame('openEDMS')
top = Show()
In addition to the class name and init notes, you likely want to use top.Show() here if you actually want to show the frame instead of calling some non-existent top-level Show function.
···
On Wednesday, April 25, 2018 at 3:12:01 PM UTC-7, Rich wrote:
When you are calling MainFrame() you are instantiating a class, which will
call the __init__ method. You are only passing a single parameter to
MainFrame() but you have defined MainFrame's __init__ to have two
parameters, parent and title. You have to pass both.
Thank you. It's been a long time since I used wxPython and I've forgotten
much more than I realized.
Best regards,
Rich
···
On Wed, 25 Apr 2018, Robin Dunn wrote:
if __name__ == '__main__':
edms = wx.App()
top = main_frame('openEDMS')
top = Show()
In addition to the class name and __init__ notes, you likely want to use
top.Show() here if you actually want to show the frame instead of calling
some non-existent top-level Show function.
I know your questions were answered, but I’m confused enough by this
statement that I’d like to explore it. You had this:
MainFrame IS the class name. That’s all Python knows. “main_frame”
is just a string that happens to be passed as a parameter to another
method call. The language doesn’t know anything about that. More,
that string won’t be seen until the class is instantiated, which can
only be done by using the Python class name.
The type error happens at the line where the error occurs:
top = MainFrame(‘openEDMS’)
This is just like calling a constructor in C++. It creates an
object, and calls the init method to initialize the object.
This is exactly the same as:
top = MainFrame.init( , ‘openEDMS’ )
Given that, you can see that you are missing the “parent” parameter
to your constructor.
···
Rich Shepard wrote:
On
Wed, 25 Apr 2018, Scott Talbert wrote:
Your class is named MainFrame not
main_frame.
I thought the reference should be to the class name, not the
and I just noticed that your __init__ takes 'title' as a (required)
parameter, and then you set the title to a hard-coded string later:
title='openEDMS',
you sure don't want to require a parameter your not going to use
-CHB
···
On Wed, Apr 25, 2018 at 5:51 PM, Tim Roberts <timr@probo.com> wrote:
MainFrame IS the class name. That's all Python knows. "main_frame" is
just a string that happens to be passed as a parameter to another method
call. The language doesn't know anything about that. More, that string
won't be seen until the class is instantiated, which can only be done by
using the Python class name.
The TypeError is telling you the problem. Your class MainFrame takes two
arguments in its __init__ method, parent and title. You've only passed one
argument.
Then I'm not seeing the type error. The class __init__ method specifies
the title:
..
but the type error is at the end of the module where there is no __init__
method, but a reference to the class name with the frame's title.
The type error happens at the line where the error occurs:
top = MainFrame('openEDMS')
This is just like calling a constructor in C++. It creates an object, and
calls the __init__ method to initialize the object. This is exactly the
same as:
top = MainFrame.__init__( <empty object>, 'openEDMS' )
Given that, you can see that you are missing the "parent" parameter to
your constructor.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
--
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.
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
and I just noticed that your __init__ takes 'title' as a (required)
parameter, and then you set the title to a hard-coded string later:
title='openEDMS',
you sure don't want to require a parameter your not going to use
In addition to the class name and __init__ notes, you likely want to use
top.Show() here if you actually want to show the frame instead of calling
some non-existent top-level Show function.
and I just noticed that your __init__ takes 'title' as a (required)
parameter, and then you set the title to a hard-coded string later:
title='openEDMS',
you sure don't want to require a parameter your not going to use