admin管理员组文章数量:1333163
I'm creating a borderless window like this
def _create_window(self):
if self.current_window is not None:
return
self.mouse_listener = MouseListener(
on_left_mouse_click=self.on_left_mouse_pressed,
on_right_mouse_click=self.on_right_mouse_pressed,
)
threading.Thread(
target=self._run_tkinter_window,
).start()
def _run_tkinter_window(self):
self.current_window = tk.Tk()
# Make the window borderless
self.current_window.overrideredirect(True)
# self.current_window.title("Ctrl + Space Pressed!")
self.width = 500
self.height = 50
if self.config is not None:
self.width = self.config["window_settings"]["width"]
self.height = self.config["window_settings"]["height"]
self.current_window.geometry(f"{self.width}x{self.height}")
screen_width = self.current_window.winfo_screenwidth()
screen_height = self.current_window.winfo_screenheight()
x = (screen_width // 2) - (self.width // 2)
y = (screen_height // 2) - (self.height // 2)
self.current_window.attributes("-topmost", True)
self.current_window.protocol(
"WM_DELETE_WINDOW",
self._close_window,
)
self.current_window.geometry(
f"{self.width}x{self.height}+{x}+{y}",
)
self.entry = tk.Entry(
self.current_window,
font=(
"Helvetica",
16,
),
)
self.entry.pack(expand=True, fill=tk.BOTH)
# Ensure the Entry widget receives keyboard input correctly
# self.entry.bind("<FocusIn>", self.on_focus)
self.current_window.update_idletasks()
self.current_window.mainloop()
I want to make something like a macos's spotlight search in Ubuntu. But when the window appears the text is entering somewhere in the bottom right corner of the screen.
And if I comment out this line
self.current_window.overrideredirect(True)
it works as expected.
What is the problem with it? Can I somehow get the expected behavior in a chromeless window?
本文标签: python 3xAdd entry to tkinter without window borderStack Overflow
版权声明:本文标题:python 3.x - Add entry to tkinter without window border - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742352194a2458717.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论