Esempio n. 1
0
 def draw_main_ui(self):
     self.root.title("openConc - a tool for corpus linguists")
     self.root.columnconfigure(0, weight=1)
     self.root.rowconfigure(0, weight=1)
     self.grid(row=0, column=0, sticky="news")
     self.maximize()
     self.columnconfigure(0, weight=1)
     self.rowconfigure(0, weight=1)
     self.style_ui()
     # --- status bar --- #
     self.status_var = tk.StringVar()
     self.status_bar = ttk.Label(self, textvariable=self.status_var, style="StatusLabel.TLabel")
     self.status_bar.grid(column=0, row=1, sticky="nesw")
     # --- main notebook --- #
     self.book = ttk.Notebook(self)
     self.book.grid(column=0, row=0, sticky="news")
     self.book.bind('<<NotebookTabChanged>>', self.book_tab_change)
     # --- settings --- #
     self.settings_frame = SettingsFrame(self)
     # corpus selection
     self.file_frame = FileFrame(self)
     # --- concordance --- #
     self.concordance_frame = ConcordanceFrame(self)
     misc.pad_children(self, 5, 5)
     # --- add to main book --- #
     self.book.add(self.file_frame, text="Files")
     self.book.add(self.concordance_frame, text="Concordance")
     self.book.add(self.settings_frame, text="Settings")
Esempio n. 2
0
 def draw_main_ui(self):
     self.root.title("openConc - a tool for corpus linguists")
     self.root.columnconfigure(0, weight=1)
     self.root.rowconfigure(0, weight=1)
     self.grid(row=0, column=0, sticky="news")
     self.maximize()
     self.columnconfigure(0, weight=1)
     self.rowconfigure(0, weight=1)
     self.style_ui()
     # --- status bar --- #
     self.status_var = tk.StringVar()
     self.status_bar = ttk.Label(self,
                                 textvariable=self.status_var,
                                 style="StatusLabel.TLabel")
     self.status_bar.grid(column=0, row=1, sticky="nesw")
     # --- main notebook --- #
     self.book = ttk.Notebook(self)
     self.book.grid(column=0, row=0, sticky="news")
     self.book.bind('<<NotebookTabChanged>>', self.book_tab_change)
     # --- settings --- #
     self.settings_frame = SettingsFrame(self)
     # corpus selection
     self.file_frame = FileFrame(self)
     # --- concordance --- #
     self.concordance_frame = ConcordanceFrame(self)
     misc.pad_children(self, 5, 5)
     # --- add to main book --- #
     self.book.add(self.file_frame, text="Files")
     self.book.add(self.concordance_frame, text="Concordance")
     self.book.add(self.settings_frame, text="Settings")
Esempio n. 3
0
 def draw_setup_ui(self):
     parent = self.parent.file_frame.corpora_frame
     self.setup_frame = ttk.Frame(parent)
     self.setup_frame.rowconfigure(0, weight=0)
     self.setup_frame.rowconfigure(2, weight=1)
     self.setup_frame.columnconfigure(0, weight=0)
     self.setup_frame.grid(row=0, column=1, sticky="news")
     # row 0
     self.open_button = ttk.Button(self.setup_frame,
                                   style=self.button_style,
                                   text="Add files",
                                   command=self.add_files)
     self.clear_button = ttk.Button(self.setup_frame,
                                    style=self.button_style,
                                    text="Clear files",
                                    command=self.clear_files)
     self.color_button = ttk.Button(self.setup_frame,
                                    style=self.button_style,
                                    text="Change color",
                                    command=self.choose_color)
     self.open_button.grid(row=0, column=0, sticky="new")
     self.clear_button.grid(row=0, column=1, sticky="new")
     self.color_button.grid(row=0, column=2, sticky="new")
     # row 1
     name_label = ttk.Label(self.setup_frame,
                            text="Corpus name",
                            font="verdana 12")
     self.name_entry = ttk.Entry(self.setup_frame,
                                 textvariable=self.name_var,
                                 font="verdana 12")
     name_label.grid(column=0, row=1, sticky="nws")
     self.name_entry.grid(row=1, column=1, columnspan=2, sticky="news")
     self.name_entry.bind('<Leave>', self.on_name_entry_leave)
     # row 3
     self.remove_button = ttk.Button(self.setup_frame,
                                     style=self.button_style,
                                     text="Remove this corpus",
                                     command=self.remove)
     self.remove_button.grid(row=3, column=2, sticky="ne")
     # default padding
     misc.pad_children(self.setup_frame, 5, 5)
     # row 2 / no padding
     self.listbox = tk.Listbox(self.setup_frame)
     self.listbox.grid(row=2, column=0, columnspan=3, sticky="news")
     self.scrollbar = ttk.Scrollbar(self.setup_frame,
                                    command=self.listbox.yview)
     self.scrollbar.grid(row=2, column=4, sticky="ns")
     self.listbox["yscrollcommand"] = self.scrollbar.set
Esempio n. 4
0
 def draw_ui(self):
     self.rowconfigure(0, weight=1)
     self.columnconfigure(0, weight=0)
     self.columnconfigure(1, weight=0)
     self.columnconfigure(2, weight=1)
     self.add_button = ttk.Button(self, command=self.add_corpus, text="Add a corpus", width=20)
     self.add_button.grid(row=1, column=0, sticky="news")
     self.corpora_frame = ttk.Frame(self)
     self.corpora_frame.rowconfigure(0, weight=1)
     self.corpora_frame.columnconfigure(0, weight=0)
     self.corpora_frame.grid(row=0, column=2, sticky="news")
     misc.pad_children(self, 5, 5)
     self.listbox = tk.Listbox(self, selectmode='browse', exportselection=0)
     self.listbox.grid(row=0, column=0, sticky="news")
     self.scrollbar = ttk.Scrollbar(self, command=self.listbox.yview)
     self.scrollbar.grid(row=0, column=1, sticky="ns")
     self.listbox["yscrollcommand"] = self.scrollbar.set
Esempio n. 5
0
 def draw_ui(self):
     self.rowconfigure(0, weight=1)
     self.columnconfigure(0, weight=0)
     self.columnconfigure(1, weight=0)
     self.columnconfigure(2, weight=1)
     self.add_button = ttk.Button(self,
                                  command=self.add_corpus,
                                  text="Add a corpus",
                                  width=20)
     self.add_button.grid(row=1, column=0, sticky="news")
     self.corpora_frame = ttk.Frame(self)
     self.corpora_frame.rowconfigure(0, weight=1)
     self.corpora_frame.columnconfigure(0, weight=0)
     self.corpora_frame.grid(row=0, column=2, sticky="news")
     misc.pad_children(self, 5, 5)
     self.listbox = tk.Listbox(self, selectmode='browse', exportselection=0)
     self.listbox.grid(row=0, column=0, sticky="news")
     self.scrollbar = ttk.Scrollbar(self, command=self.listbox.yview)
     self.scrollbar.grid(row=0, column=1, sticky="ns")
     self.listbox["yscrollcommand"] = self.scrollbar.set
