NiceLabel.Blog Everything you wanted to know about NiceLabel

20Jan/11Off

How can I show a message box using Python script in NiceForm or NiceLabel Portal?

import sys

if sys.platform == 'silverlight':
    from System.Windows import *
    result = MessageBox.Show("Would you like to see the simple version?", "MessageBox Example", MessageBoxButton.OKCancel);
    if result == MessageBoxResult.OK:
        MessageBox.Show("No caption, one button.");
else:
    import win32gui
    import win32con
    result = win32gui.MessageBox(0, "Would you like to see the simple version?", "MessageBox Example", win32con.MB_YESNO);
    if result == win32con.IDYES:
        win32gui.MessageBox(0, "No caption, one button.", "", win32con.MB_OK);

There is no single way to display message box both in NiceForm and in NiceLabel Portal. So the previous code snippet shows how you can do it on both platforms.