ANN:A wxHtmlWindow forms implementation.

T

Tom B.

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
 
C

Carlos Ribeiro

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: (e-mail address removed)
mail: (e-mail address removed)
 
T

Tom B.

Carlos Ribeiro said:
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
 
C

Carlos Ribeiro

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: (e-mail address removed)
mail: (e-mail address removed)
 
T

Tom B.

Carlos Ribeiro said:
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
 
C

Carlos Ribeiro

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: (e-mail address removed)
mail: (e-mail address removed)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top