Exemplo n.º 1
0
 def on_toolbDetect_toggled(self, widget):
     "Reload the list of local and detected devices"
     # Start the scanner thread
     if self.toolbDetect.get_active():
         self.spinnerScan.set_visible(True)
         self.spinnerScan.start()
         assert not self.thread_scanner
         self.thread_scanner = DaemonThread(self.do_scan, 'BTScanner')
         self.set_status_bar_message('Start new scan')
         self.thread_scanner.start()
     else:
         if self.thread_scanner:
             self.toolbDetect.set_sensitive(False)
             # Check if the scanner is still running and cancel it
             if self.thread_scanner.is_alive():
                 self.thread_scanner.cancel()
                 self.set_status_bar_message('Cancel running scan')
             else:
                 # The scanner thread has died for some error, we need to recover
                 # the UI to allow the user to launch the scanner again
                 print 'the thread has died, recovering the UI'
                 self.set_status_bar_message(
                     'The scanning thread has died, recovering the UI')
                 self.spinnerScan.stop()
                 self.spinnerScan.set_visible(False)
                 self.thread_scanner = None
                 self.toolbDetect.set_sensitive(True)