forked from thewayhj/psck_client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webChatFrame.py
39 lines (30 loc) · 1.4 KB
/
webChatFrame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from PyQt5 import QtWidgets
from PyQt5 import QtWebEngineWidgets
from PyQt5.QtCore import QPoint
from PyQt5.QtCore import QUrl
from PyQt5.QtCore import QUrlQuery
from MainFrame import MainFrame
from LoginFrame import LoginFrame
from Util import MyYaml
class WebChatFrame(LoginFrame):
url = "http://" + MyYaml.node_js_host + ":" + str(MyYaml.node_js_port)
#url = 'http://localhost:3000'
@staticmethod
def init(my_id = 'mw9027', oppenent_id = ''):
WebChatFrame.q_widget = QtWidgets.QWidget()
WebChatFrame.q_widget.show()
WebChatFrame.q_widget.setFixedSize(300, 600)
WebChatFrame.q_widget.move(MainFrame.mainwindow.mapToGlobal(QPoint(MainFrame.mainwindow.width()+1, -23)));
horizontalLayout = QtWidgets.QHBoxLayout(WebChatFrame.q_widget)
horizontalLayout.setContentsMargins(0, 0, 0, 0)
view = QtWebEngineWidgets.QWebEngineView(WebChatFrame.q_widget)
horizontalLayout.addWidget(view)
view.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.PluginsEnabled, True)
view.settings().setAttribute(QtWebEngineWidgets.QWebEngineSettings.JavascriptEnabled, True)
url = QUrl(WebChatFrame.url+'/chat?m_id='+my_id)
urldata = QUrlQuery()
urldata.addQueryItem('m_id', my_id)
urldata.addQueryItem('oppenent_id', oppenent_id)
url.setQuery(urldata)
view.setUrl(url)
view.show()