本文整理汇总了Python中ttk.Scrollbar类的典型用法代码示例。如果您正苦于以下问题:Python Scrollbar类的具体用法?Python Scrollbar怎么用?Python Scrollbar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Scrollbar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _scrolled_text_display
def _scrolled_text_display(title='Diagnil Text Display',
intro=None, button_proc=null_proc,
tab_stops=(), return_frame=0):
fr = Toplevel()
fr.geometry(newGeometry='-0+50')
if intro: Label(fr, text=intro).pack(padx=10, pady=10)
txt_fr = Frame(fr)
if on_win:
txt = Text(txt_fr, width=70, padx=10, pady=5, wrap=WORD,
tabs=tab_stops)
else:
txt = Text(txt_fr, width=70, padx=10, pady=5, wrap=WORD,
background=text_bg_color, tabs=tab_stops)
scroll = Scrollbar(txt_fr, command=txt.yview)
txt.configure(yscrollcommand=scroll.set)
wrapped_bind(fr, '<Key-Prior>', lambda event: txt.yview_scroll(-1, PAGES))
wrapped_bind(fr, '<Key-Next>', lambda event: txt.yview_scroll(1, PAGES))
wrapped_bind(fr, '<Enter>', lambda event: fr.focus_set())
txt.pack(side=LEFT, fill=BOTH, expand=YES)
scroll.pack(side=LEFT, fill=Y)
txt_fr.pack(padx=5, pady=5, fill=BOTH, expand=YES)
button_proc(fr)
fr.title(string=title)
if return_frame: return fr, txt
else: return txt
示例2: __init__
def __init__(self, master, **kwargs):
Frame.__init__(self, master)
textarea_frame = Frame(self, bd=1, relief=SOLID,**kwargs)
textarea_frame.pack(fill=X)
textarea_frame.pack_propagate(False)
self.textarea = Text(textarea_frame, height=1, pady=self.TAG_ENTRY_PADY, padx=self.TAG_ENTRY_PADX, highlightthickness =0, spacing1=0, spacing2=0, spacing3=0, borderwidth=0, wrap="none")
self.textarea.pack(expand=True, fill=BOTH, padx=2)
scrollbar = Scrollbar(self, orient=HORIZONTAL, command=self.textarea.xview)
scrollbar.pack(fill=X)
self.textarea.configure(xscrollcommand=scrollbar.set)
self.textarea.bind("<KeyPress>",self._on_keypress)
tag = Tag(self.textarea, "")
self.textarea.window_create("1.0", window=tag)
self.update_idletasks()
tag_reqheight = tag.winfo_reqheight()
textarea_frame.configure(height=tag_reqheight + 2*self.TAG_ENTRY_PADY+2*self.textarea["borderwidth"])
# I add a hidden frame because I want the cursor centered including when there is no tag
self.textarea.window_create("1.0", window=Frame(self.textarea, height=tag_reqheight, width=0, borderwidth=0))
tag.destroy()
示例3: __init__
def __init__(self, parent, **kwargs):
"""!
A constructor for the class
@param self The pointer for the object
@param parent The parent object for the frame
@param **kwargs Other arguments as accepted by ttk.Scrollbar
"""
#Initialise the inherited class
Scrollbar.__init__(self, parent, **kwargs)
示例4: __init__
def __init__(self, master, width=None, height=None, mousewheel_speed = 2, scroll_horizontally=True, xscrollbar=None, scroll_vertically=True, yscrollbar=None, outer_background=None, inner_frame=Frame, **kw):
super(Scrolling_Area, self).__init__(master, **kw)
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self._clipper = Frame(self, background=outer_background, width=width, height=height)
self._clipper.grid(row=0, column=0, sticky=N+E+W+S)
self._width = width
self._height = height
self.innerframe = inner_frame(self._clipper, padx=0, pady=0, highlightthickness=0)
self.innerframe.place(in_=self._clipper, x=0, y=0)
if scroll_vertically:
if yscrollbar is not None:
self.yscrollbar = yscrollbar
else:
self.yscrollbar = Scrollbar(self, orient=VERTICAL)
self.yscrollbar.grid(row=0, column=1,sticky=N+S)
self.yscrollbar.set(0.0, 1.0)
self.yscrollbar.config(command=self.yview)
else:
self.yscrollbar = None
self._scroll_vertically = scroll_vertically
if scroll_horizontally:
if xscrollbar is not None:
self.xscrollbar = xscrollbar
else:
self.xscrollbar = Scrollbar(self, orient=HORIZONTAL)
self.xscrollbar.grid(row=1, column=0, sticky=E+W)
self.xscrollbar.set(0.0, 1.0)
self.xscrollbar.config(command=self.xview)
else:
self.xscrollbar = None
self._scroll_horizontally = scroll_horizontally
self._jfraction=0.05
self._startX = 0
self._startY = 0
# Whenever the clipping window or scrolled frame change size,
# update the scrollbars.
self.innerframe.bind('<Configure>', self._on_configure)
self._clipper.bind('<Configure>', self._on_configure)
self.innerframe.xview = self.xview
self.innerframe.yview = self.yview
Mousewheel_Support(self).add_support_to(self.innerframe, xscrollbar=self.xscrollbar, yscrollbar=self.yscrollbar)
示例5: __init__
def __init__(self, master):
Frame.__init__(self, master)
scrollbar = Scrollbar(self, orient=VERTICAL)
scrollbar.pack(side=RIGHT, fill=Y)
self.canvas = Canvas(self, bd=0, highlightthickness=0, yscrollcommand=scrollbar.set)
self.canvas.pack(side=LEFT, fill=BOTH, expand=1)
scrollbar.config(command=self.canvas.yview)
self.mainframe = Frame(self.canvas)
self.mainframe_id = self.canvas.create_window((0, 0), window=self.mainframe, anchor=NW)
self.mainframe.bind('<Configure>', self.config_mainframe)
self.canvas.bind('<Configure>', self.config_canvas)
示例6: __init__
def __init__(self, master, xml=None, heading_text=None, heading_anchor=None, padding=None, cursor=None, takefocus=None, style=None):
Frame.__init__(self, master, class_="XML_Viwer")
self._vsb = Scrollbar(self, orient=VERTICAL)
self._hsb = Scrollbar(self, orient=HORIZONTAL)
kwargs = {}
kwargs["yscrollcommand"] = lambda f, l: autoscroll(self._vsb, f, l)
kwargs["xscrollcommand"] = lambda f, l: autoscroll(self._hsb, f, l)
if style is not None:
kwargs["style"] = style
if padding is not None:
kwargs["padding"] = padding
if cursor is not None:
kwargs["cursor"] = cursor
if takefocus is not None:
kwargs["takefocus"] = takefocus
self._treeview = Treeview(self, **kwargs)
if heading_text is not None:
if heading_anchor is not None:
self._treeview.heading("#0", text=heading_text, anchor=heading_anchor)
else:
self._treeview.heading("#0", text=heading_text)
self._treeview.bind("<<TreeviewOpen>>", self._on_open)
self._treeview.bind("<<TreeviewClose>>", self._on_close)
# Without this line, horizontal scrolling doesn't work properly.
self._treeview.column("#0", stretch= False)
self._vsb['command'] = self._treeview.yview
self._hsb['command'] = self._treeview.xview
self._treeview.grid(column=0, row=0, sticky=N+S+W+E)
self._vsb.grid(column=1, row=0, sticky=N+S)
self._hsb.grid(column=0, row=1, sticky=E+W)
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self._element_tree = None
self._item_ID_to_element = {}
if xml is not None:
self.parse_xml(xml)
示例7: init_ui
def init_ui(self):
self.rowconfigure(3, weight=1)
self.columnconfigure(0, weight=1)
self.button_load_type = Button(self, text="Load Type JSON", command=lambda: browse_file(self, 1, ))
self.button_load_type.grid(
row=0, columnspan=2, sticky=W + E, pady=4, padx=5)
self.button_load_color = Button(
self, text="Load Color JSON", command=lambda: browse_file(self, 2))
self.button_load_color.grid(
row=1, columnspan=2, sticky=W + E, pady=4, padx=5)
button_load = Button(
self, text="Load Images", command=lambda: browse_images(self))
button_load.grid(row=2, columnspan=2, sticky=W + E, pady=4, padx=5)
button_learn = Button(
self,
text="Test",
command=
lambda: start_testing(self.dtype, self.dcolor, self.picture_frames)
)
button_learn.grid(row=4, columnspan=2, sticky=W + E, pady=4, padx=5)
canvas = Canvas(self)
canvas.grid(row=3, sticky=W + E + N + S, column=0, pady=4, padx=5)
frame = self.picture_frame = Frame(canvas)
canvas.create_window(0, 0, window=frame, anchor='nw')
scroll_bar = Scrollbar(self, orient="vertical", command=canvas.yview)
scroll_bar.grid(sticky=E + N + S, padx=5, row=3, column=1)
canvas.configure(yscrollcommand=scroll_bar.set)
# 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 = (frame.winfo_reqwidth(), frame.winfo_reqheight())
canvas.config(scrollregion="0 0 %s %s" % size)
if frame.winfo_reqwidth() != canvas.winfo_width():
# update the canvas's width to fit the inner frame
canvas.config(width=frame.winfo_reqwidth())
frame.bind('<Configure>', _configure_interior)
def _configure_canvas(event):
if frame.winfo_reqwidth() != canvas.winfo_width():
# update the inner frame's width to fill the canvas
canvas.itemconfigure(frame, width=canvas.winfo_width())
canvas.bind('<Configure>', _configure_canvas)
示例8: __init__
def __init__(self, master, width=None, anchor=N, height=None, mousewheel_speed = 2, scroll_horizontally=True, xscrollbar=None, scroll_vertically=True, yscrollbar=None, outer_background=None, inner_frame=Frame, **kw):
Frame.__init__(self, master, class_=self.__class__)
if outer_background:
self.configure(background=outer_background)
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self._width = width
self._height = height
self.canvas = Canvas(self, background=outer_background, highlightthickness=0, width=width, height=height)
self.canvas.grid(row=0, column=0, sticky=N+E+W+S)
if scroll_vertically:
if yscrollbar is not None:
self.yscrollbar = yscrollbar
else:
self.yscrollbar = Scrollbar(self, orient=VERTICAL)
self.yscrollbar.grid(row=0, column=1,sticky=N+S)
self.canvas.configure(yscrollcommand=self.yscrollbar.set)
self.yscrollbar['command']=self.canvas.yview
else:
self.yscrollbar = None
if scroll_horizontally:
if xscrollbar is not None:
self.xscrollbar = xscrollbar
else:
self.xscrollbar = Scrollbar(self, orient=HORIZONTAL)
self.xscrollbar.grid(row=1, column=0, sticky=E+W)
self.canvas.configure(xscrollcommand=self.xscrollbar.set)
self.xscrollbar['command']=self.canvas.xview
else:
self.xscrollbar = None
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)
self.innerframe = inner_frame(self.canvas, **kw)
self.innerframe.pack(anchor=anchor)
self.canvas.create_window(0, 0, window=self.innerframe, anchor='nw', tags="inner_frame")
self.canvas.bind('<Configure>', self._on_canvas_configure)
Mousewheel_Support(self).add_support_to(self.canvas, xscrollbar=self.xscrollbar, yscrollbar=self.yscrollbar)
示例9: __init__
class Panle:
def __init__(self, master):
self.frame = Frame(master)
self.frame.pack(side=TOP)
self.label = Tkinter.Label(self.frame, text='wordEcho')
self.label.pack()
self.input = Entry(self.frame, width=45)
self.input.pack(side=LEFT)
self.button = Button(self.frame, text='翻译')
self.button.pack(side=RIGHT)
self.frame2 = Scrollbar(master)
self.frame2.pack(side=TOP)
self.ms = Message(self.frame2, anchor='w', width=150)
self.ms.pack()
示例10: _setup_breakpoint_list
def _setup_breakpoint_list(self):
self.breakpoints_frame = Frame(self.content)
self.breakpoints_frame.grid(column=0, row=0, sticky=(N, S, E, W))
self.file_notebook.add(self.breakpoints_frame, text='Breakpoints')
self.breakpoints = BreakpointView(self.breakpoints_frame, normalizer=self.filename_normalizer)
self.breakpoints.grid(column=0, row=0, sticky=(N, S, E, W))
# The tree's vertical scrollbar
self.breakpoints_scrollbar = Scrollbar(self.breakpoints_frame, orient=VERTICAL)
self.breakpoints_scrollbar.grid(column=1, row=0, sticky=(N, S))
# Tie the scrollbar to the text views, and the text views
# to each other.
self.breakpoints.config(yscrollcommand=self.breakpoints_scrollbar.set)
self.breakpoints_scrollbar.config(command=self.breakpoints.yview)
# Setup weights for the "breakpoint list" tree
self.breakpoints_frame.columnconfigure(0, weight=1)
self.breakpoints_frame.columnconfigure(1, weight=0)
self.breakpoints_frame.rowconfigure(0, weight=1)
# Handlers for GUI events
self.breakpoints.tag_bind('breakpoint', '<Double-Button-1>', self.on_breakpoint_double_clicked)
self.breakpoints.tag_bind('breakpoint', '<<TreeviewSelect>>', self.on_breakpoint_selected)
self.breakpoints.tag_bind('file', '<<TreeviewSelect>>', self.on_breakpoint_file_selected)
示例11: consolePanel
def consolePanel(self):
tmpFrm = Frame(self.bgndFrm, borderwidth = 5, relief=RAISED)
tmpFrm.grid()
tmpFrm.grid(column = 0, row = 1)
self.scrollbar = Scrollbar(tmpFrm)
self.scrollbar.pack(side=RIGHT, fill=Y)
self.log = Text(tmpFrm, wrap=WORD, yscrollcommand=self.scrollbar.set)
self.log.pack()
self.scrollbar.config(command=self.log.yview)
示例12: __init__
def __init__(self,parent,caller,**args):
Frame.__init__(self,parent,**args)
self.pack(side=TOP)
self.canvas = Canvas(self,scrollregion=(0,0,1000,1000)
,background='white',cursor='pencil')
self.canvas.bind("<Button-1>",lambda event:caller.clickCell(event,1))
self.canvas.bind("<B1-Motion>",lambda event:caller.clickCell(event,1))
self.canvas.bind("<Control-Button-1>",lambda event:caller.clickCell(event,-1))
self.canvas.bind("<Control-B1-Motion>",lambda event:caller.clickCell(event,-1))
vScroll = Scrollbar(self, orient = VERTICAL)
vScroll.pack(side = RIGHT, fill=Y)
vScroll.config(command = self.canvas.yview)
hScroll = Scrollbar(self, orient = HORIZONTAL)
hScroll.pack(side = BOTTOM, fill=X)
hScroll.config(command = self.canvas.xview)
self.canvas.config(xscrollcommand = hScroll.set, yscrollcommand = vScroll.set)
self.canvas.pack(side=LEFT)
示例13: __init__
def __init__(self, parent=None, **kwargs):
Frame.__init__(self, parent)
self.parent = parent
self.job_list_yscroll = Scrollbar(self, orient=Tkinter.VERTICAL)
self.job_list_xscroll = Scrollbar(self, orient=Tkinter.HORIZONTAL)
self.job_list = Listbox(self, xscrollcommand=self.job_list_xscroll, yscrollcommand=self.job_list_yscroll)
self.job_list_xscroll['command'] = self.job_list.xview
self.job_list_yscroll['command'] = self.job_list.yview
self.new_job_frame = Frame(self)
add_icon_filename = kwargs['add_icon_filename'] if 'add_icon_filename' in kwargs else None
if add_icon_filename == None:
self.add_job_button = Button(self.new_job_frame, text='Add Job', command=self.on_add)
else:
add_icon = PhotoImage(file=add_icon_filename)
self.add_job_button = Button(self.new_job_frame, text='Add Job', compound='bottom', image=add_icon, command=self.on_add)
self.remove_job_button = Button(self.new_job_frame, text='Remove Job', command=self.on_remove)
self.progress_frame = Frame(self)
self.progress_value = Tkinter.IntVar()
self.progress_bar = Progressbar(self.progress_frame, variable=self.progress_value)
self.button_frame = Frame(self)
self.process_button = ProcessButton(parent=self.button_frame, start_jobs=self.start_jobs)
self.quit_button = QuitButton(parent=self.button_frame, close_other_windows=self.close_top_level_windows)
self.run_job = kwargs['run_job'] if 'run_job' in kwargs else None
self.create_plots = kwargs['create_plots'] if 'create_plots' in kwargs else None
self.log_filename = kwargs['log_filename'] if 'log_filename' in kwargs else None
self.bind('<<AskToClearJobs>>', self.ask_to_clear_jobs)
self.bind('<<AskToPlotGraphs>>', self.ask_to_plot_graphs)
self.bind('<<CreatePlotGUI>>', self.create_plot_gui)
self.parent.bind('<ButtonPress>', self.on_press)
self.parent.bind('<Configure>', self.on_resize)
self.reinit_variables()
self.top_level_windows = list()
# NOTE: Because there seems to be an issue resizing child widgets when the top level (Tk) widget is being resized,
# the resize option will be disabled for this window
self.parent.resizable(width=False, height=False)
self.lift()
示例14: ScrollableFrame
class ScrollableFrame(Frame):
def __init__(self, root):
Frame.__init__(self, root)
self.canvas = ResizingCanvas(self, borderwidth=0)
self.frame = Frame(self.canvas)
self.vsb = Scrollbar(
self, orient="vertical", command=self.canvas.yview)
self.canvas.configure(yscrollcommand=self.vsb.set)
self.vsb.pack(side="right", fill="y")
self.canvas.pack(side="left", fill="both", expand=True)
self.canvas.create_window(
(4, 4), window=self.frame, anchor="nw", tags="self.frame")
self.frame.bind("<Configure>", self.OnFrameConfigure)
def OnFrameConfigure(self, event):
'''Reset the scroll region to encompass the inner frame'''
# print "OnFrameConfigure"
self.canvas.configure(scrollregion=self.canvas.bbox("all"))
示例15: __init__
def __init__(self, root):
Frame.__init__(self, root)
self.canvas = ResizingCanvas(self, borderwidth=0)
self.frame = Frame(self.canvas)
self.vsb = Scrollbar(
self, orient="vertical", command=self.canvas.yview)
self.canvas.configure(yscrollcommand=self.vsb.set)
self.vsb.pack(side="right", fill="y")
self.canvas.pack(side="left", fill="both", expand=True)
self.canvas.create_window(
(4, 4), window=self.frame, anchor="nw", tags="self.frame")
self.frame.bind("<Configure>", self.OnFrameConfigure)