olivebot/gui/window.py
xszyou 55fb0896b8 2023.01
Fay2.0:
1、控制器pc内网穿透,音频输入输出设备远程直连;
2、提供android 音频输入输出工程示例代码;
3、提供python音频输入输出工程示例代码(远程PC、树莓派等可用);
4、补传1.0语音指令音乐播放模块(暂不支持远程播放);
5、重构及补充若干工具模块:websocket、多线程、缓冲器、音频流录制器等;
6、修复1.x版本的多个bug。
2023-01-31 12:40:36 +08:00

82 lines
2.6 KiB
Python

import os
import time
from PyQt5.QtWidgets import *
from PyQt5.QtWidgets import QDialog, QHBoxLayout, QVBoxLayout
from PyQt5.QtWidgets import QGroupBox
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtCore import *
from PyQt5 import QtWidgets
from scheduler.thread_manager import MyThread
class MainWindow(QMainWindow):
SigSendMessageToJS = pyqtSignal(str)
def __init__(self):
super(MainWindow, self).__init__()
# self.setWindowFlags(Qt.WindowType.WindowShadeButtonHint)
self.setWindowTitle('FeiFei Alpha')
# self.setFixedSize(16 * 80, 9 * 80)
self.setGeometry(0, 0, 16 * 70, 9 * 70)
self.showMaximized()
# self.center()
self.browser = QWebEngineView()
self.browser.load(QUrl('http://127.0.0.1:5000'))
self.setCentralWidget(self.browser)
MyThread(target=self.runnable).start()
def runnable(self):
while True:
if not self.isVisible():
# try:
# wsa_server.get_instance().stop_server()
# wsa_server.get_web_instance().stop_server()
# thread_manager.stopAll()
# except BaseException as e:
# print(e)
os.system("taskkill /F /PID {}".format(os.getpid()))
time.sleep(0.05)
def center(self):
screen = QtWidgets.QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
def keyPressEvent(self, event):
pass
# if event.key() == Qt.Key_F12:
# self.s = TDevWindow()
# self.s.show()
# self.browser.page().setDevToolsPage(self.s.mpJSWebView.page())
def OnReceiveMessageFromJS(self, strParameter):
if not strParameter:
return
class TDevWindow(QDialog):
def __init__(self):
super(TDevWindow, self).__init__()
self.init_ui()
def init_ui(self):
self.mpJSWebView = QWebEngineView(self)
self.url = 'https://www.baidu.com/'
self.mpJSWebView.page().load(QUrl(self.url))
self.mpJSWebView.show()
self.pJSTotalVLayout = QVBoxLayout()
self.pJSTotalVLayout.setSpacing(0)
self.pJSTotalVLayout.addWidget(self.mpJSWebView)
self.pWebGroup = QGroupBox('Web View', self)
self.pWebGroup.setLayout(self.pJSTotalVLayout)
self.mainLayout = QHBoxLayout()
self.mainLayout.setSpacing(5)
self.mainLayout.addWidget(self.pWebGroup)
self.setLayout(self.mainLayout)
self.setMinimumSize(800, 800)