Esempio n. 6
0
 def draw_setup_ui(self):
     parent = self.parent.file_frame.corpora_frame
     self.setup_frame = ttk.Frame(parent)
     self.setup_frame.rowconfigure(0, weight=0)
     self.setup_frame.rowconfigure(2, weight=1)
     self.setup_frame.columnconfigure(0, weight=0)
     self.setup_frame.grid(row=0, column=1, sticky="news")
     # row 0
     self.open_button = ttk.Button(self.setup_frame, style=self.button_style, text="Add files",
                                   command=self.add_files)
     self.clear_button = ttk.Button(self.setup_frame, style=self.button_style,
                                    text="Clear files", command=self.clear_files)
     self.color_button = ttk.Button(self.setup_frame, style=self.button_style,
                                    text="Change color", command=self.choose_color)
     self.open_button.grid(row=0, column=0, sticky="new")
     self.clear_button.grid(row=0, column=1, sticky="new")
     self.color_button.grid(row=0, column=2, sticky="new")
     # row 1
     name_label = ttk.Label(self.setup_frame, text="Corpus name", font="verdana 12")
     self.name_entry = ttk.Entry(self.setup_frame, textvariable=self.name_var,
                                 font="verdana 12")
     name_label.grid(column=0, row=1, sticky="nws")
     self.name_entry.grid(row=1, column=1, columnspan=2, sticky="news")
     self.name_entry.bind('<Leave>', self.on_name_entry_leave)
     # row 3
     self.remove_button = ttk.Button(self.setup_frame, style=self.button_style,
                                     text="Remove this corpus", command=self.remove)
     self.remove_button.grid(row=3, column=2, sticky="ne")
     # default padding
     misc.pad_children(self.setup_frame, 5, 5)
     # row 2 / no padding
     self.listbox = tk.Listbox(self.setup_frame)
     self.listbox.grid(row=2, column=0, columnspan=3, sticky="news")
     self.scrollbar = ttk.Scrollbar(self.setup_frame, command=self.listbox.yview)
     self.scrollbar.grid(row=2, column=4, sticky="ns")
     self.listbox["yscrollcommand"] = self.scrollbar.set
Esempio n. 7
0
    def draw_conc_ui(self):
        parent = self.parent.concordance_frame
        self.button_style = "C{}.TButton".format(self.n)
        self.conc_frame = ttk.Frame(parent)
        self.conc_frame.rowconfigure(0, weight=1)
        self.conc_frame.rowconfigure(1, weight=0)
        self.conc_frame.columnconfigure(0, weight=1)
        parent.book.add(self.conc_frame, text=self.name_var.get())
        # row 1
        self.conc_button_frame = ttk.Frame(self.conc_frame)
        self.conc_button_frame.grid(row=1, column=0, sticky="news")
        # row 0
        self.conc_results_frame = ttk.Frame(self.conc_frame)
        self.conc_results_frame.grid(row=0, column=0, sticky="news")
        self.conc_results_frame.rowconfigure(0, weight=1)
        self.conc_results_frame.rowconfigure(1, weight=0)  # x scrollbars
        self.conc_results_frame.columnconfigure(0, weight=0)  # index
        self.conc_results_frame.columnconfigure(1, weight=1)  # conc line
        self.conc_results_frame.columnconfigure(2, weight=0)  # y  scrollbar
        self.conc_results_frame.columnconfigure(3, weight=0)   # metadata
        self.conc_ybar = ttk.Scrollbar(self.conc_results_frame, command=self.concordance_yview)
        self.conc_ybar.grid(row=0, column=2, sticky="news")
        self.conc_line_xbar = ttk.Scrollbar(self.conc_results_frame, orient="horizontal")
        self.conc_line_xbar.grid(row=1, column=1, sticky="news")
        self.conc_line_text = tk.Text(self.conc_results_frame, wrap="none", yscrollcommand=self.conc_ybar.set,
                                      xscrollcommand=self.conc_line_xbar.set, font='courier 10')
        self.conc_line_text.grid(row=0, column=1, sticky="news")
        self.conc_line_text.tag_configure('key', foreground='black', font='courier 10 bold')
        self.conc_line_xbar.config(command=self.conc_line_text.xview)
        self.conc_index_text = tk.Text(self.conc_results_frame, width=8, yscrollcommand=self.conc_ybar.set,
                                       font='courier 10', wrap="none")
        self.conc_index_text.grid(row=0, column=0, sticky="nesw")
        self.conc_meta_xbar = ttk.Scrollbar(self.conc_results_frame, orient="horizontal")
        self.conc_meta_xbar.grid(row=1, column=3, sticky="news")
        self.conc_meta_canvas = tk.Canvas(self.conc_results_frame, background="white",
                                          xscrollcommand=self.conc_meta_xbar.set)
        self.conc_meta_canvas.grid(row=0, column=3, sticky="news")
        self.conc_meta_xbar.config(command=self.conc_meta_canvas.xview)
        self.conc_meta_canvas_frame = tk.Frame(self.conc_meta_canvas)
        self.conc_meta_text = {}  # corpus & file name, later more with XML corpora if attributes
        metadata = ["Corpus", "Filename"]
        for i, m in enumerate(metadata):
            self.conc_meta_text[m] = tk.Text(self.conc_meta_canvas_frame, wrap="none", font='courier 10')
            self.conc_meta_text[m].grid(row=0, column=i, sticky="news")
        misc.disable_all_in_frame(self.conc_results_frame)
        self.parent.root.update_idletasks()
        x2 = self.conc_meta_canvas_frame.winfo_reqwidth()
        self.conc_meta_canvas.create_window(0, 0, anchor="nw", window=self.conc_meta_canvas_frame)
        self.conc_meta_canvas.config(scrollregion=(0, 0, x2, 0))
        h = self.conc_meta_canvas_frame.winfo_reqheight()
        for i, m_text in self.conc_meta_text.items():
            m_text["height"] = h
            m_text["width"] = 20

        # row 1 BUTTONS
        self.conc_button_frame = ttk.Frame(self.conc_frame)
        self.conc_button_frame.columnconfigure(0, weight=0)
        self.conc_button_frame.columnconfigure(1, weight=0)
        self.conc_button_frame.columnconfigure(5, weight=1)
        self.conc_button_frame.grid(row=1, column=0, sticky="news")
        self.conc_start_button = ttk.Button(self.conc_button_frame, text="Search this corpus",
                                            command=self.create_concordance,
                                            style=self.button_style)
        self.conc_start_button.grid(row=1, column=0, sticky="news", columnspan=3)
        self.conc_export_button = ttk.Button(self.conc_button_frame, text="Export concordance",
                                             command=self.export_concordance, state="disabled",
                                             style="Small.TButton")
        self.conc_export_button.grid(row=1, column=3, sticky="news")
        self.conc_sort_button = ttk.Button(self.conc_button_frame, text="Sort by",
                                           command=self.sort_concordance, state="disabled",
                                           style="Small.TButton")
        self.conc_sort_button.grid(row=0, column=0, sticky="news")
        self.conc_sort_combo = []
        self.conc_sort_var = []
        for i in range(0, 3):
            self.conc_sort_var.append(tk.StringVar())
            cb = ttk.Combobox(self.conc_button_frame, textvariable=self.conc_sort_var[i],
                              values=["Left", "Key", "Right", "Corpus", "Filename"],
                              state="readonly", style="Small.TCombobox")
            cb.grid(row=0, column=i+1, sticky="news")
            self.conc_sort_combo.append(cb)
        self.conc_sort_var[0].set("Key")
        self.conc_sort_var[1].set("Right")
        self.conc_sort_var[2].set("Corpus")
        self.conc_filter_var = tk.StringVar()
        tk.Label(self.conc_button_frame, text="Filter text",
                 font="verdana 9").grid(column=4, row=0, sticky="news")
        self.conc_filter_entry = ttk.Entry(self.conc_button_frame,
                                           textvariable=self.conc_filter_var,
                                           style="Small.TEntry", state="disabled")
        self.conc_filter_entry.grid(row=0, column=5, sticky="news", columnspan=3)
        self.conc_filter_button = ttk.Button(self.conc_button_frame, text="Filter",
                                             command=self.filter_concordance,
                                             style="Small.TButton", state="disabled")
        self.conc_filter_button.grid(row=1, column=4, columnspan=2, sticky="news")
        self.conc_filter_what_var = tk.StringVar()
        self.conc_filter_what_combo = ttk.Combobox(self.conc_button_frame, textvariable=self.conc_filter_what_var,
                                                   values=['Key', "Left", "Right", "Line"], state="readonly")
        self.conc_filter_what_var.set('Key')
        self.conc_filter_what_combo.grid(row=1, column=6, sticky="news")
        self.conc_unfilter_button = ttk.Button(self.conc_button_frame, text="Undo filter",
                                               command=self.unfilter_concordance,
                                               style="Small.TButton", state="disabled")
        self.conc_unfilter_button.grid(row=1, column=7, sticky="news")
        misc.pad_children(self.conc_button_frame, 5, 5)
