Python .net Winforms - How To Pass Info From A Textbox To A Button Click Event
Before I get into my question, I am (self) learning how Python and the .NET CLR interact with each other. It has been a fun, yet, at times, a frustrating experience. With that said
Solution 1:
txt
is a local variable in __init__
, meaning that you can't access it from any other function. To fix it, make it an instance variable by attaching it to self
(which refers to the instance itself):
self.txt = TextBox()
self.txt.Parent = self
self.txt.Location = Point(lbl.Left - 1, lbl.Bottom + 2) # From Left, From Top
and
defbuttonPressed(self, sender, args):
MessageBox.Show('This works.')
MessageBox.Show(self.txt.Text) # Now this does too
Post a Comment for "Python .net Winforms - How To Pass Info From A Textbox To A Button Click Event"