-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreensaver.py
More file actions
35 lines (26 loc) · 848 Bytes
/
screensaver.py
File metadata and controls
35 lines (26 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
"""
Cross-platform screensaver for OLED monitors.
Displays a full-screen black window and exits on any keypress or mouse click.
"""
import tkinter as tk
def main():
root = tk.Tk()
root.title("Screensaver")
# Make the window full-screen
root.attributes('-fullscreen', True)
# Set background to black and hide the mouse cursor
root.configure(bg='black')
root.config(cursor="none")
# Remove window decorations (borders, title bar)
root.overrideredirect(True)
# Bind event to exit the program
def exit_program(event=None):
root.quit()
# Exit on any keypress or mouse button press
root.bind('<Key>', exit_program)
root.bind('<Button>', exit_program)
# Start the main loop
root.mainloop()
if __name__ == "__main__":
main()