Esempio n. 8
0
 def draw_ui(self):
     self.rowconfigure(0, weight=1)
     self.columnconfigure(0, weight=1)
     self.book = ttk.Notebook(self)
     self.book.grid(column=0, row=0, sticky="nesw")
     self.file_frame = ttk.Frame(self)
     self.definition_frame = ttk.Frame(self)
     self.frequency_frame = ttk.Frame(self)
     self.concordance_frame = ttk.Frame(self)
     self.xml_frame = ttk.Frame(self)
     self.book.add(self.file_frame, text="File")
     self.book.add(self.definition_frame, text="Definition")
     self.book.add(self.concordance_frame, text="Concordance")
     self.book.add(self.xml_frame, text="XML")
     # --- definition --- #
     self.definition_frame.columnconfigure(0, weight=0)
     self.definition_frame.columnconfigure(1, weight=1)
     self.word_regex_entry = ttk.Entry(self.definition_frame,
                                       textvariable=self.definition['WordRegex'])
     ttk.Label(self.definition_frame, text="Word definition (regular expression)",
               font="verdana 10").grid(row=0, column=0, sticky="news")
     self.word_regex_entry.grid(row=0, column=1, sticky="news")
     self.word_set_entry = ttk.Entry(self.definition_frame,
                                     textvariable=self.definition['WordSet'])
     ttk.Label(self.definition_frame, text="Word definition (characters)",
               font="verdana 10").grid(row=1, column=0, sticky="news")
     self.word_set_entry.grid(row=1, column=1, sticky="news")
     ttk.Separator(self.definition_frame, orient="horizontal").grid(row=2, column=0,
                                                                    columnspan=2, sticky="news")
     self.pos_delimiter_entry = ttk.Entry(self.definition_frame, style="Small.TEntry", width=2,
                                          textvariable=self.definition['POSDelim'])
     ttk.Label(self.definition_frame, text="Part-of-speech tag delimiter",
               font="verdana 10").grid(row=3, column=0, sticky="news")
     self.pos_delimiter_entry.grid(row=3, column=1, sticky="nws")
     # --- file --- #
     self.file_frame.columnconfigure(0, weight=0)
     self.file_frame.columnconfigure(1, weight=1)
     self.file_frame.columnconfigure(2, weight=0)
     self.input_entry = ttk.Entry(self.file_frame, textvariable=self.file['InputDir'])
     self.input_button = ttk.Button(self.file_frame, text="Browse", command=self.browse_input,
                                    style="Small.TButton")
     ttk.Label(self.file_frame, text="Default corpus file extension",
               font="verdana 10").grid(row=0, column=0, sticky="news")
     ttk.Label(self.file_frame, text="Default corpus directory",
               font="verdana 10").grid(row=1, column=0, sticky="news")
     self.input_entry.grid(row=1, column=1, sticky="news")
     self.input_button.grid(row=1, column=2, sticky="news")
     self.output_entry = ttk.Entry(self.file_frame, textvariable=self.file['OutputDir'])
     self.output_button = ttk.Button(self.file_frame, text="Browse", command=self.browse_output,
                                     style="Small.TButton")
     ttk.Label(self.file_frame, text="Default output directory",
               font="verdana 10").grid(row=2, column=0, sticky="news")
     self.output_entry.grid(row=2, column=1, sticky="news")
     self.output_button.grid(row=2, column=2, sticky="news")
     ttk.Separator(self.file_frame, orient="horizontal").grid(row=3, column=0,
                                                              columnspan=3, sticky="news")
     self.csv_delim_entry = ttk.Entry(self.file_frame, width=2,
                                      textvariable=self.file['CSVDelim'])
     ttk.Label(self.file_frame, text="CSV delimiter",
               font="verdana 10").grid(row=4, column=0, sticky="news")
     self.csv_delim_entry.grid(row=4, column=1, sticky="nws")
     self.csv_quote_entry = ttk.Entry(self.file_frame, width=2,
                                      textvariable=self.file['CSVQuote'])
     ttk.Label(self.file_frame, text="CSV quote character",
               font="verdana 10").grid(row=5, column=0, sticky="news")
     self.csv_quote_entry.grid(row=5, column=1, sticky="nws")
     # --- XML --- #
     self.xml_frame.columnconfigure(0, weight=0)
     self.xml_frame.columnconfigure(1, weight=1)
     self.as_text_check = ttk.Checkbutton(self.xml_frame, text="Treat XML files as plaintext",
                                          variable=self.xml['TreatXMLAsText'])
     self.as_text_check.grid(row=0, column=0, sticky="news")
     self.text_nodes_check = ttk.Checkbutton(self.xml_frame, text="Search all text elements",
                                             variable=self.xml['SearchAllTextNodes'])
     self.text_nodes_check.grid(row=1, column=0, sticky="news")
     self.specified_nodes_entry = ttk.Entry(self.xml_frame,
                                            textvariable=self.xml['SearchSpecificNodes'])
     ttk.Label(self.xml_frame, text="Search only specified elements",
               font="verdana 10").grid(row=2, column=0, sticky="news")
     self.specified_nodes_entry.grid(row=2, column=1, sticky="news")
     # --- concordance --- #
     self.concordance_frame.columnconfigure(0, weight=0)
     self.concordance_frame.columnconfigure(1, weight=0)
     self.concordance_frame.columnconfigure(2, weight=0)
     self.concordance_frame.columnconfigure(3, weight=0)
     self.context_left_entry = ttk.Entry(self.concordance_frame, width=3,
                                         textvariable=self.concordance['ContextLeft'])
     ttk.Label(self.concordance_frame, text="Context left",
               font="verdana 10").grid(row=0, column=0, sticky="news")
     self.context_left_entry.grid(row=0, column=1, sticky="nws")
     self.context_right_entry = ttk.Entry(self.concordance_frame, width=3,
                                          textvariable=self.concordance['ContextRight'])
     ttk.Label(self.concordance_frame, text="Context right",
               font="verdana 10").grid(row=0, column=2, sticky="news")
     self.context_right_entry.grid(row=0, column=3, sticky="nws")
     ttk.Label(self.concordance_frame, text="Context unit",
               font="verdana 10").grid(row=0, column=4, sticky="news")
     self.unit_combo = ttk.Combobox(self.concordance_frame,
                                    textvariable=self.concordance['ContextUnit'],
                                    values=["Characters", "Words"], state="readonly")
     self.unit_combo["width"] = 8
     self.unit_combo.grid(row=0, column=5, sticky="news")
     self.conc_case_check = ttk.Checkbutton(self.concordance_frame, text="Case sensitive",
                                            variable=self.concordance['Case'])
     self.conc_case_check.grid(row=4, column=0, sticky="news", columnspan=2)
     self.regex_check = ttk.Checkbutton(self.concordance_frame, text="Regular expression",
                                        variable=self.concordance['IsRegEx'])
     self.regex_check.grid(row=4, column=2, sticky="news", columnspan=2)
     self.conc_pos_check = ttk.Checkbutton(self.concordance_frame,
                                           text="Ignore Part-of-speech tags",
                                           variable=self.concordance['IgnorePOS'])
     self.conc_pos_check.grid(row=5, column=0, sticky="news", columnspan=2)
     self.conc_xml_check = ttk.Checkbutton(self.concordance_frame, text="Ignore XML tags",
                                           variable=self.concordance['IgnoreXML'])
     self.conc_xml_check.grid(row=5, column=2, sticky="news", columnspan=2)
     misc.pad_children(self.file_frame, 5, 5)
     misc.pad_children(self.definition_frame, 5, 5)
     misc.pad_children(self.xml_frame, 5, 5)
     misc.pad_children(self.concordance_frame, 5, 5)
