Ejemplo n.º 1
0
def unit_text(unit, parent, addr):
    if unit is None:
        # ----- no unit, just a slot -------
        data = ce.getPrjUnits(parent)
        slot = next(item for item in data['slots'] if item["addr"] == addr)
        s = '<h6>Место подключения</h6><div>Может быть установлен любой совместимый (суб-)модуль.</div>'
        s = s + '<ul><li>база: %s</li>' % data['name']
        s = s + '<li>тип соединения: %s</li>' % ce.getTerm(slot['type'])
        s = s + '<li>позиция: %s</li></ul>' % addr
        return s
    data = ce.getPrjUnits(unit)
    s = '<h6>%s</h6>' % data['name']
    s = s + 'Имя: <ent href="alias" src="%s"><br>' % (
        data['alias'] if data['alias'] != '' else data['name'])
    # ----- unit commands ---------
    s = s + '<ul><li><a href="del_unit">Удалить</a> из устройства'
    if subunits_count(data):
        s = s + '<span style="color: red"> (подключенные (суб-)модули будут также удалены)</span>'
    s = s + '</li><li><a href="reset_unit">Сбросить настройки</a></li>'
    if ce.get_can_move_up(unit):
        s = s + '<li><a href="move_up_unit">Переместить вверх</a></li>'
    if ce.get_can_move_down(unit):
        s = s + '<li><a href="move_dn_unit">Переместить вниз</a></li>'
    # ----- unit information --------
    s = '%s</ul><div>%s</div>' % (s, data['desc'])
    s = '%s<ul><li>тип: %s</li>' % (s, ce.getTerm(data['type']))
    s = '%s<li>редакция: %s</li>' % (s, data['edition'])
    s = '%s<li>версия: %s</li>' % (s, data['ver'])
    s = '%s<li>ревизия: %s</li>' % (s, data['rev'])
    prop = ', '.join([ce.getTerm(item) for item in data['prop']])
    s = s + ('</ul>' if prop == '' else '<li>свойства: %s</li></ul>' % prop)
    return s
Ejemplo n.º 2
0
    def on_lib_select(self, * args):
        lib = self.lib_tree.focus()
        if lib == '': lib = None
        iid = self.modules_tree.focus()
        if iid == '':
            unit = None
            parent = None
            addr = None
        else:
            unit = None if ('|' in iid) else iid
            (parent, addr) = (next( tag for tag in self.modules_tree.item(iid, 'tags')
                                    if '@' in tag)).split('@')

        self.lib_html.set_html(get_lib_text(lib))
        self.update_modules_tree(data = ce.getPrjUnits(lib = lib, mode = 'short'))
        self.main_html.set_html(get_sys_text(unit, parent, addr, lib))
Ejemplo n.º 3
0
def insert_text(unit, parent, addr, library):
    lib_data = ce.getLibUnits(library, parent, addr)
    s = ''
    # check installing a same item type
    is_same = False
    if unit is not None:
        unit_data = ce.getPrjUnits(unit)
        is_same = unit_data['lib'] == lib_data['id']
    # check lib compatibility to slot
    if (not is_same) and lib_data['match']:
        s = '<div><a href="ins_unit">Установить "%s"</a> ' % lib_data['name']
        s = s + 'на выбранное место.'
        if unit is not None:
            s = s + '<br><span style="color: red">Это действие удалит "%s"!</span>' % (
                unit_data['alias']
                if unit_data['alias'] != '' else unit_data['name'])
            if subunits_count(unit_data):
                s = s + '<br>Установленные (суб-)модули будут по возможности переподключены.'
        s = s + '</div>'
    return s
Ejemplo n.º 4
0
 def update_modules(self, new_focus = None):
     focused  = self.modules_tree.focus()
     closed_stat = [iid for iid in self.modules_tree.get_children()
                    if not self.modules_tree.item(iid,'open')]
     
     self.modules_tree.delete(*self.modules_tree.get_children())
     self.fill_modules_tree(data = ce.getPrjUnits())
     
     for iid in closed_stat:
         if self.modules_tree.exists(iid):
             self.modules_tree.item(item=iid, open=False)
     if new_focus is not None:
         if self.modules_tree.exists(new_focus):
             focused = new_focus
         elif self.modules_tree.exists(new_focus.split('|')[0]):
             focused = new_focus.split('|')[0]
     if self.modules_tree.exists(focused):
         self.modules_tree.see(focused)
         self.modules_tree.focus(focused)
         self.modules_tree.selection_set(focused)
     self.on_lib_select()
     self.update_stat()
