We received a consultation from a store that helps us with the production of web pages, etc., about how to put together the order details of an online shop that receives pre-orders mainly online due to the influence of Corona. It's okay to put it together in Excel, but I thought I could make a simple app, so I decided to make it while investigating.  Tkinter https://python-textbok.readthedocs.io/en/1.0/Introduction_to_GUI_Programming.html Copy and paste the Introduction to GUI Program and run it. By the way, it seems that Tkinter is often included in python, so if you are developing on Mac, you do not need to install it. Try running the calculator sample program at the end of this page. The + and-that should have appeared do not appear. I tried various things, but tkinter and py2app described later seem to be very susceptible to the influence of the python version and the installation source, so I tried changing the installation source such as pyenv and miniconda, but after all I updated the OS to Catalina And probably succeeded with Python 3.8.2 (I'm sorry if it's different!) And virtualenv which were included in the genuine product. It would be a good article to record the failure record of this area, but I have not recorded it properly, so I will record it the next time I do something. case being settled. Now, let's look at the sample program and change the necessary parts.
Since it is a program that reads csv files and outputs the aggregated results, I decided to create only the side because the interface is good with the part that displays the file name, the directory call button, and the execute button. A simple task of rewriting the class defined in the sample to your own class and pressing one button. This looks good. Next, let's make the contents. I referred to the qiita articles of here and here. (Because I am a beginner, please let me know if there is a better way to quote.) For tkinter's filedialog, I referred to this tutorial. Data organization reads the usual Pandas. Website CSV, creates a dataframe subset of product names, and aggregates them.
#List only unique values
self.itemlist=df["Item's Name"].unique()
#Calculate total number from subset data frames
result={}
for item in self.itemlist:
tempdf=df.loc[df["Item's Name"]==item]
sumqty=tempdf["Qty"].sum()
result[item]=sumqty
Create a binary for Mac. I tried using py2app by referring to this site, but my Mac crashed, the app couldn't be opened, and so on. To clear various dependency problems here, I put the necessary libraries in the virtualenv environment into virtualenv with pip (I think it was only pandas and py2app this time), and finally succeeded in creating the application.
The usage of py2app itself is very easy
py2applet --make-setup test.py
python setup.py py2app
You can do it with just this. Dependent libraries don't seem to work unless they are properly separated by virtualenv. In this way, the first application life was finally completed. Even if the code could be done in one day, it took two more days to make it an app lol I'm sorry that the tone has changed. Let's meet again.
Recommended Posts