本文整理汇总了Python中spyder.widgets.findreplace.FindReplace.show方法的典型用法代码示例。如果您正苦于以下问题:Python FindReplace.show方法的具体用法?Python FindReplace.show怎么用?Python FindReplace.show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyder.widgets.findreplace.FindReplace
的用法示例。
在下文中一共展示了FindReplace.show方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WebBrowser
# 需要导入模块: from spyder.widgets.findreplace import FindReplace [as 别名]
# 或者: from spyder.widgets.findreplace.FindReplace import show [as 别名]
class WebBrowser(QWidget):
"""
Web browser widget
"""
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.home_url = None
self.webview = WebView(self)
self.webview.loadFinished.connect(self.load_finished)
self.webview.titleChanged.connect(self.setWindowTitle)
self.webview.urlChanged.connect(self.url_changed)
home_button = create_toolbutton(self, icon=ima.icon('home'),
tip=_("Home"),
triggered=self.go_home)
zoom_out_button = action2button(self.webview.zoom_out_action)
zoom_in_button = action2button(self.webview.zoom_in_action)
pageact2btn = lambda prop: action2button(self.webview.pageAction(prop),
parent=self.webview)
refresh_button = pageact2btn(QWebEnginePage.Reload)
stop_button = pageact2btn(QWebEnginePage.Stop)
previous_button = pageact2btn(QWebEnginePage.Back)
next_button = pageact2btn(QWebEnginePage.Forward)
stop_button.setEnabled(False)
self.webview.loadStarted.connect(lambda: stop_button.setEnabled(True))
self.webview.loadFinished.connect(lambda: stop_button.setEnabled(False))
progressbar = QProgressBar(self)
progressbar.setTextVisible(False)
progressbar.hide()
self.webview.loadStarted.connect(progressbar.show)
self.webview.loadProgress.connect(progressbar.setValue)
self.webview.loadFinished.connect(lambda _state: progressbar.hide())
label = QLabel(self.get_label())
self.url_combo = UrlComboBox(self)
self.url_combo.valid.connect(self.url_combo_activated)
if not WEBENGINE:
self.webview.iconChanged.connect(self.icon_changed)
self.find_widget = FindReplace(self)
self.find_widget.set_editor(self.webview)
self.find_widget.hide()
find_button = create_toolbutton(self, icon=ima.icon('find'),
tip=_("Find text"),
toggled=self.toggle_find_widget)
self.find_widget.visibility_changed.connect(find_button.setChecked)
hlayout = QHBoxLayout()
for widget in (previous_button, next_button, home_button, find_button,
label, self.url_combo, zoom_out_button, zoom_in_button,
refresh_button, progressbar, stop_button):
hlayout.addWidget(widget)
layout = QVBoxLayout()
layout.addLayout(hlayout)
layout.addWidget(self.webview)
layout.addWidget(self.find_widget)
self.setLayout(layout)
def get_label(self):
"""Return address label text"""
return _("Address:")
def set_home_url(self, text):
"""Set home URL"""
self.home_url = QUrl(text)
def set_url(self, url):
"""Set current URL"""
self.url_changed(url)
self.go_to(url)
def go_to(self, url_or_text):
"""Go to page *address*"""
if is_text_string(url_or_text):
url = QUrl(url_or_text)
else:
url = url_or_text
self.webview.load(url)
@Slot()
def go_home(self):
"""Go to home page"""
if self.home_url is not None:
self.set_url(self.home_url)
def text_to_url(self, text):
"""Convert text address into QUrl object"""
return QUrl(text)
def url_combo_activated(self, valid):
"""Load URL from combo box first item"""
#.........这里部分代码省略.........