I am developing an GUI using python tkinter in debian based linux.
Whenever I am removing root and toplevel window title bar using overrideredirect(True) method I am facing below mentioned problems.
- Entry field not working(not getting focus/not getting input) when I am clicking on it.
- Whenever I use Alt+Tab key then only it get focused.
- Then I have to keep pressed mouse left or right button on clicked position then only entry field accept input otherwise input is written on terminal window.
Could any one suggest an alternative way to remove titlebar or to hide title bar in tkinter on linux based system.This code runs well on windows system.
There is a question Tkinter's overrideredirect prevents certain events in Mac and Linux which seems same as my problem but I could not getting its solution .
from tkinter import *
class GuiApp:
def __init__(self,master):
master_frame = Frame(master,background= 'blue')
master_frame.grid()
b1 = Button(master_frame,
height=3,text="BUTTON",width=15, font=14,command=lambda parent=master: self.create_top_window(parent))
b1.grid(row=0, column=0, pady=3, padx=5)
master_frame.grab_set()
def create_top_window(self,parent):
toplevel = Toplevel(parent, bg='red', bd=5, relief=RIDGE)
toplevel.geometry('350x250')
toplevel.wm_overrideredirect(True)
# toplevel.wm_attributes('-type','splash')
label=Label(toplevel,text='Entry:')
entry=Entry(toplevel,width=10,font=13)
button = Button(toplevel, text='close', font=('TkTextFont', 14), command=toplevel.destroy)
label.grid(row=0,column=0,padx=5,pady=5)
entry.grid(row=0,column=1,padx=5,pady=5)
button.grid(row=1, column=0, padx=1, pady=1)
toplevel.grab_set()
root = Tk()
root.wm_overrideredirect(True)
#root.wm_attributes('-type','splash')
app = GuiApp(root)
root.mainloop()