So I have made a popup that works properly. but now I need the function to wait until the popup is filled in. So I started a while loop that loops until the if statement != "empty". But somehow the popup is not working. QML is getting the variable that should start the popup but it's not opening. It's starting the popup when the while loop breaks or when it ends.
Main.qml
ApplicationWindow
{
property var openpopup: "" // this prints yes when console.log()
// connectie met de backend van python
Connections
{
target: backend
function onPopupemail(variable)
{ popupemail = variable}
}
}
Start_popup.qml
Button
{
onClicked:
{
backend.sendQuery() // this starts the sendQuery function
if(openpopup == "yes"){
popup.open()
}
}
}
Popup
{
id: popup
Button
{
onClicked:
{
popup.close()
backend.updateklantnaam(popupemail.text, klantnieuw.text)
// starts updateklantnaam
}
}
}
Funcy.py
global pauseloop, thread_popupemail, thread_popupname
pauseloop = False
thread_popupemail = ""
thread_popupname = ""
def sendQuery (self)
openpopup = "yes"
self.openpopup.emit(openpopup)
global pauseloop, thread_popupname, thread_popupemail
pauseloop = True
while pauseloop == True:
time.sleep(2)
if thread_popupemail != "" and thread_popupname != "":
cursor.execute "INSERT INTO " #insert query
conn.commit()
thread_popupemail = ""
thread_popupname = ""
pauseloop = False
break
print("break loop")
@pyqtSlot(str, str)
def updateklantnaam (self, popupemail, popupname):
global thread_popupname, thread_popupemail
thread_popupemail = popupemail
thread_popupname = popupname