python画带颜色笑脸-使用Python tkinter创建一个笑脸

1586010002-jmsa.png

Using Canvas from tkinter create the SmileyFace class. This class must have the following functions:

constructor (__init__): draws a smiley face on a canvas object.

wink(smileyFace)

grin(smileyFace)

smile(smileyFace)

sad(smileyFace)

These functions return no values. They modify the look of the SmileyFace object.

Create a main() function that will place a smiley face and five buttons on a Tk() object. The buttons will be labeled as follows:

Smile

Sad

Wink

Grin

Quit

When a button other than the Quit button is clicked, the smiley face will change its appearance according with the button clicked.

For the wink, one eye must change to a line and the grin is a straight line for the face.

What I have tried:

from tkinter import *

class SmileyFace:

def smile():

global mouth

c.delete(mouth)

mouth = c.create_arc(50, 25, 200, 75, start = 180,

extent = 180)

c.create_oval(10, 10, 200, 200, width=2, fill='blue')

#def sad():

#mouth = c.create_arc

win = Tk()

c = Canvas(win)

c.pack()

mouth = c.create_arc(50, 50, 200 ,50, extent = 180)

Button(win, text = 'Smile', command = smile).pack()

(very confused and dont know what to do)

win.mainloop()

解决方案You have been given the details of the class and the different functions. Start with the basics: create a single object that draws the smiley, and a button that will call the smile() function. Build and test your code. Once you have that working you should see how to add the other functions and their respective buttons.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值