tags: Python
After using pywebview to start the program with the full screen mode, it is no window border. Of course, there is no shutdown button, you can draw a button in the front page page, call the custom API method with the JS, refer to the problem on Stackoverflow:
Directly on the code, see the comment
import sqlite3
import webview
from flask import Flask, render_template
app = Flask(__name__)
conn = sqlite3.connect('data.db', check_same_thread=False)
c = conn.cursor()
@app.route('/')
def index():
# Random drawn
data = []
cursor = c.execute('select * from tiku order by random() limit 2')
# cursor = c.execute('select * from tiku where id = 62 or id = 67')
for row in cursor:
data.append({
'id': row[0],
'title': row[1],
'answer': row[2]
})
return render_template('index.html', data=data)
# Define the API class definition to pass to the front-end JS, define internal properties _Window and set_window () methods to pass the Window objects in WebView you want to operate.
class Api:
def __init__(self):
self._window = None
def set_window(self, window):
self._window = window
def quit(self):
self._window.destroy()
def start_app():
api = Api()
window = webview.create_window(
title='Tropical Procedure',
url=app,
confirm_close=True,
fullscreen=True,
js_api=api,
)
api.set_window(window)
cn = {
'global.quitConfirmation': u'confirm to close?'
}
webview.start(localization=cn, debug=True, gui='cef')
if __name__ == '__main__':
# app.run(port=8000, debug=True)
start_app()
Front-end call
// Call the PywebView's API
$("#exit").click(function () {
pywebview.api.quit();
})
template: js: Note: Monitoring the ESC to exit full screen, if you use monitor KeyDown events (key.code === 27), the button will not be monitored when the full screen will not be recorded, so i...
Full screen function It has been solved because the user presses the full screen after entering the full screen, and the user is quit the full screen. The button does not take effect. Solve the full s...
vue project The project is divided into top navigation, side navigation, and mainContent area on the right The requirement is to make one of the pages of the project have full screen function and hide...
Recently, I was using Google Chrome to watch the full screen of the Flash video. When I quit, the video computer is suspended (the video sound is still there, but the screen has been frozen when I qui...
When you exit the full screen with ESC, the system full screen button description will change synchronously. Disadvantages: When you use F11 to expand the full screen or exit the full screen, it is no...
Problem Description When the video full-screen full-screen playback (call the original player play), then click the completion of the left upper corner, the navigation bar is shifted upwards 20. As sh...
This article will share a JS full screen method with good compatibility full screen...
Android full screen program For the full-screen scheme launched by the app, it is found that many methods are mainly for the re-immersion status bar, not the most appropriate. until this scenario: 1 S...
pywebview Packet Official article Case Practice flaskwebgui Pack: PIP Install FLASKWEBGUI github: Example: structure:...