本文介绍了TclError:错误的几何说明符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 python Tkinter 使用以下脚本为 Tkinter GUI 定义几何:

I tried to define geometry for Tkinter GUI using following script using python Tkinter:

from Tkinter import *
root = Tk()
w=300
h=200
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
root.geometry('%dx%d+%d+%d' % (w, h, x, y))
root.mainloop()`

我收到以下错误:

 TclError: bad geometry specifier "1920*1200+150+100".

推荐答案

错误看起来像你在使用 '%d*%d+%d+%d' % (w, h, x, y) 而不是 '%dx%d+%d+%d' % (w, h, x, y).
您确定使用 x 而不是 * 吗?

The error looks like you're using '%d*%d+%d+%d' % (w, h, x, y) instead of '%dx%d+%d+%d' % (w, h, x, y).
Are you sure you use the x and not the *?

这篇关于TclError:错误的几何说明符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 19:59
查看更多