Tkinter:"Bad label anchor specification"

Tkinter: "Bad label anchor specification"

我已经使用相同的 Python/Tkinter 代码工作了一个星期,但似乎莫名其妙地收到错误 "Bad label specification":

Traceback (most recent call last):
    File "C:/Users/shapirju/Desktop/NumericalAnalysis-Project2/gui.py", line 1188, in <module>
        gui = App()
    File "C:/Users/shapirju/Desktop/NumericalAnalysis-Project2/gui.py", line 62, in __init__
self.createWidgets()
    File "C:/Users/shapirju/Desktop/NumericalAnalysis-Project2/gui.py", line 70, in createWidgets
self.interpLabelframe = LabelFrame(self.root, text = "Interpolation", labelanchor=N)
    File "C:\Program Files\Python27\lib\lib-tk\ttk.py", line 776, in __init__
Widget.__init__(self, master, "ttk::labelframe", kw)
    File "C:\Program Files\Python27\lib\lib-tk\ttk.py", line 555, in __init__
Tkinter.Widget.__init__(self, master, widgetname, kw=kw)
    File "C:\Program Files\Python27\lib\lib-tk\Tkinter.py", line 2096, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: Bad label anchor specification 443664640LN

self.interpLabelframe = LabelFrame(self.root, text = "Interpolation", labelanchor=N)

行造成的

由于这在几个小时前就奏效了,也许这是一个环境问题?我在 Google.

上找不到关于此问题的任何信息

将其更改为 self.interpLabelframe = LabelFrame(self.root, text = "Interpolation", labelanchor='n') 可解决问题。

根据 source code for LabelFrame,标签锚定义为字符串 'n''we'