-
-
Notifications
You must be signed in to change notification settings - Fork 548
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
Conversation
webview/platforms/cef.py
Outdated
import win32api | ||
import win32con | ||
import win32gui | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
[WIP] Allow fixing window position to any side
@@ -252,6 +253,20 @@ def _create(): | |||
|
|||
instances[window.uid] = browser | |||
window.shown.set() | |||
|
|||
if window.icon: | |||
icon = window.icon+".ico" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems debug
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. |
The message to post on the pr when closing it. If none provided, will not comment when closing a pull requests. |
@ulukyn Would you address comments? |
Sorry, i'm very busy at the moment, let me answer :) |
if it's ok to set the icon of the window now? |
Added set_icon method for Qt and CFE Windows
Don't works on Macos