Esempio n. 9
0
    def draw_ui(self):
        settings = self.parent.settings_frame  # just for shorter refs
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        self.book = ttk.Notebook(self)
        self.book.grid(column=0, row=0, sticky="news")
        self.rowconfigure(0, weight=1)  # conc tabs
        self.rowconfigure(1, weight=0)  # search frame
        # SEARCH frame
        self.search_frame = ttk.Frame(self)
        self.search_frame.grid(row=1, column=0, sticky="news")
        self.search_frame.rowconfigure(0, weight=0)
        self.search_frame.rowconfigure(1, weight=0)
        self.search_frame.columnconfigure(0, weight=0)
        self.search_frame.columnconfigure(8, weight=1)
        # row 0
        tk.Label(self.search_frame, text="Search text",
                 font="verdana 12").grid(column=0, row=0, sticky="nw")
        self.search_var = tk.StringVar()
        self.search_combo = ttk.Combobox(self.search_frame,
                                         textvariable=self.search_var,
                                         style="Search.TCombobox",
                                         font="verdana 12")
        self.search_combo.grid(row=0, column=1, sticky="new", columnspan=8)
        # row 1
        tk.Label(self.search_frame, text="Context left",
                 font="verdana 10").grid(column=0, row=1, sticky="nw")
        tk.Label(self.search_frame, text="Context right",
                 font="verdana 10").grid(column=2, row=1, sticky="nw")
        tk.Label(self.search_frame, text="Unit",
                 font="verdana 10").grid(column=4, row=1, sticky="nw")
        self.left_entry = ttk.Entry(
            self.search_frame,
            width=5,
            textvariable=settings.concordance['ContextLeft'])
        self.right_entry = ttk.Entry(
            self.search_frame,
            width=5,
            textvariable=settings.concordance['ContextRight'])
        self.left_entry.grid(row=1, column=1, sticky="new")
        self.right_entry.grid(row=1, column=3, sticky="new")
        self.unit_combo = ttk.Combobox(
            self.search_frame,
            textvariable=settings.concordance['ContextUnit'],
            values=["Characters", "Words"],
            state="readonly")
        self.unit_combo["width"] = 8
        self.unit_combo.grid(row=1, column=5, sticky="new")

        self.case_check = ttk.Checkbutton(
            self.search_frame,
            text="Case sensitive",
            variable=settings.concordance['Case'])
        self.case_check.grid(row=1, column=6)

        self.regex_check = ttk.Checkbutton(
            self.search_frame,
            text="Regular expression",
            variable=settings.concordance['IsRegEx'])
        self.regex_check.grid(row=1, column=7)

        # ALL tab
        self.all_frame = ttk.Frame(self)
        self.all_frame.rowconfigure(0, weight=1)
        self.all_frame.rowconfigure(1, weight=0)
        self.all_frame.columnconfigure(0, weight=1)  # !!!
        self.book.add(self.all_frame, text="All corpora")
        # row 0 RESULTS
        self.results_frame = ttk.Frame(self.all_frame)
        self.results_frame.rowconfigure(0, weight=1)
        self.results_frame.rowconfigure(1, weight=0)  # x scrollbars
        self.results_frame.columnconfigure(0, weight=0)  # index
        self.results_frame.columnconfigure(1, weight=1)  # conc line
        self.results_frame.columnconfigure(2, weight=0)  # y  scrollbar
        self.results_frame.columnconfigure(3, weight=0)  # metadata
        self.results_frame.grid(row=0, column=0, sticky="news")
        self.ybar = ttk.Scrollbar(self.results_frame, command=self.yview)
        self.ybar.grid(row=0, column=2, sticky="news")
        self.line_xbar = ttk.Scrollbar(self.results_frame, orient="horizontal")
        self.line_xbar.grid(row=1, column=1, sticky="news")
        self.line_text = tk.Text(self.results_frame,
                                 wrap="none",
                                 font='courier 10',
                                 yscrollcommand=self.ybar.set,
                                 xscrollcommand=self.line_xbar.set)
        self.line_text.grid(row=0, column=1, sticky="news")
        self.line_text.tag_configure('key',
                                     foreground='black',
                                     font='courier 10 bold')
        self.line_xbar.config(command=self.line_text.xview)
        self.index_text = tk.Text(self.results_frame,
                                  width=8,
                                  yscrollcommand=self.ybar.set,
                                  font='courier 10',
                                  wrap="none")
        self.index_text.grid(row=0, column=0, sticky="news")

        self.meta_xbar = ttk.Scrollbar(self.results_frame, orient="horizontal")
        self.meta_xbar.grid(row=1, column=3, sticky="news")
        self.meta_canvas = tk.Canvas(self.results_frame,
                                     background="white",
                                     xscrollcommand=self.meta_xbar.set)
        self.meta_canvas.grid(row=0, column=3, sticky="news")
        self.meta_xbar.config(command=self.meta_canvas.xview)
        self.meta_canvas_frame = tk.Frame(self.meta_canvas)
        # by default corpus name and filename, eventually more with XML corpora
        # if attributes provided
        self.meta_text = {}
        metadata = ["Corpus", "Filename"]
        self.parent.root.update_idletasks()
        for i, m in enumerate(metadata):
            self.meta_text[m] = tk.Text(self.meta_canvas_frame,
                                        wrap="none",
                                        font='courier 10')
            self.meta_text[m].grid(row=0, column=i, sticky="news")
        self.parent.root.update_idletasks()
        x2 = self.meta_canvas_frame.winfo_reqwidth()
        self.meta_canvas.create_window(0,
                                       0,
                                       anchor="nw",
                                       window=self.meta_canvas_frame)
        self.meta_canvas.config(scrollregion=(0, 0, x2, 0))
        h = self.meta_canvas_frame.winfo_reqheight()
        for i, m_text in self.meta_text.items():
            m_text["height"] = h
            m_text["width"] = 20

        # row 1 BUTTONS
        self.button_frame = ttk.Frame(self.all_frame)
        self.button_frame.columnconfigure(0, weight=0)
        self.button_frame.columnconfigure(1, weight=0)
        self.button_frame.columnconfigure(5, weight=1)

        self.button_frame.grid(row=1, column=0, sticky="news")
        self.start_button = ttk.Button(self.button_frame,
                                       text="Search all corpora",
                                       command=self.create_concordance)
        self.start_button.grid(row=1, column=0, sticky="news", columnspan=3)
        self.export_button = ttk.Button(self.button_frame,
                                        text="Export concordance",
                                        command=self.export_concordance,
                                        state="disabled",
                                        style="Small.TButton")
        self.export_button.grid(row=1, column=3, sticky="news")
        self.sort_button = ttk.Button(self.button_frame,
                                      text="Sort by",
                                      command=self.sort_concordance,
                                      state="disabled",
                                      style="Small.TButton")
        self.sort_button.grid(row=0, column=0, sticky="news")
        self.sort_combo = []
        self.sort_var = []

        for i in range(0, 3):
            self.sort_var.append(tk.StringVar())
            cb = ttk.Combobox(
                self.button_frame,
                textvariable=self.sort_var[i],
                values=["Left", "Key", "Right", "Corpus", "Filename"],
                state="readonly",
                style="Small.TCombobox")
            cb.grid(row=0, column=i + 1, sticky="news")
            self.sort_combo.append(cb)
        self.sort_var[0].set("Key")
        self.sort_var[1].set("Right")
        self.sort_var[2].set("Corpus")
        self.filter_var = tk.StringVar()
        tk.Label(self.button_frame, text="Filter text",
                 font="verdana 9").grid(column=4, row=0, sticky="news")
        self.filter_entry = ttk.Entry(self.button_frame,
                                      textvariable=self.filter_var,
                                      style="Small.TEntry",
                                      state="disabled")
        self.filter_entry.grid(row=0, column=5, sticky="news", columnspan=3)
        self.filter_button = ttk.Button(self.button_frame,
                                        text="Filter concordance results",
                                        command=self.filter_concordance,
                                        style="Small.TButton",
                                        state="disabled")
        self.filter_button.grid(row=1, column=4, columnspan=2, sticky="news")
        self.filter_what_var = tk.StringVar()
        self.filter_what_combo = ttk.Combobox(
            self.button_frame,
            textvariable=self.filter_what_var,
            values=['Key', "Left", "Right", "Line"],
            state="readonly")
        self.filter_what_var.set('Key')
        self.filter_what_combo.grid(row=1, column=6, sticky="news")
        self.unfilter_button = ttk.Button(self.button_frame,
                                          text="Undo filter",
                                          command=self.unfilter_concordance,
                                          style="Small.TButton",
                                          state="disabled")
        self.unfilter_button.grid(row=1, column=7, sticky="news")

        misc.pad_children(self.search_frame, 5, 5)
        misc.pad_children(self.button_frame, 5, 5)
