hi,
The MainForm will have 2 buttons:
1.) Button A :
User click button A, hide Mainform then go to form1. User enter data in the textbox.Click finish button,form1 close then go back to MainForm.
2.) Button B :
User Click Button B,hide Mainform then go to form2. Click a button & some mathematical operations will be done using all parameters that have been entered in form1.
My method of passing variable is:
* Before Finish button is click, Form1 pass variables to Mainform
* a function created in MainForm to receive variables
* Click button B, Mainform pass variables to form2
* a function created in Form2 to receive.
My problem now is the Mainform doesnt received any value from form1.Here's my code:
help! Can anyone spot my mistake?
The MainForm will have 2 buttons:
1.) Button A :
User click button A, hide Mainform then go to form1. User enter data in the textbox.Click finish button,form1 close then go back to MainForm.
2.) Button B :
User Click Button B,hide Mainform then go to form2. Click a button & some mathematical operations will be done using all parameters that have been entered in form1.
My method of passing variable is:
* Before Finish button is click, Form1 pass variables to Mainform
* a function created in MainForm to receive variables
* Click button B, Mainform pass variables to form2
* a function created in Form2 to receive.
My problem now is the Mainform doesnt received any value from form1.Here's my code:
Code:
[B]FORM 1 FINISH BUTTON CODE[/B] def FINISH(self, sender, e): #----Passing Variable to MainForm---- MainForm._a = int(self._txtbox1.Text) MainForm._b = int(self._txtbox2.Text) MainForm._c = int(self._txtbox3.Text) MainForm._d = int(self._txtbox4.Text) MainForm._e = float(self._txtbox5.Text) self.close() #CLOSE FORM1 [B]FUNCTION TO RECEIVE VARIABLE in MAINFORM[/B] #--Receive variable from Form1---- def variables(self): self._a = 0 self._b = 0 self._c = 0 self._d = 0 self._e = 0 [B]BUTTON B[/B] #----Passing Variable to FORM2---- def Model(self, sender, e): self.Hide() #hide MainForm form2 = Form2.Form2() ##-----Pass Variable to Form 2 Form2._a = self._a Form2._b = self._b Form2._c = self._c Form2._d = self._d Form2._e = self._e form2.ShowDialog() self.Show() [B]FUNCTION TO RECEIVE VARIABLE in FORM2[/B] def variables(self): self._a = 0 self._b = 0 self._c = 0 self._d = 0 self._e= 0
Comment