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

How to replace the icon in the top left corner? #1411

Closed
plane55 opened this issue Jun 15, 2024 · 10 comments
Closed

How to replace the icon in the top left corner? #1411

plane55 opened this issue Jun 15, 2024 · 10 comments
Labels

Comments

@plane55
Copy link

plane55 commented Jun 15, 2024

Specification

  • pywebview version: 4.4.1
  • operating system: windows 10
  • web renderer:

Description

How to replace the icon in the top left corner?

Practicalities

Snipaste_2024-06-15_14-30-15

@r0x0r
Copy link
Owner

r0x0r commented Jun 25, 2024

pywebview extracts and displays application icon from the executable. In other words you specify the application icon via a bundler.

@Cqy11223344
Copy link

Webview. start (gui='qt '), when the gui is configured as qt, the correct icon cannot be displayed. If it is cef or other parameters, it is normal

@Cqy11223344
Copy link

Cqy11223344 commented Jul 9, 2024

QQ五笔截图未命名

@r0x0r
Copy link
Owner

r0x0r commented Jul 16, 2024

@Cqy11223344 Do you get this behaviour when application is frozen? The icon support comes only with frozen apps.

@GbSeason
Copy link

GbSeason commented Aug 13, 2024

This is my solution. Firstly, this library uses native window handles in the Windows system, so you need to consult the. NET documentation to find the loading method for window icons. Fortunately, there is just a method to load ICO files based on the path.

image

At this point, you need to make slight changes to the source code by adding the path attribute of the ICO file to the custom window object, and adding code to specify the window icon when creating the window

image

image

image

image

Create a webview and set 'icon_path'.

webview.create_window('Hello world', html="<div></div>", icon_path=f"{img}/favicon_play.ico")

Now the icon has changed.

image

@Cqy11223344
Copy link

I tried to modify it using the above method, but it still doesn't work. You can try calling it using the following method.
webview.start(gui='qt')

This is my solution. Firstly, this library uses native window handles in the Windows system, so you need to consult the. NET documentation to find the loading method for window icons. Fortunately, there is just a method to load ICO files based on the path.

image

At this point, you need to make slight changes to the source code by adding the path attribute of the ICO file to the custom window object, and adding code to specify the window icon when creating the window

image

image

image

image

Create a webview and set 'icon_path'.

webview.create_window('Hello world', html="<div></div>", icon_path=f"{img}/favicon_play.ico")

Now the icon has changed.

image

I tried to modify it using the above method, but it still doesn't work. You can try calling it using the following method.
webview.start(gui='qt')

@GbSeason
Copy link

I tried to modify it using the above method, but it still doesn't work. You can try calling it using the following method. webview.start(gui='qt')
======================================
The 'icon_path' variable needs to be declared in the 'create_window' method,otherwise, an error will be reported,
probably at line 246 of the file 'webview/init. py', insert codes declaring variables 'icon_path' like this 'icon_path:str|None=None' .

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Sep 23, 2024
Copy link

The message to post on the issue when closing it. If none provided, will not comment when closing an issue.

@r0x0r
Copy link
Owner

r0x0r commented Oct 7, 2024

I have added windows.start(icon=<path_to_icon>) to address QT and partly GTK. The icon is not displayed on Wayland, as you are supposed to specify application icon using other means.

As for other platforms (Window, macOS, Android) icon must be specified when freezing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants