This repository has been archived by the owner on Feb 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from ELC/PyQt4-Compatible
Add Backward Compatibility with PyQt4
- Loading branch information
Showing
10 changed files
with
220 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,113 @@ | ||
*.pyc | ||
.idea | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
.static_storage/ | ||
.media/ | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
venv* |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from flask import Flask | ||
from gui import init_gui | ||
|
||
app = Flask(__name__) | ||
|
||
from routes import * | ||
|
||
if __name__ == '__main__': | ||
init_gui(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
channels: | ||
- defaults | ||
dependencies: | ||
- pyqt=4.11.4 | ||
- python=3.5 | ||
- pip: | ||
- flask==0.12.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import sys | ||
import webbrowser | ||
|
||
from PyQt4.QtCore import QThread, QUrl, SIGNAL | ||
from PyQt4.QtGui import QApplication, QMainWindow, QIcon | ||
from PyQt4.QtWebKit import QWebView, QWebPage | ||
|
||
|
||
def init_gui(application, port=5000, width=300, height=400, | ||
window_title="PyFladesk", icon="appicon.png"): | ||
|
||
ROOT_URL = 'http://localhost:{}'.format(port) | ||
|
||
# open links in browser from http://stackoverflow.com/a/3188942/1103397 :D | ||
def link_clicked(url): | ||
ready_url = url.toEncoded().data().decode() | ||
if ROOT_URL not in ready_url: | ||
webbrowser.open(ready_url) | ||
else: | ||
window.webView.load(QUrl(ready_url)) | ||
|
||
def run_app(): | ||
application.run(port=port, threaded=True) | ||
|
||
qtapp = QApplication(sys.argv) | ||
|
||
webapp = QThread() | ||
webapp.__del__ = webapp.wait | ||
webapp.run = run_app | ||
webapp.start() | ||
|
||
qtapp.aboutToQuit.connect(webapp.terminate) | ||
|
||
window = QMainWindow() | ||
window.resize(width, height) | ||
window.setWindowTitle(window_title) | ||
window.webView = QWebView(window) | ||
window.setCentralWidget(window.webView) | ||
window.setWindowIcon(QIcon(icon)) | ||
|
||
window.webView.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) | ||
link_signal = SIGNAL("linkClicked (const QUrl&)") | ||
window.webView.connect(window.webView, link_signal, link_clicked) | ||
|
||
window.webView.load(QUrl(ROOT_URL)) | ||
window.show() | ||
|
||
return qtapp.exec_() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Flask==0.12.2 | ||
PyQt4==4.11.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
from flask import Flask, render_template | ||
|
||
|
||
app = Flask(__name__) | ||
|
||
from flask import render_template | ||
from app import app | ||
|
||
@app.route('/') | ||
def index(): | ||
return render_template('index.html') | ||
|
||
@app.route('/page2') | ||
def page2(): | ||
return render_template('page2.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Flask Desktop Application</title> | ||
|
||
|
||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet"> | ||
|
||
|
||
</head> | ||
|
||
<body> | ||
|
||
<div class="container"> | ||
<div class="header"> | ||
<h3 class="text-muted">Flask Desktop Application</h3> | ||
</div> | ||
|
||
<div class="row marketing"> | ||
<div class="col-lg-12"> | ||
<h1 > Page2! </h1> | ||
</div> | ||
</div> | ||
|
||
<footer class="footer"> | ||
<p><a href="{{ url_for('index') }}">Index</a></p> | ||
</footer> | ||
|
||
</div> | ||
</body> | ||
|
||
</html> |