Python 2.7 error: Indentation error -


i working example file of tkinter layout. keep getting error boggling mind.

the code worked until inserted statements:

area.pack()  area.insert(end, "hello") 

then got error:

indentation error: unexpected indentation. 

ok, commented 2 statements out (as shown below), exact same code started with, worked fine- keep getting same error again. have played around few hours , can't grasp - im sure- simple thing triggering this. thoughts?

#!/usr/bin/python # -*- coding: utf-8 -*-  """ zetcode tkinter tutorial  in script, use grid manager create more complicated layout.  author: jan bodnar last modified: december 2010 website: www.zetcode.com """  tkinter import tk, text, both, w, n, e, s ttk import frame, button, label, style   class example(frame):      def __init__(self, parent):         frame.__init__(self, parent)             self.parent = parent          self.initui()      def initui(self):          self.parent.title("windows")         self.style = style()         self.style.theme_use("default")         self.pack(fill=both, expand=1)          self.columnconfigure(1, weight=1)         self.columnconfigure(3, pad=7)         self.rowconfigure(3, weight=1)         self.rowconfigure(5, pad=7)          lbl = label(self, text="windows")         lbl.grid(sticky=w, pady=4, padx=5)          area = text(self)         area.grid(row=1, column=0, columnspan=2, rowspan=4,              padx=5, sticky=e+w+s+n)          #area.pack()             #area.insert(end, "hello")          abtn = button(self, text="activate")         abtn.grid(row=1, column=3)          cbtn = button(self, text="close")         cbtn.grid(row=2, column=3, pady=4)          hbtn = button(self, text="help")         hbtn.grid(row=5, column=0, padx=5)          obtn = button(self, text="ok")         obtn.grid(row=5, column=3)           def main():      root = tk()     root.geometry("350x300+300+300")     app = example(root)     root.mainloop()     if __name__ == '__main__':     main()   

you're mixing tabs , spaces. don't :-) 1

for future reference, run code python -tt instead of python2. if mix tabs , spaces python -tt yell @ , tell fix rather giving strange indentation errors.


1don't in language. leads pain , suffering.
2i believe default behavior python3.x.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -