473,715 Members | 5,945 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

paramter passing question

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.Fra me):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "")
win.Show(True)
*************** *************** *************** *************** ********

class MyFrame2(wx.Fra me):
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

Aug 4 '06 #1
2 1571
di********@gmai l.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.Fra me):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "")
win.Show(True)
*************** *************** *************** *************** ********

class MyFrame2(wx.Fra me):
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.Fra me):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "", sim_name=sim_na me)
win.Show(True)
*************** *************** *************** *************** ********

class MyFrame2(wx.Fra me):
def __init__(self, *args, **kwds):
.....
.....
self.sim_name=k wds.get('sim_na me', '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
Aug 5 '06 #2
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_F rame(*args, **kwargs)
TypeError: 'sim_name' is an invalid keyword argument for this function

Larry Bates wrote:
di********@gmai l.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.Fra me):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "")
win.Show(True)
*************** *************** *************** *************** ********

class MyFrame2(wx.Fra me):
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.Fra me):
def __init__(self, *args, **kwds):
.....
.....
def OnEdit(self, event):
sim_name = 'some_string'
win = MyFrame2(self, -1, "", sim_name=sim_na me)
win.Show(True)
*************** *************** *************** *************** ********

class MyFrame2(wx.Fra me):
def __init__(self, *args, **kwds):
.....
.....
self.sim_name=k wds.get('sim_na me', '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
Aug 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5207
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 parameter values passed to it. OK, here's the twist... I want to add some parameters to bFunc() from inside aFunc(). Can that be done?
1
1286
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, Sum(ViewOrdrelinjer.Subtotal) AS Total, OrdreStatus.Navn AS Status, Kunder.Firma FROM OrdreStatus INNER JOIN (Kunder INNER JOIN (Ordre INNER JOIN ViewOrdrelinjer ON Ordre.ID = ViewOrdrelinjer.OrdreID) ON Kunder.ID = Ordre.KundeID) ON OrdreStatus.ID =...
3
1176
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 URL. Can someone tell me the mechanism to do this? Thanks
5
1761
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 .Add("@City",SqlDbType.char).value = ByCity.SelectedValue end with objConn.Open() ZipCode.DataSource=objCmd.ExecuteReader
5
1408
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 function ) -Not looking for a big complicated question... ( dont waste a lot of ur time please ) I have been searching for the "Optional" parameter forever in VB.net I have found a pretty down to earth article on why NOT to use them....
9
2188
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 "/home/ottadca1/public_html/includes/leftnav.php?menuid=dave"; But the error is : Warning:
7
1758
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) {
3
1276
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 returned. Thanks Lance
0
2217
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 type list, process and return result. My question is: I like to be able to pass input parameter of type list into stored procedure and pars the list, process it and return result set. It is an SQL stored procedure (in DB2) that is called with in...
0
8821
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9103
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7973
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3175
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 we have to send another system
3
2118
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.