Skip to content

Commit 41c84a4

Browse files
committed
esc key to quit, fullscreen and frameless window.
1 parent 16f9f0c commit 41c84a4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Pi_Bluesky_TFT_Scroller/code.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""
88
import json
99
import os
10+
import sys
1011

1112
import requests
1213
import webview
@@ -180,10 +181,16 @@ def check_quit(self):
180181
# pylint: disable=unnecessary-pass
181182
pass
182183

184+
def quit(self):
185+
window.destroy()
186+
sys.exit(0)
187+
183188

184189
# create a webview and load the index.html page
185-
webview.create_window(
186-
"bsky posts", "static/index.html", js_api=Api(), width=320, height=240
190+
window = webview.create_window(
191+
"bsky posts", "static/index.html", js_api=Api(), width=320, height=240,
192+
x=0, y=0, frameless=True, fullscreen=True
193+
187194
)
188195
webview.start()
189196
# webview.start(debug=True) # use this one to enable chromium dev tools to see console.log() output from the page.

Pi_Bluesky_TFT_Scroller/static/script.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,10 @@ function autoScroll() {
117117
pywebview.api.check_quit();
118118
window.scrollBy(0, 2);
119119
}
120+
121+
document.addEventListener('keydown', function(event){
122+
/* Quit if the user presses esc key */
123+
if (event.key === "Escape"){
124+
pywebview.api.quit();
125+
}
126+
} );

0 commit comments

Comments
 (0)