Python tkinter.ttk.Scrollbar() Examples
The following are 30
code examples of tkinter.ttk.Scrollbar().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter.ttk
, or try the search function
.

Example #1
Source File: recipe-578874.py From code with MIT License | 7 votes |
def __init__(self, master, factor = 0.5, **kwargs): self.__scrollableWidgets = [] if 'orient' in kwargs: if kwargs['orient']== tk.VERTICAL: self.__orientLabel = 'y' elif kwargs['orient']== tk.HORIZONTAL: self.__orientLabel = 'x' else: raise Exception("Bad 'orient' argument in scrollbar.") else: self.__orientLabel = 'y' kwargs['command'] = self.onScroll self.factor = factor ttk.Scrollbar.__init__(self, master, **kwargs)
Example #2
Source File: texteditor.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def __init__(self): super().__init__() self.text_area = TextArea(self, bg="white", fg="black", undo=True) self.scrollbar = ttk.Scrollbar(orient="vertical", command=self.scroll_text) self.text_area.configure(yscrollcommand=self.scrollbar.set) self.line_numbers = LineNumbers(self, self.text_area, bg="grey", fg="white", width=1) self.highlighter = Highlighter(self.text_area, 'languages/python.yaml') self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y) self.line_numbers.pack(side=tk.LEFT, fill=tk.Y) self.text_area.pack(side=tk.LEFT, fill=tk.BOTH, expand=1) self.bind_events()
Example #3
Source File: friendslist.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def show_friends(self): self.configure(menu=self.menu) self.login_frame.pack_forget() self.canvas = tk.Canvas(self, bg="white") self.canvas_frame = tk.Frame(self.canvas) self.scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.canvas.yview) self.canvas.configure(yscrollcommand=self.scrollbar.set) self.scrollbar.pack(side=tk.LEFT, fill=tk.Y) self.canvas.pack(side=tk.LEFT, expand=1, fill=tk.BOTH) self.friends_area = self.canvas.create_window((0, 0), window=self.canvas_frame, anchor="nw") self.bind_events() self.load_friends()
Example #4
Source File: friendslist.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def __init__(self, **kwargs): super().__init__(**kwargs) self.title('Tk Chat') self.geometry('700x500') self.menu = tk.Menu(self, bg="lightgrey", fg="black", tearoff=0) self.friends_menu = tk.Menu(self.menu, fg="black", bg="lightgrey", tearoff=0) self.friends_menu.add_command(label="Add Friend", command=self.add_friend) self.menu.add_cascade(label="Friends", menu=self.friends_menu) self.configure(menu=self.menu) self.canvas = tk.Canvas(self, bg="white") self.canvas_frame = tk.Frame(self.canvas) self.scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.canvas.yview) self.canvas.configure(yscrollcommand=self.scrollbar.set) self.scrollbar.pack(side=tk.LEFT, fill=tk.Y) self.canvas.pack(side=tk.LEFT, expand=1, fill=tk.BOTH) self.friends_area = self.canvas.create_window((0, 0), window=self.canvas_frame, anchor="nw") self.bind_events() self.load_friends()
Example #5
Source File: friendslist.py From Tkinter-GUI-Programming-by-Example with MIT License | 6 votes |
def show_friends(self): self.configure(menu=self.menu) self.login_frame.pack_forget() self.canvas = tk.Canvas(self, bg="white") self.canvas_frame = tk.Frame(self.canvas) self.scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.canvas.yview) self.canvas.configure(yscrollcommand=self.scrollbar.set) self.scrollbar.pack(side=tk.LEFT, fill=tk.Y) self.canvas.pack(side=tk.LEFT, expand=1, fill=tk.BOTH) self.friends_area = self.canvas.create_window((0, 0), window=self.canvas_frame, anchor="nw") self.bind_events() self.load_friends()
Example #6
Source File: opcodes.py From brownie with MIT License | 6 votes |
def __init__(self, parent, columns, **kwargs): self._last = set() self._seek_buffer = "" self._seek_last = 0 self._highlighted = set() self._frame = ttk.Frame(parent) super().__init__( self._frame, columns=[i[0] for i in columns[1:]], selectmode="browse", **kwargs ) self.pack(side="left", fill="y") self.heading("#0", text=columns[0][0]) self.column("#0", width=columns[0][1]) for tag, width in columns[1:]: self.heading(tag, text=tag) self.column(tag, width=width) scroll = ttk.Scrollbar(self._frame) scroll.pack(side="right", fill="y") self.configure(yscrollcommand=scroll.set) scroll.configure(command=self.yview) self.tag_configure("NoSource", background="#161616") self.bind("<<TreeviewSelect>>", self._select_bind) root = self.root = self._root() root.bind("j", self._highlight_jumps) root.bind("r", self._highlight_revert) self.bind("<3>", self._highlight_opcode) for i in range(10): root.bind(str(i), self._seek)
Example #7
Source File: components.py From SEM with MIT License | 6 votes |
def __init__(self, root, main_window, button_opt): ttk.Frame.__init__(self, root) self.root = root self.main_window = main_window self.current_files = None self.button_opt = button_opt # define options for opening or saving a file self.file_opt = options = {} options['defaultextension'] = '.txt' options['filetypes'] = [('all files', '.*'), ('text files', '.txt')] options['initialdir'] = os.path.expanduser("~") options['parent'] = root options['title'] = 'Select files to annotate.' self.file_selector_button = ttk.Button(self.root, text=u"select file(s)", command=self.filenames) self.label = ttk.Label(self.root, text=u"selected file(s):") self.fa_search = tkinter.PhotoImage(file=os.path.join(self.main_window.resource_dir, "images", "fa_search_24_24.gif")) self.file_selector_button.config(image=self.fa_search, compound=tkinter.LEFT) self.scrollbar = ttk.Scrollbar(self.root) self.selected_files = tkinter.Listbox(self.root, yscrollcommand=self.scrollbar.set) self.scrollbar.config(command=self.selected_files.yview)
Example #8
Source File: views.py From Python-GUI-Programming-with-Tkinter with MIT License | 6 votes |
def __init__(self, parent, callbacks, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.callbacks = callbacks self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) # create treeview self.treeview = ttk.Treeview( self, columns=list(self.column_defs.keys())[1:], selectmode='browse' ) # configure scrollbar for the treeview self.scrollbar = ttk.Scrollbar( self, orient=tk.VERTICAL, command=self.treeview.yview ) self.treeview.configure(yscrollcommand=self.scrollbar.set) self.treeview.grid(row=0, column=0, sticky='NSEW') self.scrollbar.grid(row=0, column=1, sticky='NSW') # Configure treeview columns for name, definition in self.column_defs.items(): label = definition.get('label', '') anchor = definition.get('anchor', self.default_anchor) minwidth = definition.get('minwidth', self.default_minwidth) width = definition.get('width', self.default_width) stretch = definition.get('stretch', False) self.treeview.heading(name, text=label, anchor=anchor) self.treeview.column(name, anchor=anchor, minwidth=minwidth, width=width, stretch=stretch) self.treeview.bind('<<TreeviewOpen>>', self.on_open_record)
Example #9
Source File: view.py From ms_deisotope with Apache License 2.0 | 6 votes |
def configure_treeview(self): self.treeview = ttk.Treeview(self) self.treeview['columns'] = ["id", "time", 'ms_level', 'precursor_mz', 'precursor_charge', 'activation'] self.treeview.grid(row=2, column=0, sticky=tk.S + tk.W + tk.E + tk.N) self.treeview_scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.treeview.yview) self.treeview_scrollbar.grid(row=2, column=0, sticky=tk.S + tk.E + tk.N) self.treeview.configure(yscrollcommand=self.treeview_scrollbar.set) self.treeview.heading('id', text="Scan ID") self.treeview.heading('#0', text='Index') self.treeview.heading("time", text='Time (min)') self.treeview.heading("ms_level", text='MS Level') self.treeview.heading("precursor_mz", text='Precursor M/Z') self.treeview.heading("precursor_charge", text='Precursor Z') self.treeview.heading("activation", text='Activation') self.treeview.column("#0", width=75) self.treeview.column("ms_level", width=75) self.treeview.column("time", width=75) self.treeview.column("precursor_mz", width=100) self.treeview.column("precursor_charge", width=100) self.treeview.bind("<<TreeviewSelect>>", self.on_row_click)
Example #10
Source File: timeline.py From ttkwidgets with GNU General Public License v3.0 | 6 votes |
def configure(self, cnf={}, **kwargs): """Update options of the TimeLine widget""" kwargs.update(cnf) TimeLine.check_kwargs(kwargs) scrollbars = 'autohidescrollbars' in kwargs for option in self.options: attribute = "_" + option setattr(self, attribute, kwargs.pop(option, getattr(self, attribute))) if scrollbars: self._scrollbar_timeline.destroy() self._scrollbar_vertical.destroy() if self._autohidescrollbars: self._scrollbar_timeline = AutoHideScrollbar(self, command=self._set_scroll, orient=tk.HORIZONTAL) self._scrollbar_vertical = AutoHideScrollbar(self, command=self._set_scroll_v, orient=tk.VERTICAL) else: self._scrollbar_timeline = ttk.Scrollbar(self, command=self._set_scroll, orient=tk.HORIZONTAL) self._scrollbar_vertical = ttk.Scrollbar(self, command=self._set_scroll_v, orient=tk.VERTICAL) self._canvas_scroll.config(xscrollcommand=self._scrollbar_timeline.set, yscrollcommand=self._scrollbar_vertical.set) self._canvas_categories.config(yscrollcommand=self._scrollbar_vertical.set) self._scrollbar_timeline.grid(column=1, row=2, padx=(0, 5), pady=(0, 5), sticky="we") self._scrollbar_vertical.grid(column=2, row=0, pady=5, padx=(0, 5), sticky="ns") ttk.Frame.configure(self, **kwargs) self.draw_timeline()
Example #11
Source File: autohidescrollbar.py From ttkwidgets with GNU General Public License v3.0 | 6 votes |
def set(self, lo, hi): """ Set the fractional values of the slider position. :param lo: lower end of the scrollbar (between 0 and 1) :type lo: float :param hi: upper end of the scrollbar (between 0 and 1) :type hi: float """ if float(lo) <= 0.0 and float(hi) >= 1.0: if self._layout == 'place': self.place_forget() elif self._layout == 'pack': self.pack_forget() else: self.grid_remove() else: if self._layout == 'place': self.place(**self._place_kw) elif self._layout == 'pack': self.pack(**self._pack_kw) else: self.grid() ttk.Scrollbar.set(self, lo, hi)
Example #12
Source File: text_frame_gui.py From pyDEA with MIT License | 6 votes |
def create_widgets(self): ''' Creates all widgets. ''' self.grid_rowconfigure(0, weight=1) self.grid_columnconfigure(0, weight=1) xscrollbar = Scrollbar(self, orient=HORIZONTAL) xscrollbar.grid(row=1, column=0, sticky=E+W) yscrollbar = Scrollbar(self) yscrollbar.grid(row=0, column=1, sticky=N+S) self.text = Text(self, wrap=NONE, xscrollcommand=xscrollbar.set, yscrollcommand=yscrollbar.set) self.text.bind("<Control-Key-a>", self.select_all) self.text.bind("<Control-Key-A>", self.select_all) self.text.grid(row=0, column=0, sticky=N+S+E+W) xscrollbar.config(command=self.text.xview) yscrollbar.config(command=self.text.yview)
Example #13
Source File: pykms_GuiMisc.py From py-kms with The Unlicense | 6 votes |
def __init__(self, master, radios, font, changed, **kwargs): tk.Frame.__init__(self, master) self.master = master self.radios = radios self.font = font self.changed = changed self.scrollv = tk.Scrollbar(self, orient = "vertical") self.textbox = tk.Text(self, yscrollcommand = self.scrollv.set, **kwargs) self.scrollv.config(command = self.textbox.yview) # layout. self.scrollv.pack(side = "right", fill = "y") self.textbox.pack(side = "left", fill = "both", expand = True) # create radiobuttons. self.radiovar = tk.StringVar() self.radiovar.set('FILE') self.create()
Example #14
Source File: log_window.py From clai with MIT License | 6 votes |
def __init__(self, root, presenter): self.root = root self.presenter = presenter self.autoscroll_enable = tk.IntVar() window = tk.Toplevel(self.root) window.geometry("900x600") self.add_toolbar(window) self.text_gui = tk.Text(window, height=6, width=40) self.text_gui.configure(state=tk.DISABLED) vsb = ttk.Scrollbar(window, orient="vertical", command=self.text_gui.yview) self.text_gui.configure(yscrollcommand=vsb.set) vsb.pack(side="right", fill="y") self.text_gui.pack(side="left", fill="both", expand=True) presenter.attach_log(self.add_log_data)
Example #15
Source File: box.py From synthesizer with GNU Lesser General Public License v3.0 | 6 votes |
def __init__(self, app, master): super().__init__(master, text="Playlist", padding=4) self.app = app bf = ttk.Frame(self) ttk.Button(bf, text="Move to Top", width=11, command=self.do_to_top).pack() ttk.Button(bf, text="Move Up", width=11, command=self.do_move_up).pack() ttk.Button(bf, text="Move Down", width=11, command=self.do_move_down).pack() ttk.Button(bf, text="Remove", width=11, command=self.do_remove).pack() bf.pack(side=tk.LEFT, padx=4) sf = ttk.Frame(self) cols = [("title", 300), ("artist", 180), ("album", 180), ("length", 80)] self.listTree = ttk.Treeview(sf, columns=[col for col, _ in cols], height=10, show="headings") vsb = ttk.Scrollbar(orient="vertical", command=self.listTree.yview) self.listTree.configure(yscrollcommand=vsb.set) self.listTree.grid(column=1, row=0, sticky=tk.NSEW, in_=sf) vsb.grid(column=0, row=0, sticky=tk.NS, in_=sf) for col, colwidth in cols: self.listTree.heading(col, text=col.title()) self.listTree.column(col, width=colwidth) sf.grid_columnconfigure(0, weight=1) sf.grid_rowconfigure(0, weight=1) sf.pack(side=tk.LEFT, padx=4)
Example #16
Source File: ui_utils.py From thonny with MIT License | 6 votes |
def __init__(self, master): ttk.Frame.__init__(self, master) # set up scrolling with canvas vscrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL) self.canvas = tk.Canvas(self, bd=0, highlightthickness=0, yscrollcommand=vscrollbar.set) vscrollbar.config(command=self.canvas.yview) self.canvas.xview_moveto(0) self.canvas.yview_moveto(0) self.canvas.grid(row=0, column=0, sticky=tk.NSEW) vscrollbar.grid(row=0, column=1, sticky=tk.NSEW) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) self.interior = ttk.Frame(self.canvas) self.interior_id = self.canvas.create_window(0, 0, window=self.interior, anchor=tk.NW) self.bind("<Configure>", self._configure_interior, "+") self.bind("<Expose>", self._expose, "+")
Example #17
Source File: chapter8_03.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 6 votes |
def __init__(self, path): super().__init__() self.title("Ttk Treeview") columns = ("#1", "#2", "#3") self.tree = ttk.Treeview(self, show="headings", columns=columns) self.tree.heading("#1", text="Last name") self.tree.heading("#2", text="First name") self.tree.heading("#3", text="Email") ysb = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.tree.yview) self.tree.configure(yscroll=ysb.set) with open("contacts.csv", newline="") as f: for contact in csv.reader(f): self.tree.insert("", tk.END, values=contact) self.tree.bind("<<TreeviewSelect>>", self.print_selection) self.tree.grid(row=0, column=0) ysb.grid(row=0, column=1, sticky=tk.N + tk.S) self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1)
Example #18
Source File: chapter8_04.py From Tkinter-GUI-Application-Development-Cookbook with MIT License | 6 votes |
def __init__(self, path): super().__init__() self.title("Ttk Treeview") abspath = os.path.abspath(path) self.nodes = {} self.tree = ttk.Treeview(self) self.tree.heading("#0", text=abspath, anchor=tk.W) ysb = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.tree.yview) xsb = ttk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.tree.xview) self.tree.configure(yscroll=ysb.set, xscroll=xsb.set) self.tree.grid(row=0, column=0, sticky=tk.N + tk.S + tk.E + tk.W) ysb.grid(row=0, column=1, sticky=tk.N + tk.S) xsb.grid(row=1, column=0, sticky=tk.E + tk.W) self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) self.tree.bind("<<TreeviewOpen>>", self.open_node) self.populate_node("", abspath)
Example #19
Source File: source.py From brownie with MIT License | 5 votes |
def __init__(self, root, text, suffix): super().__init__(root) self._text = tk.Text(self, width=90, yscrollcommand=self._text_scroll) self._scroll = ttk.Scrollbar(self) self._scroll.pack(side="left", fill="y") self._scroll.config(command=self._scrollbar_scroll) self._line_no = tk.Text(self, width=4, yscrollcommand=self._text_scroll) self._line_no.pack(side="left", fill="y") self._text.pack(side="right", fill="y") self._text.insert(1.0, text) for k, v in TEXT_COLORS.items(): self._text.tag_config(k, **v) if suffix == ".sol": pattern = r"((?:\s*\/\/[^\n]*)|(?:\/\*[\s\S]*?\*\/))" else: pattern = r"((#[^\n]*\n)|(\"\"\"[\s\S]*?\"\"\")|('''[\s\S]*?'''))" for match in re.finditer(pattern, text): self.tag_add("comment", match.start(), match.end()) self._line_no.insert(1.0, "\n".join(str(i) for i in range(1, text.count("\n") + 2))) self._line_no.tag_configure("justify", justify="right") self._line_no.tag_add("justify", 1.0, "end") for text in (self._line_no, self._text): text.config(**TEXT_STYLE) text.config(tabs=tkFont.Font(font=text["font"]).measure(" "), wrap="none") self._line_no.config(background="#272727") self._text.bind("<ButtonRelease-1>", root._search)
Example #20
Source File: pyjsonviewer.py From PyJSONViewer with MIT License | 5 votes |
def create_widgets(self): self.tree.bind('<Double-1>', self.click_item) ysb = ttk.Scrollbar( self, orient=tk.VERTICAL, command=self.tree.yview) self.tree.configure(yscroll=ysb.set) self.tree.grid(row=0, column=0, sticky=(tk.N, tk.S, tk.E, tk.W)) ysb.grid(row=0, column=1, sticky=(tk.N, tk.S)) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1)
Example #21
Source File: check_log_gui.py From nekros with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, master): try: vsb = ttk.Scrollbar(master, orient='vertical', command=self.yview) except: pass hsb = ttk.Scrollbar(master, orient='horizontal', command=self.xview) try: self.configure(yscrollcommand=self._autoscroll(vsb)) except: pass self.configure(xscrollcommand=self._autoscroll(hsb)) self.grid(column=0, row=0, sticky='nsew') try: vsb.grid(column=1, row=0, sticky='ns') except: pass hsb.grid(column=0, row=1, sticky='ew') master.grid_columnconfigure(0, weight=1) master.grid_rowconfigure(0, weight=1) if py3: methods = tk.Pack.__dict__.keys() | tk.Grid.__dict__.keys() \ | tk.Place.__dict__.keys() else: methods = tk.Pack.__dict__.keys() + tk.Grid.__dict__.keys() \ + tk.Place.__dict__.keys() for meth in methods: if meth[0] != '_' and meth not in ('config', 'configure'): setattr(self, meth, getattr(master, meth))
Example #22
Source File: GUI.py From nekros with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, master): # Rozen. Added the try-except clauses so that this class # could be used for scrolled entry widget for which vertical # scrolling is not supported. 5/7/14. try: vsb = ttk.Scrollbar(master, orient='vertical', command=self.yview) except: pass hsb = ttk.Scrollbar(master, orient='horizontal', command=self.xview) #self.configure(yscrollcommand=_autoscroll(vsb), # xscrollcommand=_autoscroll(hsb)) try: self.configure(yscrollcommand=self._autoscroll(vsb)) except: pass self.configure(xscrollcommand=self._autoscroll(hsb)) self.grid(column=0, row=0, sticky='nsew') try: vsb.grid(column=1, row=0, sticky='ns') except: pass hsb.grid(column=0, row=1, sticky='ew') master.grid_columnconfigure(0, weight=1) master.grid_rowconfigure(0, weight=1) # Copy geometry methods of master (taken from ScrolledText.py) if py3: methods = tk.Pack.__dict__.keys() | tk.Grid.__dict__.keys() \ | tk.Place.__dict__.keys() else: methods = tk.Pack.__dict__.keys() + tk.Grid.__dict__.keys() \ + tk.Place.__dict__.keys() for meth in methods: if meth[0] != '_' and meth not in ('config', 'configure'): setattr(self, meth, getattr(master, meth))
Example #23
Source File: scrolledlistbox.py From ttkwidgets with GNU General Public License v3.0 | 5 votes |
def __init__(self, master=None, compound=tk.RIGHT, autohidescrollbar=True, **kwargs): """ Create a Listbox with a vertical scrollbar. :param master: master widget :type master: widget :param compound: side for the Scrollbar to be on (:obj:`tk.LEFT` or :obj:`tk.RIGHT`) :type compound: str :param autohidescrollbar: whether to use an :class:`~ttkwidgets.AutoHideScrollbar` or a :class:`ttk.Scrollbar` :type autohidescrollbar: bool :param kwargs: keyword arguments passed on to the :class:`tk.Listbox` initializer """ ttk.Frame.__init__(self, master) self.columnconfigure(1, weight=1) self.rowconfigure(0, weight=1) self.listbox = tk.Listbox(self, **kwargs) if autohidescrollbar: self.scrollbar = AutoHideScrollbar(self, orient=tk.VERTICAL, command=self.listbox.yview) else: self.scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.listbox.yview) self.config_listbox(yscrollcommand=self.scrollbar.set) if compound is not tk.LEFT and compound is not tk.RIGHT: raise ValueError("Invalid compound value passed: {0}".format(compound)) self.__compound = compound self._grid_widgets()
Example #24
Source File: scrolledframe.py From ttkwidgets with GNU General Public License v3.0 | 5 votes |
def __init__(self, master=None, compound=tk.RIGHT, canvasheight=400, canvaswidth=400, canvasborder=0, autohidescrollbar=True, **kwargs): """ Create a ScrolledFrame. :param master: master widget :type master: widget :param compound: "right" or "left": side the scrollbar should be on :type compound: str :param canvasheight: height of the internal canvas :type canvasheight: int :param canvaswidth: width of the internal canvas :type canvaswidth: int :param canvasborder: border width of the internal canvas :type canvasborder: int :param autohidescrollbar: whether to use an :class:`~ttkwidgets.AutoHideScrollbar` or a :class:`ttk.Scrollbar` :type autohidescrollbar: bool :param kwargs: keyword arguments passed on to the :class:`ttk.Frame` initializer """ ttk.Frame.__init__(self, master, **kwargs) self.rowconfigure(0, weight=1) self.columnconfigure(1, weight=1) if autohidescrollbar: self._scrollbar = AutoHideScrollbar(self, orient=tk.VERTICAL) else: self._scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL) self._canvas = tk.Canvas(self, borderwidth=canvasborder, highlightthickness=0, yscrollcommand=self._scrollbar.set, width=canvaswidth, height=canvasheight) self.__compound = compound self._scrollbar.config(command=self._canvas.yview) self._canvas.yview_moveto(0) self.interior = ttk.Frame(self._canvas) self._interior_id = self._canvas.create_window(0, 0, window=self.interior, anchor=tk.NW) self.interior.bind("<Configure>", self.__configure_interior) self._canvas.bind("<Configure>", self.__configure_canvas) self.__grid_widgets()
Example #25
Source File: autocomplete_entrylistbox.py From ttkwidgets with GNU General Public License v3.0 | 5 votes |
def configure(self, cnf={}, **kw): kwargs = {} kwargs.update(cnf) kwargs.update(kw) # completion settings self._allow_other_values = kwargs.pop('allow_other_values', self._allow_other_values) if 'completevalues' in kwargs: completevalues = kwargs.pop('completevalues') self._completevalues = completevalues self.listbox.delete(0, 'end') for c in self._completevalues: self.listbox.insert('end', c) # autohidescrollbar autohidescrollbar = isinstance(self._scrollbar, AutoHideScrollbar) autohidescrollbar2 = kwargs.pop('autohidescrollbar', autohidescrollbar) if autohidescrollbar != autohidescrollbar2: self._scrollbar.destroy() if autohidescrollbar2: self._scrollbar = AutoHideScrollbar(self, orient=tk.VERTICAL, command=self.listbox.yview) else: self._scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, command=self.listbox.yview) self.listbox.configure(yscrollcommand=self._scrollbar.set) self._scrollbar.grid(row=1, column=1, sticky='ns') # entry/listbox settings entry_listbox_kw = {} for key in ['font', 'exportselection', 'width']: if key in kwargs: entry_listbox_kw[key] = kwargs.pop(key) self.entry.configure(entry_listbox_kw) self.listbox.configure(entry_listbox_kw) if 'justify' in kwargs: justify = kwargs.pop('justify') self.entry.configure(justify=justify) try: self.listbox.configure(justify=justify) # this is an option only for tk >= 8.6.5 except tk.TclError: pass # frame settings ttk.Frame.config(self, kwargs)
Example #26
Source File: autohidescrollbar.py From ttkwidgets with GNU General Public License v3.0 | 5 votes |
def place(self, **kw): """ Place a widget in the parent widget. :param in\_: master relative to which the widget is placed :type in\_: widget :param x: locate anchor of this widget at position x of master :type x: int :param y: locate anchor of this widget at positiony of master :type y: int :param relx: locate anchor of this widget between 0 and 1 relative to width of master (1 is right edge) :type relx: float :param rely: locate anchor of this widget between 0 and 1 relative to height of master (1 is bottom edge) :type rely: float :param anchor: position anchor according to given direction ("n", "s", "e", "w" or combinations) :type anchor: str :param width: width of this widget in pixel :type width: int :param height: height of this widget in pixel :type height: int :param relwidth: width of this widget between 0.0 and 1.0 relative to width of master (1.0 is the same width as the master) :type relwidth: float :param relheight: height of this widget between 0.0 and 1.0 relative to height of master (1.0 is the same height as the master) :type relheight: float :param bordermode: "inside" or "outside": whether to take border width of master widget into account :type bordermode: str """ ttk.Scrollbar.place(self, **kw) try: self._place_kw = self.place_info() except TypeError: # bug in some tkinter versions self._place_kw = self._get_info("place") self._layout = 'place'
Example #27
Source File: autohidescrollbar.py From ttkwidgets with GNU General Public License v3.0 | 5 votes |
def pack(self, **kw): """ Pack a widget in the parent widget. :param after: pack it after you have packed widget :type after: widget :param anchor: position anchor according to given direction ("n", "s", "e", "w" or combinations) :type anchor: str :param before: pack it before you will pack widget :type before: widget :param expand: expand widget if parent size grows :type expand: bool :param fill: "none" or "x" or "y" or "both": fill widget if widget grows :type fill: str :param in\_: widget to use as container :type in\_: widget :param ipadx: add internal padding in x direction :type ipadx: int :param ipady: add internal padding in y direction :type ipady: int :param padx: add padding in x direction :type padx: int :param pady: add padding in y irection :type pady: int :param side: "top" (default), "bottom", "left" or "right": where to add this widget :type side: str """ ttk.Scrollbar.pack(self, **kw) try: self._pack_kw = self.pack_info() except TypeError: # bug in some tkinter versions self._pack_kw = self._get_info("pack") self._layout = 'pack'
Example #28
Source File: autohidescrollbar.py From ttkwidgets with GNU General Public License v3.0 | 5 votes |
def grid(self, **kw): """ Position a widget in the parent widget in a grid. :param column: use cell identified with given column (starting with 0) :type column: int :param columnspan: this widget will span several columns :type columnspan: int :param in\_: widget to use as container :type in\_: widget :param ipadx: add internal padding in x direction :type ipadx: int :param ipady: add internal padding in y direction :type ipady: int :param padx: add padding in x direction :type padx: int :param pady: add padding in y irection :type pady: int :param row: use cell identified with given row (starting with 0) :type row: int :param rowspan: this widget will span several rows :type rowspan: int :param sticky: "n", "s", "e", "w" or combinations: if cell is larger on which sides will this widget stick to the cell boundary :type sticky: str """ ttk.Scrollbar.grid(self, **kw) self._layout = 'grid'
Example #29
Source File: text_for_weights_gui.py From pyDEA with MIT License | 5 votes |
def create_widgets(self, weight_name): ''' Creates all widgets. ''' constraints_lbl = Label( self, text='Enter {0} weight restrictions:'.format( weight_name)) constraints_lbl.grid(padx=10, pady=2, sticky=N+W) examples_lbl = Label(self, text='e.g. {0}'.format(self.examples)) examples_lbl.grid(row=1, column=0, padx=10, pady=5, sticky=N+W) errors_lbl = Label(self, textvariable=self.errors_strvar, foreground='red', anchor=W, justify=LEFT, wraplength=80) errors_lbl.grid(row=2, column=2, sticky=N+W, padx=5, pady=5) self.grid_rowconfigure(2, weight=1) self.grid_columnconfigure(0, weight=1) xscrollbar = Scrollbar(self, orient=HORIZONTAL) xscrollbar.grid(row=3, column=0, sticky=E+W) yscrollbar = Scrollbar(self) yscrollbar.grid(row=2, column=1, sticky=N+S) self.text = Text(self, wrap=NONE, width=TEXT_WIDTH_VAL, height=TEXT_HEIGHT_VAL, xscrollcommand=xscrollbar.set, yscrollcommand=yscrollbar.set) self.text.grid(row=2, column=0, sticky=N+S+E+W) xscrollbar.config(command=self.text.xview) yscrollbar.config(command=self.text.yview)
Example #30
Source File: scrollable_frame_gui.py From pyDEA with MIT License | 5 votes |
def __init__(self, parent, *args, **kw): Frame.__init__(self, parent, *args, **kw) # create a canvas object and a vertical scrollbar for scrolling it vscrollbar = Scrollbar(self, orient=VERTICAL) vscrollbar.pack(fill=Y, side=RIGHT, expand=False) self.canvas = canvas = StyledCanvas( self, bd=0, highlightthickness=0, yscrollcommand=vscrollbar.set) canvas.pack(side=LEFT, fill=BOTH, expand=True) vscrollbar.config(command=canvas.yview) # reset the view canvas.xview_moveto(0) canvas.yview_moveto(0) # create a frame inside the canvas which will be scrolled with it self.interior = interior = Frame(canvas) interior_id = canvas.create_window(0, 0, window=interior, anchor=N+W) # track changes to the canvas and frame width and sync them, # also updating the scrollbar def _configure_interior(event): # update the scrollbars to match the size of the inner frame size = (interior.winfo_reqwidth(), interior.winfo_reqheight()) canvas.config(scrollregion="0 0 %s %s" % size) if interior.winfo_reqwidth() != canvas.winfo_width(): # update the canvas's width to fit the inner frame canvas.config(width=interior.winfo_reqwidth()) interior.bind('<Configure>', _configure_interior) def _configure_canvas(event): if interior.winfo_reqwidth() != canvas.winfo_width(): # update the inner frame's width to fill the canvas canvas.itemconfigure(interior_id, width=canvas.winfo_width()) canvas.bind('<Configure>', _configure_canvas) MouseWheel(self).add_scrolling(canvas, yscrollbar=vscrollbar)