本文整理汇总了Python中PySide.QtWebKit.QWebView.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QWebView.setSizePolicy方法的具体用法?Python QWebView.setSizePolicy怎么用?Python QWebView.setSizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtWebKit.QWebView
的用法示例。
在下文中一共展示了QWebView.setSizePolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_browser_pane
# 需要导入模块: from PySide.QtWebKit import QWebView [as 别名]
# 或者: from PySide.QtWebKit.QWebView import setSizePolicy [as 别名]
def create_browser_pane(self, title):
# Create the pane widget
pane = QWidget()
layout = QVBoxLayout()
pane.setLayout(layout)
# Create a label for the title
title_bar = QLabel("")
# title_bar.setFixedHeight(32)
title_bar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
title_bar.show()
layout.addWidget(title_bar)
# Create the "address" box
address_bar = QLineEdit()
layout.addWidget(address_bar)
# todo: we could add some tool buttons here..
toolbar_layout = QHBoxLayout()
toolbar = QWidget()
toolbar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
toolbar.setLayout(toolbar_layout)
tool_stop = QPushButton()
tool_stop.setText('Stop')
toolbar_layout.addWidget(tool_stop)
tool_back = QPushButton()
tool_back.setText('Back')
toolbar_layout.addWidget(tool_back)
tool_forward = QPushButton()
tool_forward.setText('Forward')
toolbar_layout.addWidget(tool_forward)
tool_reload = QPushButton()
tool_reload.setText('Reload')
toolbar_layout.addWidget(tool_reload)
layout.addWidget(toolbar)
# Create the web view
web_view = QWebView()
web_view.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
layout.addWidget(web_view)
# Create a status bar
status_bar = QLabel("")
status_bar.setFixedHeight(32)
status_bar.show()
status_bar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
layout.addWidget(status_bar)
# Attach signal handlers
address_bar.editingFinished.connect(functools.partial(
self._addrbar_changed, address_bar, web_view))
web_view.loadStarted.connect(
lambda: status_bar.setText('Loading...'))
web_view.loadProgress.connect(
lambda p: status_bar.setText('Loading ({0}%)...'.format(p)))
web_view.loadFinished.connect(
lambda p: status_bar.setText('Ready.'.format(p)))
web_view.statusBarMessage.connect(status_bar.setText)
web_view.titleChanged.connect(title_bar.setText)
web_view.urlChanged.connect(functools.partial(
self._url_changed, web_view))
web_view.urlChanged.connect(
lambda url: address_bar.setText(url.toString()))
# Connect tool buttons
tool_stop.clicked.connect(web_view.stop)
tool_back.clicked.connect(web_view.back)
tool_forward.clicked.connect(web_view.forward)
tool_reload.clicked.connect(web_view.reload)
return {
'main': pane,
'layout': layout,
'title': title_bar,
'address': address_bar,
'web_view': web_view,
'status': status_bar,
}