Esempio n. 10
0
    def draw_conc_ui(self):
        parent = self.parent.concordance_frame
        self.button_style = "C{}.TButton".format(self.n)
        self.conc_frame = ttk.Frame(parent)
        parent.book.add(self.conc_frame, text=self.name_var.get())
        # row 0
        self.conc_results_frame = ttk.Frame(self.conc_frame)
        self.conc_results_frame.grid(row=0, column=0, sticky="news")
        # row 1
        self.conc_button_frame = ttk.Frame(self.conc_frame)
        self.conc_button_frame.grid(row=1, column=0, sticky="news")

        self.conc_results_frame = ttk.Frame(self.conc_frame)
        self.conc_results_frame.grid(row=0, column=0, sticky="news")
        self.conc_ybar = ttk.Scrollbar(self.conc_results_frame, command=self.concordance_yview)
        self.conc_ybar.grid(row=0, column=2, sticky="news")
        self.conc_line_xbar = ttk.Scrollbar(self.conc_results_frame, orient="horizontal")
        self.conc_line_xbar.grid(row=1, column=1, sticky="news")
        self.conc_line_text = tk.Text(self.conc_results_frame, wrap="none", height=30,
                                      yscrollcommand=self.conc_ybar.set,
                                      xscrollcommand=self.conc_line_xbar.set, width=100)
        self.conc_line_text.grid(row=0, column=1, sticky="nesw")
        self.conc_line_xbar.config(command=self.conc_line_text.xview)
        self.conc_index_text = tk.Text(self.conc_results_frame, width=6,
                                       yscrollcommand=self.conc_ybar.set, height=30)
        self.conc_index_text.grid(row=0, column=0, sticky="nesw")
        self.conc_meta_xbar = ttk.Scrollbar(self.conc_results_frame, orient="horizontal")
        self.conc_meta_xbar.grid(row=1, column=3, sticky="news")
        self.conc_meta_canvas = tk.Canvas(self.conc_results_frame, background="white",
                                          xscrollcommand=self.conc_meta_xbar.set)
        self.conc_meta_canvas.grid(row=0, column=3, sticky="news")
        self.conc_meta_xbar.config(command=self.conc_meta_canvas.xview)
        self.conc_meta_canvas_frame = tk.Frame(self.conc_meta_canvas)
        self.conc_meta_text = {}  # corpus & file name, later more with XML corpora if attributes
        self.conc_meta_text["corpus"] = tk.Text(self.conc_meta_canvas_frame, wrap="none", width=20,
                                                height=30)
        self.conc_meta_text["file"] = tk.Text(self.conc_meta_canvas_frame, wrap="none", width=20,
                                              height=30)
        self.parent.root.update_idletasks()
        x2 = self.conc_meta_canvas_frame.winfo_reqwidth()
        self.conc_meta_canvas.create_window(0, 0, anchor="nw", window=self.conc_meta_canvas_frame)
        self.conc_meta_canvas.config(scrollregion=(0, 0, x2, 0))
        # row 1 BUTTONS
        self.conc_button_frame = ttk.Frame(self.conc_frame)
        self.conc_button_frame.columnconfigure(0, weight=0)
        self.conc_button_frame.columnconfigure(1, weight=0)
        self.conc_button_frame.columnconfigure(5, weight=1)
        self.conc_button_frame.grid(row=1, column=0, sticky="news")
        self.conc_start_button = ttk.Button(self.conc_button_frame, text="Search all corpora",
                                            command=self.create_concordance,
                                            style=self.button_style)
        self.conc_start_button.grid(row=1, column=0, sticky="news", columnspan=3)
        self.conc_export_button = ttk.Button(self.conc_button_frame, text="Export concordance",
                                             command=self.export_concordance, state="disabled",
                                             style="Small.TButton")
        self.conc_export_button.grid(row=1, column=3, sticky="news")
        self.conc_sort_button = ttk.Button(self.conc_button_frame, text="Sort by",
                                           command=self.sort_concordance, state="disabled",
                                           style="Small.TButton")
        self.conc_sort_button.grid(row=0, column=0, sticky="news")
        self.conc_sort_combo = []
        self.conc_sort_var = []
        for i in range(0, 3):
            self.conc_sort_var.append(tk.StringVar())
            cb = ttk.Combobox(self.conc_button_frame, textvariable=self.conc_sort_var[i],
                              values=["Left", "Key", "Right", "Corpus", "Filename"],
                              state="readonly", style="Small.TCombobox")
            cb.grid(row=0, column=i+1, sticky="news")
            self.conc_sort_combo.append(cb)
        self.conc_sort_var[0].set("Key")
        self.conc_sort_var[1].set("Right")
        self.conc_sort_var[2].set("Corpus")
        self.conc_filter_var = tk.StringVar()
        tk.Label(self.conc_button_frame, text="Filter text",
                 font="verdana 9").grid(column=4, row=0, sticky="news")
        self.conc_filter_entry = ttk.Entry(self.conc_button_frame,
                                           textvariable=self.conc_filter_var,
                                           style="Small.TEntry", state="disabled")
        self.conc_filter_entry.grid(row=0, column=5, sticky="news")
        self.conc_filter_button = ttk.Button(self.conc_button_frame, text="Filter results",
                                             command=self.filter_concordance,
                                             style="Small.TButton", state="disabled")
        self.conc_filter_button.grid(row=1, column=4, columnspan=2, sticky="news")
        misc.pad_children(self.conc_button_frame, 5, 5)
