Changeset 826:5c6ff27a9206


Ignore:
Timestamp:
09/25/16 07:58:30 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added a function to display a dialog with a Yes/No question

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/common.py

    r823 r826  
    476476
    477477#------------------------------------------------------------------------------
     478
     479def askYesNo(question, parent = None, title = WINDOW_TITLE_BASE):
     480    """Ask a Yes/No question.
     481
     482    Return a boolean indicating the answer."""
     483    dialog = gtk.MessageDialog(parent = parent,
     484                               type = MESSAGETYPE_QUESTION,
     485                               message_format = question)
     486
     487    dialog.add_button(xstr("button_no"), RESPONSETYPE_NO)
     488    dialog.add_button(xstr("button_yes"), RESPONSETYPE_YES)
     489
     490    dialog.set_title(title)
     491    result = dialog.run()
     492    dialog.hide()
     493
     494    return result==RESPONSETYPE_YES
     495
     496#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.