Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
134 views
in Technique[技术] by (71.8m points)

Python tkinter to fill color in PowerPoint shapes

I need help on my requirement, I have written a code where Tkinter pops up with color swatch, it is running successfully, now my actual issue is that I want to use those colors in the Powerpoint to fill color in Autosahpes (which have in Powerpoint). When I click on the buttons the color does not fill the shapes (shape can be a circle, oval, rectangle, etc), I am stuck, Is this possible in Python? Can somebody help me to crack this? Below is my source code is written in python.

from tkinter import *

gui = Tk()
gui.configure(background="white")
gui.title("Color")
gui.geometry("215x485")
gui.grid_columnconfigure(4,minsize=50)
gui.wm_attributes("-topmost",1)

def bg(color):
    lbl.configure(bg=color)

def fg(color):
    lbl.configure(fg=color)

lbl=Label(gui,text=('[]'))
lbl.grid(row=6,column=4)
   


#code written in the button (2,3),(5,6),(8,9)........ is the code for highlighting the text


button1 = Button(gui,bg='#c8102e',command=lambda:bg('#c8102e'),width=2,bd=3)
button1.grid(padx=1,pady=1,row=2,column=0)

button2 = Button(gui,bg='white',fg='#c8102e',command=lambda:fg('#c8102e'),text='?',bd=3)
button2.grid(padx=1,pady=1,row=2,column=1)

button3 = Button(gui,bg='white',fg='#c8102e',command=lambda:fg('#c8102e'),text='A',width=2,bd=3)
button3.grid(padx=1,pady=1,row=2,column=2)

button4 = Button(gui,bg='#982e2f',command=lambda:bg('#982e2f'),width=2,bd=3)
button4.grid(padx=1,pady=1,row=3,column=0)

button5 = Button(gui,bg='white',fg='#982e2f',command=lambda:fg('#982e2f'),text='?',bd=3)
button5.grid(padx=1,pady=1,row=3,column=1)

button6 = Button(gui,bg='white',fg='#982e2f',command=lambda:fg('#982e2f'),text='A',width=2,bd=3)
button6.grid(padx=1,pady=1,row=3,column=2)

button7 = Button(gui,bg='#611d4b',command=lambda:bg('#611d4b'),width=2,bd=3)
button7.grid(padx=1,pady=1,row=4,column=0)

button8 = Button(gui,bg='white',fg='#611d4b',command=lambda:fg('#611d4b'),text='?',bd=3)
button8.grid(padx=1,pady=1,row=4,column=1)

button9 = Button(gui,bg='white',fg='#611d4b',command=lambda:fg('#611d4b'),text='A',width=2,bd=3)
button9.grid(padx=1,pady=1,row=4,column=2)

button10 = Button(gui,bg='#505759',command=lambda:bg('#505759'),width=2,bd=3)
button10.grid(padx=1,pady=1,row=5,column=0)

button11 = Button(gui,bg='white',fg='#505759',command=lambda:fg('#505759'),text='?',bd=3)
button11.grid(padx=1,pady=1,row=5,column=1)

button12 = Button(gui,bg='white',fg='#505759',command=lambda:fg('#505759'),text='A',width=2,bd=3)
button12.grid(padx=1,pady=1,row=5,column=2)

button13 = Button(gui,bg=('#ceb888'),command=lambda:bg('#ceb888'),width=2,bd=3)
button13.grid(padx=1,pady=1,row=6,column=0)

button14 = Button(gui,bg='white',fg='#ceb888',command=lambda:fg('#ceb888'),text='?',bd=3)
button14.grid(padx=1,pady=1,row=6,column=1)

button15 = Button(gui,bg='white',fg='#ceb888',command=lambda:fg('#ceb888'),text='A',width=2,bd=3)
button15.grid(padx=1,pady=1,row=6,column=2)

button16 = Button(gui,bg='#dacaa6',command=lambda:bg('#dacaa6'),width=2,bd=3)
button16.grid(padx=1,pady=1,row=7,column=0)

button17 = Button(gui,bg='white',fg='#dacaa6',command=lambda:fg('#dacaa6'),text='?',bd=3)
button17.grid(padx=1,pady=1,row=7,column=1)

button18 = Button(gui,bg='white',fg='#dacaa6',command=lambda:fg('#dacaa6'),text='A',width=2,bd=3)
button18.grid(padx=1,pady=1,row=7,column=2)

button19 = Button(gui,bg='#e6dbc3',command=lambda:bg('#e6dbc3'),width=2,bd=3)
button19.grid(padx=1,pady=1,row=8,column=0)

button20 = Button(gui,bg='white',fg='#e6dbc3',command=lambda:fg('#e6dbc3'),text='?',bd=3)
button20.grid(padx=1,pady=1,row=8,column=1)

button21 = Button(gui,bg='white',fg='#e6dbc3',command=lambda:fg('#e6dbc3'),text='A',width=2,bd=3)
button21.grid(padx=1,pady=1,row=8,column=2)

button22 = Button(gui,bg='#a89968',command=lambda:bg('#a89968'),width=2,bd=3)
button22.grid(padx=1,pady=1,row=9,column=0)

button23 = Button(gui,bg='white',fg='#a89968',command=lambda:fg('#a89968'),text='?',bd=3)
button23.grid(padx=1,pady=1,row=9,column=1)

button24 = Button(gui,bg='white',fg='#a89968',command=lambda:fg('#a89968'),text='A',width=2,bd=3)
button24.grid(padx=1,pady=1,row=9,column=2)

button25 = Button(gui,bg='#beb38e',command=lambda:bg('#beb38e'),width=2,bd=3)
button25.grid(padx=1,pady=1,row=10,column=0)

button26 = Button(gui,bg='white',fg='#beb38e',command=lambda:fg('#beb38e'),text='?',bd=3)
button26.grid(padx=1,pady=1,row=10,column=1)

button27 = Button(gui,bg='white',fg='#beb38e',command=lambda:fg('#beb38e'),text='A',width=2,bd=3)
button27.grid(padx=1,pady=1,row=10,column=2)

button28 = Button(gui,bg='#d3ccb3',command=lambda:bg('#d3ccb3'),width=2,bd=3)
button28.grid(padx=1,pady=1,row=11,column=0)

button29 = Button(gui,bg='white',fg='#d3ccb3',command=lambda:fg('#d3ccb3'),text='?',bd=3)
button29.grid(padx=1,pady=1,row=11,column=1)

button30 = Button(gui,bg='white',fg='#d3ccb3',command=lambda:fg('#d3ccb3'),text='A',width=2,bd=3)
button30.grid(padx=1,pady=1,row=11,column=2)

button31 = Button(gui,bg='#b7b09c',command=lambda:bg('#b7b09c'),width=2,bd=3)
button31.grid(padx=1,pady=1,row=12,column=0)

button32 = Button(gui,bg='white',fg='#b7b09c',command=lambda:fg('#b7b09c'),text='?',bd=3)
button32.grid(padx=1,pady=1,row=12,column=1)

button33 = Button(gui,bg='white',fg='#b7b09c',command=lambda:fg('#b7b09c'),text='A',width=2,bd=3)
button33.grid(padx=1,pady=1,row=12,column=2)

button34 = Button(gui,bg='#c9c4b5',command=lambda:bg('#c9c4b5'),width=2,bd=3)
button34.grid(padx=1,pady=1,row=13,column=0)

button35 = Button(gui,bg='white',fg='#c9c4b5',command=lambda:fg('#c9c4b5'),text='?',bd=3)
button35.grid(padx=1,pady=1,row=13,column=1)

button36 = Button(gui,bg='white',fg='#c9c4b5',command=lambda:fg('#c9c4b5'),text='A',width=2,bd=3)
button36.grid(padx=1,pady=1,row=13,column=2)

button37 = Button(gui,bg='#dbd7cd',command=lambda:bg('#dbd7cd'),width=2,bd=3)
button37.grid(padx=1,pady=1,row=14,column=0)

button38 = Button(gui,bg='white',fg='#dbd7cd',command=lambda:fg('#dbd7cd'),text='?',bd=3)
button38.grid(padx=1,pady=1,row=14,column=1)

