0

How to get values returned from the QDialog box to the another funtion.Here below code i want to get value of x_value in ValueRequiredFuntion() from x_value of the ValueInput().

#inside __init__()  
self.ui.pushButton.clicked.connect(self.ValueInput) 


def ValueInput(self):
    x_value, ok = QInputDialog.getDouble(self, "Change X Value","Enter the New Value", 0.0,0, 100, )

def ValueRequiredFuntion(self):
    #How to get x_value here.
Devenepali
  • 157
  • 3
  • 9
  • run `ValueRequiredFuntion(x_value)` inside `ValueInput()`. Or use `self.x_value` and it will be avaliable in all functions in this class. – furas Jul 05 '19 at 02:07

1 Answers1

1

You can use self. to have access to variable in all methods

def ValueInput(self):
    self.x_value, ok = QInputDialog.getDouble(...)

def ValueRequiredFuntion(self):
    print(self.x_value)

But you could also send it as argument if you will run it directly after you close dialog.

def ValueInput(self):
    x_value, ok = QInputDialog.getDouble(...)
    self.ValueRequiredFuntion(x_value)

def ValueRequiredFuntion(self, value):
    print(value)
furas
  • 134,197
  • 12
  • 106
  • 148