'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".


Solution 1:[1]

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

Solution 2:[2]

Use x(character) instead of *

root.geometry("100x100")

Solution 3:[3]

You should use

main_application.geometry('1200x800')

not

main_application.geometry('1200*800')

The difference is between x and *

Solution 4:[4]

Always make sure you use "x" this not "*" this.

Solution 5:[5]

Even this does not works because there are blankspaces:

root.geometry('200x100 + 300 + 250') 

So you should also be careful to not include any space between the numbers and the + symbols. This works:

root.geometry('200x100+300+250') 

Solution 6:[6]

My solution is also to check the type of the parameters. It should be int.

return self.tk.call('wm', 'geometry', self._w, newGeometry)

_tkinter.TclError: bad geometry specifier "800x600+368.0+132.0"

Correct it by: self.root.geometry("%sx%s+%s+%s" % (self.FrameSizeX,self.FrameSizeY,int(FramePosX),int(FramePosY)))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fhdrsdg
Solution 2 saigopi.me
Solution 3 jlewkovich
Solution 4 MANTHAN
Solution 5 Whois7pi
Solution 6 Abhijeeth