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


Python Scrollbar.set方法代码示例

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


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

示例1: Tk_Table

# 需要导入模块: from ttk import Scrollbar [as 别名]
# 或者: from ttk.Scrollbar import set [as 别名]

#.........这里部分代码省略.........
                    def yview_command(*args):
                        self._multicolumn_listbox.interior.yview(*args)
                        self._update_position_of_entry()
            else:
                if row_numbers:
                    def yview_command(*args):
                        self._multicolumn_listbox.interior.yview(*args)
                        self._row_numbers.yview(*args)
                else:
                    yview_command = self._multicolumn_listbox.interior.yview

            self._vbar=Scrollbar(self,takefocus=0, command=yview_command, **scrollbar_kwargs)
            self._vbar.grid(row=0, column=2, sticky= N+S)

            def yscrollcommand(first,last):
                first, last = float(first), float(last)
                if first <= 0 and last >= 1:
                    if self._mousewheel_detection:
                        if autoscroll:
                            self._vbar.grid_remove()

                        if row_numbers:
                            unbind_function_onMouseWheel(self._multicolumn_listbox.interior)
                        self._mousewheel_detection = False
                else:
                    if not self._mousewheel_detection:
                        if autoscroll:
                            self._vbar.grid()

                        if row_numbers:
                            bind_function_onMouseWheel(self._row_numbers, "y", binding_widget=self._multicolumn_listbox.interior, unit="pages")
                        self._mousewheel_detection = True

                self._vbar.set(first, last)
                if editable:
                    self._update_position_of_entry()

            self._multicolumn_listbox.interior.config(yscrollcommand=yscrollcommand)

        if hscrollbar:
            if editable:
                def xview_command(*args):
                    self._multicolumn_listbox.interior.xview(*args)
                    self._update_position_of_entry()
            else:
                xview_command = self._multicolumn_listbox.interior.xview

            self._hbar=Scrollbar(self,takefocus=0, command=xview_command, **scrollbar_kwargs)
            self._hbar.grid(row=1, column=1, sticky= E+W)
            
            if autoscroll:
                if editable:
                    def xscrollcommand(f,l, self=self):
                        make_autoscroll(self._hbar, f, l)
                        self._update_position_of_entry()
                else:
                    def xscrollcommand(f,l, hbar=self._hbar):
                        make_autoscroll(hbar, f, l)

                self._multicolumn_listbox.interior.config(xscrollcommand=xscrollcommand)
            else:
                self._multicolumn_listbox.interior.config(xscrollcommand=self._hbar.set)

    def _place_vertically_row_numbers(self, event):
        self._multicolumn_listbox.interior.unbind("<Map>")
开发者ID:jacob-carrier,项目名称:code,代码行数:69,代码来源:recipe-580746.py

示例2: Scrolling_Area

# 需要导入模块: from ttk import Scrollbar [as 别名]
# 或者: from ttk.Scrollbar import set [as 别名]
class Scrolling_Area(Frame, object):

    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)

    def update_viewport(self):
        # compute new height and width
        self.update()
        frameHeight = float(self.innerframe.winfo_reqheight())
        frameWidth = float(self.innerframe.winfo_reqwidth())
        
        if self._width is not None:
            width = min(self._width, frameWidth)
        else:
            width = self._frameWidth

        if self._height is not None:
            height = min(self._height, frameHeight)
        else:
            height = self._frameHeight
        
        self._clipper.configure(width=width, height=height)

    def _on_configure(self, event):
        self._frameHeight = float(self.innerframe.winfo_reqheight())
        self._frameWidth = float(self.innerframe.winfo_reqwidth())

        # resize the visible part
        if self._scroll_horizontally:
            self.xview("scroll", 0, "unit")
            
        if self._scroll_vertically:
            self.yview("scroll", 0, "unit")       

    def xview(self, mode = None, value = None, units = None):
        value = float(value)

        clipperWidth = self._clipper.winfo_width()
        frameWidth = self._frameWidth 
        
        _startX = self._startX

        if mode is None:
            return self.xscrollbar.get()
        elif mode == 'moveto':
            # absolute movement
#.........这里部分代码省略.........
开发者ID:jacob-carrier,项目名称:code,代码行数:103,代码来源:recipe-580797.py


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