在这里开始是一些背景信息:
Python版本3.9.10 64bit
TKINTER V8.6
Macos Monterey 12.3.1
简而言之,
我正在尝试学习tkinter模块。一切正常,除了我尝试使用MessageBox时。它引发了一个错误,到目前为止,我还没有找到任何可以帮助我的东西。我尝试卸载并重新安装了TKINTER和MACVIM,但没有成功。请让我知道你们发现的! (当最初运行代码以及按按钮启动时出现错误)
错误代码:
(base)rutemauro@caios-mac-book cps121%cd/users/rutemauro/desktop/cps121; /usr/bin/env/usr/local/bin/python3/users/rut
emauro/.vscode/extensions/ms-python.python-2022.4.1/pythonfiles/lib/python/python/debugpy/启动器54603-/users/rutemauro/desktop
/cps121/python-practice/tkinter-gui/logintemplate.py
2022-04-20 01:05:35.263 Python [2534:43780]警告:预期的最小视图高度:(< nsbutton:0x7fc31191aab0>)的高度要小于或等于30.32.000000。每个视图都会以违规方式记录此错误。
2022-04-20 01:05:36.342 Python[2534:43780] Warning: Expected min height of view: () to be less than or equal to 30 but got a height of 32.000000. 它是一个简单的登录表单,因此该错误将被记录一次。
这是重要的代码:
#Login Function
def loginFunc():
if usernameEntry.get() == 0:
messagebox.showerror("login unsuccessful", "Please Enter a Password")
elif passwordEntry.get() == 0:
messagebox.showerror("login unsuccessful", "Please Enter a Password")
else:
messagebox.showinfo("login successful", "You have successfully been logged in")
#Login Button
loginButton = Button(root, text="Login", font=("Arial",16), command=loginFunc)
loginButton.pack(pady=20)
github到完整代码(我认为):https://gist.github.com/caiomauro/1abc39c5f2826d18e78555ec776df6b4
To start here is some background information:
Python Version 3.9.10 64bit
TkInter v8.6
macOS Monterey 12.3.1
Running from VS Code
In short I am trying to learn the TkInter module. Everything works well except when I try to use messagebox. It throws an error and so far I haven't found anything to help me out. I have tried uninstalling and reinstalling a tkinter and macvim with no success. Please let me know what you guys find! (Error appears when initially running code and when initiate by the button)
Error Code:
(base) rutemauro@Caios-Mac-Book cps121 % cd /Users/rutemauro/Desktop/cps121 ; /usr/bin/env /usr/local/bin/python3 /Users/rut
emauro/.vscode/extensions/ms-python.python-2022.4.1/pythonFiles/lib/python/debugpy/launcher 54603 -- /Users/rutemauro/Desktop
/cps121/python-practice/TkInter-GUI/loginTemplate.py
2022-04-20 01:05:35.263 Python[2534:43780] Warning: Expected min height of view: (<NSButton: 0x7fc31191aab0>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.
2022-04-20 01:05:36.342 Python[2534:43780] Warning: Expected min height of view: (<NSButton: 0x7fc311a59fe0>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.
Its a simple login form so here is the code that matters:
#Login Function
def loginFunc():
if usernameEntry.get() == 0:
messagebox.showerror("login unsuccessful", "Please Enter a Password")
elif passwordEntry.get() == 0:
messagebox.showerror("login unsuccessful", "Please Enter a Password")
else:
messagebox.showinfo("login successful", "You have successfully been logged in")
#Login Button
loginButton = Button(root, text="Login", font=("Arial",16), command=loginFunc)
loginButton.pack(pady=20)
github to full code (i think): https://gist.github.com/caiomauro/1abc39c5f2826d18e78555ec776df6b4
发布评论