"Fossies" - the Fresh Open Source Software Archive

Member "sk1-2.0rc4/src/wal/msgdlgs.py" (25 May 2019, 2006 Bytes) of package /linux/misc/sk1-2.0rc4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "msgdlgs.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.0rc3_vs_2.0rc4.

    1 # -*- coding: utf-8 -*-
    2 #
    3 #   Copyright (C) 2013 by Igor E. Novikov
    4 #
    5 #   This program is free software: you can redistribute it and/or modify
    6 #   it under the terms of the GNU General Public License as published by
    7 #   the Free Software Foundation, either version 3 of the License, or
    8 #   (at your option) any later version.
    9 #
   10 #   This program is distributed in the hope that it will be useful,
   11 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 #   GNU General Public License for more details.
   14 #
   15 #   You should have received a copy of the GNU General Public License
   16 #   along with this program.  If not, see <https://www.gnu.org/licenses/>.
   17 
   18 import wx
   19 from const import tr
   20 
   21 
   22 def _dialog(parent, title, text, icon, yesno=False, cancel=False):
   23     ret = None
   24     if not yesno and not cancel:
   25         dlg = wx.MessageDialog(parent, tr(text), tr(title), wx.OK | icon)
   26         dlg.ShowModal()
   27         dlg.Destroy()
   28     else:
   29         buttons = 0
   30         if yesno:
   31             buttons = wx.YES_NO
   32         if cancel:
   33             if not buttons:
   34                 buttons = wx.OK | wx.CANCEL
   35             else:
   36                 buttons |= wx.CANCEL
   37         dlg = wx.MessageDialog(parent, tr(text), tr(title), icon | buttons)
   38         ret = dlg.ShowModal()
   39         dlg.Destroy()
   40     return ret
   41 
   42 
   43 def msg_dialog(parent, title, text):
   44     _dialog(parent, title, text, wx.ICON_INFORMATION)
   45 
   46 
   47 def error_dialog(parent, title, text):
   48     _dialog(parent, title, text, wx.ICON_ERROR)
   49 
   50 
   51 def stop_dialog(parent, title, text):
   52     _dialog(parent, title, text, wx.ICON_STOP)
   53 
   54 
   55 def yesno_dialog(parent, title, text):
   56     ret = _dialog(parent, title, text, wx.ICON_WARNING, True, False)
   57     if ret == wx.ID_YES:
   58         return True
   59     return False
   60 
   61 
   62 def ync_dialog(parent, title, text):
   63     ret = _dialog(parent, title, text, wx.ICON_WARNING, True, True)
   64     if ret == wx.ID_YES:
   65         return True
   66     if ret == wx.ID_NO:
   67         return False
   68     return None