import tkinter as tk #import ttkbootstrap as ttk #from ttkbootstrap.constants import * from gui import App from caditem import CadItem from controller import Controller, GuiLogic from manage_configs import Configs import argparse import os demo_data = """ { "parent_children_mapping": { "400102130": [ "400102142" ], "400102167": [ "821116004" ], "400102168": [ "821116001" ], "400102195": [ "822066075", "822066216", "822066154", "822066101", "822064090", "822066196", "400102129", "822066217", "822066160", "822066215", "913041045", "913011009", "911011057", "822064035", "925011006", "911091041", "913051040", "911021112", "911021166", "825006003", "912041005", "911011014", "911011009", "911021144", "911021001", "913011016", "929055170", "913011010", "911021035", "829416065", "712000151", "712000100" ], "400102196": [ "400102125", "400102126", "400102130", "400102161", "400102163", "400102165", "400102166", "400102167", "400102168", "400102190", "400102195", "400102198", "400102246", "400102247", "400102267", "400102272", "400102274", "400102275", "400102277", "400102278", "400102282", "400102284", "400102417", "720002003", "721001034", "821114025", "822064091", "822066085", "822996075", "829416061", "829516004", "911021113", "911021181", "911021259", "911091054", "911091096", "911091097", "911251013", "912011009", "919050006", "924031058", "924031081" ], "400102235": [ "400102236", "400102237", "400102238", "400102239", "400102268", "911021143", "911021054", "911021055" ], "400102236": [ "MA0000006" ], "400102267": [ "400102235", "829416159", "829416077", "829416079", "911021260", "911021147", "911251014" ], "400102282": [ "822066026", "822066089", "919010052" ], "821114025": [ "911081007", "821116053" ], "821116004": [ "822026004" ], "822064035": [ "822066065" ], "822064091": [ "822066212", "822064093", "822066220", "822066200", "912011010", "911021156", "822066201", "911071027", "913011109", "911011070", "913011001", "710005021", "919010055", "720000008", "720000007" ], "822064093": [ "822066204", "822066205", "822066206", "822066207", "822066208" ], "822066075": [ "822066157", "822066162", "911261023" ], "822066160": [ "MA0000004" ], "822066162": [ "822064013" ], "822066196": [ "MA0000008" ], "822066220": [ "924031033" ], "829416159": [ "829416089" ] }, "red_ids": [ "400102274", "400102275", "400102190", "400102198", "400102161", "400102277", "400102163", "400102278", "400102282", "400102284", "400102195", "MA0000008", "MA0000004", "929055170", "400102267", "400102235", "400102236", "MA0000006", "400102237", "400102238", "400102239", "400102268", "829416159", "924031058", "924031081", "822064091", "822066199", "822066200" ], "gui_data": { "asm_id": "400102190", "teilenummer": "400102195", "pdm_kategorie_neu": "Einzelteil", "neuaufbau": "False", "lebenszyklus_status_neu": "Serie", "aus_halbzeug_neu": "True", "zusatzinfos_auto_text": "Dies sind neue Zusatzinfos", "cb_lebenszyklus_status_neu": ["Serie", "Prototyp"], "cb_werkstofftyp_neu": ["Stahl", "Aluminium", "Kunst-/ Verbundstoff", "Schwermetall"] }, "data": {} } """ #"teilenummer": "400102195", assembly class Environment: def __init__(self): self.lib_dir = os.environ.get('CREMIG_LIB') self.data_dir = os.environ.get('CREMIG_DATA') self.out_dir = os.environ.get('CREMIG_WORK') self.cfg_dir = os.environ.get('CREMIG_CFG') self.ruledesigner_csv_filename = os.environ.get('RD_DATABASE_NAME') def build_gui(model, configs): root = tk.Tk() #root = ttk.Window() app = App(root, configs) controller = Controller(model, app) controller.set_env(configs.get_env()) logic = GuiLogic(model, configs) controller.add_logic(logic) # um ohne Observer pattern auch Rückmeldungen geben zu können app.set_controller(controller) model.set_controller(controller) # Daten des Modells in der Oberfläche darstellen controller.refresh_gui() app.mainloop() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Das Programm ermöglicht einw graphisch unterstützte Migration eines Teiles oder Assemblies von Creo nach SolidEdge. Erzeugt eine korrekte Impfdatei.', prog='CreoMigrateGui') parser.add_argument('-s', '--sivasid', action='store', help='Eingabe der SIVAS-Teilenummer, für die der Migrationsstatus angezeigt werden soll', metavar="id") parser.add_argument('-d', '--demo', action='store_true', help='arbeitet ohne Server. Lädt Testdaten ein um nur eine Oberfläche darzustellen') args = parser.parse_args() environment = Environment() output_dir = environment.out_dir configs = Configs(environment.cfg_dir) configs.set_env(environment) model = CadItem() if args.demo: model.from_json(demo_data) build_gui(model, configs) elif args.sivasid: id = args.sivasid path = os.path.join(output_dir, id + '.json') if os.path.exist(path): model.load(demo_data) build_gui(model, configs) else: parser.print_help()