import wx

class HideRepairDialog(wx.Dialog):
    """choose to either assign a new vowel class or classify as an error when CMD-SHIFT-clicking on a vowel token"""

    def __init__(self, parent, ID, title):
        wx.Dialog.__init__(self, parent, ID, title)
        self.panel = wx.Panel(self)
        self.doLayout()
        ## close dialog when the "Repair" or "Error" buttons are clicked
        self.repairButton.Bind(wx.EVT_BUTTON, self.onButtonClick)
        self.errorButton.Bind(wx.EVT_BUTTON, self.onButtonClick)

    def doLayout(self):
        """do initial sizer stuff"""
        self.border_sizer = wx.BoxSizer(wx.VERTICAL)
        self.border_sizer.Add(self.initButtons(), 0, wx.EXPAND | wx.CENTER | wx.ALL, 10)
        ## set sizers and fit!
        self.panel.SetSizerAndFit(self.border_sizer)
        self.Fit()

    def initButtons(self):
        """create "Repair", "Error" and "Cancel" buttons and wrap them up in a button sizer"""
        self.repairButton = wx.Button(self.panel, wx.ID_YES, "Repair")
        self.errorButton = wx.Button(self.panel, wx.ID_NO, "Error")
        self.cancelButton = wx.Button(self.panel, wx.ID_CANCEL, "&Cancel")
        self.cancelButton.SetDefault()
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer.Add(self.cancelButton, 0, wx.ALL | wx.ALIGN_LEFT, 10)
        btnSizer.Add(self.errorButton, 0, wx.ALL | wx.ALIGN_RIGHT, 10)
        btnSizer.Add(self.repairButton, 0, wx.ALL | wx.ALIGN_RIGHT, 10)
        return btnSizer

    def onButtonClick(self, event):
        """close the dialog window when either the "Repair" or the "Error" button is clicked on"""        
        self.EndModal(event.GetId())


if __name__ == "__main__":
    
    app = wx.App(False)
    dialog = HideRepairDialog(None, -1, "TEST")
    result = dialog.ShowModal()
    if result == wx.ID_YES:
        print "Repair!"
    elif result == wx.ID_NO:
        print "Error!"
    elif result == wx.ID_CANCEL:
        print "Cancel!"
    dialog.Destroy()
    app.MainLoop()
    

    
