In a read method below, I am trying to match exact strings. When there is a match, the string next to the if-else is written. My question is if the text field is empty or the user enters text which doesn't match, how can I throw an error dialog box to the user.
The demo only shows how to link dialogs to menu's. I tried to define a dialog below but it says that a string or unicode type is required. I'm not good enough to understand this, so would appreciate some help. My method is defined below:
def readTextCtrl(self, event):
string = self.input.GetValue()
if string == 'Hello':
self.response.WriteText('Nice to meet you')
elif string == 'What day is today?':
self.response.WriteText('Monday')
elif string == 'Apple':
self.response.WriteText(' I like apples')
else:
dlg = wxMessageDialog(self, " No information available. " ,wxOK
wxICON_INFORMATION)
dlg.ShowModal()
if dlg.ShowModal() == wxOK:
dlg.Destroy()
self.Close(true)
else:
dlg.Destroy()
return stringdef readTextCtrl(self, event):
string = self.input.GetValue()
if string == 'Hello':
self.response.WriteText('Nice to meet you')
elif string == 'What day is today?':
self.response.WriteText('Monday')
elif string == 'Apple':
self.response.WriteText(' I like apples')
else:
dlg = wxMessageDialog(self, " No information available. " ,wxOK
wxICON_INFORMATION)
dlg.ShowModal()
if dlg.ShowModal() == wxOK:
dlg.Destroy()
self.Close(true)
else:
dlg.Destroy()
return string
Many thanks in advance!
···
_________________________________________________________________
Use MSN Messenger to send music and pics to your friends http://www.msn.co.uk/messenger
culprit:
dlg = wxMessageDialog(self, " No information available. " ,wxOK | wxICON_INFORMATION)
<wx docs>
wxMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Message box", long style = wxOK | wxCANCEL, const wxPoint& pos = wxDefaultPosition)
</wx docs>
as you can see you need 2 strings one for the message and one for caption. If you want to use the default caption you need to declare the style explicitly. like this:
dlg = wxMessageDialog(self, " No information available. " , style=wxOK | wxICON_INFORMATION)
that way it won't expect a string for the third parameter.
···
On Fri, 16 Apr 2004 14:27:30 +0000, jim bob <jaggydeep@hotmail.com> wrote:
In a read method below, I am trying to match exact strings. When there is a match, the string next to the if-else is written. My question is if the text field is empty or the user enters text which doesn't match, how can I throw an error dialog box to the user.
The demo only shows how to link dialogs to menu's. I tried to define a dialog below but it says that a string or unicode type is required. I'm not good enough to understand this, so would appreciate some help. My method is defined below:
def readTextCtrl(self, event):
string = self.input.GetValue()
if string == 'Hello':
self.response.WriteText('Nice to meet you')
elif string == 'What day is today?':
self.response.WriteText('Monday')
elif string == 'Apple':
self.response.WriteText(' I like apples')
else:
dlg = wxMessageDialog(self, " No information available. " ,wxOK | wxICON_INFORMATION)
dlg.ShowModal()
if dlg.ShowModal() == wxOK:
dlg.Destroy()
self.Close(true)
else:
dlg.Destroy()
return stringdef readTextCtrl(self, event):
string = self.input.GetValue()
if string == 'Hello':
self.response.WriteText('Nice to meet you')
elif string == 'What day is today?':
self.response.WriteText('Monday')
elif string == 'Apple':
self.response.WriteText(' I like apples')
else:
dlg = wxMessageDialog(self, " No information available. " ,wxOK | wxICON_INFORMATION)
dlg.ShowModal()
if dlg.ShowModal() == wxOK:
dlg.Destroy()
self.Close(true)
else:
dlg.Destroy()
return string
Many thanks in advance!
--
Peter Damoc
Hacker Wannabe
http://www.sigmacore.net/about.html
The simplest way to use all the built-in dialogs is to use the function wrappers in wx/lib/dialogs.py. There are smart defaults for all the args and there is even a convenience function for an alert dialog. If you run dialogs.py standalone it will display a list of all of the dialogs and let you try each one out.
ka
···
On Apr 16, 2004, at 8:19 AM, Derrick wrote:
Peter Damoc wrote:
On Fri, 16 Apr 2004 14:27:30 +0000, jim bob <jaggydeep@hotmail.com> >> wrote:
In a read method below, I am trying to match exact strings. When there is a match, the string next to the if-else is written. My question is if the text field is empty or the user enters text which doesn't match, how can I throw an error dialog box to the user.
The demo only shows how to link dialogs to menu's. I tried to define a dialog below but it says that a string or unicode type is required. I'm not good enough to understand this, so would appreciate some help. My method is defined below:
def readTextCtrl(self, event):
string = self.input.GetValue()
if string == 'Hello':
self.response.WriteText('Nice to meet you')
elif string == 'What day is today?':
self.response.WriteText('Monday')
elif string == 'Apple':
self.response.WriteText(' I like apples')
else:
dlg = wxMessageDialog(self, " No information available. " ,wxOK | wxICON_INFORMATION)
dlg.ShowModal()
if dlg.ShowModal() == wxOK:
dlg.Destroy()
self.Close(true)
else:
dlg.Destroy()
return stringdef readTextCtrl(self, event):
string = self.input.GetValue()
if string == 'Hello':
self.response.WriteText('Nice to meet you')
elif string == 'What day is today?':
self.response.WriteText('Monday')
elif string == 'Apple':
self.response.WriteText(' I like apples')
else:
dlg = wxMessageDialog(self, " No information available. " ,wxOK | wxICON_INFORMATION)
dlg.ShowModal()
if dlg.ShowModal() == wxOK:
dlg.Destroy()
self.Close(true)
else:
dlg.Destroy()
return string
Many thanks in advance!
culprit:
dlg = wxMessageDialog(self, " No information available. " ,wxOK | wxICON_INFORMATION)
<wx docs>
wxMessageDialog(wxWindow* parent, const wxString& message, const wxString& caption = "Message box", long style = wxOK | wxCANCEL, const wxPoint& pos = wxDefaultPosition)
</wx docs>
as you can see you need 2 strings one for the message and one for caption. If you want to use the default caption you need to declare the style explicitly. like this:
dlg = wxMessageDialog(self, " No information available. " , style=wxOK | wxICON_INFORMATION)
that way it won't expect a string for the third parameter.
Hi,
Just like what Peter said, you have to supply a string value for the caption as follows:
dlg = wxMessageDialog(self, " No information available. " , "", style=wxOK | wxICON_INFORMATION)
Derrick