鱼C论坛

 找回密码
 立即注册
查看: 771|回复: 2

[已解决]P75讲问题

[复制链接]
发表于 2020-4-13 19:52:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
from tkinter import *

root=Tk()

def callback(event):
    print("点击位置",event_x,event_y)

frame=Frame(root,width=200,height=200)
frame.bind('<Button-1>',callback)
frame.pack()

mainloop()


Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\ASUS\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "C:\Users\ASUS\Desktop\75-1.py", line 6, in callback
    print("点击位置",event_x,event_y)
NameError: name 'event_x' is not defined
最佳答案
2020-4-13 19:59:29

from tkinter import *

root=Tk()

def callback(event):
    print("点击位置",event.x,event.y)

frame=Frame(root,width=200,height=200)
frame.bind('<Button-1>',callback)
frame.pack()

mainloop()



是event.x和event.y 求最佳
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-4-13 19:59:29 | 显示全部楼层    本楼为最佳答案   

from tkinter import *

root=Tk()

def callback(event):
    print("点击位置",event.x,event.y)

frame=Frame(root,width=200,height=200)
frame.bind('<Button-1>',callback)
frame.pack()

mainloop()



是event.x和event.y 求最佳
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-4-13 20:01:34 | 显示全部楼层
我也是学tkinter的

同行
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-9-21 09:05

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表