Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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 May 21st, 2004, 03:08 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,573 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 11 h 9 m 33 sec
Reputation Power: 406
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
Text in wxPython Programs

Im tring to find a function in wxPython that will allow me to add text, images on the frame.. i have been looking for something like this for a few days, but havent found anything yet.. i need something like TextCtrl ( ) but that only allows text ( like for editors etc ) anyone has a better idea?... something that i can output data like if i was to connect to a website then i would ouput the websites data on the frame in the center or something

Reply With Quote
  #2  
Old May 21st, 2004, 06:46 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,585 DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 2 h 58 m 23 sec
Reputation Power: 1372
I think wxHtmlWindow is what you want. it will render HTML including graphics into a window.

You can also embed other widgets in it - see the wxPython demo for examples.

Dave - The Developers' Coach

Reply With Quote
  #3  
Old May 22nd, 2004, 01:14 AM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,573 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 11 h 9 m 33 sec
Reputation Power: 406
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
Ok i used SetPage( ) to set text to the htmlwindow.. but one more question.. why doesnt this want to bring up my program when i add the while loop

Code:
class HtmlWindows ( wxHtmlWindow ):
    def __init__ ( self, Parant, ID, frame ):
        wxHtmlWindow.__init__ ( self, Parant, ID )

        Socket  = socket ( AF_INET, SOCK_STREAM )

        try:
            
            Socket.connect (( HOST, int ( PORT )))
            Receive = Socket.recv ( 1025 )

            while Socket.recv ( 1025 ):
                self.SetPage( '<font color=red>' + Receive + '</font>' )
                
            Socket.close ( )

        finally:
            
            dlg  = wxMessageDialog ( self, -1, 'Connection Lost', 'Error',
                                     wxOK | wxICON_WARNING )
            dlg.ShowModal ( )
            dlg.Destroy ( )
            Socket.close ( )
            
        self.SetBackgroundColour ( 'Black' )
    

class MyPanel ( wxPanel ):
    def __init__ ( self, Parant, ID, frame ):
        wxPanel.__init__ ( self, Parant, ID )

        self.frame  = frame

        self.html   = HtmlWindows ( self, -1, self.frame )
                    
        
        sizer   = wxBoxSizer ( wxVERTICAL )
        sizer.Add ( self.html, 1, wxGROW )

        subsizer     = wxBoxSizer ( wxHORIZONTAL )
        staticText   = wxStaticText ( self, -1, "Testing" )
        textCtrl     = wxTextCtrl ( self, -1, " " )
        
        subsizer.Add ( staticText, 0, wxGROW | wxALL, 1 )
        subsizer.Add ( textCtrl,   1, wxGROW | wxALL, 1 )
        
        sizer.Add ( subsizer, 0, wxGROW )
        
        self.SetSizer ( sizer )
        self.SetAutoLayout ( True )


everything else works fine, exept for when i add that while loop then the program wont even load

Last edited by xlordt : May 22nd, 2004 at 03:29 AM.

Reply With Quote
  #4  
Old May 22nd, 2004, 05:13 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,585 DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 2 h 58 m 23 sec
Reputation Power: 1372
What happens when you try to run it? Does it throw an exception, and if so then what?

The while loop is wrong. You read in a block of 1025 bytes once with the call to socket.recv() outside of the loop, then the loop itself reads in another 1025 bytes, throws it away since you do not assign it to anything, and displays the original block you have stored in Receive. It will repeatedly show the same block, reading in the successive blocks and throwing them away. Of course if there is less than 1026 bytes of data to read in, then it will display nothing since the loop body will be skipped.

Also note that the SetPage method replaces the previous page being shown rather than appends to it.

If you are reading an HTML page from the web then it is better to use urllib instead of trying to use sockets directly, or call LoadPage instead of SetPage. Python has a lot of libraries for handling different TCP/IP protocols so that you don't have to.

Dave - The Developers' Coach

Reply With Quote
  #5  
Old May 22nd, 2004, 01:26 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonders.
Posts: 5,573 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1Folding Points: 111202 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 11 h 9 m 33 sec
Reputation Power: 406
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook MySpace
is there another alternitave to SetPage ( ) cause i need the loop to keep looping so it can get all the data from the server... Im not getting an html page from any site.. its just server info that im getting I.E irc server

Reply With Quote
  #6  
Old May 22nd, 2004, 02:34 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,585 DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level)DevCoach User rank is General 6th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 2 h 58 m 23 sec
Reputation Power: 1372
Try AppendToPage(string)

Dave - The Developers' Coach

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Text in wxPython Programs

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap