I wrote a small app in wxPython using wxGlade as designer tool. wxGlade
brings and writes a lot of code by itself and thats where my confusion
started. Its about parameter passing. Here is my little confusion.
***************CODE BEGINS************************************
class MyFrame1(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "")
win.Show(True)
************************************************** ******************
class MyFrame2(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
def onLaunch(self, event):
## This function needs to use the parameter sim_name which is
in class MyFrame1-->OnEdit
***************CODE ENDS************************************
I want to pass sim_name parameter to MyFrame2 in def OnEdit function
but I don't know how to do it. I tried couple of things but always got
some error. I have done some parameter passing in normal Python code
but *args and **kwds is a little confusing.
Could you please tell me how to send parameter "sim_name" from
MyFrame1(in OnEdit function) and how to recieve it in MyFrame2 so that
I can use that parameter in MyFrame2 namespace.
Every help is appreciated.
Thanks 2 1555 di********@gmail.com wrote:
I wrote a small app in wxPython using wxGlade as designer tool. wxGlade
brings and writes a lot of code by itself and thats where my confusion
started. Its about parameter passing. Here is my little confusion.
***************CODE BEGINS************************************
class MyFrame1(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "")
win.Show(True)
************************************************** ******************
class MyFrame2(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
def onLaunch(self, event):
## This function needs to use the parameter sim_name which is
in class MyFrame1-->OnEdit
***************CODE ENDS************************************
I want to pass sim_name parameter to MyFrame2 in def OnEdit function
but I don't know how to do it. I tried couple of things but always got
some error. I have done some parameter passing in normal Python code
but *args and **kwds is a little confusing.
Could you please tell me how to send parameter "sim_name" from
MyFrame1(in OnEdit function) and how to recieve it in MyFrame2 so that
I can use that parameter in MyFrame2 namespace.
Every help is appreciated.
Thanks
How about using the keyword args to pass it:
class MyFrame1(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "", sim_name=sim_name)
win.Show(True)
************************************************** ******************
class MyFrame2(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
self.sim_name=kwds.get('sim_name', 'default sim_name')
def onLaunch(self, event):
## This function needs to use the parameter sim_name which is
## self.sim_name can be used here
-Larry Bates
It partly works but I get error printed out on the console.
Traceback (most recent call last):
File "NewProject.py", line 87, in OnEdit
win = MyFrame4(self, -1, "",sim_name=sim_name)
File "NewProject.py", line 1098, in __init__
wx.Frame.__init__(self, *args, **kwds)
File
"/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_windows.py",
line 476, in __init__
newobj = _windows_.new_Frame(*args, **kwargs)
TypeError: 'sim_name' is an invalid keyword argument for this function
Larry Bates wrote:
di********@gmail.com wrote:
I wrote a small app in wxPython using wxGlade as designer tool. wxGlade
brings and writes a lot of code by itself and thats where my confusion
started. Its about parameter passing. Here is my little confusion.
***************CODE BEGINS************************************
class MyFrame1(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "")
win.Show(True)
************************************************** ******************
class MyFrame2(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
def onLaunch(self, event):
## This function needs to use the parameter sim_name which is
in class MyFrame1-->OnEdit
***************CODE ENDS************************************
I want to pass sim_name parameter to MyFrame2 in def OnEdit function
but I don't know how to do it. I tried couple of things but always got
some error. I have done some parameter passing in normal Python code
but *args and **kwds is a little confusing.
Could you please tell me how to send parameter "sim_name" from
MyFrame1(in OnEdit function) and how to recieve it in MyFrame2 so that
I can use that parameter in MyFrame2 namespace.
Every help is appreciated.
Thanks
How about using the keyword args to pass it:
class MyFrame1(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "", sim_name=sim_name)
win.Show(True)
************************************************** ******************
class MyFrame2(wx.Frame):
def __init__(self, *args, **kwds):
.....
.....
self.sim_name=kwds.get('sim_name', 'default sim_name')
def onLaunch(self, event):
## This function needs to use the parameter sim_name which is
## self.sim_name can be used here
-Larry Bates
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve Neill |
last post by:
Here's an interesting problem...
I have 2 functions, aFunc() and bFunc(). I call aFunc() passing a call
to bFunc() as a parameter. Function aFunc() executes bFunc(). Function
bFunc() lists the...
|
by: Eirik Eldorsen |
last post by:
I've made a query which works fine. My problem is that Access ask for a
paramter value when I run the query, and I can't understand why.
The query:
SELECT Ordre.ID, Ordre.OpprettetDato,...
|
by: Randy |
last post by:
Hello,
I'm not sure if this is the place to post this, but...
In c#, I'm trying to find out how to grab a parameter from the incomming URL
using c#. I'm passing it in from another asp page in the...
|
by: tshad |
last post by:
I can't seem to find where to reset the parameter list.
Dim objCmd as New SqlCommand(CommandText,objConn)
with objCmd.Parameters
.Add("@StateCode",SqlDbType.Char,2).value = ByState.SelectedValue...
|
by: Miro |
last post by:
This qustion is probably for people who have created large apps with subs /
or functions that have
a lot of parameters and used in a lot of places in ur whole app. ( lets say
its ur own library...
| |
by: One |
last post by:
I have a main.php file that calls a php navigation menu.
I want to pass the menu file a parameter to tell it which menu to
display.
Inside the main.php I have :
include...
|
by: shanemh |
last post by:
I'm starting out with c++ and for some reason I cant get my brain
around this one:
If I have the following:
void Foo (someClass& x)
{}
int Main (void)
{
|
by: araman |
last post by:
i have a simple paramter query. one of the fields is called vendors.
the criteria is "Like
is there a way to construct the query in which "like "
but if it is left blank then all record are...
|
by: htenay |
last post by:
I need to be able to define an array in Java and pass it on to SQL stored procedure.
I am new to store proc and found a lot of helpful tutorials on Google but found none that passes parameter of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |