-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 71acb98
Showing
13 changed files
with
877 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# 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/ | ||
share/python-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/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# 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/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ |
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,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2020 PyXLL Ltd | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 @@ | ||
recursive-include * *.xml *.png |
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,20 @@ | ||
""" | ||
PyXLL-Jupyter | ||
This package integrated Jupyter notebooks into Microsoft Excel. | ||
To install it, first install PyXLL (see https://www.pyxll.com). | ||
Briefly, to install PyXLL do the following:: | ||
pip install pyxll | ||
pyxll install | ||
Once PyXLL is installed then installing this package will add a | ||
button to the PyXLL ribbon toolbar that will start a Jupyter | ||
notebook browser as a custom task pane in Excel. | ||
To install this package use:: | ||
pip install pyxll_jupyter | ||
""" |
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,157 @@ | ||
"""Minimal browser implementation for running Jupyter. | ||
Requires: | ||
pip install PyQt5 | ||
pip install PyQtWebEngine | ||
or | ||
pip install PySide2 | ||
""" | ||
from .qtimports import * | ||
import logging | ||
_log = logging.getLogger(__name__) | ||
|
||
|
||
class Browser(QWidget): | ||
"""Tabbed browser widget.""" | ||
|
||
closed = Signal() | ||
|
||
def __init__(self, parent=None, scale=None): | ||
super().__init__(parent) | ||
self.profile = QWebEngineProfile() | ||
self.tabs = [] | ||
|
||
layout = QVBoxLayout() | ||
layout.setSpacing(0) | ||
layout.setContentsMargins(0, 0, 0, 0) | ||
|
||
self.tab_widget = TabWidget(self, self.profile, scale=scale) | ||
self.tab_widget.closed.connect(self.close) | ||
|
||
layout.addWidget(self.tab_widget) | ||
self.setLayout(layout) | ||
|
||
def create_tab(self, url): | ||
return self.tab_widget.create_tab(url) | ||
|
||
def closeEvent(self, event): | ||
self.closed.emit() | ||
|
||
|
||
class TabWidget(QTabWidget): | ||
"""Tabbed widget containing multiple QWebEngineView | ||
as a basic tabbed browser. | ||
:param parent: Parent widget. | ||
:param profile: QWebEngineProfile to use for all tabs. | ||
:param scale: Scale for scaling the content for HDI displays. | ||
""" | ||
|
||
closed = Signal() | ||
|
||
def __init__(self, parent, profile, scale=None): | ||
super().__init__(parent) | ||
self.profile = profile | ||
self.scale = scale | ||
self.tabs = [] | ||
|
||
tab_bar = self.tabBar() | ||
tab_bar.setTabsClosable(True) | ||
tab_bar.setSelectionBehaviorOnRemove(QTabBar.SelectPreviousTab) | ||
tab_bar.setMovable(True) | ||
tab_bar.setContextMenuPolicy(Qt.CustomContextMenu) | ||
tab_bar.tabCloseRequested.connect(self.close_tab) | ||
|
||
self.setDocumentMode(True) | ||
self.setElideMode(Qt.ElideRight) | ||
|
||
def close_tab(self, index): | ||
view = self.widget(index) | ||
if view: | ||
self.tabs.remove(view) | ||
self.removeTab(index) | ||
view.deleteLater() | ||
|
||
if len(self.tabs) == 0: | ||
self.close() | ||
|
||
def closeEvent(self, event): | ||
self.closed.emit() | ||
|
||
def create_tab(self, url=None): | ||
view = WebView(self) | ||
self.tabs.append(view) | ||
page = QWebEnginePage(self.profile, view) | ||
view.setPage(page) | ||
|
||
if self.scale: | ||
view.setZoomFactor(self.scale) | ||
|
||
self.addTab(view, "Loading...") | ||
view.resize(self.currentWidget().size()) | ||
self.__setup_view(view) | ||
self.setCurrentWidget(view) | ||
view.show() | ||
|
||
if url is not None: | ||
page.setUrl(QUrl(url)) | ||
|
||
def url_changed(url): | ||
_log.info("Loading page: %s" % url) | ||
|
||
page.urlChanged.connect(url_changed) | ||
|
||
return view | ||
|
||
def __setup_view(self, view): | ||
page = view.page() | ||
|
||
def title_changed(title): | ||
index = self.indexOf(view) | ||
if index != -1: | ||
self.setTabText(index, title) | ||
self.setTabToolTip(index, title) | ||
|
||
view.titleChanged.connect(title_changed) | ||
|
||
def url_changed(url): | ||
index = self.indexOf(view) | ||
if index != -1: | ||
self.tabBar().setTabData(index, url) | ||
|
||
view.urlChanged.connect(url_changed) | ||
|
||
def icon_changed(icon): | ||
index = self.indexOf(view) | ||
if index != -1: | ||
self.setTabIcon(index, icon) | ||
|
||
view.iconChanged.connect(icon_changed) | ||
|
||
def close_requested(): | ||
index = self.indexOf(view) | ||
if index != -1: | ||
self.closeTab(index) | ||
|
||
page.windowCloseRequested.connect(close_requested) | ||
|
||
|
||
class WebView(QWebEngineView): | ||
"""QWebEngineView that implements 'createWindow' so that | ||
all new windows are opened in a new tab. | ||
:param owner: QTabWidget containing this view. | ||
""" | ||
|
||
def __init__(self, owner): | ||
super().__init__() | ||
self.__owner = owner | ||
|
||
def createWindow(self, type): | ||
if type == QWebEnginePage.WebBrowserTab \ | ||
or type == QWebEnginePage.WebBrowserBackgroundTab \ | ||
or type == QWebEnginePage.WebBrowserBackgroundTab: | ||
return self.__owner.create_tab() |
Oops, something went wrong.