ANN:A wxHtmlWindow forms implementation.

Discussion in 'Python' started by Tom B., Sep 13, 2004.

  1. Tom B.

    Tom B. Guest

    It consists of a pre-filter,
    http://users.commspeed.net/tbabbitt/tom2/HTMLparse.py

    usage:

    import HTMLparse,urllib2
    TomFilter = HTMLparse.TomFilter()
    webtext = urllib2.urlopen('http://www.yahoo.com')
    formtxt = TomFilter.formfilter(webtext,'http://www.yahoo.com')
    # after feeding
    imagelist = TomFilter.imagelist
    linklist = TomFilter.linklist
    scripttext = TomFilter.scripttext
    linktextlist = TomFilter.linktextlist
    background = TomFilter.background
    backgroundcolor = TomFilter.backgroundcolor


    The parser, completes URL's, changes form tags to custom wxControl tags
    and mangles frames into rows of tables. (note encoding('utf_8','ignore').

    The next part is a custom module for web controls.
    http://users.commspeed.net/tbabbitt/tom2/webwig.py

    The controls post there events to a custom event
    and are available as a class called WebEvent. (Note Radio buttons are
    implemented as check boxes so you have to uncheck at the event end.)

    The only thing left to be done is to link the events to the program running
    the wx.html window.

    import wx
    import wx.html as html
    import wx.lib.wxpTag
    import webwig
    def __init__(self):
    .....self.Bind(webwig.EVT_UPDATE_WEBFORM,self.OnPyEvent)
    .....self.WebObjects = {}

    def OnPyEvent(self, event):
    .....self.WebEvent = event.GetVal()
    .....if self.WebEvent.Typ[:4] == 'int_':
    .........self.WebObjects[self.WebEvent.Id] = self.WebEvent
    .........self.WebObjects[self.WebEvent.Id].Typ =
    self.WebObjects[self.WebEvent.Id].Typ[4:]
    .....else:
    .........self.WebObjects[self.WebEvent.Id] = self.WebEvent

    This gives you a WebEvent object and dictionary of all web objects on
    page.
    WebEvent objects have the following properties,
    self.WebEvent.Name # the control name
    self.WebEvent.Value # the control value
    self.WebEvent.WebValue # in the form u'&%s="%s"' % (Name ,Value )
    self.WebEvent.URL # the full URL
    self.WebEvent.FormData # the full Form data in dictionary
    self.WebEvent.Data # extra data from select and data from hidden, in form
    'action'|'http://'|'method'|'POST' ect.
    self.WebEvent.Id #the controll Id
    self.WebEvent.Win # the control itself

    Here is code for the Demo (love the new demo).
    http://users.commspeed.net/tbabbitt/tom2/demowebwig.py

    I have also written a program to display its features it requires,
    PIL , http://www.pythonware.com/products/pil/
    image_view (ScrolledWindow PIL viewer)
    http://users.commspeed.net/tbabbitt/tom/image_view.py
    the Browser http://users.commspeed.net/tbabbitt/tom2/TomBrowse.py

    Inspired by the demo it separates the web page components into notebook
    pages
    and runs the Content of a STC through the above event. Errors are displayed
    on a log page.

    I know how much people have wanted something like this so I just want to get
    the code out there. The tag handler complains on pages with hidden tags but
    I can find nothing wrong with my tag syntax. There is an unhanded exception
    when I use the SetPage from the event definition but when the page is saved
    it loads back ok so I probably need to destroy the web objects on the event
    end.

    Enjoy,
    Tom Babbitt
     
    Tom B., Sep 13, 2004
    #1
    1. Advertising

  2. Tom,

    I've downloaded your code but wasn't able to run the demo. It stops
    with a "no module named Main" exception. In fact, no such module is
    mentioned in your message.

    BTW, it would be useful if you added a small description to your
    package announcement -- what it does, what is it useful for, etc. I'm
    checking it out of curiosity, but I admit that I don't know exactly
    what to expect.

    Best regards,



    --
    Carlos Ribeiro
    Consultoria em Projetos
    blog: http://rascunhosrotos.blogspot.com
    blog: http://pythonnotes.blogspot.com
    mail:
    mail:
     
    Carlos Ribeiro, Sep 13, 2004
    #2
    1. Advertising

  3. Tom B.

    Tom B. Guest

    "Carlos Ribeiro" <> wrote in message
    news:...
    > Tom,
    >
    > I've downloaded your code but wasn't able to run the demo. It stops
    > with a "no module named Main" exception. In fact, no such module is
    > mentioned in your message.
    >
    > BTW, it would be useful if you added a small description to your
    > package announcement -- what it does, what is it useful for, etc. I'm
    > checking it out of curiosity, but I admit that I don't know exactly
    > what to expect.
    >
    > Best regards,
    >

    I guess i forgot to mention it requires wxPython found at
    http://www.wxpython.org/ , the wxHtmlWindow does not process or display form
    tags from HTML pages this is an implimentation of that. You can see a
    screenshot at http://users.commspeed.net/tbabbitt/rbranch_strangness5.htm

    Tom
     
    Tom B., Sep 13, 2004
    #3
  4. On Mon, 13 Sep 2004 11:04:22 -0700, Tom B. <> wrote:
    > I guess i forgot to mention it requires wxPython found at
    > http://www.wxpython.org/ , the wxHtmlWindow does not process or display form
    > tags from HTML pages this is an implimentation of that. You can see a
    > screenshot at http://users.commspeed.net/tbabbitt/rbranch_strangness5.htm


    I have wxPython here, I don't know if there is any module named Main
    in wxWindows 2.5. Are you sure that I don't need anything else?



    --
    Carlos Ribeiro
    Consultoria em Projetos
    blog: http://rascunhosrotos.blogspot.com
    blog: http://pythonnotes.blogspot.com
    mail:
    mail:
     
    Carlos Ribeiro, Sep 13, 2004
    #4
  5. Tom B.

    Tom B. Guest

    "Carlos Ribeiro" <> wrote in message
    news:...
    > Tom,
    >
    > I've downloaded your code but wasn't able to run the demo. It stops
    > with a "no module named Main" exception. In fact, no such module is
    > mentioned in your message.
    >
    > BTW, it would be useful if you added a small description to your
    > package announcement -- what it does, what is it useful for, etc. I'm
    > checking it out of curiosity, but I admit that I don't know exactly
    > what to expect.
    >
    > Best regards,
    >
    >

    I misunderstood your reply and I apologize if my reply was an insult to your
    intelligence. The demo code is a demo but it is for the wxPython demo
    program, have a look at the demo code in the 'wxHtmlWindow' subsection of
    the 'more Windows/Controls section and compare the code to my demo code.

    Tom
     
    Tom B., Sep 13, 2004
    #5
  6. On Mon, 13 Sep 2004 11:56:12 -0700, Tom B. <> wrote:
    > I misunderstood your reply and I apologize if my reply was an insult to your
    > intelligence. The demo code is a demo but it is for the wxPython demo
    > program, have a look at the demo code in the 'wxHtmlWindow' subsection of
    > the 'more Windows/Controls section and compare the code to my demo code.


    Don't worry, I don't burn that easily :) It happens -- the problem is
    that people get used to their your own setups (programming libraries,
    directories and stuff), and it's quite easy to forget to mention
    something or other when releasing it for other people to use. Be
    welcome :)


    --
    Carlos Ribeiro
    Consultoria em Projetos
    blog: http://rascunhosrotos.blogspot.com
    blog: http://pythonnotes.blogspot.com
    mail:
    mail:
     
    Carlos Ribeiro, Sep 13, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luiz Siqueira Neto

    event on a panel inside of a wxHtmlwindow

    Luiz Siqueira Neto, Jul 11, 2003, in forum: Python
    Replies:
    0
    Views:
    314
    Luiz Siqueira Neto
    Jul 11, 2003
  2. Greg
    Replies:
    2
    Views:
    345
  3. Abe
    Replies:
    0
    Views:
    381
  4. Michael Tsang
    Replies:
    32
    Views:
    1,161
    Richard Bos
    Mar 1, 2010
  5. Eric
    Replies:
    2
    Views:
    648
Loading...

Share This Page