从高层次上讲:我希望使用Python(因为我最喜欢使用这种语言)来创建用于数据输入的GUI以管理仓库库存。有人有创建这样的东西的经验吗? Python是该工具创建的不错选择吗?
更多详细信息:我有一些数据,其中包含有关仓库中产品的信息(例如sku,数量等)。在第四季度末,仓库工作人员将检查仓库中的每个物品,并计算仓库中的手头有多少,以查看人员数量是否与归档的数量相符。如果归档的计数与人工计数之间存在任何不匹配,则该项目将移至第二轮计数。如果第二个人计数与记录计数或第一计数都不匹配,则将其标记为最终审核。
我已经编写了一个程序,该程序可以执行我想要的工作,但是,我刚刚得知,执行第二次人员计数的员工将在第一次计数仍在进行的同时这样做。这给我当前的程序带来了麻烦,从本质上讲,我需要创建一个GUI,该GUI允许用户(即,数据输入员工)从数据库中获取数据,对该数据进行更改(即,填充人数) 1列和人类计数2列),以便程序立即识别匹配项/不匹配项。它基本上将充当带有内置公式的Google工作表。
如果它有助于阐明我的某些逻辑,我将在项目的版本1下面包含一些代码。
# create some test data
import pandas as pd
# create dataframe
QUANTITY = [1,1,1,2,2,2,3,3,3]
counted_quantity_1 = [4,1,1,1,1,1,1,1,5]
counted_quantity_2 = [1,2,2,2,2,2,2,2,5]
df = pd.DataFrame({'QUANTITY': QUANTITY,
'counted_quantity_1': counted_quantity_1,
'counted_quantity_2': counted_quantity_2})
我将此代码写入了excel文件,并将其另存为test_file.xlsx
这是main_test.py文件:
import pandas as pd
# get user inputs
filename = input("Enter the name of your dataset: ") # this will be test_file
filename_formatted = filename + ".xlsx"
# get the number of counts
num_counts = input("Is this the 1st or 2nd count? (enter 1 or 2): ")
# get the warehouse location
warehouse_loc = input("What is the warehouse location (enter AZ or PA): ")
# import data
df = pd.read_excel(filename_formatted)
# create new files depending on if they are the 1st or 2nd count
if num_counts == '1':
# mismatches_1 = 1 if it is a mismatch and 0 if it is not
df['matches_1'] = df.apply(lambda x: 1 if x['counted_quantity_1'] == x['QUANTITY'] else 0, axis=1)
# keep only the mismatches
df_mismatches = df[df['matches_1'] == 0]
# export as excel file
df_mismatches.to_excel("mismatches_1_" + warehouse_loc + ".xlsx")
else:
# get a column to see if any of the three columns match
df['matches_2'] = df.apply(lambda x: 1 if x['counted_quantity_2'] == x['QUANTITY'] or x['counted_quantity_2'] == x['counted_quantity_1'] else 0, axis=1)
# keep only the mismatches (i.e., 0)
df_mismatches = df.loc[df['matches_2'] == 0]
# export as excel file
df_mismatches.to_excel("mismatches_2_" + warehouse_loc + ".xlsx")
# get a column where counted_quantity_1 == counted_quantity_2 but QUANTITY is different
df['HJ_adjust'] = df.apply(lambda x: 1 if x['counted_quantity_2'] == x['counted_quantity_1'] and x['matches_2'] == 1 else 0, axis=1)
# keep only those flagged for review
df_mismatches_HJ_rev = df[df['HJ_adjust'] == 1]
# create a new column that is count 2 minus QUANTITY
df_mismatches_HJ_rev['diff_from_HJ'] = df_mismatches_HJ_rev['counted_quantity_2'] - df_mismatches_HJ_rev['QUANTITY']
# export as excel file
df_mismatches_HJ_rev.to_excel("HJ_review_" + warehouse_loc + ".xlsx")
答案 0 :(得分:1)
Python为GUI编程提供了许多可能性。 本地GUI (即在Windows / Linux / macOS窗口中显示的GUI)最常用的python软件包有tkinter
,PyQt
,{{3} },wxPython
和PyGObject
。然后还有用于基于Web的GUI 的python软件包(即,在Web浏览器中显示的GUI),最常用的软件包可能是kivy
。 django
包甚至可以在 Excel工作簿中实现GUI。
每个软件包都有自己的优势和局限性,选择最适合您的应用程序的软件包并非易事(如果您问五个不同的人,您很可能会收到五个不同的答案)。
我建议您先阅读文档页面中的介绍/教程,以初步了解上述软件包。然后(如果需要)再次回到这里,提出更多针对性的问题。