button39 = Button(gui,bg='white',fg='#dbd7cd',command=lambda:fg('#dbd7cd'),text='A',width=2,bd=3)
button39.grid(padx=1,pady=1,row=14,column=2)

button40 = Button(gui,bg='#a39382',command=lambda:bg('#a39382'),width=2,bd=3)
button40.grid(padx=1,pady=1,row=15,column=0)

button41 = Button(gui,bg='white',fg='#a39382',command=lambda:fg('#a39382'),text='?',bd=3)
button41.grid(padx=1,pady=1,row=15,column=1)

button42 = Button(gui,bg='white',fg='#a39382',command=lambda:fg('#a39382'),text='A',width=2,bd=3)
button42.grid(padx=1,pady=1,row=15,column=2)

button43 = Button(gui,bg='#baaea1',command=lambda:bg('#baaea1'),width=2,bd=3)
button43.grid(padx=1,pady=1,row=16,column=0)

button44 = Button(gui,bg='white',fg='#baaea1',command=lambda:fg('#baaea1'),text='?',bd=3)
button44.grid(padx=1,pady=1,row=16,column=1)

button45 = Button(gui,bg='white',fg='#baaea1',command=lambda:fg('#baaea1'),text='A',width=2,bd=3)
button45.grid(padx=1,pady=1,row=16,column=2)

button46 = Button(gui,bg='#d1c9c0',command=lambda:bg('#d1c9c0'),width=2,bd=3)
button46.grid(padx=1,pady=1,row=17,column=0)

button47 = Button(gui,bg='white',fg='#d1c9c0',command=lambda:fg('#d1c9c0'),text='?',bd=3)
button47.grid(padx=1,pady=1,row=17,column=1)

button48 = Button(gui,bg='white',fg='#d1c9c0',command=lambda:fg('#d1c9c0'),text='A',width=2,bd=3)
button48.grid(padx=1,pady=1,row=17,column=2)

button49 = Button(gui,bg='#d3bba8',command=lambda:bg('#d3bba8'),width=2,bd=3)
button49.grid(padx=1,pady=1,row=2,column=6)

button50 = Button(gui,bg='white',fg='#d3bba8',command=lambda:fg('#d3bba8'),text='?',bd=3)
button50.grid(padx=1,pady=1,row=2,column=7)

button51 = Button(gui,bg='white',fg='#d3bba8',command=lambda:fg('#d3bba8'),text='A',width=2,bd=3)
button51.grid(padx=1,pady=1,row=2,column=8)

button52 = Button(gui,bg='#deccbe',command=lambda:bg('#deccbe'),width=2,bd=3)
button52.grid(padx=1,pady=1,row=3,column=6)

button53 = Button(gui,bg='white',fg='#deccbe',command=lambda:fg('#deccbe'),text='?',bd=3)
button53.grid(padx=1,pady=1,row=3,column=7)

button54 = Button(gui,bg='white',fg='#deccbe',command=lambda:fg('#deccbe'),text='A',width=2,bd=3)
button54.grid(padx=1,pady=1,row=3,column=8)

button55 = Button(gui,bg='#e9ddd3',command=lambda:bg('#e9ddd3'),width=2,bd=3)
button55.grid(padx=1,pady=1,row=4,column=6)

button56 = Button(gui,bg='white',fg='#e9ddd3',command=lambda:fg('#e9ddd3'),text='?',bd=3)
button56.grid(padx=1,pady=1,row=4,column=7)

button57 = Button(gui,bg='white',fg='#e9ddd3',command=lambda:fg('#e9ddd3'),text='A',width=2,bd=3)
button57.grid(padx=1,pady=1,row=4,column=8)

button58 = Button(gui,bg='#94a596',command=lambda:bg('#94a596'),width=2,bd=3)
button58.grid(padx=1,pady=1,row=5,column=6)

button59 = Button(gui,bg='white',fg='#94a596',command=lambda:fg('#94a596'),text='?',bd=3)
button59.grid(padx=1,pady=1,row=5,column=7)

