1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
from Tkinter import *
import tkColorChooser
import tkFileDialog
def set_in_red() :
main_window.tk_setPalette(background="red",foreground='black')
def set_in_green() :
main_window.tk_setPalette(background="green",foreground='black')
def set_in_blue() :
main_window.tk_setPalette(background="blue",foreground='black')
def set_in_yellow() :
main_window.tk_setPalette(background="yellow",foreground='black')
def show_colorchooser() :
tkColorChooser.askcolor(parent=main_window)
def show_filechooser() :
tkFileDialog.askopenfile(parent=main_window)
main_window=Tk()
but_show_colorchooser=Button(main_window,text="Color Chooser ",command=show_colorchooser)
but_show_filechooser=Button(main_window,text="File Chooser ",command=show_filechooser)
but_set_in_red=Button(main_window,text="Red",bg='red',command=set_in_red)
but_set_in_green=Button(main_window,text="Green",bg='green',command=set_in_green)
but_set_in_blue=Button(main_window,text="Blue",bg='blue',command=set_in_blue)
but_set_in_yellow=Button(main_window,text="Yellow",bg='yellow',command=set_in_yellow)
but_show_colorchooser.grid(row=0,column=0,columnspan=4,sticky="EW")
but_show_filechooser.grid(row=0,column=4,columnspan=4,sticky="EW")
but_set_in_red.grid(row=1,column=0,sticky="EW")
but_set_in_green.grid(row=1,column=2,sticky="EW")
but_set_in_blue.grid(row=1,column=4,sticky="EW")
but_set_in_yellow.grid(row=1,column=7,sticky="EW")
main_window.mainloop() |
Partager