I cannot figure out, how I'm able to get variable (dictionary) out from the class.
When the button "ETSI" is clicked, the code will get all inputs from the GUI window (type fields and checkboxes) that the user provided and creates a dictionary out of that data.
The problem is that I cannot figure out how to return that dictionary, from the class.
CODE:
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from PyQt5 import uic
import sys
class UI(QWidget):
def __init__(self):
super().__init__()
# --- Init window ------#
uic.loadUi("DesignerWindow/window.ui", self)
# --- Button action ------#
button = self.findChild(QPushButton, 'etsiButton')
# ---- Define action for the button ---#
button.clicked.connect(self.clicked_btn)
def clicked_btn(self):
resultList = {}
# Sijainti
sijaintiInput = self.sijaintiInput.text()
if sijaintiInput != "":
resultList ["sijainti"] = sijaintiInput
# Hinta
hintaInputMin = self.hintaInputMin.text()
if hintaInputMin != "":
resultList ["hintaMin"] = hintaInputMin
hintaInputMax = self.hintaInputMax.text()
if hintaInputMax != "":
resultList ["hintaMax"] = hintaInputMax
# Asuintilojen pinta-ala
atpInputMin = self.atpInputMin.text()
if atpInputMin != "":
resultList ["atpMin"] = atpInputMin
return resultList
# Execute
app = QApplication([])
window = UI()
window.show()
sys.exit(app.exec_())