Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TclError: bad geometry specifier [closed]

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()`

I'm getting following error:

 TclError: bad geometry specifier "1920*1200+150+100".
like image 485
Satya Chandra Avatar asked Apr 29 '26 16:04

Satya Chandra


2 Answers

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 *?

like image 89
fhdrsdg Avatar answered May 01 '26 06:05

fhdrsdg


Use x(character) instead of *

root.geometry("100x100")
like image 34
saigopi.me Avatar answered May 01 '26 06:05

saigopi.me



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!