当前位置: 首页>>代码示例>>Python>>正文


Python tkinter.Scrollbar方法代码示例

本文整理汇总了Python中tkinter.Scrollbar方法的典型用法代码示例。如果您正苦于以下问题:Python tkinter.Scrollbar方法的具体用法?Python tkinter.Scrollbar怎么用?Python tkinter.Scrollbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter的用法示例。


在下文中一共展示了tkinter.Scrollbar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _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) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:21,代码来源:chartparser_app.py

示例2: __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) 
开发者ID:jsexauer,项目名称:networkx_viewer,代码行数:26,代码来源:viewer.py

示例3: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Scrollbar [as 别名]
def __init__(self, control, board):
        self.control = control
        if self.control.game_mode != 2:
            self.can.bind('<Button-1>', self.control.callback)

        self.lb = tkinter.Listbox(ChessView.root,selectmode="browse")
        self.scr1 = tkinter.Scrollbar(ChessView.root)
        self.lb.configure(yscrollcommand=self.scr1.set)
        self.scr1['command'] = self.lb.yview
        self.scr1.pack(side='right',fill="y")
        self.lb.pack(fill="x")

        self.lb.bind('<<ListboxSelect>>', self.printList)  # Double-    <Button-1>
        self.board = board
        self.last_text_x = 0
        self.last_text_y = 0
        self.print_text_flag = False

    # def start(self):
    #     tkinter.mainloop() 
开发者ID:chengstone,项目名称:cchess-zero,代码行数:22,代码来源:ChessView.py

示例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) 
开发者ID:glitchassassin,项目名称:lackey,代码行数:23,代码来源:SikuliGui.py

示例5: __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) 
开发者ID:VCCRI,项目名称:SVPV,代码行数:22,代码来源:gui_widgets.py

示例6: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Scrollbar [as 别名]
def __init__(self, master, initwidget, nmemb, orient=tk.HORIZONTAL, reverse=False, **kwargs):
        assert callable(initwidget)
        super().__init__(master, **kwargs)
        self._interior = tk.Frame(self)
        self.scroller = ScrollingUpdate(self,
                initlist=[initwidget(master=self._interior) for i in range(nmemb)],
                orient=orient,
                reverse=reverse)
        self.scrollbar = tk.Scrollbar(self, orient=orient)
        if orient == tk.HORIZONTAL:
            self.grid_columnconfigure(0, weight=1)
            self._interior.grid(row=0, column=0, sticky="nswe")
            self.scrollbar.grid(row=1, column=0, sticky="nswe")
        elif orient == tk.VERTICAL:
            self.grid_rowconfigure(0, weight=1)
            self._interior.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
            self.scrollbar.pack(side=tk.LEFT, fill=tk.Y)
        self.orient = orient 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:20,代码来源:scroll.py

示例7: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Scrollbar [as 别名]
def __init__(self, parent, **kwargs):
        super().__init__(parent, highlightthickness=0, **kwargs)
       
        vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
        vscrollbar.pack(side=tk.RIGHT, fill=tk.Y)
      
        self.canvas = canvas = tk.Canvas(self, bd=2, highlightthickness=0,
                        yscrollcommand=vscrollbar.set)
        
        canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        vscrollbar.config(command=canvas.yview)
        
        canvas.xview_moveto(0)
        canvas.yview_moveto(0)

        self.interior = interior = tk.Frame(canvas)
        self.interior_id = canvas.create_window(0, 0,
            window=interior,
            anchor=tk.NW)
        
        self.interior.bind("<Configure>", self.configure_interior)
        self.canvas.bind("<Configure>", self.configure_canvas)
        self.scrollbar = vscrollbar
        self.mouse_position = 0 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:26,代码来源:tkwidgets.py

示例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() 
开发者ID:SystemRage,项目名称:py-kms,代码行数:20,代码来源:pykms_GuiMisc.py

示例9: __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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:26,代码来源:turtle.py

示例10: __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 = methods.difference(text_meths)

        for m in methods:
            if m[0] != '_' and m != 'config' and m != 'configure':
                setattr(self, m, getattr(self.frame, m)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:scrolledtext.py

示例11: run

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Scrollbar [as 别名]
def run(self):
        root = tk.Tk()
        self.root = root
        root.title("Application Log")
        text = tk.Text(root)
        text.pack(side=tk.LEFT, fill=tk.BOTH, expand = tk.YES)
        text.config(wrap=tk.WORD)
        self.text = text
        yscroll = tk.Scrollbar(command=text.yview)
        text['yscrollcommand'] = yscroll.set
        yscroll.pack(side=tk.RIGHT, fill=tk.Y)
        text.config(state=tk.DISABLED)
        self.update()
        root.mainloop()
        self.r_queue.put(("die", None))

# Q: OK. So you put Tkinter in it's own process.
#    Now why is Pystray in another process too?!
# A: Because if I don't, MPV and GNOME Appindicator
#    try to access the same resources and cause the
#    entire application to segfault.
#
# I suppose this means I can put the Tkinter GUI back
# into the main process. This is true, but then the
# two need to be merged, which is non-trivial. 
开发者ID:iwalton3,项目名称:plex-mpv-shim,代码行数:27,代码来源:gui_mgr.py

示例12: 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) 
开发者ID:Xunius,项目名称:Menotexport,代码行数:19,代码来源:menotexport-gui.py

示例13: 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") 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:11,代码来源:nemo_app.py

示例14: __init__

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Scrollbar [as 别名]
def __init__(self, master=None):
        super().__init__(master)
        self.text = tk.Text(self, width=80, height=40)
        self.vsb = tk.Scrollbar(self, command=self.text.yview)
        self.text.pack(side=tk.LEFT, expand=True, fill=tk.BOTH)
        self.vsb.pack(side=tk.RIGHT, expand=True, fill=tk.Y)
        self.text.insert(tk.END, HELP_TXT)
        self.text.config(state=tk.DISABLED, xscrollcommand=self.vsb.set) 
开发者ID:Dogeek,项目名称:rpg-text,代码行数:10,代码来源:map-creator.py

示例15: create

# 需要导入模块: import tkinter [as 别名]
# 或者: from tkinter import Scrollbar [as 别名]
def create(self, filename='none'):
        """
        This method creates a horizontal AreaVi widget. It returns the
        AreaVi widget that was created. It as well installs the plugins
        that appear in the vyrc file in the AreaVi widget.
        """
        frame     = Frame(master=self)
        scrollbar = Scrollbar(master=frame)
        area      = AreaVi(filename, frame , border=3, relief=RAISED, 
                           yscrollcommand=scrollbar.set)
        scrollbar.config(command=area.yview)
        scrollbar.pack(side='right', fill=Y)

        from vyapp.plugins import HANDLE

        for handle, args, kwargs in HANDLE:
            handle(area, *args, **kwargs)

        area.focus_set()
        area.pack(expand=True, side='left', fill=BOTH)
        self.add(frame)

        def save_focus(event):
            self.master.focused_area = area

        self.master.focused_area = area
        area.bind('<FocusIn>', save_focus)
        return area 
开发者ID:vyapp,项目名称:vy,代码行数:30,代码来源:panel.py


注:本文中的tkinter.Scrollbar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。