How to use easygui - 10 common examples

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 micmarty / Instronizer / src / classifier / test_file_chooser.py View on Github external
import easygui
from pathlib import Path, PurePath
import subprocess

'''GUI for choosing single wav file'''
# Needs modification (@moonman)

file_path = easygui.fileopenbox(
    default='~/Desktop/*.wav',
    filetypes=['*.wav'],
    title='Choose a single wav file with solo instrument')

out_dir = easygui.diropenbox(
    default='~/Music',
    title='Choose ouput directory for generated spectrograms')

# Create output dir
file_path = Path(file_path) 
out_dir = Path(out_dir, 'spectrograms')
out_dir.mkdir(exist_ok=True)
print("Created directory: ", out_dir)

# Execute preprocessor
subprocess.check_call(['python', '/home/miczi/Projects/single-instrument-recognizer/src/preprocessor.py', 
                        '--single-file-input', str(file_path), 
                        '--output-spectrograms-dir', str(out_dir)])

subprocess.check_call(['python', '/home/miczi/Projects/single-instrument-recognizer/src/mobilenet_train.py',
                        '-a', 'mobilenet',
github n8henrie / icsConverter / icsconverter.py View on Github external
event.add('dtstamp', datetime.replace( datetime.now(), tzinfo=LocalTimezone() ))
            event['uid'] = str(randint(1,10**30)) + datetime.now().strftime('%Y%m%dT%H%M%S') + '___n8henrie.com'

            cal.add_component(event)
            rownum += 1

    except Exception, e:
        if rownum > 0:
            easygui.msgbox('I had a problem with an event. I think I might have gotten through about {0} events and had trouble with an event with subject: {1}. Sorry!'.format(rownum, row['Subject']))
            logger.exception(e)
        elif rownum == 0:
            easygui.msgbox('Looks like I didn\'t even get through the first event. Sorry!')
            logger.exception(e)
        else:
            easygui.msgbox('Somehow it looks like I processed negative events... that shouldn\'t have happened. Sorry!')
            logger.exception(e)
        sys.exit(2)

    try:
        # Write final .ics file to same directory as input file.
        if isdir(expanduser('~/Desktop')):
            f = open(easygui.filesavebox(msg='Save .ics File', title='', default=expanduser('~/Desktop/') + 'calendar.ics', filetypes=['*.ics']), 'wb')
        else:
            f = open(easygui.filesavebox(msg='Save .ics File', title='', default=expanduser('~/') + 'calendar.ics', filetypes=['*.ics']), 'wb')

    # For testing comment 4 lines above (2 x if / else) and use this:
    #    f = open('path_to_tester.csvcalendar.ics', 'wb')

        f.write(cal.to_ical())
        f.close()
github vzat / signature_extractor / masterForgery.py View on Github external
def errorPrompt(errorMsg):
    print 'Error: ' + errorMsg
    easygui.msgbox(msg = errorMsg, title = 'ERROR', ok_button = 'OK')
    quit()
github n8henrie / icsConverter / icsconverter.py View on Github external
try:
        if infile == None:
            start_dir = '~/'
            if isdir(expanduser("~/Desktop")):
                start_dir = '~/Desktop/'
            msg = 'Please select the .csv file to be converted to .ics'
            infile = easygui.fileopenbox(msg=msg, title="", default=expanduser(start_dir), filetypes=["*.csv"])

        reader_builder = list(csv.DictReader(open(infile, 'U'), skipinitialspace = True))

    # For testing comment 4 lines above (2 x if / else) and use this:
    #        reader_builder = list(csv.DictReader(open('path_to_tester.csv', 'rb'), skipinitialspace = True))

    except Exception as e:
        logger.exception(e)
        easygui.msgbox("Looks like there was an error opening the file, didn't even make it to the conversion part. Sorry!")
        sys.exit(1)

    # Filter out events with empty subjects, a required element
    # for a calendar event.
    # Code found here: http://bit.ly/Z4Pg4h
    reader_builder[:] = [d for d in reader_builder if d.get('Subject') != '']

    headers = reader_builder[0].keys()
    logger.debug('reader_builder[0].keys(): {}'.format(headers))
    check_headers(headers)

    reader = clean_spaces(reader_builder)

    # Start calendar file
    cal = Calendar()
    cal.add('prodid', 'n8henrie.com')
github ohsnapitsnathan / brainkit / brainkit.py View on Github external
eg.msgbox("Press the reset button on the stimulator, then click OK")
                    print("Waiting for the stimulator to come back online...")
                    time.sleep(10)
                    
                    postsession=[]
                    for item in protosplit[1].split("\n"):
                        if "/2" in item or "/3" in item and "NPHYS" not in item:
                            postsession.append(item[:item.find("/")])
                    print(str(postsession))
                    if len(postsession) > 0:
                        hasData=True
                        postsession.append("Comments")
                        postData=eg.multenterbox("This protocol requires values for the following post-session metrics","Outcome measures",postsession)
                    if "NPHYS/2" in protosplit[1] or "NPHYS/3" in protosplit[1]:
                        hasdata=True
                        eg.msgbox("This protocol calls for neurophysiological data collection. Click OK to begin data collection.")
                        connectStim()
                        postname=fileName+"-postsession-"+str(randint(0,9999))
                        recordData(postname)
                    #now string things together to make the log file
                    header=""
                    data=""
                    if len(prename) >0:
                        header=header+"prestim-nphys-file\t"
                        data=data+prename+"\t"
                    if len(postname) > 0:
                        header=header+"poststim-nphys-file\t"
                        data=data+postname+"\t"
                    header=header+"sham\t"
                    if sham:
                        data=data+"1\t"
                    else:
github ironman5366 / W.I.L.L / will / plugincreate.py View on Github external
else:
            if easygui.ynbox("Would you like to exit?"):
                sys.exit()
            else:
                getdata(inputtype, easyguiargs)

    plugname = getdata("enterbox", "What would you like to name the plugin?")
    # Add more choices here if the plugin module gets increased variability
    typechoices = ["Python", "Terminal Command"]
    plugtype = getdata("buttonbox", ("Please pick a plugintype", typechoices))
    if plugtype == typechoices[0]:
        formalplugtype = 'python'
    elif plugtype == typechoices[1]:
        formalplugtype = 'exec'
    else:
        easygui.msgbox("Unrecognized plugin type {0}".format(plugtype))
        sys.exit()
    required = []
    possiblerequired = ["command", "name", "email", "phone", "time", "date"]
    for item in possiblerequired:
        if getdata('ynbox', 'Does your plugin require {0} to be passed to it?'.format(item)):
            required.append(item)
        else:
            pass
    syns = []
    synsraw = getdata("enterbox",
                      "Please enter all synonym words or phrases for your plugin, seperated with commas. No spaces in between synonyms. If there are no synonyms, just hit OK.")
    if ',' in synsraw:
        for item in synsraw.split(','):
            syns.append(item)
    else:
        if synsraw != '':
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()

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

63 / 100
Full package analysis