TclError: bad geometry specifier

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

from Tkinter import *
root = Tk() 
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))

I'm getting following error:

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

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

_tkinter.TclError: bad geometry specifier "500*500" I am trying to change the size of Tkinter window with the following line root.geometry('500 45684/tkinter-error-tkinter-tclerror-bad-geometry-specifier

Use x(character) instead of *


TclError: bad geometry specifier. Sujet résolu. D'AlgorithmeGod 20 août 2018 à 17:03:41. Salut à tous ,suis nouveau ici et débutant sur python,et excusez moi si

You should use




The difference is between x and *

def checkInvalidParam(self, widget, name, value, errmsg=None, keep_orig=True): orig = widget[name] if errmsg is not None: errmsg = errmsg.format(value) with self.assertRaises(tkinter.TclError) as cm: widget[name] = value if errmsg is not None: self.assertEqual(str(cm.exception), errmsg) if keep_orig: self.assertEqual(widget[name], orig) else: widget[name] = orig with self.assertRaises(tkinter

tkinter - While executing the below code getting an error bad geometry specifier in python - Stack Overflow. While trying the below code:import tkinterprint(tkinter.TkVersion)print(tkinter.TclVersion)mainWindow = tkinter.Tk()mainWindow.title("Hello Python")mainWindow.geometry("1200X1024") Stack Overflow.

Tkinter provides many methods; one of them is the geometry() method. This method is used to set the dimensions of the Tkinter window and is used to set the position of the main window on the user’s desktop. Code #1: Tkinter window without using geometry method.

  • 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 *?
  • ya You are correct i used * instead of x... Now It is working
  • I'll post it as an answer so everyone can see that the question has been answered.
  • Also rot.geometry(... should be root.geometry(...