Open jhi2 opened 3 months ago
Hello! Can you post a code excerpt and the traceback? Thanks!
PS C:\Users\johnd\source\repos\PyUi3> & "C:/Program Files/Python312/python.exe" c:/Users/johnd/source/repos/PyUi3/PyUI3/test.py
Traceback (most recent call last):
File "c:\Users\johnd\source\repos\PyUi3\PyUI3\test.py", line 4, in
here is the code i used to test it(ai generated):
import PyUI3
# Create a window
window = PyUI3.ApplicationWindow()
# Add some widgets
label = PyUI3.Label(window, "Welcome to PyUI3!", pos=(150, 50))
button = PyUI3.Button(window, "Click Me!", pos=(150, 100))
entry = PyUI3.Entry(window, pos=(150, 150))
# Define a callback function for the button
def button_click():
label.text = f"Hello, {entry.text}!"
# Bind the callback to the button
button.on_click = button_click
# Start the main loop
window.run()
I think @ynkdir would be helpful with this.
"Class not registered" means that WindowsAppSDK is not initialized. You need to initialize Com and WindowsAppSDK before using WinUI API. See win32more.xaml.XamlApplication.Start() for detail.
Typical application code is
from win32more.Microsoft.UI.Xaml import Window
from win32more.xaml import XamlApplication
class App(XamlApplication):
def OnLaunched(self, args):
# Now, Com and WindowsAppSDK were initialized.
# You can use WinUI from here.
win = Window()
win.Activate()
XamlApplication.Start(App)
"Class not registered" means that WindowsAppSDK is not initialized. You need to initialize Com and WindowsAppSDK before using WinUI API. See win32more.xaml.XamlApplication.Start() for detail.
Typical application code is
from win32more.Microsoft.UI.Xaml import Window from win32more.xaml import XamlApplication class App(XamlApplication): def OnLaunched(self, args): # Now, Com and WindowsAppSDK were initialized. # You can use WinUI from here. win = Window() win.Activate() XamlApplication.Start(App)
I will try that
No, Here is what i did in the run function:
def run(self):
for item in self.roster:
self.win.Content = item
XamlApplication.Start(self.app)
self.win.Activate()
Please submit a PR to fix the issue.
So, I built a formatter, didint work AT ALL! I used it on this repo. I had to revert, so its fixed now
@ynkdir Did you see the post above the one above this one? There are a few mods to it, but still error
So, I built a formatter, didint work AT ALL! I used it on this repo. I had to revert, so its fixed now
I know, right? did you see, it look sorta-minified?
Did you try my example code? It show you an empty window. If I were you, I would start with a working code and gradually add my own code step by step, ensuring the program continues to work. I don't write your library.
i know how to use win32more, but can you please contribute and help me fix the code?
@JPHutchins Hello again. As the title suggests, there is an error on window init. Can you please help me? continued from the conversation on toga.