MCPcopy Index your code
hub / github.com/PyQt5/PyQt / __init__

Method __init__

QWebChannel/CallEachWithJs.py:24–42  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

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())

Callers

nothing calls this directly

Calls 4

WebChannelObjectClass · 0.90
registerObjectMethod · 0.80
addWidgetMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected