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


Python Gui.sb方法代码示例

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


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

示例1: figure8

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import sb [as 别名]
def figure8():
    print 'Figure 17.6'

    g = Gui()
    options = dict(side=TOP, fill=X)

    # create the widgets
    g.fr()
    la = g.la(side=TOP, text='List of colors:')
    lb = g.lb(side=LEFT)
    sb = g.sb(side=RIGHT, fill=Y)
    g.endfr()

    bu = g.bu(side=BOTTOM, text='OK', command=g.quit)

    # fill the listbox with color names
    colors = []
    for line in open('/etc/X11/rgb.txt'):
        t = line.split('\t')
        name = t[-1].strip()
        colors.append(name)

    for color in colors:
        lb.insert(END, color)

    # tell the listbox and the scrollbar about each other
    lb.configure(yscrollcommand=sb.set)
    sb.configure(command=lb.yview)

    g.mainloop()
    g.destroy()
开发者ID:ANB2,项目名称:ThinkPython,代码行数:33,代码来源:pack_demo.py

示例2: apply_color

# 需要导入模块: from swampy import Gui [as 别名]
# 或者: from swampy.Gui import sb [as 别名]
def apply_color():
    color = get_selection()
    if color:
        ca.itemconfig(item1, fill=color)


la = g.la(text="List of colors:")

g.row()
# lb is for listbox
lb = g.lb()
lb.bind("<ButtonRelease-1>", print_selection)

# sb is for scrollbar
sb = g.sb()
g.endrow()


bu = g.bu(text="Apply color", command=apply_color)
g.endcol()

# fill the listbox with color names
fp = open("/etc/X11/rgb.txt")
fp.readline()

for line in fp:
    t = line.split("\t")
    name = t[2].strip()
    lb.insert(END, name)
开发者ID:Ehsan1981,项目名称:ThinkPython,代码行数:31,代码来源:widget_demo.py


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