How to use the easygui.filesavebox 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 realpython / python-basics-exercises / ch18-graphical-user-interfaces / 2-example-app-pdf-page-rotator.py View on Github external
# 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)
    output_path = gui.filesavebox(title=save_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 output_path is None:
    exit()

# Open the input PDF, rotate all of the pages, and add the rotated
github n8henrie / icsConverter / icsconverter.py View on Github external
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()

    except Exception, e:
        easygui.msgbox('Looks like the conversion went okay, but there was some kind of error writing the file. Sorry!')
        logger.exception(e)
        sys.exit(3)
github vzat / signature_extractor / masterForgery.py View on Github external
def writeImageToFile(img, mask):
    # The mask of the signature can be used as the alpha channel of the image
    b, g, r = cv2.split(img)
    imgWithAlpha = cv2.merge((b, g, r, mask))

    file = easygui.filesavebox()
    fileName = file + '.png'

    if fileName is None:
        errorPrompt('No Name Selected')

    cv2.imwrite(fileName, imgWithAlpha)
github realpython / python-basics-exercises / ch18-graphical-user-interfaces / 3-challenge-use-gui-elements-to-help-a-user-modify-files.py View on Github external
# 9. Ask for the location to save the extracted pages
output_file_path = gui.filesavebox("", "Save the trimmed PDF as...", "*.pdf")

# 10. If the user does not select a save location, exit the program.
if output_file_path is None:
    exit()

# 11. If the chosen save location is the same as the input file path:
#      - Warn the user that they can not overwrite the input file.
#      - Return the step 9.
while input_file_path == output_file_path:  # cannot use same file as input
    gui.msgbox(
        "Cannot overwrite original file!", "Please choose another file..."
    )
    output_file_path = gui.filesavebox(
        "", "Save the trimmed PDF as...", "*.pdf"
    )
    if output_file_path is None:
        exit()

# 12. Perform the page extraction
output_PDF = PdfFileWriter()

for page_num in range(int(page_start) - 1, int(page_end)):
    page = input_file.getPage(page_num)
    output_PDF.addPage(page)

with open(output_file_path, "wb") as output_file:
    output_PDF.write(output_file)
github horstjens / ThePythonGameBook / python / goblindice / combatsimviewer.py View on Github external
def savefile(oldtext, text):
    filename = easygui.filesavebox()  # return None if user click Cancel
    if filename == None:
        return  # user selected Cancel
    output = open(filename, "a")  # a: append
    output.write("\n- - - - -\n{}\n{}".format(oldtext, text))
    output.close()
github decalage2 / oletools / oletools / olebrowse.py View on Github external
]
        action = easygui.choicebox(msg, title='olebrowse', choices=actions)
        if action is None or 'Back' in action:
            break
        elif action.startswith('Hex'):
            data = ole.openstream(stream).getvalue()
            ezhexviewer.hexview_data(data, msg='Stream: %s' % stream, title='olebrowse')
##            elif action.startswith('Text'):
##                data = ole.openstream(stream).getvalue()
##                easygui.codebox(title='Text view - %s' % stream, text=data)
##            elif action.startswith('Repr'):
##                data = ole.openstream(stream).getvalue()
##                easygui.codebox(title='Repr view - %s' % stream, text=repr(data))
        elif action.startswith('Save'):
            data = ole.openstream(stream).getvalue()
            fname = easygui.filesavebox(default='stream.bin')
            if fname is not None:
                f = open(fname, 'wb')
                f.write(data)
                f.close()
                easygui.msgbox('stream saved to file %s' % fname)
github mattb112885 / clusterDbAnalysis / lib / GuiBase.py View on Github external
def _get_file_name(self, extension="txt"):
        '''
        
        This returns the name of a file the user wants to save as
        or None if the user cancels or does not name a file.

        '''
        filename = easygui.filesavebox(msg = "Where do you want to save the file (extension %s will automatically be added)?" %(extension))
        # User cancelled.
        if filename is None:
            return None
        filename = filename + "." + extension
        # Check for file existence and ask if it is OK to overwrite the file.
        if os.path.exists(filename):
            ok_to_overwrite = easygui.buttonbox(msg="File %s already exists. Overwrite?" %(filename), choices = ("No", "Yes") )
            if ok_to_overwrite == "Yes":
                return filename
            else:
                return None
        else:
            return filename
    def _save_file_dialogs(self, extension = "txt"):
github fievelmousekewitz / EpicorAutoPilot / EpicorAutoPilot.py View on Github external
def Choice_Backup_Live():
    rightnow = datetime.datetime.now()
    defaultfilename =  rightnow.strftime("%B")
    defaultfilename = defaultfilename[:3] 
    
    if easygui.ynbox('Online Backup?') == 1:
         ynonline = "online"
    else:
        ynonline = ""
    easygui.msgbox(msg='After selecting Source, Destination & Online please wait, this can take a while and you will see no progress bar.')
    PilotApp.Backup(
        easygui.fileopenbox(
            'Select database to backup',
            default=PilotApp.Settings['EpicorDBDir']+'\\'),
        easygui.filesavebox(
            'Filename to backup to',
            default=PilotApp.Settings['EpicorDBDir']+'\\'+ defaultfilename + 'live' + str(rightnow.day ) ),
        ynonline)

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

56 / 100
Full package analysis

Similar packages