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

Add an option to set the icon of the window #786

Closed
wants to merge 19 commits into from
Closed

Conversation

ulukyn
Copy link

@ulukyn ulukyn commented Oct 7, 2021

Added set_icon method for Qt and CFE Windows

Don't works on Macos

import win32api
import win32con
import win32gui

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not like to introduce pywin32 as another dependency. Could you do it with Python's builtin ctypes.WinDLL?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, i can take a look sure.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@ulukyn ulukyn marked this pull request as draft October 12, 2021 14:38
@ulukyn ulukyn marked this pull request as ready for review October 12, 2021 14:41
@@ -252,6 +253,20 @@ def _create():

instances[window.uid] = browser
window.shown.set()

if window.icon:
icon = window.icon+".ico"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work with png files? Ie. is it necessary to append the .ico suffix?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows require .ico, ways to convert a .png to .ico are a little too complex for me. So I think easier to provide both .ico and .png and so, use a sufixless name of icon

bigx = windll.user32.GetSystemMetrics(11) #SM_CXICON
bigy = windll.user32.GetSystemMetrics(12) #SM_CYICON
big_icon = windll.user32.LoadImageW(0, icon, 1, bigx, bigy, 0x00000010)
windll.user32.SendMessageW(handle, 0x0080, 1, big_icon)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code can be moved into winforms.py. CEF is just a component inside the winform.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sure. I will try to do it this week-end

@@ -462,6 +470,9 @@ def on_load_finished(self):
def set_title(self, title):
self.set_title_trigger.emit(title)

def set_icon(self, icon):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_icon support should be added to winforms as well.

@@ -160,6 +161,10 @@ def get_elements(self, selector):

return self.evaluate_js(code)

@_shown_call
def get_instance(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems debug code i have used for test, must be removed

@@ -701,6 +716,9 @@ def get_position(uid):
def get_size(uid):
window = BrowserView.instances[uid]
return window.width(), window.height()

def get_instance(uid):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems debug

@github-actions
Copy link

This PR 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 Nov 22, 2021
@github-actions
Copy link

The message to post on the pr when closing it. If none provided, will not comment when closing a pull requests.

@github-actions github-actions bot closed this Nov 28, 2021
@r0x0r
Copy link
Owner

r0x0r commented Dec 2, 2021

@ulukyn Would you address comments?

@ulukyn
Copy link
Author

ulukyn commented Dec 3, 2021

Sorry, i'm very busy at the moment, let me answer :)

@Jzhenli
Copy link

Jzhenli commented Apr 22, 2024

if it's ok to set the icon of the window now?

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

Successfully merging this pull request may close these issues.

3 participants