Application doesnt stay in background as i switches to other app.I hope a quicker reply from the coders. But it works well if i minimze it will the minimize button.
What could be my mistake ,, or what could be the solution.
import tkinter as tk
root = tk.Tk()
root.geometry("400x400")
root.overrideredirect(1)
root.resizable(False, False)
def close():
root.destroy()
def minimizeWindow():
root.withdraw()
root.overrideredirect(False)
root.iconify()
def check_map(event): # apply override on deiconify.
if str(event) == "<Map event>":
root.overrideredirect(1)
print ('Deiconified', event)
else:
print ('Iconified', event)
bar_frame = tk.Frame(root)
bar_frame.grid(row=0, column=0, sticky="ew")
bar_frame.columnconfigure(0, weight=1)
# This appears to have the same results so not sure what the difference is from iconbitmap.
# root.tk.call('wm', 'iconphoto', root._w, icon)
tk.Button(bar_frame, text='x', command=close).grid(row=0, column=1)
tk.Button(bar_frame, text='-', command=minimizeWindow).grid(row=0, column=2)
root.bind('<Map>', check_map) # added bindings to pass windows status to function
root.bind('<Unmap>', check_map)
import mouse
wy=0
ex=0
def standard_bind():
root.bind('<B1-Motion>', lambda e: event(e, Mode=True))
def event(widget, Mode=False):
global ex, wy
if Mode:
ex = widget.x
wy = widget.y
root.bind('<B1-Motion>', lambda e: event(e))
root.geometry('+%d+%d' % (mouse.get_position()[0]-ex, mouse.get_position()[1]-wy))
root.bind('<B1-Motion>', lambda e: event(e, Mode=True))
root.bind('<ButtonRelease-1>', lambda e: standard_bind())
root.mainloop()