how to get user input from wx.html?

Hmm, still can't get the event to fire. Here's my
code, anything obviously wrong?

import wx
import wx.html
import forms

class MyHtmlFrame(wx.Frame):

    def __init__(self, parent, title):

        wx.Frame.__init__(self, parent, -1, title)

        self.Bind(forms.form.EVT_FORM_SUBMIT,
self.OnFormSubmit)

        html = wx.html.HtmlWindow(self)

        if "gtk2" in wx.PlatformInfo:

            html.SetStandardFonts()

        html.SetPage(

            "<form id='form1' name='form1'
method='get' action=''>"
            " <p><input type='text' name='name'>"
            " <p><input type='text' name='email'>"
            " <input type='submit' name='Submit'
value='Submit'>"
            "</form>"

            )

    def OnFormSubmit(self, event):
        print "submit!"

app = wx.App(redirect=0)
frm = MyHtmlFrame(None, "Simple HTML")
frm.Show()
app.MainLoop()

···

____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping

I forgot what I'd written and gave you bad advice :wink:

The event isn't a command event, and it's delivered to the HTMLWindow,
so you need to bind on that to get the event. It probably should be a
command event though - you can change this by making FormSubmitEvent
inherit from wx.PyCommandEvent instead of wx.PyEvent.

···

On Jan 24, 2008 5:05 PM, Alec Bennett <whatyoulookin@yahoo.com> wrote:

Hmm, still can't get the event to fire. Here's my
code, anything obviously wrong?

import wx
import wx.html
import forms

class MyHtmlFrame(wx.Frame):

    def __init__(self, parent, title):

        wx.Frame.__init__(self, parent, -1, title)

        self.Bind(forms.form.EVT_FORM_SUBMIT,
self.OnFormSubmit)

        html = wx.html.HtmlWindow(self)

        if "gtk2" in wx.PlatformInfo:

            html.SetStandardFonts()

        html.SetPage(

            "<form id='form1' name='form1'
method='get' action=''>"
            " <p><input type='text' name='name'>"
            " <p><input type='text' name='email'>"
            " <input type='submit' name='Submit'
value='Submit'>"
            "</form>"

            )

    def OnFormSubmit(self, event):
        print "submit!"

app = wx.App(redirect=0)
frm = MyHtmlFrame(None, "Simple HTML")
frm.Show()
app.MainLoop()

I've been frustrated in that I've not seen throughout the web an example
of processing form data from wx.HtmlWindow.

This thread never got to the final conclusion with a piece of code that
worked.

I want to use HtmlWindow and an html form as my GUI, but not have to create
a local server and use a browser, but to just render an html page locally
in my program and capture the activity/changes/submissions.

This thread was headed there but stopped before a full working example
was given.

anyone have a link or can "complete" the example here so it works? I'll
probably play with this and try to implement the last suggestion and if I
get
it to work, I'll post the final working example here, and probably to the
Wiki
as well.

Thanks!

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/how-to-get-user-input-from-wx-html-tp2359459p5724711.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Maybe because processing the info got it for the web form isnot job of wxpython,that need to be handled for the web server.

I really don’t understand for what reason you can’t use wxpython to create the form/gui and process the info with it.

···

Enviado desde mi smartphone LG G3

El 21/08/2015 03:00, “Rufus V. Smith” rufusvsmith@gmail.com escribió:

I’ve been frustrated in that I’ve not seen throughout the web an example

of processing form data from wx.HtmlWindow.

This thread never got to the final conclusion with a piece of code that

worked.

I want to use HtmlWindow and an html form as my GUI, but not have to create

a local server and use a browser, but to just render an html page locally

in my program and capture the activity/changes/submissions.

This thread was headed there but stopped before a full working example

was given.

anyone have a link or can “complete” the example here so it works? I’ll

probably play with this and try to implement the last suggestion and if I

get

it to work, I’ll post the final working example here, and probably to the

Wiki

as well.

Thanks!

View this message in context: http://wxpython-users.1045709.n5.nabble.com/how-to-get-user-input-from-wx-html-tp2359459p5724711.html

Sent from the wxPython-users mailing list archive at Nabble.com.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Rufus V. Smith wrote:

I've been frustrated in that I've not seen throughout the web an example
of processing form data from wx.HtmlWindow.

This thread never got to the final conclusion with a piece of code that
worked.

I want to use HtmlWindow and an html form as my GUI, but not have to create
a local server and use a browser, but to just render an html page locally
in my program and capture the activity/changes/submissions.

So, you're trying to use HTML as your UI description language, instead
of something like xrc, right? I think you're in for a fair amount of
pain. You're talking about intercepting all of the events that could
cause the form to be submitted, and then parsing the tree of controls to
extract their contents, making sure that you handle the different field
types. In my humble opinion, it would be a lot easier to embed a simple
web server in your application to catch the requests and respond. Web
servers just aren't that much work.

The normal thing would be to translate your HTML into normal wx fields
and do it native. I do understand the appeal of the HTML approach,
however. It very neatly separates presentation from processing.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Thanks Tim.

I don't know about xrc so I'll take a look at that.

Also, the embedded web server just sounded daunting. Perhaps that's just the fear of the unknown.

For background, I do a lot of work with embedded processors. I like to use Python and wxPython
to create GUI testing front-ends for myself: A few buttons, some data entry fields, some display
fields. Typically they translate into some form of serial command, or message on a CAN bus, etc.

