In [10]:
from simpy import Environment
from simpy import Store
from random import choice
import pandas as pd
from cross.config import Config

class CrossTestConfig(Config):
    # RANDOM_SEED = 57
    # NUM_PACKAGES = 100
    # INTERVAL_TIME = 10
    # TYPE_PIP_LINE = Store(env)
    # ==========================测试机配置参数===================================
    # 产生package机器ID列表,本次杭州仿真模型一般一个机器只有一个入口队列
#     ID_LAST_MACHINE = ['last_1']
    # 测试机器ID列表
    # ID_TEST_MACHINE = ['test_1']
#     # 根据测试机器后面可能去的机器ID列表
#     ID_NEXT_MACHINE = ['next_1', 'next_2', 'next_3', 'next_4']
    # 测试机资源数
    CAPACITY_RESOURCE = None  # 如果测试机器内部无资源调用,设置为None,否则设置资源数(如人力)
    # 测试机单资源处理时延
    PROCESS_TIME = None  # 如果测试机器没有处理货物延时,设置为None,否则设置为对应延时

        
class PackageGenerator(object):
    def __init__(self, env=Environment, num_package=None, interval_time=None):
        """"""
        self.env=env
        self.num_package = num_package
        self.interval_time = interval_time
        self.package_cls = None   #  为后续采用Package类预留
    
    
    def config_package(self, id_last_machine, id_next_machine):
        """"""
        pass

    
    
class LogicTest(object):
    """"""
    def __init__(self, env, test_cls, config):
        self.env = env
        self.test_cls = test_cls
        self.config = config
        self.pipline = {}
        self.pipline_dic = {}
        self.path = []
    
    
    def _path_gen(self):
        """"""
        for o in self.config.ID_LAST_MACHINE:
            tmp1 = []
            for t in self.config.ID_TEST_MACHINE:
                tmp1.append(''.join([o,'_', t]))
                tmp2 = []
                for d in self.config.ID_NEXT_MACHINE:
                    tmp2.append(''.join([t, '_', d]))
                    self.path.append([o, t, d])
                self.pipline_dic[t] = tmp2
            self.pipline_dic[o] = tmp1
    
    def _pipline_generator(self):
        for v in self.pipline_dic.values():
            self.pipline.update({it: 'store' for it in v })
        
    def generator(self):
        """"""
        self._path_gen()
        self._pipline_generator()
    
    def packages_generator(self):
        """"""
        pass
    
    


if __name__ == '__main__':
    env = Environment()
    t1 = LogicTest(env, str, CrossTestConfig)
    t1.generator()
    # tf2 = pd.DataFrame(t1.pipline)
    p1 = t1.pipline
    p2 = t1.pipline_dic
    print(p1)


{'test_machine_1_next_machine_1': 'store', 'test_machine_1_next_machine_2': 'store', 'test_machine_1_next_machine_3': 'store', 'test_machine_1_next_machine_4': 'store', 'test_machine_2_next_machine_1': 'store', 'test_machine_2_next_machine_2': 'store', 'test_machine_2_next_machine_3': 'store', 'test_machine_2_next_machine_4': 'store', 'test_machine_3_next_machine_1': 'store', 'test_machine_3_next_machine_2': 'store', 'test_machine_3_next_machine_3': 'store', 'test_machine_3_next_machine_4': 'store', 'test_machine_4_next_machine_1': 'store', 'test_machine_4_next_machine_2': 'store', 'test_machine_4_next_machine_3': 'store', 'test_machine_4_next_machine_4': 'store', 'last_machine_1_test_machine_1': 'store', 'last_machine_1_test_machine_2': 'store', 'last_machine_1_test_machine_3': 'store', 'last_machine_1_test_machine_4': 'store'}

In [6]:
p1


Out[6]:
{'last_machine_1_test_machine_1': 'store',
 'last_machine_1_test_machine_2': 'store',
 'last_machine_1_test_machine_3': 'store',
 'last_machine_1_test_machine_4': 'store',
 'test_machine_1_next_machine_1': 'store',
 'test_machine_1_next_machine_2': 'store',
 'test_machine_1_next_machine_3': 'store',
 'test_machine_1_next_machine_4': 'store',
 'test_machine_2_next_machine_1': 'store',
 'test_machine_2_next_machine_2': 'store',
 'test_machine_2_next_machine_3': 'store',
 'test_machine_2_next_machine_4': 'store',
 'test_machine_3_next_machine_1': 'store',
 'test_machine_3_next_machine_2': 'store',
 'test_machine_3_next_machine_3': 'store',
 'test_machine_3_next_machine_4': 'store',
 'test_machine_4_next_machine_1': 'store',
 'test_machine_4_next_machine_2': 'store',
 'test_machine_4_next_machine_3': 'store',
 'test_machine_4_next_machine_4': 'store'}

In [3]:
p2


Out[3]:
{'last_machine_1': ['last_machine_1_test_machine_1',
  'last_machine_1_test_machine_2',
  'last_machine_1_test_machine_3',
  'last_machine_1_test_machine_4'],
 'test_machine_1': ['test_machine_1_next_machine_1',
  'test_machine_1_next_machine_2',
  'test_machine_1_next_machine_3',
  'test_machine_1_next_machine_4'],
 'test_machine_2': ['test_machine_2_next_machine_1',
  'test_machine_2_next_machine_2',
  'test_machine_2_next_machine_3',
  'test_machine_2_next_machine_4'],
 'test_machine_3': ['test_machine_3_next_machine_1',
  'test_machine_3_next_machine_2',
  'test_machine_3_next_machine_3',
  'test_machine_3_next_machine_4'],
 'test_machine_4': ['test_machine_4_next_machine_1',
  'test_machine_4_next_machine_2',
  'test_machine_4_next_machine_3',
  'test_machine_4_next_machine_4']}