Esempio n. 11
0
    def draw_ui(self):
        settings = self.parent.settings_frame  # just for shorter refs
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        self.book = ttk.Notebook(self)
        self.book.grid(column=0, row=0, sticky="news")
        self.rowconfigure(0, weight=1)  # conc tabs
        self.rowconfigure(1, weight=0)  # search frame
        # SEARCH frame
        self.search_frame = ttk.Frame(self)
        self.search_frame.grid(row=1, column=0, sticky="news")
        self.search_frame.rowconfigure(0, weight=0)
        self.search_frame.rowconfigure(1, weight=0)
        self.search_frame.columnconfigure(0, weight=0)
        self.search_frame.columnconfigure(8, weight=1)
        # row 0
        tk.Label(self.search_frame, text="Search text", font="verdana 12").grid(column=0, row=0,
                                                                                sticky="nw")
        self.search_var = tk.StringVar()
        self.search_combo = ttk.Combobox(self.search_frame, textvariable=self.search_var,
                                         style="Search.TCombobox", font="verdana 12")
        self.search_combo.grid(row=0, column=1, sticky="new", columnspan=8)
        # row 1
        tk.Label(self.search_frame, text="Context left", font="verdana 10").grid(column=0, row=1,
                                                                                 sticky="nw")
        tk.Label(self.search_frame, text="Context right", font="verdana 10").grid(column=2, row=1,
                                                                                  sticky="nw")
        tk.Label(self.search_frame, text="Unit", font="verdana 10").grid(column=4, row=1,
                                                                         sticky="nw")
        self.left_entry = ttk.Entry(self.search_frame, width=5,
                                    textvariable=settings.concordance['ContextLeft'])
        self.right_entry = ttk.Entry(self.search_frame, width=5,
                                     textvariable=settings.concordance['ContextRight'])
        self.left_entry.grid(row=1, column=1, sticky="new")
        self.right_entry.grid(row=1, column=3, sticky="new")
        self.unit_combo = ttk.Combobox(self.search_frame,
                                       textvariable=settings.concordance[
                                           'ContextUnit'],
                                       values=["Characters", "Words"], state="readonly")
        self.unit_combo["width"] = 8
        self.unit_combo.grid(row=1, column=5, sticky="new")

        self.case_check = ttk.Checkbutton(
            self.search_frame, text="Case sensitive", variable=settings.concordance['Case'])
        self.case_check.grid(row=1, column=6)

        self.regex_check = ttk.Checkbutton(
            self.search_frame, text="Regular expression", variable=settings.concordance['IsRegEx'])
        self.regex_check.grid(row=1, column=7)

        # ALL tab
        self.all_frame = ttk.Frame(self)
        self.all_frame.rowconfigure(0, weight=1)
        self.all_frame.rowconfigure(1, weight=0)
        self.all_frame.columnconfigure(0, weight=1)  # !!!
        self.book.add(self.all_frame, text="All corpora")
        # row 0 RESULTS
        self.results_frame = ttk.Frame(self.all_frame)
        self.results_frame.rowconfigure(0, weight=1)
        self.results_frame.rowconfigure(1, weight=0)  # x scrollbars
        self.results_frame.columnconfigure(0, weight=0)  # index
        self.results_frame.columnconfigure(1, weight=1)  # conc line
        self.results_frame.columnconfigure(2, weight=0)  # y  scrollbar
        self.results_frame.columnconfigure(3, weight=0)   # metadata
        self.results_frame.grid(row=0, column=0, sticky="news")
        self.ybar = ttk.Scrollbar(self.results_frame, command=self.yview)
        self.ybar.grid(row=0, column=2, sticky="news")
        self.line_xbar = ttk.Scrollbar(self.results_frame, orient="horizontal")
        self.line_xbar.grid(row=1, column=1, sticky="news")
        self.line_text = tk.Text(self.results_frame, wrap="none", font='courier 10',
                                 yscrollcommand=self.ybar.set,
                                 xscrollcommand=self.line_xbar.set)
        self.line_text.grid(row=0, column=1, sticky="news")
        self.line_text.tag_configure('key', foreground='black', font='courier 10 bold')
        self.line_xbar.config(command=self.line_text.xview)
        self.index_text = tk.Text(self.results_frame, width=8, yscrollcommand=self.ybar.set, font='courier 10',
                                  wrap="none")
        self.index_text.grid(row=0, column=0, sticky="news")

        self.meta_xbar = ttk.Scrollbar(self.results_frame, orient="horizontal")
        self.meta_xbar.grid(row=1, column=3, sticky="news")
        self.meta_canvas = tk.Canvas(self.results_frame, background="white",
                                     xscrollcommand=self.meta_xbar.set)
        self.meta_canvas.grid(row=0, column=3, sticky="news")
        self.meta_xbar.config(command=self.meta_canvas.xview)
        self.meta_canvas_frame = tk.Frame(self.meta_canvas)
        # by default corpus name and filename, eventually more with XML corpora
        # if attributes provided
        self.meta_text = {}
        metadata = ["Corpus", "Filename"]
        self.parent.root.update_idletasks()
        for i, m in enumerate(metadata):
            self.meta_text[m] = tk.Text(self.meta_canvas_frame, wrap="none", font='courier 10')
            self.meta_text[m].grid(row=0, column=i, sticky="news")
        self.parent.root.update_idletasks()
        x2 = self.meta_canvas_frame.winfo_reqwidth()
        self.meta_canvas.create_window(0, 0, anchor="nw", window=self.meta_canvas_frame)
        self.meta_canvas.config(scrollregion=(0, 0, x2, 0))
        h = self.meta_canvas_frame.winfo_reqheight()
        for i, m_text in self.meta_text.items():
            m_text["height"] = h
            m_text["width"] = 20

        # row 1 BUTTONS
        self.button_frame = ttk.Frame(self.all_frame)
        self.button_frame.columnconfigure(0, weight=0)
        self.button_frame.columnconfigure(1, weight=0)
        self.button_frame.columnconfigure(5, weight=1)

        self.button_frame.grid(row=1, column=0, sticky="news")
        self.start_button = ttk.Button(self.button_frame, text="Search all corpora",
                                       command=self.create_concordance)
        self.start_button.grid(row=1, column=0, sticky="news", columnspan=3)
        self.export_button = ttk.Button(self.button_frame, text="Export concordance",
                                        command=self.export_concordance, state="disabled",
                                        style="Small.TButton")
        self.export_button.grid(row=1, column=3, sticky="news")
        self.sort_button = ttk.Button(self.button_frame, text="Sort by",
                                      command=self.sort_concordance, state="disabled",
                                      style="Small.TButton")
        self.sort_button.grid(row=0, column=0, sticky="news")
        self.sort_combo = []
        self.sort_var = []

        for i in range(0, 3):
            self.sort_var.append(tk.StringVar())
            cb = ttk.Combobox(self.button_frame, textvariable=self.sort_var[i],
                              values=[
                                  "Left", "Key", "Right", "Corpus", "Filename"],
                              state="readonly", style="Small.TCombobox")
            cb.grid(row=0, column=i + 1, sticky="news")
            self.sort_combo.append(cb)
        self.sort_var[0].set("Key")
        self.sort_var[1].set("Right")
        self.sort_var[2].set("Corpus")
        self.filter_var = tk.StringVar()
        tk.Label(self.button_frame, text="Filter text", font="verdana 9").grid(column=4, row=0,
                                                                               sticky="news")
        self.filter_entry = ttk.Entry(self.button_frame, textvariable=self.filter_var,
                                      style="Small.TEntry", state="disabled")
        self.filter_entry.grid(row=0, column=5, sticky="news", columnspan=3)
        self.filter_button = ttk.Button(self.button_frame, text="Filter concordance results",
                                        command=self.filter_concordance,
                                        style="Small.TButton",
                                        state="disabled")
        self.filter_button.grid(row=1, column=4, columnspan=2, sticky="news")
        self.filter_what_var = tk.StringVar()
        self.filter_what_combo = ttk.Combobox(self.button_frame, textvariable=self.filter_what_var,
                                              values=['Key', "Left", "Right", "Line"], state="readonly")
        self.filter_what_var.set('Key')
        self.filter_what_combo.grid(row=1, column=6, sticky="news")
        self.unfilter_button = ttk.Button(self.button_frame, text="Undo filter",
                                          command=self.unfilter_concordance, style="Small.TButton", state="disabled")
        self.unfilter_button.grid(row=1, column=7, sticky="news")

        misc.pad_children(self.search_frame, 5, 5)
        misc.pad_children(self.button_frame, 5, 5)
