本文整理汇总了Python中spyderlib.widgets.findreplace.FindReplace.show方法的典型用法代码示例。如果您正苦于以下问题:Python FindReplace.show方法的具体用法?Python FindReplace.show怎么用?Python FindReplace.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.widgets.findreplace.FindReplace
的用法示例。
在下文中一共展示了FindReplace.show方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WebBrowser
# 需要导入模块: from spyderlib.widgets.findreplace import FindReplace [as 别名]
# 或者: from spyderlib.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(QWebPage.Reload)
stop_button = pageact2btn(QWebPage.Stop)
previous_button = pageact2btn(QWebPage.Back)
next_button = pageact2btn(QWebPage.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)
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"""
text = to_text_string(self.url_combo.currentText())
#.........这里部分代码省略.........
示例2: WebBrowser
# 需要导入模块: from spyderlib.widgets.findreplace import FindReplace [as 别名]
# 或者: from spyderlib.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.zoom_factor = 1.0
self.webview = WebView(self)
self.connect(self.webview, SIGNAL("loadFinished(bool)"), self.load_finished)
self.connect(self.webview, SIGNAL("titleChanged(QString)"), self.setWindowTitle)
self.connect(self.webview, SIGNAL("urlChanged(QUrl)"), self.url_changed)
previous_button = create_toolbutton(
self, get_icon("previous.png"), tip=self.tr("Previous"), triggered=self.webview.back
)
next_button = create_toolbutton(self, get_icon("next.png"), tip=self.tr("Next"), triggered=self.webview.forward)
home_button = create_toolbutton(self, get_icon("home.png"), tip=self.tr("Home"), triggered=self.go_home)
zoom_out_button = create_toolbutton(
self, get_icon("zoom_out.png"), tip=self.tr("Zoom out"), triggered=self.zoom_out
)
zoom_in_button = create_toolbutton(
self, get_icon("zoom_in.png"), tip=self.tr("Zoom in"), triggered=self.zoom_in
)
refresh_button = create_toolbutton(self, get_icon("reload.png"), tip=self.tr("Reload"), triggered=self.reload)
stop_button = create_toolbutton(self, get_icon("stop.png"), tip=self.tr("Stop"), triggered=self.webview.stop)
stop_button.setEnabled(False)
self.connect(self.webview, SIGNAL("loadStarted()"), lambda: stop_button.setEnabled(True))
self.connect(self.webview, SIGNAL("loadFinished(bool)"), lambda: stop_button.setEnabled(False))
progressbar = QProgressBar(self)
progressbar.setTextVisible(False)
progressbar.hide()
self.connect(self.webview, SIGNAL("loadStarted()"), progressbar.show)
self.connect(self.webview, SIGNAL("loadProgress(int)"), progressbar.setValue)
self.connect(self.webview, SIGNAL("loadFinished(bool)"), progressbar.hide)
label = QLabel(self.get_label())
self.url_combo = UrlComboBox(self)
self.connect(self.url_combo, SIGNAL("valid(bool)"), self.url_combo_activated)
self.connect(self.webview, SIGNAL("iconChanged()"), 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="find.png", tip=translate("FindReplace", "Find text"), toggled=self.toggle_find_widget
)
self.connect(self.find_widget, SIGNAL("visibility_changed(bool)"), 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 self.tr("Address:")
def apply_zoom_factor(self):
"""Apply zoom factor"""
if hasattr(self.webview, "setZoomFactor"):
# Assuming Qt >=v4.5
self.webview.setZoomFactor(self.zoom_factor)
else:
# Qt v4.4
self.webview.setTextSizeMultiplier(self.zoom_factor)
def set_zoom_factor(self, zoom_factor):
"""Set zoom factor"""
self.zoom_factor = zoom_factor
self.apply_zoom_factor()
def get_zoom_factor(self):
"""Return zoom factor"""
return self.zoom_factor
def zoom_out(self):
#.........这里部分代码省略.........