microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.35k stars 678 forks source link

Proposal: Add Python support to WinUI 3 #3364

Open freakboy3742 opened 4 years ago

freakboy3742 commented 4 years ago

Proposal: Add Python support to WinUI3

Summary

WinUI 3 should include an official Python API, allowing end-users to build native Windows GUI apps in Python.

Rationale

Scope

Important Notes

This has been proposed in direct response to this tweet from @WindowsDocs, and this follow up from @zooba. It may be related to #1421.

Open Questions

iamkartiknayak commented 3 years ago

Please make it happen!!

alireza138812 commented 3 years ago

So please do it

benoitlathiere commented 2 years ago

Please add Python support to WinUI 3. Wxpython is not beautiful.. 👍🤞

sayyid5416 commented 2 years ago

This issue is older than 1 year, still there's no response from WinUI team. I do not know what they are planning, but it is always a good idea to provide some details on such a popular proposal.

reedless commented 2 years ago

Here from 2022.

As of 28 Jul 2021, the pip package winui was reserved by Microsoft Corporation: https://pypi.org/project/winui/ Hopefully this means that they are working towards a package?

sayyid5416 commented 2 years ago

As of 28 Jul 2021, the pip package winui was reserved by Microsoft Corporation: https://pypi.org/project/winui/ Hopefully this means that they are working towards a package?

Yes indeed, but there's no update from WinUI team on this issue. This is not fair for such old and popular issue.

Fluent-Aero commented 2 years ago

貌似开发一个能用Python调用C++接口的中间函数就可以了?

一定不止这么简单吧

miketech commented 2 years ago

+1

Would allow so many Python devs to create awesome data centric Windows apps with native lool and feel. Win UI could get many developers over night.

Aldrich-Code commented 2 years ago

貌似开发一个能用Python调用C++接口的中间函数就可以了?

一定不止这么简单吧

Python很多库就是这么干的

dylech30th commented 2 years ago

WinUI team needs more developers, from what I can see it's already been hard for them to triage and solve the huge amount of issues. Since the current WinUI 3 itself is really half-baked, I think the priority target of the team would be implementing features and handling bug&performance issues, I suspect that a proposal like foreign language support must have a relatively low priority until they make the WinUI 3 full-featured. Having said that, if anyone wants to get a quick reply, I suggest you post a comment in #6726 , it would be much more noticeable for them

pjmlp commented 2 years ago

They already can't manage just with C# and C++, and the folks responsible for killing C++/CX are now having fun with Rust/WinRT instead of making it a proper developer experience.

We don't need even more distractions with so few developers, just look at the amount of commits per day across all projects.

saint4eva commented 2 years ago

WinUI team needs more developers, from what I can see it's already been hard for them to triage and solve the huge amount of issues. Since the current WinUI 3 itself is really half-baked, I think the priority target of the team would be implementing features and handling bug&performance issues, I suspect that a proposal like foreign language support must have a relatively low priority until they make the WinUI 3 full-featured. Having said that, if anyone wants to get a quick reply, I suggest you post a comment in #6726 , it would be much more noticeable for them

That is what you get when a team decides to bet the feature of their platform on a less productive stack - C++

Here from 2022.

As of 28 Jul 2021, the pip package winui was reserved by Microsoft Corporation: https://pypi.org/project/winui/ Hopefully this means that they are working towards a package?

WinUI itself is far from being feature complete. Do you think they would ever touch that python package again? CS/WinRT, CS/ Win32 and C++/WinRT have many issues that need to be resolved.

wherewhere commented 2 years ago

After J#, C#, F# and B# (VB.NET), it will comes out P#? 😜

MosGeo commented 2 years ago

Just thinking outloud (not an expert): would something like using pybind11 https://github.com/pybind/pybind11 work for this case?

aarmn commented 2 years ago

After J#, C#, F# and B# (VB.NET), it will comes out P#? 😜

Ironpython was enough of a fail for them, I guess

contextfree commented 2 years ago

After J#, C#, F# and B# (VB.NET), it will comes out P#? 😜

WinUI is WinRT-based, not .NET-based, so no. 🤖

wherewhere commented 2 years ago

WinUI is WinRT-based, not .NET-based, so no. 🤖

P++ 😙

lmjaedentai commented 2 years ago

Fully agree with that We love python

SpazElectro commented 1 year ago

Agreed.

aarmn commented 1 year ago

Years and nothing apart from random notifications from this

P-PPPP commented 1 year ago

Agree

monkeycc commented 1 year ago

2023 Agree

Ianzb commented 1 year ago

agree

tiagorangel1 commented 1 year ago

Yes please

JasonMo1 commented 1 year ago

please

JasonMo1 commented 1 year ago

Friends, I have found this, it can use some fluent widgets in PyQt or Pyside. https://github.com/zhiyiYo/PyQt-Fluent-Widgets

