def initialize(self): self.grid() self.entry_font = tkFont.Font(family='courier', size=10) self.paste_to_field = Tkinter.Text(self, borderwidth="2", relief="sunken", height=20, width=100, font=self.entry_font) self.paste_to_field.grid(column=0, row =0, columnspan=19, sticky='W, E') scrl_top = Tkinter.Scrollbar(self, command=self.paste_to_field.yview) self.paste_to_field.config(yscrollcommand=scrl_top.set) scrl_top.grid(row=0, column=20, sticky='N, S, E') submit_button = Tkinter.Button(self, width=8, text="Submit", command=self.OnSubmitButtonClick) submit_button.grid(column=0, row=1, sticky='E') self.bind_all(sequence='<Control-Alt-KeyPress-C>', func=self.submit_text) clear_button = Tkinter.Button(self, width=8, text="Clear", command=self.OnClearButtonClick) clear_button.grid(column=2, row=1, sticky='W') self.line_mode_var = Tkinter.IntVar() self.line_mode_bool = sh.get_multiline_bool() self.line_mode_var.set(self.line_mode_bool) line_mode_cb = Tkinter.Checkbutton(self, text='Multiline Mode', variable=self.line_mode_var) line_mode_cb.grid(column=5, row=1, sticky='W') line_mode_cb.bind(sequence='<Leave>', func=self.multiline_bool_update) self.options_var = Tkinter.StringVar() self.options_var.set(sl.options_list[0]) self.mode_selection = Tkinter.OptionMenu(self, self.options_var, *sl.options_list) self.mode_selection.config(width=18, justify='left') self.mode_selection.grid(column=6, row=1, sticky='W') self.mode_update() self.mode_selection.bind(sequence='<Leave>', func=self.mode_update) options_button = Tkinter.Button(self, width=8, text="Options", command=self.options_window_create) options_button.grid(column=18, row=1, sticky='E') self.copy_from_field = Tkinter.Text(self, borderwidth="2", relief="sunken", height=20, width=100, state='disabled', font=self.entry_font) self.copy_from_field.grid(column=0, row =3, columnspan=19, sticky='W, E') scrl_bottom = Tkinter.Scrollbar(self, command=self.copy_from_field.yview) self.copy_from_field.config(yscrollcommand=scrl_bottom.set) scrl_bottom.grid(row=3, column=20, sticky='N, S, E') self.quit_button = Tkinter.Button(self, width=8, text='Quit', command=self.OnQuitClick) self.quit_button.grid(column=17, columnspan=3, row=4, sticky='E')
def make_selection(text, multiline_bool=None, selection=None, text_processing=False): tp_dict = tp_dh.get_pattern_dict(update=False) if not selection: # Get settings from settings.xml selection = sh.get_mode() if not multiline_bool: multiline_bool = sh.get_multiline_bool() if text_processing: text = tp_obj(text, 1, pattern_dict=tp_dict) mode = options_dict.get(selection) return mode(text, multiline_bool, pattern_dict=tp_dict)
def multiline_bool_update(self, *args): self.line_mode_bool = self.line_mode_var.get() sh.set_line_mode_bool(self.line_mode_bool) new_bool = sh.get_multiline_bool()