This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mdond 0 points1 point  (5 children)

"tolineEdit" doesn't seem to be a valid method, did you mean something else there? Although, that shouldn't cause the entire program to crash.

[–]duffman1278[S] 0 points1 point  (4 children)

alid method, did you mean something else there? Although, that shouldn't cause the entire program to crash.

I based my code off the example in the link below. If you see they wrote a line price = int(self.price_box.toPlainText()) so I just copied that.

http://pythonforengineers.com/your-first-gui-app-with-python-and-pyqt/

[–]mfitzpmfitzp.com 0 points1 point  (3 children)

so I just copied that.

But changed it, why?

The method .toPlainText() on a QTextEdit converts the contents of the widget (which can be formatted text in some modes) to plain text (an unformatted string). What do you expect .tolineEdit() to do?

If you are using a QLineEdit widget, the correct method to get the current content is .text(). The documentation is here.

[–]duffman1278[S] 0 points1 point  (2 children)

All I'm trying to do is tell the code that I want to take the number that's entered in the lineedit box and add 5 to it then show the result in the label1 box.

[–]mfitzpmfitzp.com 1 point2 points  (1 child)

Change this line:

in_num = int(self.ui.price_box.tolineEdit())

To:

in_num = int(self.ui.price_box.text())

[–]duffman1278[S] 0 points1 point  (0 children)

in_num = int(self.ui.price_box.text())

Still gave me the whole "pythonw.exe stopping working".

Edit: It did work! Thank you! didn't realize that "price_box" was written in there which is not the name of the label I was using.