tiagorangel1 commented 1 year ago

Looks great, thanks for the link!

yizigezi commented 1 year ago

感觉需要Microsoft先出一个python与dotnet互通的库。目前仅有第三方实现,也许需要先做出这个再考虑WinUI3 API

SpamixOfficial commented 1 year ago

As much as I love linux and hate microsoft, PLEASE MICROSOFT! As a developer I prioritize user experience and I want all users to feel like they are at home when they are using my applications, and thats why I want to use winui for my application. Sadly though, it is not YET implemented, do I hope they do it soon.

sayyid5416 commented 1 year ago

It's been 3 LONG YEARS, and not a single reply from Microsoft on this thread. Well, that's very disappointing.

frinkifail commented 1 year ago

add it already :(

sotanakamura commented 1 year ago

I found that we can use WinUI 3 controls with Python. Now PyWinRT and I are working some problems to support it.

SpamixOfficial commented 1 year ago

I found that we can use WinUI 3 controls with Python. Now PyWinRT and I are working some problems to support it.

Amazing! Please mention me when you've got a solution!

SpamixOfficial commented 1 year ago

It's been 3 LONG YEARS, and not a single reply from Microsoft on this thread. Well, that's very disappointing.

Tbh they are Microsoft, what do we expect?

sotanakamura commented 1 year ago

I found pywinrt cannot treat WinUI well because it is constructed on top of the abstraction of cppwinrt. I decided to create a new winmd parser to generate a pure python projection without C++. It may take some time.

sotanakamura commented 11 months ago

Progress report

Background

There are several python language projection for Windows Runtime. PyWinRT is one of the python projection for Windows Runtime API. It is constructed on top of the C++/WinRT and it has a technical problem that it cannot treat directly the internal mechanism of Windows Runtime. I decided to create a new pure python projection, but it takes a lot of time to make it ready to use.

Another work

I found another project py-win32more. It is a pure python library providing a python language projection for Win32 APIs based on win32metadata. It can treat the internal mechanism of Windows Runtime completely. The creator recently have supported Windows Runtime APIs and Windows App SDK APIs. We will add the support of WinUI 3 soon and I think you can use WinUI 3 easily in Python in the future.

Sample

This will be improved in the future especially for constructors.

from win32more.xaml import XamlApplication
from win32more.Microsoft.UI.Xaml import Window
from win32more.Microsoft.UI.Xaml.Controls import ColorPicker

class App(XamlApplication):
    def OnLaunched(self, args):
        win = Window.CreateInstance(None, None)
        clr = ColorPicker.CreateInstance(None, None)
        win.Content = clr
        win.Activate()

XamlApplication.Start(App)
saint4eva commented 11 months ago

@sotanakamura You guys are doing amazing work. Can we write the UI in code - in python instead of xaml markup?

sotanakamura commented 11 months ago

@saint4eva Yes. Writing UIs in Python is useful to set a event handler and bind some data. Of cource, you can also write the UIs in XAML.

sotanakamura commented 8 months ago

Update

Constructors are now simpler.

from win32more.Microsoft.UI.Xaml import Window
from win32more.Microsoft.UI.Xaml.Controls import ColorPicker
from win32more.xaml import XamlApplication

class App(XamlApplication):
    def OnLaunched(self, args):
        win = Window()
        clr = ColorPicker()
        win.Content = clr
        win.Activate()

XamlApplication.Start(App)
jhi2 commented 5 months ago

Hey iirc there is a python library for this. It's called pythonnet, a python library for the .NET framework.

Actually, .NET is not the same as winUI3

jhi2 commented 5 months ago

I would love to work with C developers to make a python binding for WinUI3

zooba commented 4 months ago

If people are really keen, I started experimenting with a code generator approach for binding Python code-behind to a particular XAML. It's not generic dynamic bindings, but past experience (I've built this concept about 4 times now since Win8) shows generic bindings really aren't the way.

Code and a couple of really basic samples are at https://github.com/zooba/pymsbuild-winui I'm not actively working on it right now, so I'd suggest if you want to significantly develop it then create a fork and work on it there - don't expect every little change to be merged in immediately, but if some serious progress is made then I would consider sharing maintainership and merging it in.

jhi2 commented 4 months ago

Update

Constructors are now simpler.

from win32more.Microsoft.UI.Xaml import Window
from win32more.Microsoft.UI.Xaml.Controls import ColorPicker
from win32more.xaml import XamlApplication

class App(XamlApplication):
    def OnLaunched(self, args):
        win = Window()
        clr = ColorPicker()
        win.Content = clr
        win.Activate()

XamlApplication.Start(App)

WOW THAT IS SOOOOOOOOO COOL

jhi2 commented 3 months ago

I am working on a wINui3 guI TOOLKIT for Python see jhi2/PyUI3