Create attractive VASL scenarios, with loads of useful information embedded to assist with game play. https://vasl-templates.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
vasl-templates/vasl_templates/main_window.py

38 lines
1.5 KiB

""" Main application window. """
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtCore import QUrl
from vasl_templates.webapp.config.constants import APP_NAME
from vasl_templates.webapp import app as webapp
# ---------------------------------------------------------------------
class MainWindow( QWidget ):
"""Main application window."""
def __init__( self, url ):
# initialize
super().__init__()
self.setWindowTitle( APP_NAME )
# initialize the layout
# FUDGE! We offer the option to disable the QWebEngineView since getting it to run
# under Windows (especially older versions) is unreliable (since it uses OpenGL).
# By disabling it, the program will at least start (in particular, the webapp server),
# and non-technical users can then open an external browser and connect to the webapp
# that way. Sigh...
layout = QVBoxLayout( self )
if not webapp.config.get( "DISABLE_WEBENGINEVIEW" ):
# load the webapp
browser = QWebEngineView()
layout.addWidget( browser )
browser.setUrl( QUrl(url) )
else:
label = QLabel()
label.setText( "Running the {} application.\n\nClose this window when you're done.".format( APP_NAME ) )
layout.addWidget( label )
QDesktopServices.openUrl( QUrl(url) )