Files

141 lines
4.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""v1.0.34 界面图(1440×900,现场 19 寸):
① 不分组(三个维度按钮,没有下拉)
② 按客户 + 下拉展开(选客户只占一行,不再铺 chips)
③ 按分类 + 下拉展开
"""
import json
import os
import sys
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, ROOT)
os.chdir(ROOT)
import tkinter as tk
from PIL import ImageGrab
import ui.app as A
W, H = 1440, 900
OUT = os.path.join('docs', 'design')
os.makedirs(OUT, exist_ok=True)
cfg = json.load(open('config.json', encoding='utf-8'))
cfg.setdefault('server', {})['mock'] = True
cfg.setdefault('flow', {})['confirm_before_submit'] = True
cfg['ui'] = {'mode': 'window', 'width': W, 'height': H,
'borderless': True, 'todo_group': 'none'}
A.load_config = lambda *a, **k: cfg
DATA = [
('荣县分公司', '叶菜', '藕', '散装', 14.60, '斤'),
('荣县分公司', '叶菜', '大白菜', '散装', 61.04, '斤'),
('荣县分公司', '根茎', '圆萝卜', '散装', 2.00, '斤'),
('市邮政', '叶菜', '小白菜', '散装', 18.50, '斤'),
('市邮政', '根茎', '马铃薯', '散装', 50.00, '斤'),
('市邮政', '水果', '红富士苹果', '80#', 100.00, '斤'),
('富顺分公司', '叶菜', '四季豆', '散装', 26.00, '斤'),
('富顺分公司', '叶菜', '莴笋', '散装', 20.00, '斤'),
('富顺分公司', '水果', '冰糖橙', '散装', 30.00, '斤'),
('大安分公司', '根茎', '胡萝卜', '散装', 12.00, '斤'),
('大安分公司', '水果', '水果黄瓜', '散装', 4.00, '斤'),
('大安分公司', '菌菇', '香菇', '一级', 2.00, '包'),
]
rows = []
for i, (cust, cat, name, spec, qty, unit) in enumerate(DATA):
rows.append({'id': 'pk-%03d' % i, 'pick_code': 'PK202611050%02d' % (i // 4),
'order_code': 'DD20261105%03d' % i, 'sort_order': i + 1,
'sku_code': 'SKU%04d' % (2100 + i), 'item_name': name,
'spec': spec, 'category_name': cat, 'unit': unit,
'customer_name': cust, 'company_name': cust,
'required_qty': qty, 'remaining_qty': qty,
'requires_photo': False})
def grab(win, name):
"""抓窗口区域;下拉是独立 Toplevel,抓之前要把它重新顶到最前"""
try:
win.attributes('-topmost', True)
win.lift()
win.focus_force()
except Exception:
pass
pop = getattr(app, '_group_pop', None)
if pop is not None:
try:
pop.lift()
except Exception:
pass
win.update_idletasks()
win.update()
import time as _t
_t.sleep(0.35)
win.update()
if pop is not None:
try:
pop.lift()
except Exception:
pass
x, y = win.winfo_rootx(), win.winfo_rooty()
w, h = win.winfo_width(), win.winfo_height()
ImageGrab.grab((x, y, x + w, y + h)).save(os.path.join(OUT, name))
print(name, w, 'x', h)
root = tk.Tk()
app = A.App(root)
def step1():
for w in root.winfo_children():
w.destroy()
app.engine.station = 'picking'
app._build()
app.ready = True
app.engine.rows = rows
app.lbl_weight.configure(text='7.30')
app.lbl_jin.configure(text='14.6 斤')
app._fill_todo(rows)
root.after(700, step2)
def step2():
grab(root, 'group-none-1440x900.png')
app._set_group_mode('customer')
root.after(500, step3)
def step3():
grab(root, 'group-customer-closed-1440x900.png')
app._toggle_group_dd()
root.after(500, step4)
def step4():
grab(root, 'group-customer-dd-1440x900.png')
app._close_group_dd()
app._set_group_mode('category')
root.after(400, step5)
def step5():
app._toggle_group_dd()
root.after(500, step6)
def step6():
grab(root, 'group-category-dd-1440x900.png')
app._set_group_pick('根茎')
root.after(400, step7)
def step7():
grab(root, 'group-picked-1440x900.png')
root.destroy()
root.after(900, step1)
root.mainloop()