Edouard@2428: #!/usr/bin/env python Edouard@2428: # -*- coding: utf-8 -*- Edouard@2428: Edouard@2428: # See COPYING file for copyrights details. Edouard@2428: Edouard@2428: from __future__ import absolute_import Edouard@2428: import wx Edouard@2428: edouard@2492: edouard@2492: # class RichMessageDialog is still not available in wxPython 3.0.2 Edouard@2428: class IDMergeDialog(wx.Dialog): Edouard@2428: def __init__(self, parent, title, question, optiontext, button_texts): Edouard@2428: wx.Dialog.__init__(self, parent, title=title) Edouard@2428: Edouard@2428: main_sizer = wx.BoxSizer(wx.VERTICAL) Edouard@2428: Edouard@2428: message = wx.StaticText(self, label=question) edouard@3303: main_sizer.Add(message, border=20, edouard@2492: flag=wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.LEFT | wx.RIGHT) Edouard@2428: Edouard@2428: self.check = wx.CheckBox(self, label=optiontext) edouard@3303: main_sizer.Add(self.check, border=20, Edouard@2428: flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_HORIZONTAL) Edouard@2428: Edouard@2428: buttons_sizer = wx.BoxSizer(wx.HORIZONTAL) edouard@2492: for label, wxID in zip(button_texts, [wx.ID_YES, wx.ID_NO, wx.ID_CANCEL]): Edouard@2428: Button = wx.Button(self, label=label) edouard@2492: Edouard@2428: def OnButtonFactory(_wxID): Edouard@2428: return lambda event: self.EndModal(_wxID) edouard@2492: Edouard@2428: self.Bind(wx.EVT_BUTTON, OnButtonFactory(wxID), Button) edouard@3303: buttons_sizer.Add(Button) Edouard@2428: edouard@3303: main_sizer.Add(buttons_sizer, border=20, Edouard@2428: flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_RIGHT) Edouard@2428: Edouard@2428: self.SetSizer(main_sizer) Edouard@2428: self.Fit() Edouard@2428: Edouard@2428: self.Bind(wx.EVT_CHAR_HOOK, self.OnEscapeKey) Edouard@2428: Edouard@2428: def OnEscapeKey(self, event): Edouard@2428: keycode = event.GetKeyCode() Edouard@2428: if keycode == wx.WXK_ESCAPE: Edouard@2428: self.EndModal(wx.ID_CANCEL) Edouard@2428: else: Edouard@2428: event.Skip() Edouard@2428: Edouard@2428: def OptionChecked(self): Edouard@2428: return self.check.GetValue()