|
| 1 | +from PyQt5.QtCore import Qt,QObject, QThread, pyqtSignal |
| 2 | +from PyQt5.QtWidgets import QApplication, QSplitter,QPushButton, QWidget, QVBoxLayout, QMainWindow, QGridLayout, QLayout,QLabel,QToolBar,QToolButton |
| 3 | +from PyQt5.QtGui import QPalette, QColor |
| 4 | +from multiprocessing import Process,Queue,Pipe |
| 5 | + |
| 6 | +class Worker(QObject): |
| 7 | + signal = pyqtSignal(str) |
| 8 | + def __init__(self,queue): |
| 9 | + QObject.__init__(self) |
| 10 | + self.queue = queue |
| 11 | + def run(self): |
| 12 | + while True: |
| 13 | + text = self.queue.get() |
| 14 | + self.signal.emit(text) |
| 15 | + |
| 16 | +#<---------------------shared memory worker class--------------> |
| 17 | +# class Worker1(QObject): |
| 18 | +# from utils.wires.wire_str import read_string |
| 19 | +# from time import sleep |
| 20 | +# signal = pyqtSignal(str) |
| 21 | +# def __init__(self): |
| 22 | +# QObject.__init__(self) |
| 23 | +# def run(self): |
| 24 | +# while True: |
| 25 | +# txt = self.read_string("ERROR#LOG").get() |
| 26 | +# print(txt) |
| 27 | +# self.signal.emit(txt[0]) |
| 28 | +#______________________________________________________________> |
| 29 | + |
| 30 | +class Console(QMainWindow,QWidget,QObject): |
| 31 | + |
| 32 | + |
| 33 | + def __init__(self,fmqueue,msgQueue): |
| 34 | + def quitfn(self): |
| 35 | + msgQueue.put("#QUIT") |
| 36 | + super(Console, self).__init__() |
| 37 | + |
| 38 | + |
| 39 | + self.resize(800, 600) |
| 40 | + self.queue = fmqueue |
| 41 | + |
| 42 | + self.ToolBar = self.addToolBar(" ") |
| 43 | + self.addToolBar(Qt.BottomToolBarArea, self.ToolBar) |
| 44 | + self.quitBtn = QPushButton() |
| 45 | + self.quitBtn.move(50, 50) |
| 46 | + self.quitBtn.setText("Quit!") |
| 47 | + self.ToolBar.addWidget(self.quitBtn) |
| 48 | + self.quitBtn.clicked.connect(quitfn) |
| 49 | +#------------------------------------------------------------------------------------# |
| 50 | + self.console = QVBoxLayout() |
| 51 | + self.toolbar = QToolBar() |
| 52 | + self.toolbar.addWidget(QLabel("Console")) |
| 53 | + self.text_console = QLabel("") |
| 54 | + self.text_console.setAutoFillBackground(True) |
| 55 | + p = self.text_console.palette() |
| 56 | + p.setColor(self.text_console.backgroundRole(), Qt.black) |
| 57 | + self.text_console.setPalette(p) |
| 58 | + self.text_console.setAlignment(Qt.AlignLeft) |
| 59 | + |
| 60 | + self.console.addWidget(self.toolbar) |
| 61 | + self.console.addWidget(self.text_console) |
| 62 | + |
| 63 | + |
| 64 | + self.left = QWidget() |
| 65 | + self.left.setLayout(self.console) |
| 66 | +#------------------------------------------------------------------------------------# |
| 67 | + self.freqm = QVBoxLayout() |
| 68 | + self.toolbar2 = QToolBar() |
| 69 | + self.toolbar2.addWidget(QLabel("Frequency Monitor")) |
| 70 | + |
| 71 | + self.text_freq = QLabel("") |
| 72 | + self.text_freq.setAutoFillBackground(True) |
| 73 | + p2 = self.text_freq.palette() |
| 74 | + p2.setColor(self.text_freq.backgroundRole(), Qt.black) |
| 75 | + self.text_freq.setPalette(p2) |
| 76 | + self.text_freq.setAlignment(Qt.AlignLeft) |
| 77 | + |
| 78 | + self.freqm.addWidget(self.toolbar2) |
| 79 | + self.freqm.addWidget(self.text_freq) |
| 80 | + |
| 81 | + self.right = QWidget() |
| 82 | + self.right.setLayout(self.freqm) |
| 83 | +#------------------------------------------------------------------------------------# |
| 84 | + self.splitter = QSplitter(Qt.Horizontal) |
| 85 | + self.splitter.addWidget(self.left) |
| 86 | + self.splitter.addWidget(self.right) |
| 87 | + |
| 88 | + self.setCentralWidget(self.splitter) |
| 89 | + |
| 90 | +#------------------------------------------------------------------------------------# |
| 91 | + |
| 92 | + def loginfo_console(self, msg): |
| 93 | + txt = self.text_console.text() |
| 94 | + self.text_console.setText(txt+"\n"+msg) |
| 95 | + |
| 96 | + def loginfo_fm(self, msg): |
| 97 | + end = "END" |
| 98 | + txt = self.text_freq.text() |
| 99 | + self.text_freq.setText(txt+"\n"+msg) |
| 100 | + msg= msg.strip() |
| 101 | + if msg == end: |
| 102 | + self.text_freq.setText(" ") |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | +StyleSheet = ''' |
| 111 | +
|
| 112 | +/* QPushButton --------------------------------------------------------------- */ |
| 113 | +QPushButton { |
| 114 | + spacing: 30px; |
| 115 | + padding: 10px 50px; |
| 116 | + background-color: rgb(133, 131, 131); |
| 117 | + color: rgb(255,255,255); |
| 118 | + border-radius: 3px; |
| 119 | + margin-right:50px; |
| 120 | + subcontrol-position: right center; |
| 121 | +} |
| 122 | +QPushButton:selected { |
| 123 | + background-color: rgb(128, 128, 128); |
| 124 | +} |
| 125 | +QPushButton:pressed { |
| 126 | + background: rgb(255, 179, 179); |
| 127 | + color: rgb(255,0,0) |
| 128 | +} |
| 129 | +''' |
| 130 | + |
| 131 | + |
| 132 | +def set_theme(): |
| 133 | + palette = QPalette() |
| 134 | + palette.setColor(QPalette.Window, QColor(53, 53, 53)) |
| 135 | + palette.setColor(QPalette.WindowText, Qt.white) |
| 136 | + palette.setColor(QPalette.Base, QColor(25, 25, 25)) |
| 137 | + palette.setColor(QPalette.AlternateBase, QColor(53, 53, 53)) |
| 138 | + palette.setColor(QPalette.ToolTipBase, Qt.black) |
| 139 | + palette.setColor(QPalette.ToolTipText, Qt.white) |
| 140 | + palette.setColor(QPalette.Text, Qt.white) |
| 141 | + palette.setColor(QPalette.Button, QColor(53, 53, 53)) |
| 142 | + palette.setColor(QPalette.ButtonText, Qt.white) |
| 143 | + palette.setColor(QPalette.BrightText, Qt.red) |
| 144 | + palette.setColor(QPalette.Link, QColor(42, 130, 218)) |
| 145 | + palette.setColor(QPalette.Highlight, QColor(42, 130, 218)) |
| 146 | + palette.setColor(QPalette.HighlightedText, Qt.black) |
| 147 | + return palette |
| 148 | + |
0 commit comments