In [4]:
pd.DataFrame(t1.path)


Out[4]:
0 1 2
0 last_machine_1 test_machine_1 next_machine_1
1 last_machine_1 test_machine_1 next_machine_2
2 last_machine_1 test_machine_1 next_machine_3
3 last_machine_1 test_machine_1 next_machine_4
4 last_machine_1 test_machine_2 next_machine_1
5 last_machine_1 test_machine_2 next_machine_2
6 last_machine_1 test_machine_2 next_machine_3
7 last_machine_1 test_machine_2 next_machine_4
8 last_machine_1 test_machine_3 next_machine_1
9 last_machine_1 test_machine_3 next_machine_2
10 last_machine_1 test_machine_3 next_machine_3
11 last_machine_1 test_machine_3 next_machine_4
12 last_machine_1 test_machine_4 next_machine_1
13 last_machine_1 test_machine_4 next_machine_2
14 last_machine_1 test_machine_4 next_machine_3
15 last_machine_1 test_machine_4 next_machine_4

In [72]:
from tkinter import *

# root = Tk()
master = Tk()

e = Entry(master)
e.pack({'side': 'left'})

e.focus_set()

def callback():
    print(e.get())

b = Button(master, text="get", width=10, command=callback)
b.pack()

mainloop()

In [68]:
from tkinter import *


root = Tk()


FRAME_WIDTH = 1350  # 界面的总计宽度
FRAME_WIDTH_LEFT = 800  # 左侧界面的总计宽度
FRAME_WIDTH_RIGHT = 550  # 右侧界面的总计宽度
FRAME_WIDTH_LEFT_HALF = 350  #左侧界面的半宽度

FRAME_HEIGHT = 750  # 界面的总计高度
FRAME_HEIGHT_HEAD = 100  # 标题的高度
FRAME_HEIGHT_CENTER = 500  # 中间界面的总计高度
FRAME_HEIGHT_CENTER_PACKAGE = 50  # 包裹设置界面高度
FRAME_HEIGHT_BOTTOM = 50  # 底部界面的总高度
FRAME_HEIGHT_LEFT_CENTER = 330


class ConfigApp(object):
    """"""
    RELOAD_FRAME = {
        'RIGHT_FRAME': {
            'attr': {
                'width': FRAME_WIDTH_RIGHT,
                'height': FRAME_HEIGHT,
                'bd': 2,
                'relief': 'raise',
                'bg': '#A2B5CD'
            },
            'pack': {'side': 'right'}
        },
        'RIGHT_TITLE': {
            'attr': {
                'width': FRAME_WIDTH_RIGHT,
                'height': 50,
                'bd': 2,
                'relief': 'raise'
            },
            'pack': {'side': 'top'}
        },
        'RIGHT_BUTTON': {
            'attr': {
                'width': FRAME_WIDTH_RIGHT,
                'height': FRAME_HEIGHT_BOTTOM,
                'bd': 2,
                'relief': 'raise'
            },
            'pack': {'side': 'bottom'}
        }
    }
    
    
class App(Frame):
    """"""
    def __init__(self, master=None, pack: dict=None, attr: dict=None):
        super().__init__(master=master)
        self.pack_dic = pack
        self.attr = attr
        self._init_frame()

    def _init_frame(self):
        if self.pack_dic:
            self.pack(self.pack_dic)
        else:
            self.pack()
        if self.attr:
            self.config(self.attr)
    def reset_pack(self):
        """"""
        pass

    
def init_app(master, wig):
    """"""

    return App(master=master,
               pack=ConfigApp.RELOAD_FRAME[wig]['pack'],
               attr=ConfigApp.RELOAD_FRAME[wig]['attr'])


right = init_app(
        master=root,
        wig='RIGHT_FRAME')

right_output_pad_title = init_app(
        master=right,
        wig='RIGHT_TITLE'
    )

w = Label(
    right_output_pad_title, 
    text="Hello, world!", 
    anchor=W)
# w.pack({'side': 'top'})
# lblReceipt.pack()


root.mainloop()

In [6]:
from tkinter import *


m = PanedWindow(orient=VERTICAL)
m.pack(fill=BOTH, expand=1)

top = Label(m, text="top pane")
m.add(top)

bottom = Label(m, text="bottom pane")
m.add(bottom)


root.mainloop()

In [71]:
ONLY_LAND = True

DB_PACKAGE = {
            'land': {
                'parcel': 'i_od_parcel_landside',
                'small': 'i_od_small_landside'
            },
            'air': {
                'parcel': 'i_od_parcel_airside',
                'small': 'i_od_small_airside'
            }
        }


truck_uld_data = {}
if ONLY_LAND:
    DB_PACKAGE.pop('air')
    truck_uld_data.update(DB_PACKAGE)
else:
    truck_uld_data.update(DB_PACKAGE)
    
truck_uld_data


Out[71]:
{'land': {'parcel': 'i_od_parcel_landside', 'small': 'i_od_small_landside'}}

In [46]:
foo = [2, 18, 9, 22, 17, 24, 8, 12, 27]
print([v for k, _ in DB_PACKAGE.items() if (k == 'air' and ONLY_LAND)])


[{'parcel': 'i_od_parcel_airside', 'small': 'i_od_small_airside'}]