#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    44
    Rep Power
    11

    Text and html window


    Is taking a text box content and the directly feed it to html window a good idea? .. let see how can I explaine this, I have 1 text box(for input) and I html window in a frame, what I want to do is accept input from user, the take the input and feed it to the html window, so every time the user type something the value will be passed to a function and the feeded to the html window:

    For example
    Code:
    def event(self, event):#this function is triggered everytime user type anything in the textBox
       page = self.textBox.GetValue()
       self.htmlWindow.SetPage(page)
    is this a good idea or not? also I'm thinking of using file instead but writing and reading file will slow down the program.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Its a nice idea, an interesting one at least though im not exactly sure of the purpose.. i'm assuming you are building an application with a sort of editor that lets the user preview there page as is currently in the editor window.

    It also kinda sounds like you want to gather user input and insert it into the html page via a function call.

    Am i anywhere close here?

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    Are you talking about a wxWindows program? This is not clear from your post, but looking at the code I guess it is.

    I don't see any problem with what you are doing, except that you will probably want to convert the string to handle HTML characters correctly, unless you expect the user to to type raw HTML into the text box. For example if the user types in something like:

    if a < b:

    then the HTML parser will think that <b is the start of a bold tag, and will totally screw up the page.

    To do the conversion use either cgi.escape or xml.sax.saxutils.quoteattr. These will both convert things like < into &gt; so that they are displayed correctly in HTML

    Dave - The Developers' Coach
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    Another point to note is that HTML ignores whitespace, including carriage returns/line feeds. You may want to replace '\n' with '<br>' in your string.

    Dave - The Developers' Coach
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    44
    Rep Power
    11
    Originally Posted by netytan
    Its a nice idea, an interesting one at least though im not exactly sure of the purpose.. i'm assuming you are building an application with a sort of editor that lets the user preview there page as is currently in the editor window.

    It also kinda sounds like you want to gather user input and insert it into the html page via a function call.

    Am i anywhere close here?

    Mark.
    Inspired by Hyperedit, what I'm tying to do is set up split window, 1 with text area(for editing), and the other one with html window, so user can write html code in the text area and the html window will render the code instantly as user type, voila!!! live preview. I've tried it before and it does works, but I'm asking it here beacause I'm a bit anxious with memory consumption, will it crash etc.
  10. #6
  11. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    I used the approach you described for my first wxPython program (Hissing Sid)

    Not the best code in the world but you can find it's source here.

    grim
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Well we know its possible because HTML editors like DreamWeaver do this and have been doing this for a long time .

    I dout there are any errors spacifically linked to this type of application i.e. you mentioned 'crashing'. But obviously, if the program is writen well, there should be no crashing .
    One thing i might suggest though would be have a button to update the view otherwise the page will get pretty much distroyed as you for example start to create a new table since the HTML will be not be valid while your doing this .

    Sure there are ways to work around all this though. I think Pythons up to the challenge! Looking forward to seeing this in action!

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo