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 April 24th, 2004, 07:43 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
wxPYTHON message dialog

Code:
FIRST THE CODE - WxPython:

def On_LOpen(self, event):
        dlg = wxMessageDialog(self, 'Message',
          'Caption', wxYES | wxNO | wxCANCEL | wxICON_INFORMATION)

        try:
            if dlg.ShowModal() == wxID_YES:
                self.txt.WriteText('YES')
            elif dlg.ShowModal() == wxID_NO:
                self.txt.WriteText('NO')
        finally:
            dlg.Destroy()
        
	event.Skip()


I try to test the functionality of a message dialog, if I hit the 'YES' button the textbox(not included here) will display the word 'YES', the 'NO' button will cause the textbox to display 'NO' the 'CANCEL' will close the messagedialog , the 'YES' button works, the 'NO' button also works but in a different way, I have to hit the button twice before the dialog dissapear and the text appear, I can figure out the problem, any idea.

Reply With Quote
  #2  
Old April 24th, 2004, 07:51 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,226 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 23 h 35 m 17 sec
Reputation Power: 263
It is because you are calling dlg.ShowModal() twice. The first time it returns wxID_NO but you are comparing it with wxID_YES, so the test fails. Then you call it again to and compare the result with wxID_NO. What you need to do is call it once and save the result in a variable:

Code:
def On_LOpen(self, event):
        dlg = wxMessageDialog(self, 'Message',
          'Caption', wxYES | wxNO | wxCANCEL | wxICON_INFORMATION)

        try:
            result = dlg.ShowModal()
            if  result == wxID_YES:
                self.txt.WriteText('YES')
            elif result == wxID_NO:
                self.txt.WriteText('NO')
        finally:
            dlg.Destroy()
        
	event.Skip()


Dave - The Developers' Coach

Reply With Quote
  #3  
Old April 24th, 2004, 09:20 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
Thanks so much man, you've saved me from a very serious head ache

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > wxPYTHON message dialog


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
Stay green...Green IT