I have a python program that merges 'n' number of excel files where 'n' is asked from the user. I have the python program made but i don't know how to make an interface where it asks the user to select the files that the user wants to merge and the output destination. Any kind of help would be highly appreciated.
Assuming that you are looking for a GUI front end I personally would recommend wxPython.
- Free, Gratis & Open Source
- Simple Licence including commercial use
- Native Look & Feel
- Cross Platform
- Great Demo with reusable sample code
pip install wxpython then once the installation is finished run
wxdemo to download, install and run the demo for the installed version (download and install is once per installation).
wxdocs will similarly download, install & open in your browser the documentation for your version of wxPython.
Disclaimer: I am the original author of the wxDemo utility
As @Mawg mentioned in the comments if you only need a command line interface
argparse (Official HowTo) is the way to go. One trick that I like to do with my python code is to combine wxPython with
argparse so that if the user supplies all of the required parameters on the command line it just works but if there are none, or a
--gui option is used then the wxPython is called.
If the user is expected to select multiple Excel files some code such as:
import wx import os APP = None # Global wx Application - you are required to have exactly one def gui_get_files(): """ Use a wx GUI to prompt the user for the file(s) """ global APP if APP is None: APP = wx.App() filelist =  wcard = "Excel Files|*.xlsx|Old Files|*.xls|CSV|*.csv" # Excel Wildcards msg = f"Select files to add, if you have finished adding click cancel" dlg = wx.FileDialog(None, message=msg, defaultDir=os.getcwd(), defaultFile="", wildcard=wcard, style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST | wx.FD_PREVIEW ) result = wx.ID_OK while result == wx.ID_OK: result = dlg.ShowModal() if result == wx.ID_OK: filelist.extend(dlg.GetPaths()) return filelist print(gui_get_files()) # Just to test this out
Appears several times and on cancel after picking several files returns:
['C:\\Users\\Gadget\\Documents\\No_Country.xlsx', 'C:\\Users\\Gadget\\Documents\\PUGGE.xlsx', 'C:\\Users\\Gadget\\Documents\\PUGGE_Members.xlsx']