Esempio n. 12
0
    def draw_conc_ui(self):
        parent = self.parent.concordance_frame
        self.button_style = "C{}.TButton".format(self.n)
        self.conc_frame = ttk.Frame(parent)
        parent.book.add(self.conc_frame, text=self.name_var.get())
        # row 0
        self.conc_results_frame = ttk.Frame(self.conc_frame)
        self.conc_results_frame.grid(row=0, column=0, sticky="news")
        # row 1
        self.conc_button_frame = ttk.Frame(self.conc_frame)
        self.conc_button_frame.grid(row=1, column=0, sticky="news")

        self.conc_results_frame = ttk.Frame(self.conc_frame)
        self.conc_results_frame.grid(row=0, column=0, sticky="news")
        self.conc_ybar = ttk.Scrollbar(self.conc_results_frame,
                                       command=self.concordance_yview)
        self.conc_ybar.grid(row=0, column=2, sticky="news")
        self.conc_line_xbar = ttk.Scrollbar(self.conc_results_frame,
                                            orient="horizontal")
        self.conc_line_xbar.grid(row=1, column=1, sticky="news")
        self.conc_line_text = tk.Text(self.conc_results_frame,
                                      wrap="none",
                                      height=30,
                                      yscrollcommand=self.conc_ybar.set,
                                      xscrollcommand=self.conc_line_xbar.set,
                                      width=100)
        self.conc_line_text.grid(row=0, column=1, sticky="nesw")
        self.conc_line_xbar.config(command=self.conc_line_text.xview)
        self.conc_index_text = tk.Text(self.conc_results_frame,
                                       width=6,
                                       yscrollcommand=self.conc_ybar.set,
                                       height=30)
        self.conc_index_text.grid(row=0, column=0, sticky="nesw")
        self.conc_meta_xbar = ttk.Scrollbar(self.conc_results_frame,
                                            orient="horizontal")
        self.conc_meta_xbar.grid(row=1, column=3, sticky="news")
        self.conc_meta_canvas = tk.Canvas(
            self.conc_results_frame,
            background="white",
            xscrollcommand=self.conc_meta_xbar.set)
        self.conc_meta_canvas.grid(row=0, column=3, sticky="news")
        self.conc_meta_xbar.config(command=self.conc_meta_canvas.xview)
        self.conc_meta_canvas_frame = tk.Frame(self.conc_meta_canvas)
        self.conc_meta_text = {
        }  # corpus & file name, later more with XML corpora if attributes
        self.conc_meta_text["corpus"] = tk.Text(self.conc_meta_canvas_frame,
                                                wrap="none",
                                                width=20,
                                                height=30)
        self.conc_meta_text["file"] = tk.Text(self.conc_meta_canvas_frame,
                                              wrap="none",
                                              width=20,
                                              height=30)
        self.parent.root.update_idletasks()
        x2 = self.conc_meta_canvas_frame.winfo_reqwidth()
        self.conc_meta_canvas.create_window(0,
                                            0,
                                            anchor="nw",
                                            window=self.conc_meta_canvas_frame)
        self.conc_meta_canvas.config(scrollregion=(0, 0, x2, 0))
        # row 1 BUTTONS
        self.conc_button_frame = ttk.Frame(self.conc_frame)
        self.conc_button_frame.columnconfigure(0, weight=0)
        self.conc_button_frame.columnconfigure(1, weight=0)
        self.conc_button_frame.columnconfigure(5, weight=1)
        self.conc_button_frame.grid(row=1, column=0, sticky="news")
        self.conc_start_button = ttk.Button(self.conc_button_frame,
                                            text="Search all corpora",
                                            command=self.create_concordance,
                                            style=self.button_style)
        self.conc_start_button.grid(row=1,
                                    column=0,
                                    sticky="news",
                                    columnspan=3)
        self.conc_export_button = ttk.Button(self.conc_button_frame,
                                             text="Export concordance",
                                             command=self.export_concordance,
                                             state="disabled",
                                             style="Small.TButton")
        self.conc_export_button.grid(row=1, column=3, sticky="news")
        self.conc_sort_button = ttk.Button(self.conc_button_frame,
                                           text="Sort by",
                                           command=self.sort_concordance,
                                           state="disabled",
                                           style="Small.TButton")
        self.conc_sort_button.grid(row=0, column=0, sticky="news")
        self.conc_sort_combo = []
        self.conc_sort_var = []
        for i in range(0, 3):
            self.conc_sort_var.append(tk.StringVar())
            cb = ttk.Combobox(
                self.conc_button_frame,
                textvariable=self.conc_sort_var[i],
                values=["Left", "Key", "Right", "Corpus", "Filename"],
                state="readonly",
                style="Small.TCombobox")
            cb.grid(row=0, column=i + 1, sticky="news")
            self.conc_sort_combo.append(cb)
        self.conc_sort_var[0].set("Key")
        self.conc_sort_var[1].set("Right")
        self.conc_sort_var[2].set("Corpus")
        self.conc_filter_var = tk.StringVar()
        tk.Label(self.conc_button_frame, text="Filter text",
                 font="verdana 9").grid(column=4, row=0, sticky="news")
        self.conc_filter_entry = ttk.Entry(self.conc_button_frame,
                                           textvariable=self.conc_filter_var,
                                           style="Small.TEntry",
                                           state="disabled")
        self.conc_filter_entry.grid(row=0, column=5, sticky="news")
        self.conc_filter_button = ttk.Button(self.conc_button_frame,
                                             text="Filter results",
                                             command=self.filter_concordance,
                                             style="Small.TButton",
                                             state="disabled")
        self.conc_filter_button.grid(row=1,
                                     column=4,
                                     columnspan=2,
                                     sticky="news")
        misc.pad_children(self.conc_button_frame, 5, 5)
