get textbox text value and store in a variable in ironpython WFP

Viewed 14

I want to get the inputted text to the textbox to a variable but I am failing big time. Uinsg Ironpython 2.7.9 .Net 4.0

class MyClass(Form):

def __init__(self):
    global PAM
    name = 0
    self.Text = 'Text Widget Demo'
    self.label = Label()
    self.label.Text = "This is text widget Demo"
    self.label.Location = Point(100, 150)
    self.label.Height = 50
    self.label.Width = 250
    self.textbox = TextBox()
    self.textbox.Text = str(PAM)
    self.textbox.Enabled = True
    self.textbox.Location = Point(50, 50)
    self.textbox.Width = 200
    self.Controls.Add(self.label)
    self.Controls.Add(self.textbox)
    #self.all_c.append(self.textbox.Text)
    PAM = self.textbox.Text
    self.but = Button()
    self.but.Text = 'Ok'
    self.but.Location = Point(75,75)
    self.but.Click += self.OnClick
    self.Controls.Add(self.but)
    return PAM
    
    
def OnClick(self,sender,args):
    MessageBox.Show(self.textbox.Text)
    #Close()
#def Close(self):
    #self.close()

#form = LabelDemoForm() dapp.Run(MyClass())

Windows 10

1 Answers

Hi so I figure it out with dumb luck it appears assigning a the value form the textbox has to be done after the click statement (this can be very wrong but it works)

so in the def OnClick(self, sender, args): text_retrieve = self.textbox.Text

and you can assign the value the user inputs to this variable "text_retrieve"

Related