Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import time
- import requests as r
- from PyQt6.QtWidgets import QApplication, QWidget
- from sign_in import SignIn
- from flow import Flow
- from threading import Thread
- class Client:
- def __init__(self):
- self.app = QApplication(sys.argv)
- self.in_call = False
- self.SignInForm = QWidget()
- self.FlowForm = QWidget()
- self.SignIn = SignIn()
- self.SignIn.setupUi(self.SignInForm)
- self.SignInForm.show()
- self.SignIn.pushButton.clicked.connect(self.initiate_authorization)
- def initiate_authorization(self):
- req = r.get('URL_HERE', auth=(self.SignIn.login.text(), self.SignIn.password.text()))
- if req.status_code == 200:
- self.login, self.password = self.SignIn.login.text(), self.SignIn.password.text()
- self.SignInForm.close()
- self.setup_flow()
- else:
- pass
- def setup_flow(self):
- self.Flow = Flow()
- self.Flow.setupUi(self.FlowForm)
- self.FlowForm.show()
- self.Flow.pushButton.clicked.connect(self.initiate_call)
- # Here is
- self.flow_cycle = Thread(target=self.flow) # the part I'm intested in the most
- self.flow_cycle.setDaemon(True)
- self.flow_cycle.start()
- # the function with "while: True"
- def flow(self):
- while not self.in_call:
- call = (r.get('https://autovoix.com/api/last-calls', auth=(self.login, self.password)).json())[0]
- called_number = call['called_number']
- self.Flow.label_3.setText(str(call['id']))
- self.Flow.label_4.setText(str(call['status']))
- time.sleep(10)
- self.FlowForm.close()
- # the function that I want to stop the first function.
- def initiate_call(self):
- self.in_call = True
- client = Client()
- sys.exit(client.app.exec())
Advertisement
Add Comment
Please, Sign In to add comment