[wxpython-users] a few stupid questions ...

Stef Mientki s.mientki at ru.nl
Mon Apr 28 13:15:20 PDT 2008



Christopher Barker wrote:
> Stef Mientki wrote:
>> I tried this
>> class Message ( object ) :
>>  def __init__ ( self ) :
>>    pass
>>  def ok ( self, caption = '', message = '', parent = None ) :
>>    wx.MessageDialog (  parent, message, caption,
>>                        style = wx.OK | wx.ICON_INFORMATION )
>>
>> But that gives the following error:
>> unbound method ok() must be called with Message instance as first 
>> argument (got str instance instead)
>
> Did you instantiate a Message instance?
Aha, that seems to problem, the code below works now, Thanks Chris !!
cheers,
Stef

# ***********************************************************************
# ***********************************************************************
class _Message ( object ) :
  def __init__ ( self ) :
    pass
  def ok ( self, caption = '', message = '', type = None, parent = None ) :
    dialog = wx.MessageDialog (  parent, message, caption,
                                 style = wx.OK | wx.ICON_INFORMATION )
    dialog.ShowModal()
    dialog.Destroy ()
# ***********************************************************************

# Here we create a global message instance
Message = _Message ()




More information about the wxpython-users mailing list