tello_qt.py
Go to the documentation of this file.
1 from __future__ import division, print_function, absolute_import
2 
3 import sys
4 from PyQt5.QtCore import Qt
5 from PyQt5 import uic, QtWidgets
6 from thread_qt import WifiThread
7 
8 qtCreatorFile = "mainwindow.ui"
9 Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)
10 
11 class MyApp(QtWidgets.QMainWindow, Ui_MainWindow):
12  def __init__(self):
13  QtWidgets.QMainWindow.__init__(self)
14  Ui_MainWindow.__init__(self)
15  self.setupUi(self)
16 
17  self.status_label.setAutoFillBackground(True)
18 
19  self.status_palette_connected = self.status_label.palette()
20  self.status_palette_connected.setColor(self.status_label.backgroundRole(), Qt.green)
21  self.status_palette_connected.setColor(self.status_label.foregroundRole(), Qt.black)
22 
23  self.status_palette_disconnected = self.status_label.palette()
24  self.status_palette_disconnected.setColor(self.status_label.backgroundRole(), Qt.yellow)
25  self.status_palette_disconnected.setColor(self.status_label.foregroundRole(), Qt.black)
26 
27  self.status_palette_paused = self.status_label.palette()
28  self.status_palette_paused.setColor(self.status_label.backgroundRole(), Qt.gray)
29  self.status_palette_paused.setColor(self.status_label.foregroundRole(), Qt.black)
30 
32  self.wifi_thread.updated.connect(self.handler)
33  self.wifi_thread.start()
34 
35  def handler(self):
36  if self.wifi_thread.wifi_active:
37  text = self.wifi_thread.wifi_ssid
38  palette = self.status_palette_connected
39  else:
40  text = 'no connection'
41  palette = self.status_palette_disconnected
42 
43  self.status_label.setPalette(palette);
44  self.status_label.setText(text)
45 
46 if __name__ == "__main__":
47  app = QtWidgets.QApplication(sys.argv)
48  window = MyApp()
49  window.show()
50  sys.exit(app.exec_())
def __init__(self)
Definition: tello_qt.py:12
Ui_MainWindow
Definition: tello_qt.py:9
status_palette_connected
Definition: tello_qt.py:19
status_palette_disconnected
Definition: tello_qt.py:23
def handler(self)
Definition: tello_qt.py:35


tello_driver
Author(s): Jordy van Appeven
autogenerated on Wed May 13 2020 03:34:54