2024-10-02 00:33:56 发布
网友
请不要使用Class,unuyu init,uuuyu,等等,因为这些都超出了我的知识和理解范围。基本上,如果有人能告诉我如何在相同的空白/缩进级别的代码中做到这一点,我将不胜感激。在
在windows上使用python3.4.3
谢谢
oystein hr为您提供解决方案,您可以使用它作为正常功能。在
示例基于Byan Oakley示例代码:https://stackoverflow.com/a/3794505/1832058
布莱恩·奥克利建议使用<<TreeviewSelect>>:https://stackoverflow.com/a/12064135/1832058
<<TreeviewSelect>>
import tkinter as tk from tkinter import ttk def OnDoubleClick(event): item = tree.selection() print('item:', item) print('event:', event) item = tree.selection()[0] print("you clicked on", tree.item(item,"text")) root = tk.Tk() tree = ttk.Treeview() tree.pack() for i in range(10): tree.insert("", "end", text="Item %s" % i) #tree.bind("<Double-1>", OnDoubleClick) # double click #tree.bind("<Button-1>", OnDoubleClick) # single click tree.bind("<<TreeviewSelect>>", OnDoubleClick) # single click, without "index out of range" error root.mainloop()
没有行“充当按钮”,因为您可以单击它来运行函数。在
oystein hr为您提供解决方案,您可以使用它作为正常功能。在
示例基于Byan Oakley示例代码:
https://stackoverflow.com/a/3794505/1832058
布莱恩·奥克利建议使用
<<TreeviewSelect>>
:https://stackoverflow.com/a/12064135/1832058没有行“充当按钮”,因为您可以单击它来运行函数。在
相关问题 更多 >
编程相关推荐