Ejemplo n.º 5
0
    def create_widgets(self):
        top=self.winfo_toplevel()
        top.rowconfigure(0, minsize=400, weight=1)
        top.columnconfigure(0, minsize=600, weight=1)

        self.ico_lib = PhotoImage(data=resources.ICO_LIB)
        self.ico_lib_ins = PhotoImage(data=resources.ICO_LIB_INS)
        self.ico_mod = PhotoImage(data=resources.ICO_MOD)
        self.ico_mod_ins = PhotoImage(data=resources.ICO_MOD_INS)
        self.ico_mod_no = PhotoImage(data=resources.ICO_MOD_NO)
        self.ico_mod_no_ins = PhotoImage(data=resources.ICO_MOD_NO_INS)
        self.ico_red_bulb = PhotoImage(data=resources.ICO_RED)
        self.ico_green_bulb = PhotoImage(data=resources.ICO_GREEN)
        

        self.main_pane = PanedWindow(master = self,
                                     bd=2,
                                     orient=HORIZONTAL,
                                     sashrelief = 'groove')
        
        self.lib_pane = PanedWindow(master = self.main_pane,
                                    bd=2,
                                    orient=VERTICAL,
                                    sashrelief = 'groove')

        self.modules_tree = ScrolledTree(master=self.main_pane,
                                         show='tree headings',
                                         selectmode='browse')
        self.modules_tree["columns"]=("ed")
        self.modules_tree.column("#0", width=150, minwidth=150)
        self.modules_tree.column("ed", width=70, minwidth=70, stretch=NO)
        self.modules_tree.heading("#0",text="Модуль",anchor=W)
        self.modules_tree.heading("ed", text="Тип",anchor=W)
        self.modules_tree.bind("<<TreeviewSelect>>", self.on_module_select)
        self.modules_tree.tag_configure('DEF', image=self.ico_mod)
        self.modules_tree.tag_configure('EMPTY', image=self.ico_mod_no)
        self.modules_tree.tag_configure('DMATCH', image=self.ico_mod_ins)
        self.modules_tree.tag_configure('EMATCH', image=self.ico_mod_no_ins)
        
        self.lib_tree = ScrolledTree(master=self.lib_pane,
                                     show='tree headings',
                                     selectmode='browse')
        self.lib_tree["columns"]=('type')
        self.lib_tree.column("#0", width=100, minwidth=100)
        self.lib_tree.column("type", width=70, minwidth=70, stretch=NO)
        self.lib_tree.heading("#0",text="Модуль",anchor=W)
        self.lib_tree.heading("type", text="Тип",anchor=W)
        self.lib_tree.bind("<<TreeviewSelect>>", self.on_lib_select)
        self.lib_tree.tag_configure('DEF', image=self.ico_lib)
        self.lib_tree.tag_configure('MATCH', image=self.ico_lib_ins)
         
        self.main_html = HTMLScrolledText(master = self.main_pane,
                                          relief='flat', bd = 2,
                                          padx=10, pady=2,
                                          state=DISABLED,
                                          html = get_sys_text(None, None, None, None))
        self.main_html.bind('<<get_order>>', self.on_get_order)
        self.main_html.bind('<<req_info>>', self.on_req_info)
        self.main_html.bind('<<del_unit>>', self.on_del_unit)
        self.main_html.bind('<<reset_unit>>', self.on_reset_unit)
        self.main_html.bind('<<move_up_unit>>', self.on_move_up_unit)
        self.main_html.bind('<<move_dn_unit>>', self.on_move_dn_unit)
        self.main_html.bind('<<ins_unit>>', self.on_ins_unit)
        self.main_html.bind('<<alias>>', self.on_alias)

        self.lib_html = HTMLScrolledText(master = self.lib_pane,
                                         relief='flat', bd = 2,
                                         padx=10, pady=2,
                                         state=DISABLED,
                                         html = get_lib_text(None))
        
        self.top_frame = Frame(master=self,
                               relief='groove', bd = 2,
                               padx=2, pady=2)
        self.stat_label = Button(master = self.top_frame,
                                 image = self.ico_red_bulb,
                                 relief = 'flat',
                                 takefocus = 0,
                                 command = self.on_req_info)
        self.stat_label.pack(side = LEFT)
                                 

        self.main_pane.add(self.modules_tree, minsize=200, width=200)
        self.main_pane.add(self.main_html, minsize=200)
        self.main_pane.add(self.lib_pane, minsize=200, width=200)
        self.lib_pane.add(self.lib_tree, minsize=200)
        self.lib_pane.add(self.lib_html, minsize=100, height=200)

        self.top_frame.grid(column=0, row=0, sticky='nesw')
        self.main_pane.grid(column=0, row=1, sticky='nesw')
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, minsize=30, weight=0)
        self.rowconfigure(1, weight=1)

        self.fill_lib_tree(data = ce.getLibUnits())
        self.fill_modules_tree(data = ce.getPrjUnits())
        self.update_stat()