我正在開發與Tkinter reStructuredText編輯器。如果我運行下面的代碼,我得到IndentationError ..Python Tkinter不創建按鈕
from Tkinter import *
from tkFileDialog import asksaveasfile as savefile
class RSTkinter:
def __init__(self):
self.pencere_load()
self.araclar()
def pencere_load(self):
pencere.resizable(width=FALSE,height=FALSE)
pencere.title("RSTkinter")
def araclar(self):
h1 = Button(text=u"Başlıklar",command=self.h1p)
h1.place(rely=0.0)
..
..
topic = Button(text="Topic",command=self.topic_p) # ..topic:: başlık \n\t içerik
topic.place(rely=0.0,relx=0.63)
def topic_p(self):
topic = Toplevel()
topic.title("RSTkinter - Not")
topic.resizable(width=FALSE,height=FALSE)
topic.geometry("200x140")
topic_b_l = Label(topic,text=u"Topic başlığı: ")
topic_b_l.place(relx=0.0,rely=0.0)
self.topic_b = Text(topic)
self.topic_b.place(relx=0.3,rely=0.0,width=130)
topic_i_l = Label(topic,text=u"Topiç içeriği")
topic_i_l.place(relx=0.0,rely=0.4)
self.topic_i = Text(topic)
self.topic_i.place(relx=0.3,rely=0.5,width=130)
topic_y = Button(topic,text=u"Ekle",command=self.topic_yap)
topic_y.place(relx=0.0,rely=0.2)
def topic_yap(self):
return self.metin.insert(END,"\n.. topic:: %s \n\t%s"%(self.topic_b.get(1.0,END)),self.topic_i.get(1.0,END)))
pencere = Tk()
rst = RSTkinter()
mainloop()
完整的錯誤:
File "RSTkinter15.py", line 85
topic = Button(text="Topic",command=self.topic_p) #..^
IndentationError: unexpected indent
我該怎麼辦?
你是否在混合標籤和空格? [鏈接](http://stackoverflow.com/search?q= [python] IndentationError) – 2013-02-21 13:48:30