Beispiel #1
0
 def test_timeout(self):
     # Note: If these test's fail, the unit tests will hang.
     self.assertEqual(pymsgbox._alertTkinter('timeout test', timeout=300),
                      pymsgbox.TIMEOUT_RETURN_VALUE)
     self.assertEqual(pymsgbox._confirmTkinter('timeout test', timeout=300),
                      pymsgbox.TIMEOUT_RETURN_VALUE)
     self.assertEqual(pymsgbox.prompt('timeout test', timeout=300),
                      pymsgbox.TIMEOUT_RETURN_VALUE)
     self.assertEqual(pymsgbox.password('timeout test', timeout=300),
                      pymsgbox.TIMEOUT_RETURN_VALUE)
Beispiel #2
0
def alert(text='',
          title='',
          button=pymsgbox.OK_TEXT,
          root=None,
          timeout=None,
          icon=NO_ICON,
          _tkinter=False):
    """Displays a simple message box with text and a single OK button. Returns the text of the button clicked on."""
    if (_tkinter) or (timeout is not None) or (button != pymsgbox.OK_TEXT):
        # Timeouts are not supported by Windows message boxes.
        # Call the original tkinter alert function, not this native one:
        return pymsgbox._alertTkinter(text, title, button, root, timeout)

    messageBoxFunc(0, text, title,
                   MB_OK | MB_SETFOREGROUND | MB_TOPMOST | icon)
    return button