Example #1
0
    def __init__(self, window):
        window.title("Reference list")

        self.list = Tree(
            window,
            tree=False,
            columns=(
                dict(heading="Origin", width=1),
                dict(heading="Name", width=20, stretch=True),
                dict(heading="Authority", width=6),
                dict(heading="Common name", width=15),
                dict(heading="Family", width=(3, Tree.FIGURE)),
                dict(heading="Family", width=8),
                dict(heading="Family", width=6),
                dict(heading="Division", width=(1, Tree.FIGURE)),
                dict(heading="Division", width=6),
                dict(heading="Note", width=3),
                dict(heading="SPECNUM", width=(4, Tree.FIGURE)),
            ),
        )
        scroll(self.list, resize=True)
        self.list.focus_set()

        self.items = dict()
        self.records = 0
Example #2
0
    def default_exception_handler(self, context):
        super().default_exception_handler(context)

        lines = list()
        lines.append(context.pop("message"))
        exc = context.pop("exception")
        for item in sorted(context.items()):
            lines.append("{}={!r}".format(*item))
        exc = "".join(format_exception(type(exc), exc, exc.__traceback__))
        lines.append(exc.rstrip())

        window = tkinter.Toplevel(self._widget)
        window.title("Exception")
        text = tkinter.Text(window, wrap="word")
        scroll(text)
        text.focus_set()
        text.insert(tkinter.END, "\n".join(lines))
        text.see(tkinter.END)
        text["state"] = tkinter.DISABLED
Example #3
0
 def default_exception_handler(self, context):
     super().default_exception_handler(context)
     
     lines = list()
     lines.append(context.pop("message"))
     exc = context.pop("exception")
     for item in sorted(context.items()):
         lines.append("{}={!r}".format(*item))
     exc = "".join(format_exception(type(exc), exc, exc.__traceback__))
     lines.append(exc.rstrip())
     
     window = tkinter.Toplevel(self._widget)
     window.title("Exception")
     text = tkinter.Text(window, wrap="word")
     scroll(text)
     text.focus_set()
     text.insert(tkinter.END, "\n".join(lines))
     text.see(tkinter.END)
     text["state"] = tkinter.DISABLED
Example #4
0
 def init(gui, ctrl, window, master, focus=False, resize=False,
 **kw):
     ctrl.place(gui)
     ctrl.widget = ttk.Frame(master)
     ctrl.tree = tkwrap.Tree(ctrl.widget, columns=ctrl.columns, **kw)
     tkwrap.scroll(ctrl.tree, resize=resize)
     
     if ctrl.selected:
         #~ self.select_binding = self.evc_list.bind_select(self.select)
         select = partial(gui.TreeBase.select, gui, ctrl)
         ctrl.tree.bind_select(select)
     if ctrl.opened:
         open = partial(gui.TreeBase.open, gui, ctrl)
         ctrl.tree.bind("<<TreeviewOpen>>", open)
     if window.command:
         activate = partial(gui.activate, window)
         ctrl.tree.bind("<Double-1>", activate)
     
     if focus:
         ctrl.tree.focus_set()
         return True
Example #5
0
def main(*, ca_csv=(), cpl_excel=(), freqs=(), freqs_csv=(), quad=()):
    root = Tk()
    ui = Ui(root)

    ui.add_files(CaCsvReader, ca_csv, convert_cpl)
    ui.add_files(CplExcelReader, cpl_excel, convert_cpl)
    ui.add_files(FreqExcelReader, freqs, convert_freqs)
    ui.add_files(FreqCsvReader, freqs_csv, convert_freqs)
    ui.add_files(QuadratReader, quad)

    ui.names = list()
    for (i, (_, item)) in enumerate(sorted(ui.items.items())):
        ui.list.move(item, "", i)

        name = ui.list.set(item, 1)
        level = ui.names
        leaf = None
        for word in name.translate(NameSimplifier()).split():
            if not level or level[-1]["word"] != word:
                level.append(dict(word=word, children=list()))
            leaf = level[-1]
            level = leaf["children"]
        leaf["name"] = name

    win = Toplevel(root)
    win.title("Plant entry")

    ui.entry = Entry(win, width=30, validate="key", validatecommand=ValidateCommand(root, ui.entry_changed))
    ui.entry.pack(fill=tkinter.BOTH)
    ui.entry.focus_set()
    ui.entry.bind("<Return>", ui.add_entry)
    ui.entry.bind("<Up>", partial(ui.select_match, "prev"))
    ui.entry.bind("<Down>", partial(ui.select_match, "next"))

    frame = Frame(win)
    ui.matches = Tree(frame, tree=False, columns=(dict(heading="Matches", width=30),))
    scroll(ui.matches, resize=True)
    frame.pack(fill=tkinter.BOTH, expand=True)

    root.mainloop()