How to use the easygui.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 / test_cases / flash_multiple_rb.py View on Github external
import sys

sys.path.append('..')
import easygui

# This is an example of Robby's need to have callbacks.  Since location is retained this works better.
choices = ["on", "off", "forward", "backward", "right", "left"] 
inp = ''
while inp != "None": #happens when the user presses ESC
    inp = easygui.buttonbox("controller","robot", choices)
    if inp == "forward":
        pass
    elif inp == "backward":
        pass
    elif inp == "off":
        break
github robertlugg / easygui / test_cases / button_box_tests.py View on Github external
choices = [("Alice", 1), ("Bob", 2), ("Charlie", 3)]
    choices = collections.OrderedDict(choices)
    value = eg.buttonbox(
        msg="Sorting of buttons demo, choices passed as an ordered dict",
        choices=choices,
        default_choice="Bob")
    print("Return: {}".format(value))

    value = eg.buttonbox(
        msg='Sorting of buttons test, choices as list of pairs = [("Alice", 1), ("Bob", 2), ("Charlie", 3)]',
        choices=[("Alice", 1), ("Bob", 2), ("Charlie", 3)],
        default_choice="Bob")
    print("Return: {}".format(value))

    eg.buttonbox(msg='Simple use test: \nbuttonbox(msg="Simple call test", choices=["Alice", "Bob", "Charlie"], default_choice="Bob")', choices=["Alice", "Bob", "Charlie"], default_choice="Bob")
