Add method to return some values
def getValues(self):
return value
popup = pbarpre.Popupedit()
if popup.exec_():
value = popup.getValues()
Pregunta
I have a Mainwindow and from there I'm calling a popup. The popup has to options to click. Now, how can I "return" the clicked option to my mainwindow?
I'm importing the file where the popup is to my main:
import pbarpre
[...]
def callpopup(self):
pbarpre.Popupedit()
[...]
pbarpre.py:
class Popupedit(QtGui.QDialog):
def __init__(self):
QtGui.QWidget.__init__(self)
self.ja = QtGui.QPushButton(u"Y")
self.ja.setFixedSize(90,25)
self.nein = QtGui.QPushButton(u"N")
self.nein.setFixedSize(90,25)
self.nein.clicked.connect(self.exit)
self.label = QtGui.QLabel(u"blablabla")
hbox = QtGui.QHBoxLayout()
hbox.addWidget(self.ja)
hbox.addWidget(self.nein)
vbox = QtGui.QVBoxLayout()
vbox.addWidget(self.label)
vbox.setAlignment(self.label, QtCore.Qt.AlignCenter)
vbox.addLayout(hbox)
self.setLayout(vbox)
self.setWindowTitle(u'?')
self.setFixedSize(300,100)
self.setWindowFlags(QtCore.Qt.Popup)
self.exec_()
def exit(self):
self.close()
Solución
Add method to return some values
def getValues(self):
return value
popup = pbarpre.Popupedit()
if popup.exec_():
value = popup.getValues()