Beispiel #1
0
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()
Beispiel #2
0
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()
Beispiel #3
0
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)

# tell the listbox and the scrollbar about each other
Beispiel #4
0
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)