github Jflick58 / Easysentiment / easysentiment / scraper_and_analysis.py View on Github external
def scrape_and_analyze():
    """scrape and analyze."""
    # Opens a GUI on start

    version = 'Easysentiment 1.2'

    options = ['Start', 'Developer Page', 'Exit']

    button = g.buttonbox(
        'Welcome to Easysentiment Twitter Scraper and Seniment Analyzer Version 1.2' +
        '\n' + '\n' + '\n' + '\n' + '\n' +
        'Created by Justin Flick, Copyright 2017 Licensed Under MIT License',
        title=version, choices=options
    )

    if button == options[0]:
        pass
    if button == options[1]:
        webbrowser.open('https://github.com/Jflick58', new=0, autoraise=True)
    if button == options[2]:
        sys.exit()

    msg = "Enter your query information. Output will be in the form of a .csv file"
    title = version
    fieldNames = [  # NOQA
github ironman5366 / W.I.L.L / plugins / chromecast.py View on Github external
chromecasts_available = pychromecast.get_chromecasts_as_dict().keys()
    chromecast_name = None
    for chromecast in chromecasts_available:
        if isinstance(known_chromecasts, list):
            if chromecast in known_chromecasts:
                chromecast_name = chromecast
        elif isinstance(known_chromecasts, str):
            if chromecast == known_chromecasts:
                chromecast_name = chromecast

        else:
            return "Error: unrecognized chromecast conifg {0}".format(str(known_chromecasts))
    if chromecast_name:
        cast(chromecast_name)
    else:
        chromecast_choice = easygui.buttonbox(title="Chromecasts Found", msg="Please choose a chromecast", choices=chromecasts_available)
        if chromecast_choice:
            if easygui.ynbox("Would you like to save this chromecast in your W.I.L.L config?"):
                config.add_config({"known_chromecasts":[chromecast_choice]})
            cast(chromecast_choice)
        else:
            return "Error: No chromecast chosen"
    # cast.wait()
github realpython / python-basics-exercises / ch18-graphical-user-interfaces / 2-example-app-pdf-page-rotator.py View on Github external
file_type = "*.pdf"
input_path = gui.fileopenbox(title=open_title, default=file_type)

# If nothing was returned by gui.fileopenbox(), the user either
# hit cancel or closed the window so we should exit the program.
if input_path is None:
    exit()

# Ask the user by how many degrees each page should be rotated.
# If the user dosn't select anything, keep displaying the
# buttonbox() element until they do.
choices = ("90", "180", "270")
message = "Rotate the PDF clockwise by how many degrees?"
degrees = None
while degrees is None:
    degrees = gui.buttonbox(message, "Choose rotation...", choices)

# Convert the chosen number of degrees to an integer
degrees = int(degrees)

# Ask the user what they would like to call the new PDF and where
# it should be saved.
save_title = "Save the rotated PDF as..."
output_path = gui.filesavebox(title=save_title, default=file_type)

# If the user tries to overwrite the file they originally selected
# for rotation, warn them and ask them to select a new file path.
# Keep doing this until a valid file path is chosen.
warn_title = "Warning!"
warn_message = "Cannot overwrite original file!"
while input_path == output_path:
    gui.msgbox(warn_message, warn_title)
github ohsnapitsnathan / brainkit / brainkit.py View on Github external
print("Could not connect to server")
while True:
    choices=["(1) Create protocol manually","(2) Create protocol from experiment","(3) Run protocol","(4) Record data","(5) Run stimulator self tests"]
    userChoice=eg.choicebox("Welcome to BrainKit. Select an option to continue",title="BrainKit 1.0",choices=choices)
    if "1" in userChoice:
        createProtocol()
    if "2" in userChoice: #create protocol from experiment
        eFileName=eg.fileopenbox(title="Select the experiment file that you want to open")
        filepath=""
        splitup=eFileName.split("\\")
        for item in range(0,len(splitup)-1):
            filepath=filepath+splitup[item]+"\\"
        os.chdir(filepath) #set working directory so that we can load the data files
        eFile=open(eFileName,'r')
        efLines=eFile.readlines()
        exType=eg.buttonbox(title="Select experiment type",msg="What type of experiment is this?",choices=["Correlation experiment","Paired test experiment"])
        if ("Correlation" in exType): # Correlating an IV with neurophys data
            header=efLines[0]
            splitHead=header.split("\t")[1:]
            iv=eg.choicebox(title="Select behavioral variable",msg="Select which column designates the behavioral or cognitive variable of interest for this experiment",choices=splitHead)
            if iv:
                dv=[]
                ivnum=-1
                for item in range(0,len(splitHead)):
                    if iv in splitHead[item]:
                        ivnum=item
##                    #dv.append(item)
##                for item in range(1,len(splitHead)):
##                    dv.append(splitHead[item])

                setup=eg.multenterbox(title="Analysis settings",msg="Choose the settings you want for this analysis.",fields=["Critical p:","Use Bonferroni correction for multiple comparisons?(y/n)","Permutations per variable","Epoch size(seconds)","Artifact rejection threshold"],values=["0.05","n","10000","10","0.5"])
                allSession=[]
github horstjens / ThePythonGameBook / python / goblindice / combatsimviewer.py View on Github external
picdict = {"Grunty": "grunty200.gif", "Stinky": "stinky200.gif"}

    m1_wins, m2_wins, battles, battlerounds, m1_hp, m2_hp, \
        vtext, log = clean() # set valuues to zero / empty
    oldtext = ""

    calc_buttons = ["+1 battle", "+10 battles", "+100 battles", "1000", "10000"]
    buttonlist = ["log", "clear", "edit", "save"]
    buttonlist.extend(calc_buttons)  # append each calcbutton to the list
    buttonlist.append("quit")  # append one single elemet

    while True:
        text = make_txt(
            m1, m2, m1_wins, m2_wins, m1_hp, m2_hp, battles, battlerounds
        )
        action = easygui.buttonbox(
            oldtext + text + vtext,
            "combat sim viewer",
            buttonlist,
            image=victorimage
        )
        if action == "quit":  # --------menu handler-----------
            break
        elif action == "log":
            show_log(battles, vtext, log)
        elif action == "clear":
            m1wins, m2wins, battles, battlerounds, m1_hp, m2_hp, \
                vtext, log = clean()
            text, oldtext, victorimage = "", "", None
        elif action == "edit":
            m1, m2 = edit_monsters(m1, m2)
            oldtext = text + "\n" + "- - - " * 10 + "\n"
github mattb112885 / clusterDbAnalysis / gui / PhyloTrees.py View on Github external
trimmed_dir = os.path.join(results_location, "trimmed_alignments")
        if not os.path.exists(trimmed_dir):
            os.makedirs(trimmed_dir)

        # Now we need a list of core genes.
        runid = self._get_runid()
        sys.stderr.write("Getting a list of core genes in the specified cluster run. Please be patient...\n")
        orglist = getOrganismsInClusterRun(runid, self.sqlite_cursor)
        # ALL and UNIQUE - the genes must have representatives in every organism in the cluster run and have exactly one copy per organism.
        cluster_runs = findGenesByOrganismList(orglist, runid, cl = None, all_org = True, uniq_org = True, pct_cutoff = None, outgroup = None)

        # The user can choose to only make a tree from a subset of the clusters if he or she wants.
        # Subset is the default because it is way faster to compute.
        msg = "Do you want to make a tree from ALL core genes or only a SUBSET of them? (Note that using ALL takes a lot of time)"
        choices = ("Subset", "All")
        choice = easygui.buttonbox(msg=msg, title='', choices=choices)
        if choice is None:
            raise UserCancelError("User cancelled the operation")

        if choice == "Subset":
            # Make a subset
            #     Build a list of the clusters with annotation
            #     User selects which one(s) he or she wants
            ann2id = {}
            sys.stderr.write("Populating list of clusters from which to choose...\n")
            for cr in cluster_runs:
                runid = cr[0]
                clusterid = cr[1]
                ann = findRepresentativeAnnotation(runid, clusterid, self.sqlite_cursor)
                ann += "(ID %s)" %(clusterid)
                ann2id[ann] = (runid, clusterid)
            msg = """Please select one or more of the following clusters to include (click to select and click OK when finished)"""
github horstjens / ThePythonGameBook / python / lizardpaper_easygui.py View on Github external
def ask(msg="Your answer please:", choices=["yes", "no"]):
    return easygui.buttonbox(msg, "your answer:", choices)

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

61 / 100
Full package analysis