Esempio n. 13
0
    def draw_conc_ui(self):
        parent = self.parent.concordance_frame
        self.button_style = "C{}.TButton".format(self.n)
        self.conc_frame = ttk.Frame(parent)
        self.conc_frame.rowconfigure(0, weight=1)
        self.conc_frame.rowconfigure(1, weight=0)
        self.conc_frame.columnconfigure(0, weight=1)
        parent.book.add(self.conc_frame, text=self.name_var.get())
        # row 1
        self.conc_button_frame = ttk.Frame(self.conc_frame)
        self.conc_button_frame.grid(row=1, column=0, sticky="news")
        # row 0
        self.conc_results_frame = ttk.Frame(self.conc_frame)
        self.conc_results_frame.grid(row=0, column=0, sticky="news")
        self.conc_results_frame.rowconfigure(0, weight=1)
        self.conc_results_frame.rowconfigure(1, weight=0)  # x scrollbars
        self.conc_results_frame.columnconfigure(0, weight=0)  # index
        self.conc_results_frame.columnconfigure(1, weight=1)  # conc line
        self.conc_results_frame.columnconfigure(2, weight=0)  # y  scrollbar
        self.conc_results_frame.columnconfigure(3, weight=0)  # metadata
        self.conc_ybar = ttk.Scrollbar(self.conc_results_frame,
                                       command=self.concordance_yview)
        self.conc_ybar.grid(row=0, column=2, sticky="news")
        self.conc_line_xbar = ttk.Scrollbar(self.conc_results_frame,
                                            orient="horizontal")
        self.conc_line_xbar.grid(row=1, column=1, sticky="news")
        self.conc_line_text = tk.Text(self.conc_results_frame,
                                      wrap="none",
                                      yscrollcommand=self.conc_ybar.set,
                                      xscrollcommand=self.conc_line_xbar.set,
                                      font='courier 10')
        self.conc_line_text.grid(row=0, column=1, sticky="news")
        self.conc_line_text.tag_configure('key',
                                          foreground='black',
                                          font='courier 10 bold')
        self.conc_line_xbar.config(command=self.conc_line_text.xview)
        self.conc_index_text = tk.Text(self.conc_results_frame,
                                       width=8,
                                       yscrollcommand=self.conc_ybar.set,
                                       font='courier 10',
                                       wrap="none")
        self.conc_index_text.grid(row=0, column=0, sticky="nesw")
        self.conc_meta_xbar = ttk.Scrollbar(self.conc_results_frame,
                                            orient="horizontal")
        self.conc_meta_xbar.grid(row=1, column=3, sticky="news")
        self.conc_meta_canvas = tk.Canvas(
            self.conc_results_frame,
            background="white",
            xscrollcommand=self.conc_meta_xbar.set)
        self.conc_meta_canvas.grid(row=0, column=3, sticky="news")
        self.conc_meta_xbar.config(command=self.conc_meta_canvas.xview)
        self.conc_meta_canvas_frame = tk.Frame(self.conc_meta_canvas)
        self.conc_meta_text = {
        }  # corpus & file name, later more with XML corpora if attributes
        metadata = ["Corpus", "Filename"]
        for i, m in enumerate(metadata):
            self.conc_meta_text[m] = tk.Text(self.conc_meta_canvas_frame,
                                             wrap="none",
                                             font='courier 10')
            self.conc_meta_text[m].grid(row=0, column=i, sticky="news")
        misc.disable_all_in_frame(self.conc_results_frame)
        self.parent.root.update_idletasks()
        x2 = self.conc_meta_canvas_frame.winfo_reqwidth()
        self.conc_meta_canvas.create_window(0,
                                            0,
                                            anchor="nw",
                                            window=self.conc_meta_canvas_frame)
        self.conc_meta_canvas.config(scrollregion=(0, 0, x2, 0))
        h = self.conc_meta_canvas_frame.winfo_reqheight()
        for i, m_text in self.conc_meta_text.items():
            m_text["height"] = h
            m_text["width"] = 20

        # row 1 BUTTONS
        self.conc_button_frame = ttk.Frame(self.conc_frame)
        self.conc_button_frame.columnconfigure(0, weight=0)
        self.conc_button_frame.columnconfigure(1, weight=0)
        self.conc_button_frame.columnconfigure(5, weight=1)
        self.conc_button_frame.grid(row=1, column=0, sticky="news")
        self.conc_start_button = ttk.Button(self.conc_button_frame,
                                            text="Search this corpus",
                                            command=self.create_concordance,
                                            style=self.button_style)
        self.conc_start_button.grid(row=1,
                                    column=0,
                                    sticky="news",
                                    columnspan=3)
        self.conc_export_button = ttk.Button(self.conc_button_frame,
                                             text="Export concordance",
                                             command=self.export_concordance,
                                             state="disabled",
                                             style="Small.TButton")
        self.conc_export_button.grid(row=1, column=3, sticky="news")
        self.conc_sort_button = ttk.Button(self.conc_button_frame,
                                           text="Sort by",
                                           command=self.sort_concordance,
                                           state="disabled",
                                           style="Small.TButton")
        self.conc_sort_button.grid(row=0, column=0, sticky="news")
        self.conc_sort_combo = []
        self.conc_sort_var = []
        for i in range(0, 3):
            self.conc_sort_var.append(tk.StringVar())
            cb = ttk.Combobox(
                self.conc_button_frame,
                textvariable=self.conc_sort_var[i],
                values=["Left", "Key", "Right", "Corpus", "Filename"],
                state="readonly",
                style="Small.TCombobox")
            cb.grid(row=0, column=i + 1, sticky="news")
            self.conc_sort_combo.append(cb)
        self.conc_sort_var[0].set("Key")
        self.conc_sort_var[1].set("Right")
        self.conc_sort_var[2].set("Corpus")
        self.conc_filter_var = tk.StringVar()
        tk.Label(self.conc_button_frame, text="Filter text",
                 font="verdana 9").grid(column=4, row=0, sticky="news")
        self.conc_filter_entry = ttk.Entry(self.conc_button_frame,
                                           textvariable=self.conc_filter_var,
                                           style="Small.TEntry",
                                           state="disabled")
        self.conc_filter_entry.grid(row=0,
                                    column=5,
                                    sticky="news",
                                    columnspan=3)
        self.conc_filter_button = ttk.Button(self.conc_button_frame,
                                             text="Filter",
                                             command=self.filter_concordance,
                                             style="Small.TButton",
                                             state="disabled")
        self.conc_filter_button.grid(row=1,
                                     column=4,
                                     columnspan=2,
                                     sticky="news")
        self.conc_filter_what_var = tk.StringVar()
        self.conc_filter_what_combo = ttk.Combobox(
            self.conc_button_frame,
            textvariable=self.conc_filter_what_var,
            values=['Key', "Left", "Right", "Line"],
            state="readonly")
        self.conc_filter_what_var.set('Key')
        self.conc_filter_what_combo.grid(row=1, column=6, sticky="news")
        self.conc_unfilter_button = ttk.Button(
            self.conc_button_frame,
            text="Undo filter",
            command=self.unfilter_concordance,
            style="Small.TButton",
            state="disabled")
        self.conc_unfilter_button.grid(row=1, column=7, sticky="news")
        misc.pad_children(self.conc_button_frame, 5, 5)