The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
while loops problem
Discuss while loops problem in the Python Programming forum on Dev Shed. while loops problem Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 25th, 2004, 11:51 PM
|
 |
Only the strong survives!!.
|
|
Join Date: Feb 2003
Location: A World of wonders.
|
|
|
while loops problem
arg i been at this for a while now.... tring to figure out why is it that when i add a loop in my program the program wont load? or even when i add a for loop i get nothing back  ( while loop is in OnInit ( ) )
Code:
class HtmlWindows ( wxHtmlWindow ):
def __init__ ( self, Parant, ID, frame ):
wxHtmlWindow.__init__ ( self, Parant, ID )
self.SetBackgroundColour ( 'Black' )
def Data ( self, Data ):
self.AppendToPage ( Data )
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 )
class MyFrame ( wxFrame ):
def __init__ ( self, Parant, ID, Title ):
wxFrame.__init__ ( self, Parant, ID, Title,
style=wxCAPTION|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxTHICK_FRAME,
size = ( 650, 400 ))
self.Panel = MyPanel ( self, -1, self )
self.CentreOnScreen ( wxBOTH )
#wxInitAllImageHandlers()
#img = wxImage ( 'folder.gif' )
#img.LoadFile ( 'folder.gif', wxBITMAP_TYPE_GIF )
self.CreateStatusBar ( 2 )
self.SetStatusWidths ( [ -1, 150 ] )
self.SetStatusText ( ctime( time( ) ), 1 )
Menu = wxMenu ( )
Menu.Append ( ID_EXIT, '&Exit', 'Exit The Program' )
MenuBar = wxMenuBar ( )
MenuBar.Append ( Menu, '&File' )
self.SetMenuBar ( MenuBar )
EVT_MENU ( self, ID_EXIT, self.ExitProgram )
def ExitProgram ( self, event ):
self.Close ( True )
class MyApp ( wxApp ):
def OnInit ( self ):
Frame = MyFrame ( NULL, -1, '*:: xlordt ::*' )
while 1:
Frame.Panel.html.Data ( 'hmm' )
Frame.Show ( True )
self.SetTopWindow ( Frame )
return True
Win = MyApp ( 0 )
Win.MainLoop ( )
Last edited by xlordt : May 25th, 2004 at 11:53 PM.
|

May 26th, 2004, 05:03 AM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 6
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
while 1:
Frame.Panel.html.Data ( 'hmm' )
if this is a while True loop, how do you expect it to break;
and if it is not going to break; how do you expect the program to get out of the OnInit method. i think there should be some terminating condition for the while loop
bye
Vikram
|

May 26th, 2004, 03:32 PM
|
 |
Only the strong survives!!.
|
|
Join Date: Feb 2003
Location: A World of wonders.
|
|
Quote: | Originally Posted by softking while 1:
Frame.Panel.html.Data ( 'hmm' )
if this is a while True loop, how do you expect it to break;
and if it is not going to break; how do you expect the program to get out of the OnInit method. i think there should be some terminating condition for the while loop
bye
Vikram |
No it has nothing to do with the loop beaking.. the problem was that wxPython does not work this way..i realized that i hade 2 choices either use wxYield ( ) or make it threaded.. so far i get the program to loop now.. but it loops to fast..as i am testing it to connect to an irc server.. so ya now i have another prog 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|