ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thank You For This!! I think it's Exactly what I wanted.
Code:
private void button1_Click(object sender, System.EventArgs e)
{
FormTwo handleData= FormTwo(txtUserInput.Text)
handleData.showDialog();
}
and in form 2 I have this constructor:
public FormTwo(String Data)
{
InitializeComponent();
viewData.text = Data;
}
It's the equivalent of doing this is C#, correct? Like the code I posted above? I create an instance of the subform, capture the string in the textbox of the parent form, and then using the constructor of the subform, set the variable.
You've done what no one on stackoverflow could do. They downvoted my question, and are voting on closing it. The reason? Too broad/good answers too long for this format! REALLY? On a coding forum!?!!? Stuff like this makes me think I should give up with stackoverflow anyway. I want to be/will later be a linux only user.
Glad to help you.
Hard to compare c# and python, but theoretically yes, the approach is the same: "using the constructor of the subform, set the variable".
If you really want to say thanks just click on YES.
Is that the proper practice in Python, when passing data between forms, to call the subform constructor?
I'm asking, because in my research of Python, I understand certain aspects of OOP are not used in Python, for example, protected/private variables. Using properties and decorators instead of getter and setter methods.
So ideally, how would a python programmer tackle the problem of passing data from a parent form to a subform? If the above isn't typically how it's done.
Last edited by Nexusfactor; 06-01-2015 at 05:42 PM.
hm. I would say you can use getter-setter in python too, that is a bit tricky (I mean to make a variable private), but not impossible.
When you create a new instance of an object (like subform) you can pass data using the constructor or by a special init function or also by setters, it depends on you. I would say it is quite similar in C++, java and python and c# of course.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.