Reputation: 1
I started creating my first GUI with PyQt4 a few hours ago and I've caught a snag. I've researched all over the web and while some resources have come close they've never really answered my question.
Basically I want to know if it is possible to take user input text from a widget and store that text into a variable from a button click.
So far I have looked into QLineEdit methods but have not found what I am looking for. Is there a better way to accomplish this?
Upvotes: 0
Views: 957
Reputation: 34116
Maybe something like this?
...
def __init__(self):
...
self.button.clicked.connect(self.on_button_click)
...
def on_button_click(self):
self.variable = self.line_edit.text()
print(self.variable)
...
Upvotes: 3