3

I have a strange problem. To understand what really happened, I tried myself and googled, but no result. I simplified my code:

#mainw.py
import tkinter as tk
import modalw

class Main(tk. Frame) :
    def__init__(self, master) :
        tk.Frame.__init__(self, master) 
        self.master = master
        self.btn = tk.Button(master, text='modalwin', command=self.openwin)
        self.btn.pack()
    def openwin(self):
        mod = modalw.Modal()

#modalw.py
import tkinter as tk

class Modal(tk. Frame) :
    def__init__(self, master) :
        tk.Frame.__init__(self, master) 
        self.top = tk.TopLevel()
        #I'm not sure these 3 lines of code are true
        self.top.transient(master)
        self.top.grab_set()
        master.wait_window(self)
        self.lbl = tk.Label(self.top, text='Hello')
        self.lbl.pack()
        self.btn2 = tk.Button(master, text='change text', command=self.change)
        self.btn2.pack()
    def change(self):
        self.lbl.config(text='Good bye') 

Problem is, after opening modal window, I minimize(iconify) all windows (pressing Ctrl+D), then when I try maximize(deiconify), both windows above isn't maximized anyway. Can somebody explain this? Is it my error or should I use other way?

This is a screen gif:

1

For info: my OS is Windows 7 and I checked in other PC.

bzimor
  • 1,618
  • 2
  • 14
  • 26
  • What OS are you using? I minimized and restored all windows without troubles in linux (using xfce 'show desktop' shortcut). In addition, there are a few typos in your code. You also use the variable `master` in your classes but their `__init__` method has no argument `master`. – j_4321 Jan 18 '17 at 15:07
  • 1
    Same issue on Windows 11 – thomasc Nov 08 '21 at 20:07
  • I have the same problem, did you manage to solve it? – Vitor Gonçalves Apr 16 '22 at 11:07
  • in my case, I have an application that when calling a topLevel and do alt tab, nothing happens when I click on the icon again, because I put a focus_force and it gets lost when I go back to the application, I can't find answer about this. – Vitor Gonçalves Apr 16 '22 at 11:10

1 Answers1

1

Well, OS might be your issue because I'm on windows- this all works fine and I can maximise and minimise at any moment with no added lines of code. I've been told that Linux has no issues as well - so I really need to know what OS you're operating on. But for now your OS is preventing you. Try and find some code to fix it.