Use python to make a code of what to eat today

Hello friends, eating is an essential thing for everyone every day, but sometimes you don't know what to eat.

So what I share with you today is to implement MIUI's small plug-in "What to eat today". The program is a bit crude, but it does not affect the operation.

The following figure shows the code implementation effect: 

Here is the source code:

import tkinter as tk
import random
mywindow=tk.Tk()
mywindow.title('What to eat today')
food=['yellow croaker','steak','crayfish','ice cream','tomato scrambled eggs', 'Let's lose weight','ribs','chicken stewed mushrooms','steamed hairy crab','Coke','chicken leg','pigeon','pizza','burger','french fries','chicken wings' ,'juice']

random.shuffle(food)
def mychick():
    print('eat today',food[1])
    mylab.config(text='eat today')
    mybut.config(text=food[1])
    random.shuffle(food )
    

mylab=tk.Label(mywindow,
               text='what to eat today',
               fg='yellow',bg='blue',
               font=('Arial',12),
               width=20,
               height=2
               )
mylab.pack( )
mybut=tk.Button(mywindow,
                text='click me',
                fg='blue',
                bg='yellow',
                font=('Arial',12),
                width=15,
                height=3,
                command=mychick
                )
mybut.pack()
mywindow.mainloop()

You can also add your favorite food in the food list, or make some improvements in the animation to make the program more interesting.

That's all for this article, thanks for reading this article

Guess you like

Origin blog.csdn.net/hu20100913/article/details/126392646