【发布时间】:2019-12-29 04:46:48
【问题描述】:
我是 tkinter 的新手,我不能 100% 确定整个 frame、self 等是如何工作的。
我有这个:
class ScalesPage(Frame):
def GetNotes():
key = KeyEntry.get()
intervals = ScaleEntry.get()
WholeNotes = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B']*4
Root = WholeNotes.index(key)
Chromatic = WholeNotes[Root:Root+12]
print([Chromatic[i] for i in scales[intervals]])
def __init__(self, parent, controller):
Frame.__init__(self, parent)
global KeyEntry
KeyEntry = Entry(self)
KeyEntry.pack()
global ScaleEntry
ScaleEntry = Entry(self)
ScaleEntry.pack()
ScaleButtonEnter = Button(self, text="Enter", command=GetNotes)
ScaleButtonEnter.pack()
我正在尝试让ScaleButtonEnter 执行GetNotes(),但我不断收到错误
NameError: 名称“GetNotes”未定义
我假设我错过了一些简单的东西,但我对 tkinter 还不够熟悉,无法弄清楚。
【问题讨论】: