简体   繁体   English

如何添加后退按钮以返回上一页

[英]How to add a back button to go back to previous page

I'm currently new to Ubuntu programming, and learning the basic's of it. 我目前是Ubuntu编程的新手,正在学习它的基础知识。 I've been following this tutorial as some of you might know in previous questions asked about it I've made before. 我一直在关注本教程,因为你们中的某些人可能在以前问过的有关我以前提出的问题中知道。

Now, I've created a Web browser using 'quickly'. 现在,我已经使用“快速”创建了一个Web浏览器。 It's a simple program witch helps create programs on Ubuntu. 这是一个简单的程序,它可以帮助在Ubuntu上创建程序。 In the video It showed how to 'refresh' the page witch is basically this code: 在视频中,它显示了如何“刷新”页面女巫基本上是以下代码:

def on_refreshbutton_clicked(self, widget):  
    self.webview.reload()

Now, my question is to make the page go back from a previous page is it this code: 现在,我的问题是使该页面从上一页返回是该代码:

def on_refreshbutton_clicked(self, widget):
    self.webview.back()

I used 'refreshbutton' as a example, but if you would like to view the full source of the the code just ask for it and I'll provide you with a link with which you can view the source. 我以“ refreshbutton”为例,但是如果您想查看代码的完整源代码,只需索取它,我将为您提供一个链接,您可以使用该链接查看源代码。

*Code Edit from Mark R. - Thanks for the update. *来自Mark R的代码编辑。-感谢您的更新。

Create new button and give it label backbutton Than try to add this code to your py file. 创建新按钮并为其添加标签backbutton,然后尝试将此代码添加到py文件中。

def on_backbutton_clicked(self, widget):
    self.webview.go_back()

It will go back. 它将回去。 Also you can add forward button. 您也可以添加前进按钮。

def on_forwardbutton_clicked(self, widget):
    self.webview.go_forward()

I hope I am not too late. 希望我还不晚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM