'How to make a window you can't exit with any python module?
I'm trying to make a classroom manager that can allow teachers to control the students' device during lesson.(Temporarily displaying a window to 'lock' the screen of the student when the teacher is talking)
I need to make a window that will automatically open in fullscreen when the teacher presses a button. However, making a window students can't exit was what I have been truggling with.
I cantry to use pygame.set_mode(... pygame.FULLSCREEN)
But the user can overide by Alt
-F4
or Ctr
-Alt
-del
Solution 1:[1]
Ok, so I found something equivalent to what I'm trying to achieve: in pygame just override the quit event by doing nothing! so replace
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit()
with
for event in pygame.event.get():
if event.type == pygame.QUIT:
pass
which does nothing when quit occurs. In PyQt:
class MainWindow(QWidget): # or QMainWindow
...
def closeEvent(self, event):
# do stuff
if can_exit:
event.accept() # let the window close
else:
event.ignore()
And in Tkinter change:
import Tkinter as tk
import tkMessageBox as messagebox
root = tk.Tk()
def on_closing():
if messagebox.askokcancel("Quit", "Do you want to quit?"):
root.destroy()
root.protocol("WM_DELETE_WINDOW", on_closing)
root.mainloop()
To:
import Tkinter as tk
import tkMessageBox as messagebox
root = tk.Tk()
def on_closing():
pass
root.protocol("WM_DELETE_WINDOW", on_closing)
root.mainloop()
I may have also forgotten to mention that the targeted audiences have managed devices with a policy enabled not allowing students to use task managers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | AzlanCoding |