Glam Prestige Journal

Bright entertainment trends with youth appeal.

I get this error:

Traceback (most recent call last): File "bin/mybrowser", line 32, in <module> import mybrowser File "/home/shaunyo/mybrowser/mybrowser/__init__.py", line 14, in <module> from mybrowser import MybrowserWindow File "/home/shaunyo/mybrowser/mybrowser/MybrowserWindow.py", line 32 def on_refreshbutton_clicked(self, widget): ^
IndentationError: unindent does not match any outer indentation level

This is my code:

 self.refreshbutton = self.builder.get_object("refreshbutton") def on_refreshbutton_clicked(self, widget): print "refresh"

Does anyone know what's wrong?

4

2 Answers

I think you should have your code like

<TAB> self.refreshbutton = self.builder.get_object("refreshbutton")
<TAB> def on_refreshbutton_clicked(self, widget):
<TAB> print "refresh"

in your editor give a TAB everytime while entering in a new line.

Ok @Shaun

I think your code should look like

frank@FRANK-NATHE:~$ cat h.py
self.refreshbutton = self.builder.get_object("refreshbutton")
def on_refreshbutton_clicked(self, widget): print "refresh"

so don't use a tab for the 1st and 2nd lines and then use a tab for the 3rd line

If you still get confused then

enter image description here

7

It looks like that the code is with the refresh function is not being run. Try indenting these highlighted lines an extra tab.

enter image description here

becomes

enter image description here

so that the code is run in the finish_initializing() function. Python is very particular with it's indentation

Note that the self.refreshbutton line is in line with the # Code for other... comment in the 2nd image

7

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy