python中秋快乐
时间: 2023-10-07 18:12:14 浏览: 95
在Python中,可以使用tkinter库来创建一个窗口并在窗口中显示一条信息“中秋快乐”。以下是一个示例代码:
```python
import tkinter
from turtle import *
def yes():
tkinter.messagebox.showinfo(title=‘中秋快乐’,message=“祝你中秋快乐!”)
window.quit()
window2=tkinter.Toplevel()
image=tkinter.Label(window2,image=img)
image.pack()
l1=tkinter.Label(window2,text=‘月是故乡明’, bg=‘white’, font=(‘Arial’, 12,‘bold’), width=70, height=2)
l1.pack()
turtle.setup(800,800,900,200)
turtle.speed(0)
huaban()
yuan()
neitu()
write()
window2.quit()
exit()
def no():
tkinter.messagebox.showinfo(title=‘中秋快乐’,message=“不收不行哦!”)
def write():
goto(-40,10)
turtle.color(“red”)
turtle.write(“中秋快乐”,font=(“Time”,18,“bold”))
time.sleep(2)
window = tkinter.Tk()
canvas = tkinter.Canvas(window, width = 300, height = 200)
canvas.pack()
button1 = tkinter.Button(window, text = "收下", command = yes)
button1.pack()
button2 = tkinter.Button(window, text = "不收", command = no)
button2.pack()
window.mainloop()
```
阅读全文