python - pyqt how to connect stop button -


i tried design pyqt gui in when press start initiates function fun1 , starts selenium script in funbrowser. , intended when press "stop", function funbrowser stops running regardless of control in funbrowser. , pyqt window should closed , program has stopped.but still printing "hi" using spyder windows 7 python 3.6 should connect button stop funbrowser stops.

class example(qwidget):     def __init__(self):         super().__init__()         self.initui()      def funbrowser(self,browser,details):         browser.get("https://fileml.com/l/0w5o")         time.sleep(1)         browser.switch_to.frame("offer-iframe")         elemlist=browser.find_elements_by_xpath("//ul/li/a")         list_of_names=[] #all present         in range(len(elemlist)):             list_of_names.append(str(elemlist[i].text))         print("\n")         print(list_of_names)         lon=len(list_of_names)*[0]         available=[] #all linked         in range(len(elemlist)):             if "register free" in elemlist[i].text:                 lon[i]="register"                 available.append("register")             if "health samples" in elemlist[i].text:                 lon[i]="health"                 available.append("health")         print("available",available)         print("lon",lon)         selected=random.choice(available)         print("selected ",selected)          clickon=lon.index(selected)         print(clickon)         elemlist[clickon].click()         alert = browser.switch_to.alert         alert.accept()          def fun1(self):         browser=webdriver.firefox()         self.funbrowser(browser,details)      def fun2(self):         import sys         self.hide()         quit()         print("..")      def launch_thread(self):         import threading         x=threading.thread(target=self.fun1)         x.start()      def initui(self):          self.setgeometry(300, 300, 300, 220)         self.setwindowtitle('icon')         self.setwindowicon(qicon('web.png'))                 self.layout=qtwidgets.qgridlayout()         self.btn1=qtwidgets.qpushbutton("start",self)         self.btn1.clicked.connect(self.launch_thread)         self.btn2=qtwidgets.qpushbutton("stop",self)         self.btn2.clicked.connect()         self.btn3=qtwidgets.qpushbutton("quit",self)         self.btn3.clicked.connect(self.close)         self.layout.addwidget(self.btn1,0,0)         self.layout.addwidget(self.btn2,0,1)         self.layout.addwidget(self.btn3,0,2)         self.setlayout(self.layout)         self.show() 

what function should have connec self.btn2("stop")


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -