MCPcopy Create free account
hub / github.com/cztomczak/cefpython / setupLayout

Method setupLayout

examples/qt.py:152–189  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

150 self.setupLayout()
151
152 def setupLayout(self):
153 self.resize(WIDTH, HEIGHT)
154 self.cef_widget = CefWidget(self)
155 self.navigation_bar = NavigationBar(self.cef_widget)
156 layout = QGridLayout()
157 # noinspection PyArgumentList
158 layout.addWidget(self.navigation_bar, 0, 0)
159 # noinspection PyArgumentList
160 layout.addWidget(self.cef_widget, 1, 0)
161 layout.setContentsMargins(0, 0, 0, 0)
162 layout.setSpacing(0)
163 layout.setRowStretch(0, 0)
164 layout.setRowStretch(1, 1)
165 # noinspection PyArgumentList
166 frame = QFrame()
167 frame.setLayout(layout)
168 self.setCentralWidget(frame)
169
170 if (PYSIDE2 or PYQT5) and WINDOWS:
171 # On Windows with PyQt5 main window must be shown first
172 # before CEF browser is embedded, otherwise window is
173 # not resized and application hangs during resize.
174 self.show()
175
176 # Browser can be embedded only after layout was set up
177 self.cef_widget.embedBrowser()
178
179 if (PYSIDE2 or PYQT5) and LINUX:
180 # On Linux with PyQt5 the QX11EmbedContainer widget is
181 # no more available. An equivalent in Qt5 is to create
182 # a hidden window, embed CEF browser in it and then
183 # create a container for that hidden window and replace
184 # cef widget in the layout with the container.
185 # noinspection PyUnresolvedReferences, PyArgumentList
186 self.container = QWidget.createWindowContainer(
187 self.cef_widget.hidden_window, parent=self)
188 # noinspection PyArgumentList
189 layout.addWidget(self.container, 1, 0)
190
191 def closeEvent(self, event):
192 # Close browser (force=True) and free CEF reference

Callers 1

__init__Method · 0.95

Calls 3

CefWidgetClass · 0.85
embedBrowserMethod · 0.80
NavigationBarClass · 0.70

Tested by

no test coverage detected