我在使用StringVar()控制变量绑定事件(鼠标光标操作)时遇到问题。问题的一部分是我不知道如何将它们结合在一起
我想做的是获取我创建的矩形形状的名称并为其指定名称
class GraphicMap(Frame):
def __init__(self, master = None):
Frame.__init__(self, master)
............## lines of code
self.content = StringVar()
self.map.bind(("<Button-1>", self.bind)
def attrib(self, graphic):
self.name = graphic #name i will assign to rectangle shapes
................# lines of code
## i have created rectangle shapes on a canvas with different
names, using this method.
##now i would like to use this method for when i click on a shape, it
presents the self.name i have allocated.
def binding(self, event):
self.name = event.name
return event.name
def setContent(self):
self.content.set(self.name)
正如你们所看到的,我并没有正确地合并这个,它不能计算。关于我可能做错什么有什么帮助吗
您正在绑定到
self.bind
,但尚未定义self.bind
。由于您继承自Frame
,因此self.bind
是标准的bind
方法相关问题 更多 >
编程相关推荐