Skip to content

Commit

Permalink
esc key to quit, fullscreen and frameless window.
Browse files Browse the repository at this point in the history
  • Loading branch information
FoamyGuy committed Nov 26, 2024
1 parent 16f9f0c commit 41c84a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Pi_Bluesky_TFT_Scroller/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""
import json
import os
import sys

import requests
import webview
Expand Down Expand Up @@ -180,10 +181,16 @@ def check_quit(self):
# pylint: disable=unnecessary-pass
pass

def quit(self):
window.destroy()
sys.exit(0)


# create a webview and load the index.html page
webview.create_window(
"bsky posts", "static/index.html", js_api=Api(), width=320, height=240
window = webview.create_window(
"bsky posts", "static/index.html", js_api=Api(), width=320, height=240,
x=0, y=0, frameless=True, fullscreen=True

)
webview.start()
# webview.start(debug=True) # use this one to enable chromium dev tools to see console.log() output from the page.
7 changes: 7 additions & 0 deletions Pi_Bluesky_TFT_Scroller/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,10 @@ function autoScroll() {
pywebview.api.check_quit();
window.scrollBy(0, 2);
}

document.addEventListener('keydown', function(event){
/* Quit if the user presses esc key */
if (event.key === "Escape"){
pywebview.api.quit();
}
} );

0 comments on commit 41c84a4

Please sign in to comment.