Search results
27 paź 2009 · However, this value is positive when you reload the page using keyboard shortcuts (F5, Ctrl-R) or close the browser using keyboard shortcurts (e.g. Alt-F4). Thus, you cannot rely the event position to differenciate browser close event from page reload event. – Julien Kronegg. Dec 17, 2012 at 14:33.
8 paź 2010 · Once the timer event elapses, it checks the cancelLogout flag to see if the logout event has been canceled. If the timer has been canceled, then it would stop the timer. If the browser or tab was closed, then the cancelLogout flag would remain false and the event handler would log the user out.
18 lis 2012 · 77. Ok, I found a working solution for this, it consists of using the beforeunload event and then making the handler return null. This executes the wanted code without a confirmation box popping-up. It goes something like this: window.onbeforeunload = closingCode; function closingCode(){. // do something...
2. To capture the event of the close button being pressed without deriving from QWidget and the sort, you could use an event filter. Here's a simple demonstration, using a simple application that displays a QWidget: If you use the QWidget itself, you need to capture QEvent::Close: #include <QApplication>.
2 kwi 2013 · Unfortunately the popup window does not have any close event that you can listen to but there is a closed property that is true when window gets closed. A solution to get around this problem is to start a timer and check the closed property of the child window every second and clear the timer when the window gets closed. Here is the code:
Your example will work as long as the pop-up window url is in the same domain as the parent page, and you change the event to all lowercase: var new_window = window.open('some url') new_window.onbeforeunload = function(){ /* my code */ }
21 wrz 2008 · Here's a working example, tested on Windows 7 & 10: # Python 3. import tkinter. import tkinter.scrolledtext as scrolledtext. root = tkinter.Tk() # make the top right close button minimize (iconify) the main window. root.protocol("WM_DELETE_WINDOW", root.iconify) # make Esc exit the program.
20 sie 2013 · Putting window.close directly after print causes the window to disappear before the print dialog. However, using setTimeout causes the close to be queued on the event queue, the 100ms timeout isn't actually a timing thing, the timer will be blocked until the print dialog is closed at which time the 100ms timer is started. A much better solution.
If you want to close an PyQt5 app from a menu: When menu event triggered call: self.MainWindow.close() (or what window do you want to close. Add this code before sys.exit(app.exec()): self.MainWindow.closeEvent = lambda event:self.closeEvent(event)
28 gru 2014 · Then implement a new signal called closing() and emit it from your implementation of QMainWindow::closeEvent(). Then you can connect to that signal to do something right before the window is closed. You can also use closeEvent directly to do what you need to do, like save state, sync data or whatever.