Git Product home page Git Product logo

Comments (4)

Aues6uen11Z avatar Aues6uen11Z commented on May 25, 2024

Another problem related to frameless mode, window.maximize() abnormally behaves as full-screen (covering the Windows taskbar), while setting frameless=False is fine. Is there a way to resolve this?

from time import sleep

import webview

def maximize(window):

    sleep(5)
    print('Maximizing window')
    window.maximize()

if __name__ == '__main__':
    window = webview.create_window(
        'Maximize window example', frameless=True, html='<h1>window</h1>'
    )
    webview.start(maximize, window)

from pywebview.

Aues6uen11Z avatar Aues6uen11Z commented on May 25, 2024

I found that on my Win10 computer, a frameless window cannot be minimized by clicking its taskbar icon

For the first question, I found a solution in C# https://www.fluxbytes.com/csharp/minimize-a-form-without-border-using-the-taskbar/, and asked GPT how to use .NET in Python through pythonnet. Finally, I overwrote the CreateParams property in the BrowserForm class, but it didn’t work. Can someone help me?

# webview/platforms/winforms.py

class BroswerView:
    ...
    class BrowserForm(WinForms.Form):
    ...
    @property
    def CreateParams(self):
        cp = super().CreateParams
        WS_MINIMIZEBOX = 0x20000
        CS_DBLCLKS = 0x8
        cp.Style |= WS_MINIMIZEBOX
        cp.ClassStyle |= CS_DBLCLKS
        return cp

from pywebview.

r0x0r avatar r0x0r commented on May 25, 2024

I ran into a similar problem some time ago - form methods cannot be overridden for BrowserForm for some reason.

It can be done, though. See for example overridding WndProc here
I did some investigating on this, but could not arrive to a conclusion why it does not work for pywebview. Ideas welcome.

from pywebview.

Aues6uen11Z avatar Aues6uen11Z commented on May 25, 2024

WndProc is a method, while CreateParams is a property, and this difference may be causing the different results. I noticed that in C# when overriding CreateParams, there is a get and GPT’s explanation is

In C#, the get keyword is used to define the getter method of a property. The getter method is a special method that is called when you try to read the value of the property.

In your example, the get defines the getter method for the CreateParams property. When you try to read the value of CreateParams, the code block following the get is executed, and its result is returned.

This is a read-only property because it only defines the getter method and does not define a setter method. If you try to modify the value of this property, you will get a compilation error.

In Python, you can use the property decorator to define getter and setter methods. However, due to limitations in pythonnet, you may not be able to directly override C#'s read-only properties in Python. You may need to find other ways to achieve your goal.

After that, I tried different approaches, all of which ended in failure. This matter has exceeded my capabilities...

from pywebview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.