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 levelThis is my code:
self.refreshbutton = self.builder.get_object("refreshbutton") def on_refreshbutton_clicked(self, widget): print "refresh"Does anyone know what's wrong?
42 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
It looks like that the code is with the refresh function is not being run. Try indenting these highlighted lines an extra tab.
becomes
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