help with TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

help with TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'

pythonist12
Hi, can anyone help me with this error .
I'm trying to make an contact manager to help me in my work as a blind person. The idea is create
data base to store all the phone and fax number I
needed in my work, but I have problem with the update method in Dialogs() class
I can't get the row.name scop variable to get the function work and I get the following error:
Traceback (most recent call last):
  File "E:\projects\data manager\skeliton\data manager\contact_manager.py", line
 118, in Onupdate
    old_name = MainPanel(MainFrame).getValue()
  File "E:\projects\data manager\skeliton\data manager\contact_manager.py", line
 136, in __init__
    wx.Panel.__init__(self, parent)
  File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_windows.py", line 68, in __
init__
    _windows_.Panel_swiginit(self,_windows_.new_Panel(*args, **kwargs))
TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'


--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

contact_manager.py (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: help with TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'

Tim Roberts
[hidden email] wrote:

> Hi, can anyone help me with this error .
> I'm trying to make an contact manager to help me in my work as a blind
> person. The idea is create
> data base to store all the phone and fax number I
> needed in my work, but I have problem with the update method in
> Dialogs() class
> I can't get the row.name scop variable to get the function work and I
> get the following error:
> Traceback (most recent call last):
>   File "E:\projects\data manager\skeliton\data
> manager\contact_manager.py", line
>  118, in Onupdate
>     old_name = MainPanel(MainFrame).getValue()
>   File "E:\projects\data manager\skeliton\data
> manager\contact_manager.py", line
>  136, in __init__
>     wx.Panel.__init__(self, parent)
>   File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_windows.py", line
> 68, in __
> init__
>     _windows_.Panel_swiginit(self,_windows_.new_Panel(*args, **kwargs))
> TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'
I'm not sure what you're trying to do in Onupdate, but the code you have
is wrong:
    old_name = MainPanel(MainFrame).getValue()
That line will create a brand new MainPanel, passing the "MainFrame"
class (not an INSTANCE of that class) as the first parameter.  That's
clearly wrong.  I don't think you are storing the "old name" anywhere;
perhaps you need to save a copy of it in your "setValues" function.

In several places, you have a similar problem when you write
DataOperation().table_name.  That creates a brand new object each time. 
Instead of that, you should create a single DataOperation() object and
store it in a member variable.  You even do that inside the
DataOperation class in the "insert" method, where you should use "self"
instead.

The SQL in Onupdate is also wrong.  You need to use parameter
substitution, just like you did in the INSERT calls above.  As it is,
your UPDATE call merely replaces the name, tel, and fax fields with
copies of their existing values.

I have attached something that makes these changes.  I don't have
ObjectListView, so I'm not sure this is entirely right, but it should
get you started.

--
Tim Roberts, [hidden email]
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

contact_manager.py (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: help with TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'

pythonist12
Hi thanks you for your reply, I tryed your file and it didn't work
my original code shows the error message when I press the update button only,
but with your file the error appears when I start the script .
What I want from the following line
    old_name = MainPanel(MainFrame).getValue()
is to get the value stored in the name variable from the getValue() function
and give it to old_name to complete the sql function UPDATE

I hope I made myself clear

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help with TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'

Rufus V. Smith

> On Sep 25, 2017, at 2:51 PM, [hidden email] wrote:
>
> Hi thanks you for your reply, I tryed your file and it didn't work
> my original code shows the error message when I press the update button only,
> but with your file the error appears when I start the script .
> What I want from the following line
>     old_name = MainPanel(MainFrame).getValue()
> is to get the value stored in the name variable from the getValue() function
> and give it to old_name to complete the sql function UPDATE
>
> I hope I made myself clear

One of the points you missed from that example was that this line:

> old_name = MainPanel(MainFrame).getValue()

is fundamentally flawed.  You can't get an existing value that way, because you
are creating a brand new MainPanel object, and getting whatever the default value is.
you should have a line during init such as:

        self.mainPanel = MainPanel(...)

then, later on, to get the value from it using:

        old_name = self.mainPanel.getValue()

Do you understand object constructors versus object references?

It's crucial.


--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help with TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'

Tim Roberts
In reply to this post by pythonist12
[hidden email] wrote:
> Hi thanks you for your reply, I tryed your file and it didn't work
> my original code shows the error message when I press the update
> button only,
> but with your file the error appears when I start the script .

WHAT error?  The code I sent you works on my machine (after I commented
out the ObjectListView references), so the fundamentals are correct.  It
looks like you and I use different philosophies in tabs vs spaces , but
I would hope you could fix that.


> What I want from the following line
>     old_name = MainPanel(MainFrame).getValue()
> is to get the value stored in the name variable from the getValue()
> function
> and give it to old_name to complete the sql function UPDATE

But "MainPanel" and "MainFrame" are not variables, and they are not
objects.  They are types.  That statement is just like writing this:
    old_name = list(unicode).getValue()

It's nonsense.  If you want to access members of your main panel object
from the Dialogs code, then you need to have a variable that contains
that object.  Now, as it happens, you do pass an instance of the
MainPanel to the Dialogs constructor (the "parent"), but right now you
are throwing that away.  If you were to store "parent" in a member
variable in Dialogs.__init__, then you could refer to it in
Dialogs.Onupdate.

However, my code shows a more efficient way of handling that, by just
remembering the original name when it is first handed to us.

--
Tim Roberts, [hidden email]
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help with TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'

pythonist12
Hi thank you
First now my code work after reading your comments on my code and after review and correct some errors in the code
second after you saw my code and the mistakes I made on it, can you suggest any internet resources to improve my python oop.


--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: help with TypeError: in method 'new_Panel', expected argument 1 of type 'wxWindow *'

pythonist12
In reply to this post by Rufus V. Smith
Hi thank you for your comment.
First now my code works
second after you saw my code and the mistakes I made on it, can you suggest any internet resources to improve my python oop.


--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.