button60 = Button(gui,bg='white',fg='#94a596',command=lambda:fg('#94a596'),text='A',width=2,bd=3)
button60.grid(padx=1,pady=1,row=5,column=8)

button61 = Button(gui,bg='#afbcb0',command=lambda:bg('#afbcb0'),width=2,bd=3)
button61.grid(padx=1,pady=1,row=6,column=6)

button62 = Button(gui,bg='white',fg='#afbcb0',command=lambda:fg('#afbcb0'),text='?',bd=3)
button62.grid(padx=1,pady=1,row=6,column=7)

button63 = Button(gui,bg='white',fg='#afbcb0',command=lambda:fg('#afbcb0'),text='A',width=2,bd=3)
button63.grid(padx=1,pady=1,row=6,column=8)

button64 = Button(gui,bg='#c9d2ca',command=lambda:bg('#c9d2ca'),width=2,bd=3)
button64.grid(padx=1,pady=1,row=7,column=6)

button65 = Button(gui,bg='white',fg='#c9d2ca',command=lambda:fg('#c9d2ca'),text='?',bd=3)
button65.grid(padx=1,pady=1,row=7,column=7)

button66 = Button(gui,bg='white',fg='#c9d2ca',command=lambda:fg('#c9d2ca'),text='A',width=2,bd=3)
button66.grid(padx=1,pady=1,row=7,column=8)

button67 = Button(gui,bg='#7a99ac',command=lambda:bg('#7a99ac'),width=2,bd=3)
button67.grid(padx=1,pady=1,row=8,column=6)

button68 = Button(gui,bg='white',fg='#7a99ac',command=lambda:fg('#7a99ac'),text='?',bd=3)
button68.grid(padx=1,pady=1,row=8,column=7)

button69 = Button(gui,bg='white',fg='#7a99ac',command=lambda:fg('#7a99ac'),text='A',width=2,bd=3)
button69.grid(padx=1,pady=1,row=8,column=8)

button70 = Button(gui,bg='#9bb3c1',command=lambda:bg('#9bb3c1'),width=2,bd=3)
button70.grid(padx=1,pady=1,row=9,column=6)

button71 = Button(gui,bg='white',fg='#9bb3c1',command=lambda:fg('#9bb3c1'),text='?',bd=3)
button71.grid(padx=1,pady=1,row=9,column=7)

button72 = Button(gui,bg='white',fg='#9bb3c1',command=lambda:fg('#9bb3c1'),text='A',width=2,bd=3)
button72.grid(padx=1,pady=1,row=9,column=8)

button73 = Button(gui,bg='#bcccd5',command=lambda:bg('#bcccd5'),width=2,bd=3)
button73.grid(padx=1,pady=1,row=10,column=6)

button74 = Button(gui,bg='white',fg='#bcccd5',command=lambda:fg('#bcccd5'),text='?',bd=3)
button74.grid(padx=1,pady=1,row=10,column=7)

button75 = Button(gui,bg='white',fg='#bcccd5',command=lambda:fg('#bcccd5'),text='A',width=2,bd=3)
button75.grid(padx=1,pady=1,row=10,column=8)

button76 = Button(gui,bg='#a4bcc2',command=lambda:bg('#a4bcc2'),width=2,bd=3)
button76.grid(padx=1,pady=1,row=11,column=6)

button77 = Button(gui,bg='white',fg='#a4bcc2',command=lambda:fg('#a4bcc2'),text='?',bd=3)
button77.grid(padx=1,pady=1,row=11,column=7)

button78 = Button(gui,bg='white',fg='#a4bcc2',command=lambda:fg('#a4bcc2'),text='A',width=2,bd=3)
button78.grid(padx=1,pady=1,row=11,column=8)

button79 = Button(gui,bg='#bbcdd1',command=lambda:bg('#bbcdd1'),width=2,bd=3)
button79.grid(padx=1,pady=1,row=12,column=6)

button80 = Button(gui,bg='white',fg='#bbcdd1',command=lambda:fg('#bbcdd1'),text='?',bd=3)
button80.grid(padx=1,pady=1,row=12,column=7)

button81 = Button(gui,bg='white',fg='#bbcdd1',comman

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...