3

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".
Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46
Satya Chandra
  • 728
  • 2
  • 12
  • 26

6 Answers6

6

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

fhdrsdg
  • 10,297
  • 2
  • 41
  • 62
1

Use x(character) instead of *

root.geometry("100x100")
saigopi.me
  • 14,011
  • 2
  • 83
  • 54
0

You should use

main_application.geometry('1200x800')

not

main_application.geometry('1200*800')

The difference is between x and *

jlewkovich
  • 2,725
  • 2
  • 35
  • 49
0

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

MANTHAN
  • 11
  • 2
0

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') 
Whois7pi
  • 151
  • 1
  • 6
0

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