Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a python tkinter window with no X (close) button
    primarykey
    data
    text
    <p>I'm writing a 'wizard' type Python Tkinter GUI that collects information from the user and then performs several actions based on the user's entries: file copying, DB updates, etc. The processing normally takes 30-60 seconds and during that time, I want to:</p> <ol> <li>Provide the user with text updates on the activity and progress</li> <li>Prevent the user from closing the app until it's finished what it's doing</li> </ol> <p>I started on the route of having the text updates appear in a child window that's configured to be <code>trainsient</code> and using <code>wait_window</code> to pause the main loop until the activities are done. This worked fine for other custom dialog boxes I created which have OK/cancel buttons that call the window's <code>destroy</code> method. The basic approach is:</p> <pre><code>def myCustomDialog(parent,*args): winCDLG = _cdlgWin(parent,*args) winCDLG.showWin() winCDLG.dlgWin.focus_set() winCDLG.dlgWin.grab_set() winCDLG.dlgWin.transient(parent) winCDLG.dlgWin.wait_window(winCDLG.dlgWin) return winCDLG.userResponse class _cdlgWin(): def __init__(self,parent,*args): self.parent = parent self.dlgWin = tk.Toplevel() self.userResponse = '' def showWin(self): #Tkinter widgets and geometry defined here def _btnOKClick(self): #self.userResponse assigned from user entry/entries on dialog self.dlgWin.destroy() def _btnCancelClick(self): self.dlgWin.destroy() </code></pre> <p>However this approach isn't working for the new monitor-and-update dialog I want to create.</p> <p>First, because there's no user-initiated action to trigger the copy/update activities and then the <code>destroy</code>, I have to put them either in showWin, or in another method. I've tried both ways but I'm stuck between a race condition (the code completes the copy/update stuff but then tries to destroy the window before it's there), and never executing the copy/update stuff in the first place because it hits the <code>wait_window</code> before I can activate the other method.</p> <p>If I could figure out a way past that, then the secondary problem (preventing the user from closing the child window before the work's done) is covered by the answers below.</p> <p>So... is there any kind of bandaid I could apply to make this approach work the way I want? Or do I need to just scrap this because it can't work? (And if it's the latter, is there any way I can accomplish the original goal?)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload