Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto icon #1

Merged
merged 8 commits into from Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions webview/__init__.py
Expand Up @@ -118,7 +118,7 @@ def create_window(title, url=None, html=None, js_api=None, width=800, height=600
resizable=True, fullscreen=False, min_size=(200, 100), hidden=False,
frameless=False, easy_drag=True,
minimized=False, on_top=False, confirm_close=False, background_color='#FFFFFF',
transparent=False, text_select=False):
transparent=False, text_select=False, auto_title=False, auto_icon=False):
"""
Create a web view window using a native GUI. The execution blocks after this function is invoked, so other
program logic must be executed in a separate thread.
Expand All @@ -138,6 +138,8 @@ def create_window(title, url=None, html=None, js_api=None, width=800, height=600
:param background_color: Background color as a hex string that is displayed before the content of webview is loaded. Default is white.
:param text_select: Allow text selection on page. Default is False.
:param transparent: Don't draw window background.
:param auto_title: Automatically set title of webpage as window title
:param auto_icon: Automatically set icon of webpage as window icon
:return: window object.
"""

Expand All @@ -150,7 +152,7 @@ def create_window(title, url=None, html=None, js_api=None, width=800, height=600
window = Window(uid, make_unicode(title), url, html,
width, height, x, y, resizable, fullscreen, min_size, hidden,
frameless, easy_drag, minimized, on_top, confirm_close, background_color,
js_api, text_select, transparent)
js_api, text_select, transparent, auto_title, auto_icon)

windows.append(window)

Expand Down
10 changes: 8 additions & 2 deletions webview/platforms/qt.py
Expand Up @@ -89,7 +89,7 @@ def call(self, func_name, param, value_id):
class WebView(QWebView):
def __init__(self, parent=None):
super(BrowserView.WebView, self).__init__(parent)

if parent.frameless and parent.easy_drag:
QApplication.instance().installEventFilter(self)
self.setMouseTracking(True)
Expand Down Expand Up @@ -278,7 +278,13 @@ def __init__(self, window):

self.view.setPage(BrowserView.WebPage(self.view))
self.view.page().loadFinished.connect(self.on_load_finished)


if getattr(window, 'auto_title, False): # automatically set webpage title as window title
self.view.setWindowTitle.connect(self.set_title)

if getattr(window, 'auto_icon, False): # automatically set webpage icon as window icon
self.view.iconChanged.connect(lambda : self.setWindowIcon(self.view.icon()))

self.setCentralWidget(self.view)

self.create_window_trigger.connect(BrowserView.on_create_window)
Expand Down
4 changes: 3 additions & 1 deletion webview/window.py
Expand Up @@ -46,7 +46,7 @@ def _loaded_call(function):
class Window:
def __init__(self, uid, title, url, html, width, height, x, y, resizable, fullscreen,
min_size, hidden, frameless, easy_drag, minimized, on_top, confirm_close,
background_color, js_api, text_select, transparent):
background_color, js_api, text_select, transparent, auto_title, auto_icon):
self.uid = uid
self.title = make_unicode(title)
self.original_url = None if html else url # original URL provided by user
Expand All @@ -68,6 +68,8 @@ def __init__(self, uid, title, url, html, width, height, x, y, resizable, fullsc
self.on_top = on_top
self.minimized = minimized
self.transparent = transparent
self.auto_title = auto_title # auto_title
self.auto_icon = auto_icon # auto_icon

self._js_api = js_api
self._functions = {}
Expand Down