The allure of html is the ability to quickly reformat my GUI and add/remove pieces either with
an editor or even real-time. Like adding a panel button that is the picture of a toggle switch, when
clicked, changes to a picture of a toggle switch in the other position, etc.

I don't know what's best: htmlwindow, webview, or something else. (I've no significant experience
with Javascript and html, which hampers my decision too).

I think I'll Google xrc, and "python embedded web server" and see where I can go from there.

Rufus

···

-----Original Message-----
From: wxpython-users@googlegroups.com [mailto:wxpython-users@googlegroups.com] On Behalf Of Tim Roberts
Sent: Friday, August 21, 2015 12:44 PM
To: wxpython-users@googlegroups.com
Subject: Re: [wxPython-users] Re: how to get user input from wx.html?

Rufus V. Smith wrote:

I've been frustrated in that I've not seen throughout the web an
example of processing form data from wx.HtmlWindow.

This thread never got to the final conclusion with a piece of code
that worked.

I want to use HtmlWindow and an html form as my GUI, but not have to
create a local server and use a browser, but to just render an html
page locally in my program and capture the activity/changes/submissions.

So, you're trying to use HTML as your UI description language, instead of something like xrc, right? I think you're in for a fair amount of pain. You're talking about intercepting all of the events that could cause the form to be submitted, and then parsing the tree of controls to extract their contents, making sure that you handle the different field types. In my humble opinion, it would be a lot easier to embed a simple web server in your application to catch the requests and respond. Web servers just aren't that much work.

The normal thing would be to translate your HTML into normal wx fields and do it native. I do understand the appeal of the HTML approach, however. It very neatly separates presentation from processing.

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

If you want to quickly make changes in the GUI try wxFormBuilder

···

2015-08-24 10:28 GMT-05:00 Rufus V. Smith rufusvsmith@gmail.com:

Thanks Tim.

I don’t know about xrc so I’ll take a look at that.

Also, the embedded web server just sounded daunting. Perhaps that’s just the fear of the unknown.

For background, I do a lot of work with embedded processors. I like to use Python and wxPython

to create GUI testing front-ends for myself: A few buttons, some data entry fields, some display

fields. Typically they translate into some form of serial command, or message on a CAN bus, etc.

The allure of html is the ability to quickly reformat my GUI and add/remove pieces either with

an editor or even real-time. Like adding a panel button that is the picture of a toggle switch, when

clicked, changes to a picture of a toggle switch in the other position, etc.

I don’t know what’s best: htmlwindow, webview, or something else. (I’ve no significant experience

with Javascript and html, which hampers my decision too).

I think I’ll Google xrc, and “python embedded web server” and see where I can go from there.

Rufus

-----Original Message-----

From: wxpython-users@googlegroups.com [mailto:wxpython-users@googlegroups.com] On Behalf Of Tim Roberts

Sent: Friday, August 21, 2015 12:44 PM

To: wxpython-users@googlegroups.com

Subject: Re: [wxPython-users] Re: how to get user input from wx.html?

Rufus V. Smith wrote:

I’ve been frustrated in that I’ve not seen throughout the web an

example of processing form data from wx.HtmlWindow.

This thread never got to the final conclusion with a piece of code

that worked.

I want to use HtmlWindow and an html form as my GUI, but not have to

create a local server and use a browser, but to just render an html

page locally in my program and capture the activity/changes/submissions.

So, you’re trying to use HTML as your UI description language, instead of something like xrc, right? I think you’re in for a fair amount of pain. You’re talking about intercepting all of the events that could cause the form to be submitted, and then parsing the tree of controls to extract their contents, making sure that you handle the different field types. In my humble opinion, it would be a lot easier to embed a simple web server in your application to catch the requests and respond. Web servers just aren’t that much work.

The normal thing would be to translate your HTML into normal wx fields and do it native. I do understand the appeal of the HTML approach, however. It very neatly separates presentation from processing.

Tim Roberts, timr@probo.com

Providenza & Boekelheide, Inc.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Saludos / Best regards

Mario Lacunza
Email:: mlacunza@gmail.com
Personal Website:: http://www.lacunza.biz/
Hosting:: http://mlv-host.com/
Mascotas Perdidas:: http://mascotas-perdidas.com/
Skype: mlacunzav

Lima - Peru

I finally got back to looking at that code that was in the wiki and modified the
short example to make this minimal working code. This should be a good jump start
for someone trying to use the forms module downloaded from the wiki here

Short Example:
import wx
import wx.html
import forms

class MyHtmlFrame(wx.Frame):
def init(self, parent, title):
super(MyHtmlFrame,self).init(parent, wx.ID_ANY, title)
html = wx.html.HtmlWindow(self)
html.Bind(forms.form.EVT_FORM_SUBMIT, self.OnFormSubmit)
html.SetPage(
“”
"

Enter Name: "
"

Email: "
"

"
“”
)

def OnFormSubmit(self, evt):
    print "Submitting to %s via %s with args %s"% (
           evt.form.action, evt.form.method, evt.args)

app = wx.App()
frm = MyHtmlFrame(None, “Simple HTML”)
frm.Show()
app.MainLoop()

``

···

On Monday, August 24, 2015 at 11:28:08 AM UTC-4, Rufus wrote:

Thanks Tim.

Rufus V. Smith wrote:

I’ve been frustrated in that I’ve not seen throughout the web an
example of processing form data from wx.HtmlWindow.

This thread never got to the final conclusion with a piece of code
that worked.