def frame_family(root): """Frame for the parent and child document items.""" # Configure grid frame = ttk.Frame(root, **kw_f) frame.rowconfigure(0, weight=0) frame.rowconfigure(1, weight=1) frame.rowconfigure(2, weight=0) frame.rowconfigure(3, weight=1) frame.columnconfigure(0, weight=1) # Place widgets widget.Label(frame, text="Linked To:").grid(row=0, column=0, sticky=tk.W, **kw_gp) self.text_parents = widget.noUserInput_init( widget.Text(frame, width=width_text, wrap=tk.WORD)) self.text_parents_hyperlink = utilTkinter.HyperlinkManager( self.text_parents) self.text_parents.grid(row=1, column=0, **kw_gsp) widget.Label(frame, text="Linked From:").grid(row=2, column=0, sticky=tk.W, **kw_gp) self.text_children = widget.noUserInput_init( widget.Text(frame, width=width_text, wrap=tk.WORD)) self.text_children_hyperlink = utilTkinter.HyperlinkManager( self.text_children) self.text_children.grid(row=3, column=0, **kw_gsp) return frame
def frame_document(root): """Frame for current document's outline and items.""" # Configure grid frame = ttk.Frame(root, **kw_f) frame.rowconfigure(0, weight=0) frame.rowconfigure(1, weight=5) frame.rowconfigure(2, weight=0) frame.rowconfigure(3, weight=0) frame.columnconfigure(0, weight=0) frame.columnconfigure(1, weight=0) frame.columnconfigure(2, weight=0) frame.columnconfigure(3, weight=0) frame.columnconfigure(4, weight=1) frame.columnconfigure(5, weight=1) @_log def treeview_outline_treeviewselect(event): """Handle selecting an item in the tree view.""" if self.ignore: return thewidget = event.widget curselection = thewidget.selection() if curselection: uid = curselection[0] self.stringvar_item.set(uid) @_log def treeview_outline_delete(event): # pylint: disable=W0613 """Handle deleting an item in the tree view.""" if self.ignore: return self.remove() # Place widgets widget.Label(frame, text="Outline:").grid(row=0, column=0, columnspan=4, sticky=tk.W, **kw_gp) widget.Label(frame, text="Items:").grid(row=0, column=4, columnspan=2, sticky=tk.W, **kw_gp) c_columnId = ("Id",) self.treeview_outline = widget.TreeView(frame, columns=c_columnId) # pylint: disable=W0201 for col in c_columnId: self.treeview_outline.heading(col, text=col) # Add a Vertical scrollbar to the Treeview Outline treeview_outline_verticalScrollBar = widget.ScrollbarV(frame, command=self.treeview_outline.yview) treeview_outline_verticalScrollBar.grid(row=1, column=0, columnspan=1, **kw_gs) self.treeview_outline.configure(yscrollcommand=treeview_outline_verticalScrollBar.set) self.treeview_outline.bind("<<TreeviewSelect>>", treeview_outline_treeviewselect) self.treeview_outline.bind("<Delete>", treeview_outline_delete) self.treeview_outline.grid(row=1, column=1, columnspan=3, **kw_gsp) self.text_items = widget.noUserInput_init(widget.Text(frame, width=width_text, wrap=tk.WORD)) self.text_items.grid(row=1, column=4, columnspan=2, **kw_gsp) self.text_items_hyperlink = utilTkinter.HyperlinkManager(self.text_items) # pylint: disable=W0201 widget.Button(frame, text="<", width=0, command=self.left).grid(row=2, column=0, sticky=tk.EW, padx=(2, 0)) widget.Button(frame, text="v", width=0, command=self.down).grid(row=2, column=1, sticky=tk.EW) widget.Button(frame, text="^", width=0, command=self.up).grid(row=2, column=2, sticky=tk.EW) widget.Button(frame, text=">", width=0, command=self.right).grid(row=2, column=3, sticky=tk.EW, padx=(0, 2)) widget.Button(frame, text="Add Item", command=self.add).grid(row=2, column=4, sticky=tk.W, **kw_gp) widget.Button(frame, text="Remove Selected Item", command=self.remove).grid(row=2, column=5, sticky=tk.E, **kw_gp) return frame
def frame_item(root): """Frame for the currently selected item.""" # Configure grid frame = ttk.Frame(root, **kw_f) frame.rowconfigure(0, weight=0) frame.rowconfigure(1, weight=4) frame.rowconfigure(2, weight=0) frame.rowconfigure(3, weight=1) frame.rowconfigure(4, weight=1) frame.rowconfigure(5, weight=1) frame.rowconfigure(6, weight=1) frame.rowconfigure(7, weight=0) frame.rowconfigure(8, weight=0) frame.rowconfigure(9, weight=0) frame.rowconfigure(10, weight=0) frame.rowconfigure(11, weight=4) frame.columnconfigure(0, weight=1, pad=kw_f['padding'] * 2) frame.columnconfigure(1, weight=1) @_log def text_focusin(_): """Handle entering a text field.""" self.ignore = True @_log def text_item_focusout(event): """Handle updated text text.""" self.ignore = False thewidget = event.widget value = thewidget.get('1.0', tk.END) self.stringvar_text.set(value) @_log def text_extendedvalue_focusout(event): """Handle updated extended attributes.""" self.ignore = False thewidget = event.widget value = thewidget.get('1.0', tk.END) self.stringvar_extendedvalue.set(value) # Selected Item widget.Label(frame, text="Selected Item:").grid(row=0, column=0, columnspan=3, sticky=tk.W, **kw_gp) self.text_item = widget.Text(frame, width=width_text, height=height_text, wrap=tk.WORD) self.text_item.bind('<FocusIn>', text_focusin) self.text_item.bind('<FocusOut>', text_item_focusout) self.text_item.grid(row=1, column=0, columnspan=3, **kw_gsp) # Column: Properties self.create_properties_widget(frame).grid(row=2, rowspan=2, column=0, columnspan=2, sticky=tk.NSEW, **kw_gp) # Column: Links self.create_links_widget(frame).grid(row=4, rowspan=3, column=0, columnspan=2, sticky=tk.NSEW, **kw_gp) # External Reference self.create_reference_widget(frame).grid(row=7, rowspan=2, column=0, columnspan=2, sticky=tk.NSEW, **kw_gp) widget.Label(frame, text="Extended Attributes:").grid(row=9, column=0, columnspan=3, sticky=tk.W, **kw_gp) self.combobox_extended = widget.Combobox( frame, textvariable=self.stringvar_extendedkey) self.combobox_extended.grid(row=10, column=0, columnspan=3, **kw_gsp) self.text_extendedvalue = widget.Text(frame, width=width_text, height=height_ext, wrap=tk.WORD) self.text_extendedvalue.bind('<FocusIn>', text_focusin) self.text_extendedvalue.bind('<FocusOut>', text_extendedvalue_focusout) self.text_extendedvalue.grid(row=11, column=0, columnspan=3, **kw_gsp) return frame
def frame_item(root): """Frame for the currently selected item.""" # Configure grid frame = ttk.Frame(root, **kw_f) frame.rowconfigure(0, weight=0) frame.rowconfigure(1, weight=4) frame.rowconfigure(2, weight=0) frame.rowconfigure(3, weight=1) frame.rowconfigure(4, weight=1) frame.rowconfigure(5, weight=1) frame.rowconfigure(6, weight=1) frame.rowconfigure(7, weight=0) frame.rowconfigure(8, weight=0) frame.rowconfigure(9, weight=0) frame.rowconfigure(10, weight=0) frame.rowconfigure(11, weight=4) frame.columnconfigure(0, weight=0, pad=kw_f['padding'] * 2) frame.columnconfigure(1, weight=1) frame.columnconfigure(2, weight=1) @_log def text_focusin(_): """Handle entering a text field.""" self.ignore = True @_log def text_item_focusout(event): """Handle updated text text.""" self.ignore = False thewidget = event.widget value = thewidget.get('1.0', tk.END) self.stringvar_text.set(value) @_log def text_extendedvalue_focusout(event): """Handle updated extended attributes.""" self.ignore = False thewidget = event.widget value = thewidget.get('1.0', tk.END) self.stringvar_extendedvalue.set(value) # Place widgets widget.Label(frame, text="Selected Item:").grid(row=0, column=0, columnspan=3, sticky=tk.W, **kw_gp) self.text_item = widget.Text(frame, width=width_text, height=height_text, wrap=tk.WORD) self.text_item.bind('<FocusIn>', text_focusin) self.text_item.bind('<FocusOut>', text_item_focusout) self.text_item.grid(row=1, column=0, columnspan=3, **kw_gsp) widget.Label(frame, text="Properties:").grid(row=2, column=0, sticky=tk.W, **kw_gp) widget.Label(frame, text="Links:").grid(row=2, column=1, columnspan=2, sticky=tk.W, **kw_gp) widget.Checkbutton(frame, text="Active", variable=self.intvar_active).grid(row=3, column=0, sticky=tk.W, **kw_gp) self.listbox_links = widget.Listbox(frame, width=width_uid, height=6) self.listbox_links.grid(row=3, column=1, rowspan=4, **kw_gsp) widget.Entry(frame, width=width_uid, textvariable=self.stringvar_link).grid(row=3, column=2, sticky=tk.EW + tk.N, **kw_gp) widget.Checkbutton(frame, text="Derived", variable=self.intvar_derived).grid(row=4, column=0, sticky=tk.W, **kw_gp) widget.Button(frame, text="<< Link Item", command=self.link).grid(row=4, column=2, **kw_gp) widget.Checkbutton(frame, text="Normative", variable=self.intvar_normative).grid(row=5, column=0, sticky=tk.W, **kw_gp) widget.Checkbutton(frame, text="Heading", variable=self.intvar_heading).grid(row=6, column=0, sticky=tk.W, **kw_gp) widget.Button(frame, text=">> Unlink Item", command=self.unlink).grid(row=6, column=2, **kw_gp) widget.Label(frame, text="External Reference:").grid(row=7, column=0, columnspan=3, sticky=tk.W, **kw_gp) widget.Entry(frame, width=width_text, textvariable=self.stringvar_ref).grid(row=8, column=0, columnspan=3, **kw_gsp) widget.Label(frame, text="Extended Attributes:").grid(row=9, column=0, columnspan=3, sticky=tk.W, **kw_gp) self.combobox_extended = widget.Combobox(frame, textvariable=self.stringvar_extendedkey) self.combobox_extended.grid(row=10, column=0, columnspan=3, **kw_gsp) self.text_extendedvalue = widget.Text(frame, width=width_text, height=height_ext, wrap=tk.WORD) self.text_extendedvalue.bind('<FocusIn>', text_focusin) self.text_extendedvalue.bind('<FocusOut>', text_extendedvalue_focusout) self.text_extendedvalue.grid(row=11, column=0, columnspan=3, **kw_gsp) return frame