def __init__(self, master=None, cnf={}, **kw): if not "background" in kw: kw["background"] = EDIT_BACKGROUND EnhancedTextWithLogging.__init__(self, master=master, cnf=cnf, **kw) self._original_background = kw["background"] # Allow binding to events of all CodeView texts self.bindtags(self.bindtags() + ('CodeViewText', )) tktextext.fixwordbreaks(tk._default_root)
def __init__(self, master, exercise_provider_class): self._destroyed = False self._poll_scheduler = None super().__init__(master, borderwidth=0, relief="flat") self._provider = exercise_provider_class(self) self._executor = concurrent.futures.ThreadPoolExecutor( max_workers=self._provider.get_max_threads()) self._page_future = None # type: Optional[concurrent.futures.Future] self._image_futures = {} self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) self.vert_scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, style=scrollbar_style("Vertical")) self.vert_scrollbar.grid(row=0, column=1, sticky=tk.NSEW, rowspan=2) self.hor_scrollbar = ttk.Scrollbar(self, orient=tk.HORIZONTAL, style=scrollbar_style("Horizontal")) self.hor_scrollbar.grid(row=2, column=0, sticky=tk.NSEW) tktextext.fixwordbreaks(tk._default_root) self.init_header(row=0, column=0) spacer = ttk.Frame(self, height=1) spacer.grid(row=1, sticky="nsew") self._html_widget = HtmlText( master=self, renderer_class=ExerciseHtmlRenderer, link_and_form_handler=self._on_request_new_page, image_requester=self._on_request_image, read_only=True, wrap="word", font="TkDefaultFont", padx=0, pady=0, insertwidth=0, borderwidth=0, highlightthickness=0, yscrollcommand=self.vert_scrollbar.set, xscrollcommand=self.hor_scrollbar.set, ) self._html_widget.grid(row=1, column=0, sticky="nsew") self.vert_scrollbar["command"] = self._html_widget.yview self.hor_scrollbar["command"] = self._html_widget.xview self._poll_scheduler = None # TODO: go to last page from previous session? self.go_to("/") self._poll_provider_responses()
def __init__(self, master, show_hidden_files=False, last_folder_setting_name=None, breadcrumbs_pady=(5, 7)): self._cached_dir_data = {} ttk.Frame.__init__(self, master, borderwidth=0, relief="flat") self.vert_scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, style=scrollbar_style("Vertical")) self.vert_scrollbar.grid(row=0, column=1, sticky=tk.NSEW, rowspan=3) tktextext.fixwordbreaks(tk._default_root) self.building_breadcrumbs = False self.init_header(row=0, column=0) spacer = ttk.Frame(self, height=1) spacer.grid(row=1, sticky="nsew") self.tree = ttk.Treeview( self, columns=["#0", "kind", "path"], displaycolumns=(0, ), yscrollcommand=self.vert_scrollbar.set, ) self.tree["show"] = "headings" self.tree.grid(row=2, column=0, sticky=tk.NSEW) self.vert_scrollbar["command"] = self.tree.yview self.columnconfigure(0, weight=1) self.rowconfigure(2, weight=1) self.show_hidden_files = show_hidden_files self.tree["show"] = ("tree", ) self.tree.bind("<3>", self.on_secondary_click, True) if misc_utils.running_on_mac_os(): self.tree.bind("<2>", self.on_secondary_click, True) self.tree.bind("<Control-1>", self.on_secondary_click, True) self.tree.bind('<Double-Button-1>', self.on_double_click, True) self.tree.bind("<<TreeviewOpen>>", self.on_open_node) wb = get_workbench() self.folder_icon = wb.get_image("folder") self.python_file_icon = wb.get_image("python-file") self.text_file_icon = wb.get_image("text-file") self.generic_file_icon = wb.get_image("generic-file") self.hard_drive_icon = wb.get_image("hard-drive") self.tree.column("#0", width=500, anchor=tk.W) # set-up root node self.tree.set("", "kind", "root") self.menu = tk.Menu(self.tree, tearoff=False) self._last_folder_setting_name = last_folder_setting_name self.focus_into_saved_folder()
def __init__(self, master=None, cnf={}, **kw): super().__init__(master=master, tag_current_line=get_workbench().get_option( "view.highlight_current_line"), cnf=cnf, **kw) # Allow binding to events of all CodeView texts self.bindtags(self.bindtags() + ("CodeViewText", )) tktextext.fixwordbreaks(tk._default_root)
def __init__(self, master): super().__init__(master, borderwidth=0, relief="flat") self._provider_name = None self._provider_records_by_name = { p["name"]: p for p in get_workbench().get_exercise_providers() } self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) self.vert_scrollbar = ttk.Scrollbar( self, orient=tk.VERTICAL, style=scrollbar_style("Vertical") ) self.vert_scrollbar.grid(row=0, column=1, sticky=tk.NSEW, rowspan=3) tktextext.fixwordbreaks(tk._default_root) self.init_header(row=0, column=0) self.breadcrumbs_bar.set_links( [ ("_home", tr("Home")), ("/", "lahendus.ut.ee"), ("/c1", "Programmeerimise algkursus"), ("/c1/ch1", "1. Funktsioonid"), ("/c1/ch1", "14. Küpsisetort vol. 2"), ] ) spacer = ttk.Frame(self, height=1) spacer.grid(row=1, sticky="nsew") self._html_widget = HtmlText( master=self, link_and_form_handler=self._on_request_new_page, read_only=True, wrap="word", font="TkDefaultFont", padx=10, pady=0, insertwidth=0, borderwidth=0, highlightthickness=0, ) self._html_widget.grid(row=1, column=0, sticky="nsew") self.go_to_provider_selection_page()
def __init__(self, master=None, cnf={}, **kw): if "replace_tabs" not in kw: kw["replace_tabs"] = False super().__init__( master=master, tag_current_line=get_workbench().get_option("view.highlight_current_line"), cnf=cnf, **kw ) # Allow binding to events of all CodeView texts self.bindtags(self.bindtags() + ("CodeViewText",)) tktextext.fixwordbreaks(tk._default_root) # monkey patching self.bind('<<Selection>>', self.on_monkey, True)
def __init__(self, master, show_hidden_files=False, show_expand_buttons=True): global LOCAL_FILES_ROOT_TEXT LOCAL_FILES_ROOT_TEXT = _("This computer") self.show_expand_buttons = show_expand_buttons self._cached_child_data = {} self.path_to_highlight = None ttk.Frame.__init__(self, master, borderwidth=0, relief="flat") self.vert_scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, style=scrollbar_style("Vertical")) self.vert_scrollbar.grid(row=0, column=1, sticky=tk.NSEW, rowspan=3) tktextext.fixwordbreaks(tk._default_root) self.building_breadcrumbs = False self.init_header(row=0, column=0) spacer = ttk.Frame(self, height=1) spacer.grid(row=1, sticky="nsew") self.tree = ttk.Treeview( self, columns=["#0", "kind", "path", "name", "time", "size"], displaycolumns=( # 4, # 5 ), yscrollcommand=self.vert_scrollbar.set, selectmode="extended", ) self.tree.grid(row=2, column=0, sticky=tk.NSEW) self.vert_scrollbar["command"] = self.tree.yview self.columnconfigure(0, weight=1) self.rowconfigure(2, weight=1) self.show_hidden_files = show_hidden_files self.tree["show"] = "tree" self.tree.bind("<3>", self.on_secondary_click, True) if misc_utils.running_on_mac_os(): self.tree.bind("<2>", self.on_secondary_click, True) self.tree.bind("<Control-1>", self.on_secondary_click, True) self.tree.bind("<Double-Button-1>", self.on_double_click, True) self.tree.bind("<<TreeviewOpen>>", self.on_open_node) wb = get_workbench() self.folder_icon = wb.get_image("folder") self.python_file_icon = wb.get_image("python-file") self.text_file_icon = wb.get_image("text-file") self.generic_file_icon = wb.get_image("generic-file") self.hard_drive_icon = wb.get_image("hard-drive") self.tree.column("#0", width=200, anchor=tk.W) self.tree.heading("#0", text="Name", anchor=tk.W) self.tree.column("time", width=60, anchor=tk.W) self.tree.heading("time", text="Time", anchor=tk.W) self.tree.column("size", width=40, anchor=tk.E) self.tree.heading("size", text="Size (bytes)", anchor=tk.E) self.tree.column("kind", width=30, anchor=tk.W) # self.tree.heading("kind", text="Kind") # self.tree.column("path", width=300, anchor=tk.W) # self.tree.heading("path", text="path") # self.tree.column("name", width=60, anchor=tk.W) # self.tree.heading("name", text="name") # set-up root node self.tree.set(ROOT_NODE_ID, "kind", "root") self.menu = tk.Menu(self.tree, tearoff=False) self.current_focus = None
def __init__(self, master, show_hidden_files=False, last_folder_setting_name=None): ttk.Frame.__init__(self, master, borderwidth=0, relief="flat") self.vert_scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, style=scrollbar_style("Vertical")) self.vert_scrollbar.grid(row=0, column=1, sticky=tk.NSEW, rowspan=4) self.toolbar = ttk.Frame(self, style="ViewToolbar.TFrame") self.toolbar.grid(row=0, sticky="nsew") self.toolbar.grid(row=1, sticky="nsew") self.init_toolbar() tktextext.fixwordbreaks(tk._default_root) self.building_breadcrumbs = False self.path_bar = tktextext.TweakableText(self, borderwidth=0, relief="flat", height=1, font="TkDefaultFont", wrap="word", padx=6) self.init_path_bar() self.set_breadcrumbs( "This computer\\C:\\Users\\Aivar\\Documents\\Python\\PyGame\\NikaNaka" ) self.path_bar.grid(row=2, sticky="nsew") self.tree = ttk.Treeview( self, columns=["#0", "kind", "path"], displaycolumns=(0, ), yscrollcommand=self.vert_scrollbar.set, ) self.tree["show"] = "headings" self.tree.grid(row=3, column=0, sticky=tk.NSEW) self.vert_scrollbar["command"] = self.tree.yview self.columnconfigure(0, weight=1) self.rowconfigure(3, weight=1) self.show_hidden_files = show_hidden_files self.tree["show"] = ("tree", ) wb = get_workbench() self.folder_icon = wb.get_image("folder") self.python_file_icon = wb.get_image("python-file") self.text_file_icon = wb.get_image("text-file") self.generic_file_icon = wb.get_image("generic-file") self.hard_drive_icon = wb.get_image("hard-drive") self.tree.column("#0", width=500, anchor=tk.W) # set-up root node self.tree.set("", "kind", "root") self.tree.set("", "path", "") self.refresh_tree() self.tree.bind("<<TreeviewOpen>>", self.on_open_node) self._last_folder_setting_name = last_folder_setting_name self.open_initial_folder()