Python Forum

Full Version: Question regarding python pyqt script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've built my GUi using qt and converted it and with some help I feel I'm close on the script portion to get my python script working with the GUI but I have some questions.

So this is a converter GUI. Someone will click a tab to select fluid conversion for example then a radio button for ML-OZ vs OZ-ML there is a qlineedit box to enter the value and a qlineedit for the output of the calculation and a button to initial the convertion.

My two questions:
1. is my loggic right with this.

If ML_OZ.isChecked():
Volume = float(get lineedit8)
Answer = (Volume / 29.5735296)
print
I've built my GUi using qt and converted it and with some help I feel I'm close on the script portion to get my python script working with the GUI but I have some questions.

So this is a converter GUI. Someone will click a tab to select fluid conversion for example then a radio button for ML-OZ vs OZ-ML there is a qlineedit box to enter the value and a qlineedit for the output of the calculation and a button to initial the convertion.

My two questions:(Note:my code isn't complete I just want to make sure I'm on the right track with this first.)
1. is my loggic right with this.

def on_click(self.pushButton_5):
    If ML_OZ.isChecked():
        Volume = float(get lineedit8)
        Answer = (Volume / 29.5735296)
        print
    elif OZ_ML.isChecked():
2. Do I print "answer" to the qlineedit box or do I settext?

Hope this makes sense.
1. Will not work, because "Volume = float(get lineedit8)" will throw an error, also, why not just try "Answer = (int(lineedit8.text()) / 29.5735286)"?
2. "print" is a function for python console, not for PyQt, so you have to "lineedit8.setText(str(Answer))".