Replies: 4 comments
-
I have given this a thought and I reckon this could be implemented in one form or another. The first challenge I encountered is that DOM events could not be properly serialiazed. I have implemented a new serializer for JS API, which can now handle DOM events, as well as Nodes and other objects not supported by This lays groundwork for built-in DOM event support. As for actual implementation, I am open to suggestions how API should look like. Maybe something like |
Beta Was this translation helpful? Give feedback.
-
Hi Roman,
Thanks for getting back to me and also for creating this library. I am just
getting started with python so i don't know too much about implementation.
My intent is to use a drag & drop HTML designer to make user interfaces. I
would like a quick and easy way to wire them up with python script and then
tern them into executable files that someone can just download and run on
their machine.
From my understanding, the browser keeps a list of objects when you call
button.addEventListener("click", function() {alert("Button clicked!"); It
would be good to connect this event to a python function so when this event
is triggered, it also triggers a python function and passes it some data.
What i'm thinking:
*JAVASCRIPT CODE:*
function SomeFunction(sender)
{
return (Button)(sender)
};
button.addEventListener("click", SomeFunction)
*PYTHON CODE:*
#triggers the python function when the html function is triggered.
window.bind_function(functionName='SomeFunction', function=MyFunction)
def MyFunction(object):
htmlControl=object #a serialized object from brower.
…On Tue, Sep 12, 2023 at 1:41 PM Roman ***@***.***> wrote:
I have given this a thought and I reckon this could be implemented in one
form or another. The first challenge I encountered is that DOM events could
not be properly serialiazed. I have implemented a new serializer for JS
API, which can now handle DOM events, as well as Nodes and other objects
not supported by JSON.stringify. The change is now in master.
I have added a DOM event example too. You can take a look at it here
https://github.com/r0x0r/pywebview/blob/master/examples/dom_events.py
This lays groundwork for built-in DOM event support. As for actual
implementation, I am open to suggestions how API should look like. Maybe
something like window.bind_event(selector, event_name, handler)
—
Reply to this email directly, view it on GitHub
<#1212 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BCNPCB25AYAF4KT4S5AHBPLX2DCGRANCNFSM6AAAAAA4PGNV74>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I have implemented a preliminary support for DOM events. API is not set in stone, but so far I am quite happy with it. You can check a basic example here https://github.com/r0x0r/pywebview/blob/dom/examples/dom_events.py This and other DOM features will make for the next major (5.0) version of pywebview. |
Beta Was this translation helpful? Give feedback.
-
That’s cool, you can wire up all your events in the one bind function 😎
…On Thursday, September 14, 2023, Roman ***@***.***> wrote:
I have implemented a preliminary support for DOM events. API is not set in
stone, but so far I am quite happy with it. You can check a basic example
here https://github.com/r0x0r/pywebview/blob/dom/examples/dom_events.py
This and other DOM features will make for the next major
(5.0) version of pywebview.
—
Reply to this email directly, view it on GitHub
<#1212 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BCNPCB7DLDSB6XMSSRNCBILX2NO5NANCNFSM6AAAAAA4PGNV74>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi,
I recently started learning Python. One thing that instantly bugged me is that I cannot find an easy way to make desktop GUI's. The frameworks they have available like Tkinter produce very dated controls and are a lot of effort to work with..
I stumbled upon this project while looking for alternatives to using Flash/Python to create GUI's.
This is a cool Library since you can bypass the server Framework and just directly code Python / HTML controls which saves a lot of work making API calls.
One thing that i don't like is that you still need to write a lot of Javascript code to bind HTML events to Python code.
It would be really cool if the Library could build a virtual dom that will allow you to quickly bind functions and handle events from Python.
So for example you would have a list of HTML items:
Python code:
BindingObject ("Click", "FunctionDoSomething")
htmlElement=DOM.ElementsById["Button1"]
htmlElement.AddEventHander(BindingObject)
def FunctionDoSomething:
Print("hello World")
In the background, it would just wire up the event handlers to save you from typing up the Javascript. You can just provide the HTML markup.
Anyways, i look forward to learning more about this library.
Beta Was this translation helpful? Give feedback.
All reactions