How to use the easygui.boxes.button_box.buttonbox function in easygui

To help you get started, we’ve selected a few easygui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robertlugg / easygui / easygui / boxes / derived_boxes.py View on Github external
ok_button="OK", image=None, root=None):
    """
    Display a message box

    :param str msg: the msg to be displayed
    :param str title: the window title
    :param str ok_button: text to show in the button
    :param str image: Filename of image to display
    :param tk_widget root: Top-level Tk widget
    :return: the text of the ok_button
    """
    if not isinstance(ok_button, ut.basestring):
        raise AssertionError(
            "The 'ok_button' argument to msgbox must be a string.")

    return buttonbox(msg=msg,
                     title=title,
                     choices=[ok_button],
                     image=image,
                     default_choice=ok_button,
                     cancel_choice=ok_button)
github robertlugg / easygui / easygui / boxes / demo.py View on Github external
def demo_buttonbox():
    reply = buttonbox(choices=['one', 'two', 'two', 'three'],
                      default_choice='two')
    print("Reply was: {!r}".format(reply))

    title = "Demo of Buttonbox with many, many buttons!"
    msg = ("This buttonbox shows what happens when you "
           "specify too many buttons.")
    reply = buttonbox(msg=msg, title=title,
                      choices=['1', '2', '3', '4', '5', '6', '7'],
                      cancel_choice='7')
    print("Reply was: {!r}".format(reply))
    return reply
github robertlugg / easygui / easygui / boxes / button_box_demos.py View on Github external
def demo_grid_of_images():
    package_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))  # My parent's directory
    images = list()
    images.append(os.path.join(package_dir, "python_and_check_logo.gif"))
    images.append(os.path.join(package_dir, "zzzzz.gif"))
    images.append(os.path.join(package_dir, "python_and_check_logo.png"))
    images = [images, images, images, images]
    value = buttonbox(
        title="Demo with images",
        msg="Demo with images, press buttons or images and show images",
        choices=['ok', '[C]ancel'],
        images=images,
        default_choice="ok",
        cancel_choice="[C]ancel")
    print("Return: {}".format(value))
github robertlugg / easygui / easygui / boxes / button_box_demos.py View on Github external
def demo_buttonbox_cancel():
    value = buttonbox(
        title="Demo with cancel",
        msg="Demo with cancel button, choose a button",
        choices=["Button[1]", "Button[2]", "Button[3]", "Cancel-[x]"],
        default_choice="Button[2]",
        cancel_choice="Cancel-[x]")
    print("Return: {}".format(value))
github robertlugg / easygui / easygui / boxes / demo.py View on Github external
def demo_buttonbox_with_image():
    msg = "Do you like this picture?\nIt is "
    choices = ["Yes", "No", "No opinion"]

    for image in [
            os.path.join(package_dir, "python_and_check_logo.gif"),
            os.path.join(package_dir, "python_and_check_logo.jpg"),
            os.path.join(package_dir, "python_and_check_logo.png"),
            os.path.join(package_dir, "zzzzz.gif")]:
        reply = buttonbox(msg + image, image=image, choices=choices)
        print("Reply was: {!r}".format(reply))
    return reply
github robertlugg / easygui / easygui / boxes / derived_boxes.py View on Github external
ok_button="OK", image=None, root=None):
    """
    Display a message box

    :param str msg: the msg to be displayed
    :param str title: the window title
    :param str ok_button: text to show in the button
    :param str image: Filename of image to display
    :param tk_widget root: Top-level Tk widget
    :return: the text of the ok_button
    """
    if not isinstance(ok_button, ut.basestring):
        raise AssertionError(
            "The 'ok_button' argument to msgbox must be a string.")

    return buttonbox(msg=msg,
                     title=title,
                     choices=[ok_button],
                     image=image,
                     root=root,
                     default_choice=ok_button,
                     cancel_choice=ok_button)
github robertlugg / easygui / easygui / boxes / derived_boxes.py View on Github external
:param str title: the window title
    :param list choices: a list or tuple of the choices to be displayed
    :param str image: Filename of image to display
    :param str default_choice: The choice you want highlighted
      when the gui appears
    :param str cancel_choice: If the user presses the 'X' close, which button
      should be pressed
    :return: True if first button pressed or dialog is cancelled, False if
      second button is pressed
    """
    if len(choices) != 2:
        raise AssertionError(
            'boolbox takes exactly 2 choices!  Consider using indexbox instead'
        )

    reply = buttonbox(msg=msg,
                      title=title,
                      choices=choices,
                      image=image,
                      default_choice=default_choice,
                      cancel_choice=cancel_choice)
    if reply is None:
        return None
    if reply == choices[0]:
        return True
    else:
        return False
github robertlugg / easygui / easygui / boxes / button_box_demos.py View on Github external
def demo_buttonbox_simple():
    value = buttonbox(
        title="Simple demo",
        msg="Simple demo, choose a button",
        choices=["Button[1]", "Button[2]", "Button[3]"],
        default_choice="Button[2]")
    print("Return: {}".format(value))
github robertlugg / easygui / easygui / boxes / button_box_demos.py View on Github external
def demo_with_callback():
    """ This demoes callbacks and choices as dictionaries"""

    def update(box):
        number = random.randint(1, 10)
        msg = "This demoes interfacing WITH a callback. \nYou got number {} \nNotice the absence of flicking".format(number)
        box.set_msg(msg)

    msg = "This demoes interfacing with a callback \nPush to get a random number between 1 and 10"

    buttonbox(
        title="This demoes interfacing with a callback",
        msg=msg,
        choices=["Get me a number", "[C]ancel"],
        default_choice="Get me a number",
        cancel_choice="[C]ancel",
        callback=update)

easygui

EasyGUI is a module for very simple, very easy GUI programming in Python. EasyGUI is different from other GUI generators in that EasyGUI is NOT event-driven. Instead, all GUI interactions are invoked by simple function calls.

BSD-3-Clause
Latest version published 3 years ago

Package Health Score

59 / 100
Full package analysis

Similar packages