How can I best center a Tkinter window on my display screen?
Not knowing Tkinter that well, here is a somewhat simple minded approach:
from Tkinter import *
def center_window(w=300, h=200):
# get screen width and height
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
# calculate position x, y
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
root.geometry('%dx%d+%d+%d' % (w, h, x, y))
root = Tk()
Edited 5 Years Ago
by vegaseat: changed code frame
Please I have an autocomplete textbox which fetches value from a tabe in the database. But after i choose the name i want to get the id of the value ...
I want to draw a triangle using mouse events like mousePressed(), mouseReleased() and mouseDragged(). But triangle did not show until mouse release. Please tell me what i am ...
what i have done is copied answer in label and now matching the radiobutton option with it so far so good but i dont know how to uncheck radio button ...