hi guys,
below my code:
the software works, but there is a really annoying behaviour. if you open the first menu window first of the the other ones, it will start always below another window already opened from your operating system (see my gif attached). it happens just one time only with the first menu window. I think it depends by the "self.window.iconbitmap("icon.ico")" and "self.parent.withdraw()" statements, because this issue doesn't happen with the second menu and "Settings" windows
how can I fix this issue?
below my code:
#!/usr/bin/python3 from tkinter import * from tkinter import ttk class MainWindow: def __init__(self, parent): self.parent = parent parent.title("My Software") parent.iconbitmap("icon.ico") parent.geometry("530x515+360+200") parent.resizable (width=False, height=False) parent.configure(background="#f0f0f0") tools = IntVar() tools.set(1) ttk.Radiobutton(self.parent, text = "Menu 1 (my window has an icon!)", variable = tools, value = 1).pack() ttk.Radiobutton(self.parent, text = "Menu 2 (my window hasn't an icon!)", variable = tools, value = 2).pack() self.tools = tools ttk.Button(self.parent, text = "OK", command = self.__OpenTool).pack() ttk.Button(self.parent, text = "Settings", command = self.__OpenSettings).pack() def __OpenTool(self): tool = self.tools.get() if tool == 1: FirstWindow(self.parent) self.parent.withdraw() elif tool == 2: SecondWindow(self.parent) self.parent.withdraw() def __OpenSettings(self): SixthWindow(self.parent) class FirstWindow: def __init__(self, parent): self.parent = parent self.window = Toplevel(parent=None) self.window.title("My Software - Menu 1 (my window has an icon!)") self.window.iconbitmap("icon.ico") self.window.geometry("530x515+360+200") self.window.resizable (width=False, height=False) self.window.configure(background="#f0f0f0") self.window.protocol("WM_DELETE_WINDOW", self.__CloseEvent) def __CloseEvent(self): self.parent.deiconify() self.window.destroy() class SecondWindow: def __init__(self, parent): self.parent = parent self.window = Toplevel(parent=None) self.window.title("My Software - Menu 2 (my window hasn't an icon!)") self.window.geometry("530x515+360+200") self.window.resizable (width=False, height=False) self.window.configure(background="#f0f0f0") self.window.protocol("WM_DELETE_WINDOW", self.__CloseEvent) def __CloseEvent(self): self.parent.deiconify() self.window.destroy() class SixthWindow: def __init__(self, parent): self.parent = parent self.window = Toplevel(parent=None) self.window.title("My Software - Settings") self.window.iconbitmap("icon.ico") self.window.geometry("530x515+360+200") self.window.resizable (width=False, height=False) self.window.configure(background="#f0f0f0") self.window.protocol("WM_DELETE_WINDOW", self.__CloseEvent) def __CloseEvent(self): self.parent.deiconify() self.window.destroy() def main(): root = Tk() app = MainWindow(root) root.mainloop() if __name__ == "__main__": main()if you choose to open one of the two avalable menus, a new window will appear and the main window hides itself. it's the same for the new window opened via the "Settings" button, but in this case the main window will not disappear. the setting and first menu windows have an icon, instead the second menu window uses the default icon from Tkinter.
the software works, but there is a really annoying behaviour. if you open the first menu window first of the the other ones, it will start always below another window already opened from your operating system (see my gif attached). it happens just one time only with the first menu window. I think it depends by the "self.window.iconbitmap("icon.ico")" and "self.parent.withdraw()" statements, because this issue doesn't happen with the second menu and "Settings" windows
how can I fix this issue?