使Tkinter窗口在父窗口或屏幕上居中的功能
center-tk-window的Python项目详细描述
中央油箱窗口
在父窗口或屏幕上使Tkinter窗口居中的小库。
安装
要安装,请运行以下命令:
pip install center_tk_window
用法
importtkinterimportcenter_tk_windowroot_window=tkinter.Tk()window_to_center=tkinter.Toplevel(root_window)# Center a window on its parent unless it is the root window in which case it will be centered on screen.center_tk_window.center(root_window,window_to_center)# Center a window on its parentcenter_tk_window.center_on_parent(root_window,window_to_center)# Center a window on the screencenter_tk_window.center_on_screen(window_to_center)