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


Python Listbox.yview_scroll方法代码示例

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


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

示例1: second_window

# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import yview_scroll [as 别名]
def second_window(root, info):
    def next_step():
        idxs = lbox.curselection()
        for blogger in idxs:
            name = bloggers()[blogger]
            if name not in info['bloggers']:
                info['bloggers'].append(name)
        if 'Blogs' in info['platforms']:
            blog_posts(root, info)
        else:
            third_window(root, info)

    def cantfind(info=info):
        idxs = lbox.curselection()
        for blogger in idxs:
            name = bloggers()[blogger]
            if name not in info['bloggers']:
                info['bloggers'].append(name)
        add_blogger(info=info)

    def active_next(*args):
        send.state(['!disabled', 'active'])

    def back():
        idxs = lbox.curselection()
        for blogger in idxs:
            name = bloggers()[blogger]
            if name not in info['bloggers']:
                info['bloggers'].append(name)
        first_window(root, info=info)

    c = ttk.Frame(root, padding=(5, 0, 0, 0))
    c.grid(column=0, row=0, sticky=(N, W, E, S))

    background_image = tkinter.PhotoImage(file='%s/Desktop/natappy/images/moon.gif' % home)
    background_label = tkinter.Label(c, image=background_image)
    background_label.image = background_image
    background_label.place(x=0, y=0, relwidth=1, relheight=1)

    root.grid_columnconfigure(0, weight=3)
    root.grid_rowconfigure(0, weight=3)

    lbox = Listbox(c, selectmode=MULTIPLE)
    lbox.grid(column=0, row=1, rowspan=11, columnspan=7, sticky=(
        N, W, S), padx=(10, 10), pady=(1, 1), ipadx=75)

    yscroll = ttk.Scrollbar(command=lbox.yview, orient=VERTICAL)
    yscroll.grid(row=0, column=0, padx=(0, 10), sticky=(N, W, S))

    lbox.configure(yscrollcommand=yscroll.set)

    for blogger in bloggers():
        lbox.insert(END, blogger)
        lbox.bind("<<ListboxSelect>>")

    lbox.yview_scroll(40, 'units')

    cantfind = ttk.Button(c, text='Add new bloggers', command=cantfind)
    cantfind.grid(column=4, row=1, padx=(10, 0), sticky=(N, S, E, W), pady=(20, 10))

    send = ttk.Button(c, text='Next', command=next_step, default='active', state='disabled')
    send.grid(column=6, row=11, sticky=E, pady=20, padx=(2, 20))

    close = ttk.Button(c, text='Back', command=back, default='active')
    close.grid(column=5, row=11, sticky=S + E, pady=20, padx=2)

    lbox.bind('<<ListboxSelect>>', active_next)

    if info['bloggers']:
        for blogger in info['bloggers']:
            i = bloggers().index(blogger)
            lbox.selection_set(i)
        active_next()

    for i in range(len(bloggers()), 2):
        lbox.itemconfigure(i, background='#f0f0ff')

    c.grid_columnconfigure(0, weight=1)
    c.grid_rowconfigure(5, weight=1)

    root.title('2/5 Select bloggers')
    root.geometry('680x550+300+40')
开发者ID:glebanatalia,项目名称:natappy,代码行数:84,代码来源:natappy_gui.py


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