MCPcopy Create free account
hub / github.com/PyQt5/PyQt / Window

Class Window

QWebChannel/CallEachWithJs.py:22–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21
22class Window(QWidget):
23
24 def __init__(self, *args, **kwargs):
25 super(Window, self).__init__(*args, **kwargs)
26 self.m_obj = WebChannelObject(self)
27 # 注册该窗口,可以访问该窗口的属性,槽函数,信号
28 # https://doc.qt.io/qt-5/qwidget.html#properties
29 # https://doc.qt.io/qt-5/qwidget.html#signals
30 # https://doc.qt.io/qt-5/qwidget.html#public-slots
31 self.m_obj.registerObject('qtwindow', self)
32 self.m_obj.start()
33
34 layout = QVBoxLayout(self)
35 self.editTitle = QLineEdit(self, placeholderText='输入标题')
36 layout.addWidget(self.editTitle)
37 layout.addWidget(QPushButton('修改标题', self, clicked=self.onChangeTitle))
38
39 QDesktopServices.openUrl(
40 QUrl.fromLocalFile(
41 os.path.join(os.path.dirname(sys.argv[0] or __file__),
42 'Data/CallEachWithJs.html')))
43
44 def onChangeTitle(self):
45 self.setWindowTitle(self.editTitle.text())
46
47 # ------- 把非槽函数通过pyqtSlot重新暴露 -------
48 @pyqtSlot(int, int)
49 def resize(self, width, height):
50 super().resize(width, height)
51
52
53if __name__ == '__main__':

Callers 1

CallEachWithJs.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected