0

platfrom: windows python3.7

i used self.overrideredirect(True), to hide the title bar but i aslo can't zoom the window at the same time. i only want to hide the title bar.

At first i tried to detect when the mouse is hover on the edge of the window and then use self.geometry() to change the size of the window.

but i failed when i began to write to code, i don't know how to detect when the mouse is hover on the edge of the window.

Does Tkinter expose enough functionality to allow me to implement the task at hand? Or are there easier/higher-level ways to achieve what I want to do?

Danhui Xu
  • 69
  • 10
  • I think you can't detect when it hovers edget, you can only check if mouse position is near border (ie. 2-3 pixels) but still inside window. – furas Sep 24 '22 at 10:16
  • Does this answer your question? [How to remove title bar in Tkinter program?](https://stackoverflow.com/questions/49550862/how-to-remove-title-bar-in-tkinter-program) – Claudio Sep 24 '22 at 10:42
  • 1
    Does this answer your question? https://stackoverflow.com/questions/22421888/tkinter-windows-without-title-bar-but-resizable#22424245 Tkinter: windows without title bar but resizable – Claudio Sep 24 '22 at 11:03
  • 1
    See here: https://stackoverflow.com/a/22424245/7711283 for an example of how to write own code to resize a window – Claudio Sep 24 '22 at 11:10

1 Answers1

0

Check out the code of class Example for a way of making a window without menu bar movable by using the right mouse button and re-sizable by grabbing a grip placed in the right bottom corner:

import tkinter as tk
import tkinter.ttk as ttk

class Example(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.floater = FloatingWindow(self)

class FloatingWindow(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        tk.Toplevel.__init__(self, *args, **kwargs)
        self.overrideredirect(True)
        self.wm_geometry("400x400+100+100")

        self.label = tk.Label(self, text="Grab the lower-right corner to resize\nMove window with right mouse button")
        self.label.pack(side="top", fill="both", expand=True)

        self.grip1 = ttk.Sizegrip(self)
        self.grip1.place(relx=1.0, rely=1.0, anchor="se")
        self.grip1.lift(self.label)

        self.bind("<B3-Motion>", self.OnMotion)

    def OnMotion(self, event):
        x1 = self.winfo_pointerx()
        y1 = self.winfo_pointery()
        #x0 = self.winfo_rootx()
        #y0 = self.winfo_rooty()
        #w  = self.winfo_width()
        #h  = self.winfo_height()
        self.wm_geometry("+%s+%s" % (x1,y1))
        return

app=Example()
app.mainloop()
Claudio
  • 7,474
  • 3
  • 18
  • 48