本文整理汇总了Python中Tkinter.Scrollbar方法的典型用法代码示例。如果您正苦于以下问题:Python Tkinter.Scrollbar方法的具体用法?Python Tkinter.Scrollbar怎么用?Python Tkinter.Scrollbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter
的用法示例。
在下文中一共展示了Tkinter.Scrollbar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def __init__(self, parent, property_dict, *args, **kw):
tk.Frame.__init__(self, parent, *args, **kw)
# create a canvas object and a vertical scrollbar for scrolling it
self.vscrollbar = vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
vscrollbar.pack(fill=tk.Y, side=tk.RIGHT, expand=tk.FALSE)
self.canvas = canvas = tk.Canvas(self, bd=0, highlightthickness=0,
yscrollcommand=vscrollbar.set)
canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=tk.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 = tk.Frame(canvas)
self.interior_id = canvas.create_window(0, 0, window=interior,
anchor='nw')
self.interior.bind('<Configure>', self._configure_interior)
self.canvas.bind('<Configure>', self._configure_canvas)
self.build(property_dict)
示例2: _sb_canvas
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def _sb_canvas(self, root, expand='y',
fill='both', side='bottom'):
"""
Helper for __init__: construct a canvas with a scrollbar.
"""
cframe =Tkinter.Frame(root, relief='sunk', border=2)
cframe.pack(fill=fill, expand=expand, side=side)
canvas = Tkinter.Canvas(cframe, background='#e0e0e0')
# Give the canvas a scrollbar.
sb = Tkinter.Scrollbar(cframe, orient='vertical')
sb.pack(side='right', fill='y')
canvas.pack(side='left', fill=fill, expand='yes')
# Connect the scrollbars to the canvas.
sb['command']= canvas.yview
canvas['yscrollcommand'] = sb.set
return (sb, canvas)
示例3: _sb_canvas
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def _sb_canvas(self, root, expand='y',
fill='both', side='bottom'):
"""
Helper for __init__: construct a canvas with a scrollbar.
"""
cframe =Tkinter.Frame(root, relief='sunk', border=2)
cframe.pack(fill=fill, expand=expand, side=side)
canvas = Tkinter.Canvas(cframe, background='#e0e0e0')
# Give the canvas a scrollbar.
sb = Tkinter.Scrollbar(cframe, orient='vertical')
sb.pack(side='right', fill='y')
canvas.pack(side='left', fill=fill, expand='yes')
# Connect the scrollbars to the canvas.
sb['command']= canvas.yview
canvas['yscrollcommand'] = sb.set
return (sb, canvas)
示例4: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def __init__(self, master, textvariable=None, *args, **kwargs):
tk.Frame.__init__(self, master)
# Init GUI
self._y_scrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
self._text_widget = tk.Text(self, yscrollcommand=self._y_scrollbar.set, *args, **kwargs)
self._text_widget.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
self._y_scrollbar.config(command=self._text_widget.yview)
self._y_scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
if textvariable is not None:
if not isinstance(textvariable, tk.Variable):
raise TypeError("tkinter.Variable type expected, {} given.".format(
type(textvariable)))
self._text_variable = textvariable
self.var_modified()
self._text_trace = self._text_widget.bind('<<Modified>>', self.text_modified)
self._var_trace = textvariable.trace("w", self.var_modified)
示例5: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def __init__(self, master, width=500, height=350,
canvwidth=600, canvheight=500):
TK.Frame.__init__(self, master, width=width, height=height)
self._rootwindow = self.winfo_toplevel()
self.width, self.height = width, height
self.canvwidth, self.canvheight = canvwidth, canvheight
self.bg = "white"
self._canvas = TK.Canvas(master, width=width, height=height,
bg=self.bg, relief=TK.SUNKEN, borderwidth=2)
self.hscroll = TK.Scrollbar(master, command=self._canvas.xview,
orient=TK.HORIZONTAL)
self.vscroll = TK.Scrollbar(master, command=self._canvas.yview)
self._canvas.configure(xscrollcommand=self.hscroll.set,
yscrollcommand=self.vscroll.set)
self.rowconfigure(0, weight=1, minsize=0)
self.columnconfigure(0, weight=1, minsize=0)
self._canvas.grid(padx=1, in_ = self, pady=1, row=0,
column=0, rowspan=1, columnspan=1, sticky='news')
self.vscroll.grid(padx=1, in_ = self, pady=1, row=0,
column=1, rowspan=1, columnspan=1, sticky='news')
self.hscroll.grid(padx=1, in_ = self, pady=1, row=1,
column=0, rowspan=1, columnspan=1, sticky='news')
self.reset()
self._rootwindow.bind('<Configure>', self.onResize)
示例6: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def __init__(self, master=None, **kw):
self.frame = Frame(master)
self.vbar = Scrollbar(self.frame)
self.vbar.pack(side=RIGHT, fill=Y)
kw.update({'yscrollcommand': self.vbar.set})
Text.__init__(self, self.frame, **kw)
self.pack(side=LEFT, fill=BOTH, expand=True)
self.vbar['command'] = self.yview
# Copy geometry methods of self.frame without overriding Text
# methods -- hack!
text_meths = vars(Text).keys()
methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys()
methods = set(methods).difference(text_meths)
for m in methods:
if m[0] != '_' and m != 'config' and m != 'configure':
setattr(self, m, getattr(self.frame, m))
示例7: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def __init__(self, parent, header, width=10, selectmode=tk.BROWSE):
tk.Frame.__init__(self, parent)
self.parent = parent
self.num_f = len(header)
self.headers = []
self.lbs = []
self.c = 0
self.sel_idxs = []
self.scroll = tk.Scrollbar(self, orient=tk.VERTICAL)
for i in range(0, self.num_f):
self.headers.append(tk.Label(self, text=header[i]))
self.headers[-1].grid(row=0, column=self.c, sticky=tk.EW)
self.lbs.append(tk.Listbox(self, width=width, selectmode=selectmode, yscrollcommand=self.yscroll, bg='white'))
self.lbs[-1].grid(row=1, column=self.c, sticky=tk.EW)
self.lbs[-1].bind("<<ListboxSelect>>", self.select)
self.c += 1
self.scroll.config(command=self.lbs[0].yview)
self.scroll.grid(row=1, column=self.c, sticky=tk.NS)
示例8: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter 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()
示例9: addMessageFrame
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def addMessageFrame(self):
frame=Frame(self)
frame.pack(fill=tk.BOTH,side=tk.TOP,\
expand=1,padx=8,pady=5)
self.messagelabel=tk.Label(frame,text='Message',bg='#bbb')
self.messagelabel.pack(side=tk.TOP,fill=tk.X)
self.text=tk.Text(frame)
self.text.pack(side=tk.TOP,fill=tk.BOTH,expand=1)
self.text.height=10
scrollbar=tk.Scrollbar(self.text)
scrollbar.pack(side=tk.RIGHT,fill=tk.Y)
self.text.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.text.yview)
示例10: create_imgwin
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def create_imgwin(self, img_fn, title):
'''
creates a window to display an image
'''
from os.path import basename
# create child window
img = PhotoImage(file=img_fn)
win = Toplevel()
wwid = min(800, img.width())
whei = min(800, img.height())
win.geometry(('%dx%d' % (wwid+28, whei+28)))
win.title(basename(title))
frame = Frame(win, bd=0)
frame.pack()
xscrollbar = Scrollbar(frame, orient='horizontal')
xscrollbar.pack(side='bottom', fill='x')
yscrollbar = Scrollbar(frame, orient='vertical')
yscrollbar.pack(side='right', fill='y')
canvas = Canvas(frame, bd=0, width=wwid, height=whei,
scrollregion=(0, 0, img.width(), img.height()),
xscrollcommand=xscrollbar.set,
yscrollcommand=yscrollbar.set)
canvas.pack(side='top', fill='both', expand=1)
canvas.create_image(0, 0, image=img, anchor='nw')
xscrollbar.config(command=canvas.xview)
yscrollbar.config(command=canvas.yview)
frame.pack()
# next statement is important! creates reference to img
canvas.img = img
示例11: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def __init__(self, root, vals, rng):
self._root = root
self._original_rng = rng
self._original_vals = vals
self._frame = Tkinter.Frame(root)
self._frame.pack(expand=1, fill='both')
# Set up the canvas
self._canvas = Tkinter.Canvas(self._frame, background='white')
self._canvas['scrollregion'] = (0,0,200,200)
# Give the canvas scrollbars.
sb1 = Tkinter.Scrollbar(self._frame, orient='vertical')
sb1.pack(side='right', fill='y')
sb2 = Tkinter.Scrollbar(self._frame, orient='horizontal')
sb2.pack(side='bottom', fill='x')
self._canvas.pack(side='left', fill='both', expand=1)
# Connect the scrollbars to the canvas.
sb1.config(command=self._canvas.yview)
sb2['command']=self._canvas.xview
self._canvas['yscrollcommand'] = sb1.set
self._canvas['xscrollcommand'] = sb2.set
self._width = self._height = -1
self._canvas.bind('<Configure>', self._configure)
# Start out with linear coordinates.
self.config_axes(0, 0)
示例12: __init__
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def __init__(self, master=None, **kw):
"""Construct a Ttk Scrollbar with parent master.
STANDARD OPTIONS
class, cursor, style, takefocus
WIDGET-SPECIFIC OPTIONS
command, orient
"""
Widget.__init__(self, master, "ttk::scrollbar", kw)
示例13: create
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def create(self, **kwargs):
return tkinter.Scrollbar(self.root, **kwargs)
示例14: strap_design_frame_builder
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def strap_design_frame_builder(self):
self.strap_inputs_frame = tk.Frame(self.strap_design_frame)
self.strap_inputs_frame.pack(side=tk.LEFT, anchor='nw')
self.strap_calc_frame = tk.Frame(self.strap_design_frame)
self.strap_calc_frame.pack(side=tk.RIGHT ,anchor='ne', fill=tk.BOTH, expand=1)
tk.Label(self.strap_inputs_frame, text="B = ", font=self.helv).grid(row=0, column=0, sticky = tk.E)
tk.Entry(self.strap_inputs_frame, textvariable=self.bs, width=10, validate="key", validatecommand=self.reset_status).grid(row=0, column=1)
tk.Label(self.strap_inputs_frame, text="in", font=self.helv).grid(row=0, column=2)
tk.Label(self.strap_inputs_frame, text="H = ", font=self.helv).grid(row=1, column=0, sticky = tk.E)
tk.Entry(self.strap_inputs_frame, textvariable=self.hs, width=10, validate="key", validatecommand=self.reset_status).grid(row=1, column=1)
tk.Label(self.strap_inputs_frame, text="in", font=self.helv).grid(row=1, column=2)
self.strap_vbar_size = tk.StringVar()
self.inputs.append(self.strap_vbar_size)
self.strap_vbar_size.set('3')
self.strap_vbar_size_label = tk.Label(self.strap_inputs_frame, text="Shear\nBar Size (#) : ", font=self.helv)
self.strap_vbar_size_label.grid(row=2,column=0, pady=2)
self.strap_vbar_size_menu = tk.OptionMenu(self.strap_inputs_frame, self.strap_vbar_size, '3', '4', '5', command=self.reset_status)
self.strap_vbar_size_menu.config(font=self.helv)
self.strap_vbar_size_menu.grid(row=2, column=1, padx= 2, sticky=tk.W)
self.strap_bar_size = tk.StringVar()
self.inputs.append(self.strap_bar_size)
self.strap_bar_size.set('3')
self.strap_bar_size_label = tk.Label(self.strap_inputs_frame, text="Flexure\nBar Size (#) : ", font=self.helv)
self.strap_bar_size_label.grid(row=4,column=0, pady=2)
self.strap_bar_size_menu = tk.OptionMenu(self.strap_inputs_frame, self.strap_bar_size, '3', '4', '5','6','7','8','9','10','11','14','18', command=self.reset_status)
self.strap_bar_size_menu.config(font=self.helv)
self.strap_bar_size_menu.grid(row=4, column=1, padx= 2, sticky=tk.W)
self.strap_calc_txtbox = tk.Text(self.strap_calc_frame, height = 25, width = 70, bg= "grey90", font= self.helv_norm, wrap=tk.WORD)
self.strap_calc_txtbox.grid(row=0, column=0, sticky='nsew')
self.strap_scroll = tk.Scrollbar(self.strap_calc_frame, command=self.strap_calc_txtbox.yview)
self.strap_scroll.grid(row=0, column=1, sticky='nsew')
self.strap_calc_txtbox['yscrollcommand'] = self.strap_scroll.set
示例15: initScrollText
# 需要导入模块: import Tkinter [as 别名]
# 或者: from Tkinter import Scrollbar [as 别名]
def initScrollText(self,frm,txt,contents):
scl = tk.Scrollbar(frm)
scl.config(command = txt.yview)
scl.pack(side="right",fill="y")
txt.pack(side = "left", expand=True, fill="x")
txt.config(yscrollcommand = scl.set)
txt.insert("1.0",contents)
frm.pack(fill = "x")
tk.Frame(height=2, bd=1, relief="ridge").pack(fill="x")