本文整理汇总了Python中ttk.Scrollbar方法的典型用法代码示例。如果您正苦于以下问题:Python ttk.Scrollbar方法的具体用法?Python ttk.Scrollbar怎么用?Python ttk.Scrollbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ttk
的用法示例。
在下文中一共展示了ttk.Scrollbar方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_treeview
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
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)
示例2: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
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)
示例3: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
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()
示例4: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
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)
示例5: _set_up_tree_widget
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
def _set_up_tree_widget(self):
tree_container = ttk.Frame(self.container)
tree_container.grid(row=0, column=0, sticky=tk.W+tk.E+tk.N+tk.S)
#tree_container.pack(fill='both', expand=True)
# create a treeview with dual scrollbars
self.tree = ttk.Treeview(tree_container, columns=self.headers, show="headings")
vsb = ttk.Scrollbar(tree_container, orient="vertical", command=self.tree.yview)
hsb = ttk.Scrollbar(tree_container, orient="horizontal", command=self.tree.xview)
self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)
self.tree.grid(column=0, row=0, sticky='nsew')
vsb.grid(column=1, row=0, sticky='ns')
hsb.grid(column=0, row=1, sticky='ew')
tree_container.grid_columnconfigure(0, weight=1)
tree_container.grid_rowconfigure(0, weight=1)
self.tree.bind("<Double-1>", self.double_click)
示例6: create
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
def create(self, **kwargs):
return ttk.Scrollbar(self.root, **kwargs)
示例7: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
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))
示例8: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
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))
示例9: __init__
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
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 = Pack.__dict__.keys() | Grid.__dict__.keys() \
| Place.__dict__.keys()
else:
methods = Pack.__dict__.keys() + Grid.__dict__.keys() \
+ Place.__dict__.keys()
for meth in methods:
if meth[0] != '_' and meth not in ('config', 'configure'):
setattr(self, meth, getattr(master, meth))
示例10: set
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
def set(self, lo_val, hi_val): #pylint: disable=W0221
if float(lo_val) <= 0.0 and float(hi_val) >= 1.0:
self.grid_remove()
else:
self.grid()
ttk.Scrollbar.set(self, lo_val, hi_val)
示例11: new_query_tab
# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Scrollbar [as 别名]
def new_query_tab(self, title, query):
"""add a Tab 'title' to the notebook, containing the Script 'query'"""
fw_welcome = ttk.Panedwindow(self.tk_win, orient=VERTICAL) # tk_win
fw_welcome.pack(fill='both', expand=True)
self.notebook.add(fw_welcome, text=(title))
# new "editable" script
f1 = ttk.Labelframe(fw_welcome, text='Script', width=200, height=100)
fw_welcome.add(f1)
fw_label = Text(f1, bd=1, undo=True)
scroll = ttk.Scrollbar(f1, command=fw_label.yview)
fw_label.configure(yscrollcommand=scroll.set)
fw_label.insert(END, (query))
fw_label.pack(side=LEFT, expand=YES, fill=BOTH, padx=2, pady=2)
scroll.pack(side=RIGHT, expand=NO, fill=BOTH, padx=2, pady=2)
# keep tab reference by tk id
working_tab_id = "." + fw_welcome._name
# keep tab reference to script (by tk id)
self.fw_labels[working_tab_id] = fw_label
# new "Results" Container
fr = ttk.Labelframe(fw_welcome, text='Results', width=200, height=100)
fw_welcome.add(fr)
# containing a notebook
fw_result_nb = Notebook(fr, style="ButtonNotebook")
fw_result_nb.pack(fill='both', expand=True)
# resize rules
fw_welcome.columnconfigure(0, weight=1)
# keep reference to result_nb objects (by tk id)
self.fw_result_nbs[working_tab_id] = fw_result_nb
# activate this tab print(self.notebook.tabs())
self.notebook.select(working_tab_id)
# workaround to have a visible result pane on initial launch
self.add_treeview(
working_tab_id, "_", "", "click on ('->') to run Script")
return working_tab_id # gives back tk_id reference of the new tab