Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 23rd, 2004, 08:55 AM
flixxer flixxer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 44 flixxer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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.

Reply With Quote
  #2  
Old June 23rd, 2004, 10:39 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,532 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 38 m 15 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to 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.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old June 23rd, 2004, 11:10 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,203 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 16 h 24 m 11 sec
Reputation Power: 262
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 > so that they are displayed correctly in HTML

Dave - The Developers' Coach

Reply With Quote
  #4  
Old June 23rd, 2004, 11:17 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,203 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 16 h 24 m 11 sec
Reputation Power: 262
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

Reply With Quote
  #5  
Old June 28th, 2004, 06:05 AM
flixxer flixxer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 44 flixxer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Quote:
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.

Reply With Quote
  #6  
Old June 28th, 2004, 06:18 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 7
Send a message via MSN to Grim Archon
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
__________________
*** Experimental Python Markup CGI V2 ***

Reply With Quote
  #7  
Old June 28th, 2004, 06:21 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,532 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 38 m 15 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Text and html window


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway