- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在互联网上找到了源代码一个简单的程序,用于创建带有选项的窗口从键盘输入数学运算并显示结果。这是代码:
import tkinter as tk
from math import *
def evaluate(event):
res.configure(text="Result: " + str(eval(entry.get())))
w = tk.Tk()
tk.Label(w, text="Your Expression:").pack()
entry = tk.Entry(w)
entry.bind("event", evaluate)
entry.pack()
res = tk.Label(w)
res.pack()
w.mainloop()
我收到错误:
C:\Users\rob\PycharmProjects\untitled2\venv\Scripts\python.exe "C:/Users/rob/Desktop/new test.py" Traceback (most recent call last): File "C:/Users/rob/Desktop/new test.py", line 12, in entry.bind("", evaluate) File "C:\Users\rob\AppData\Local\Programs\Python\Python37\lib\tkinter__init__.py", line 1248, in bind return self._bind(('bind', self._w), sequence, func, add) File "C:\Users\rob\AppData\Local\Programs\Python\Python37\lib\tkinter__init__.py", line 1203, in _bind self.tk.call(what + (sequence, cmd)) _tkinter.TclError: no events specified in binding
请帮忙。我开始学习 Python,但我不知道解决方案。
最佳答案
您报告的错误很清楚,
“...绑定(bind)中未指定事件”
改变这个
entry.bind('<event>', evaluate)
有了这个
entry.bind("<Return>",evaluate)
关于python - 如何修复 "- _tkinter.TclError: no events specified in binding",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56343229/
我查阅了CustomTkinter的文档,它似乎没有内置对使用SizeNotifier的响应式布局的支持。如何在没有“SizeNotifier”的情况下在CustomTkinter应用程序中实现响应式
我带着一个新的错误回到这里,我不能解决...这是一个奇怪的错误,idk,我把图像在同一目录的程序,在目录中指定的代码.啊,我不知道,但这是所有的代码:。我希望这对你来说足够了..。我很沮丧,我把图像放
我知道您会说这是重复的,但事实并非如此。我收到错误: Traceback (most recent call last): File "calculator.py", line 1, in from
所有教程都简单import tkinter , 不过,我想知道为什么不 import _tkinter ?如果我的理解是正确的,_tkinter是 cpython 和 tkinter 中的实际库是接口
我正在尝试在 Predix 上推送 Python 微服务。 该代码具有 matplotlib 依赖性。 对于具有以下堆栈跟踪的应用程序, cf Push 失败。 2017-05-08T19:39:51
这个问题已经有答案了: "UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot s
我想在c++代码中使用python,但是出现错误,这是最简单的“hello word”程序。 导入PIL.Image是可以的,但是对于Tkinter,它会输出“ImportError: No modu
我知道这个问题已经被问过好几次了,但我还是想不出我的问题的答案。我不断收到同样的错误,但不知道如何解决。 这是我的代码: from Tkinter import * from PIL import I
这个问题在这里已经有了答案: python ImportError: No module named Tkinter (5 个答案) 关闭 3 年前。 在我的 Linux Mint 18 上,我试图
我正在使用 python 2.7.2 和 windows 7。我搜索了互联网、帮助和其他资源,但我找不到我的问题的答案。 我的一个源导入 tkinter,而这个导入 _tkinter。此时它说 Imp
我在我的 Linux 上使用 Page GUI 构建器创建了一个 gui。它有一个框架和一个 Canvas 。我正在尝试在其中一个框架上播放视频。现在,当我运行代码时,我收到 _tkinter.Tcl
在我的 python 应用程序中,我使用 matplotlib。当我开始运行时,它会抛出一个错误: ImportError: No named '_tkinter', please install t
一位 friend 发给我一些 Tkinter/Tix 代码,但它是针对 Python 2 的: from Tkinter import * import Tix import ScrolledTex
我一直在搜索它,但在网上找不到关于这个主题的任何内容。 当我在 python 3.5 中开发导入 tkinter 或 pyglet 的程序时,我完全能够从我的 Linux Mint 安装上的命令行启动
我遇到了与许多其他问题相同的问题,但尚未找到有效的解决方案。这是在 Windows 10 64 位、Python 3.6 32 位上。 我试过多次卸载,64 位 Python,安装文件中路径和变量的各
我正在尝试使用 pyenv 安装版本的 python 3.6.5 在 RHEL 上使用 Matplotlib。 (使用以下命令安装) → pyenv install 3.6.5 Installing
我有一些旧的 Python 脚本,它们使用了与当前系统所配备的不同版本的 tkinter。在过去,有一个名为 _tkinter.createfilehandler() 的方法存在并且有效。对于当前版本
我想在菜单栏上显示一个图标,所以使用这个 information ,我这样编码: img = Image.open("help.png") menubar.add_cascade(label="Hel
Ubuntu 16.04 ,安装了 nvidia-docker,一个正在运行的 tensorflow 容器, python 2.7 我想在容器内运行一个简单的 python 代码。如下图 from t
我正在尝试构建一个实时项目,其中状态每秒更新一次,因此某些部分代码会不断重复。当我想更改必须更新的信息时,我只需单击新按钮,它会为我提供第一个窗口,我可以在其中更新新信息。但这样做会给我以下错误。请帮
我是一名优秀的程序员,十分优秀!