From 402a6b2e8ac4409b386a5d222e29ddbb97a5a01a Mon Sep 17 00:00:00 2001 From: Kavindu Santhusa <63494497+Ksengine@users.noreply.github.com> Date: Tue, 20 Oct 2020 07:13:43 +0000 Subject: [PATCH 1/8] auto title automatically set webpage title as window title if user want --- webview/platforms/qt.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webview/platforms/qt.py b/webview/platforms/qt.py index e4041745..b46c1290 100755 --- a/webview/platforms/qt.py +++ b/webview/platforms/qt.py @@ -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) @@ -278,7 +278,10 @@ 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) + self.setCentralWidget(self.view) self.create_window_trigger.connect(BrowserView.on_create_window) From 4f532a294863def9a8c3969bcd32ff99203f3bdc Mon Sep 17 00:00:00 2001 From: Kavindu Santhusa <63494497+Ksengine@users.noreply.github.com> Date: Tue, 20 Oct 2020 07:19:49 +0000 Subject: [PATCH 2/8] auto title --- webview/window.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webview/window.py b/webview/window.py index 3632d163..92ed0b0a 100644 --- a/webview/window.py +++ b/webview/window.py @@ -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): self.uid = uid self.title = make_unicode(title) self.original_url = None if html else url # original URL provided by user @@ -68,6 +68,7 @@ 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._js_api = js_api self._functions = {} From e8debf8fdf04a9870dc834f044450655558ce8c5 Mon Sep 17 00:00:00 2001 From: Kavindu Santhusa <63494497+Ksengine@users.noreply.github.com> Date: Tue, 20 Oct 2020 07:20:14 +0000 Subject: [PATCH 3/8] auto title From 2a3b6576fe1944843cfb62672b12636acd2a32c8 Mon Sep 17 00:00:00 2001 From: Kavindu Santhusa <63494497+Ksengine@users.noreply.github.com> Date: Tue, 20 Oct 2020 07:52:49 +0000 Subject: [PATCH 4/8] auto title Automatically set title of webpage as window title --- webview/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webview/__init__.py b/webview/__init__.py index d16b6a90..4648399b 100755 --- a/webview/__init__.py +++ b/webview/__init__.py @@ -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): """ 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. @@ -138,6 +138,7 @@ 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 :return: window object. """ @@ -150,7 +151,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) windows.append(window) From a18fc74bfe5d206f3ec1b5fd10ce01e7ff630281 Mon Sep 17 00:00:00 2001 From: Kavindu Santhusa <63494497+Ksengine@users.noreply.github.com> Date: Tue, 20 Oct 2020 08:13:23 +0000 Subject: [PATCH 5/8] auto icon Automatically set icon of webpage as window icon --- webview/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webview/__init__.py b/webview/__init__.py index 4648399b..6539f42c 100755 --- a/webview/__init__.py +++ b/webview/__init__.py @@ -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, auto_title=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. @@ -139,6 +139,7 @@ def create_window(title, url=None, html=None, js_api=None, width=800, height=600 :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. """ From d83f4f2ba59211b22e177494afacb899edd504e2 Mon Sep 17 00:00:00 2001 From: Kavindu Santhusa <63494497+Ksengine@users.noreply.github.com> Date: Tue, 20 Oct 2020 08:15:01 +0000 Subject: [PATCH 6/8] auto icon Automatically set icon of webpage as window icon --- webview/window.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webview/window.py b/webview/window.py index 92ed0b0a..6d97b7e9 100644 --- a/webview/window.py +++ b/webview/window.py @@ -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, auto_title): + 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 @@ -69,6 +69,7 @@ def __init__(self, uid, title, url, html, width, height, x, y, resizable, fullsc 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 = {} From e9573f82e2d5000a881c42543c461199be66afc1 Mon Sep 17 00:00:00 2001 From: Kavindu Santhusa <63494497+Ksengine@users.noreply.github.com> Date: Tue, 20 Oct 2020 08:19:12 +0000 Subject: [PATCH 7/8] auto icon Automatically set icon of webpage as window icon --- webview/platforms/qt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webview/platforms/qt.py b/webview/platforms/qt.py index b46c1290..653a6cb4 100755 --- a/webview/platforms/qt.py +++ b/webview/platforms/qt.py @@ -282,6 +282,9 @@ def __init__(self, window): 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) From e4efec1be53f390e1478ca322601d1af95806cca Mon Sep 17 00:00:00 2001 From: Kavindu Santhusa <63494497+Ksengine@users.noreply.github.com> Date: Tue, 20 Oct 2020 08:20:09 +0000 Subject: [PATCH 8/8] auto icon --- webview/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webview/__init__.py b/webview/__init__.py index 6539f42c..9749282d 100755 --- a/webview/__init__.py +++ b/webview/__init__.py @@ -152,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,auto_title) + js_api, text_select, transparent, auto_title, auto_icon) windows.append(window)