current position：Home>Don't know what to eat every day? Python to tell you! Generate recipes and don't worry about what to eat every day!
Don't know what to eat every day? Python to tell you! Generate recipes and don't worry about what to eat every day!
2022-01-30 06:34:58 【Programming small code farmer】
I believe many people have such a worry , Every day when I come home from work, I think for a long time about what to do and eat today , Stir fried meat with chili , Only yesterday , Hot and sour shredded potatoes were made a few days ago ！ In short, every day I think about what to eat at home today , How do you do it? ！ If you ask me why I don't order takeout , First, the takeout may not be very clean , Don't worry about eating , Second, a lot of takeout food is too bad , Especially the powder I eat every morning , That powder shop can be opened , I might as well grab some bone soup and eat noodles in the morning ！ It's terrible , So I'll have one today. What menu did it give me , Let's just do something ！ So you don't have to think about it every day , If you can use , I can share it with you directly , The source code is at the end of the article ！
I have enough to eat , Make a recipe generator , Random generation “ Three dishes and one soup ”, Perfect solution to the difficulty of buying vegetables ~
Project brief introduction
from “ Under the kitchen ” Crawling 【 Home Dishes 】【 Kwai Chi 】【 Serve a meal 】【 Soup soup 】 The most popular of the four dishes , Save in csv file , Make an interface , Randomly generate recipes of three dishes and one soup , The recipe contains the name of the dish , The ingredients , score , Tutorial links , And display the food words cloud in the interface , User repeatable , Recipe can be generated many times ：
function ui_support.py file ：
If not satisfied , You can also click 【 eliminate 】 Button , Continue to regenerate ~
From this project , You can learn the following ：
1. Basic process of reptile
2.xpath Extract the data
3. establish , write in , Read csv
4.pandas Randomly selected data sample()
5.DateFrame To List
6.ui Generation tool page Use
7. Based on build ui Code , Add event trigger logic
8. Ci cloud production
There is one in the project file read.txt file , It also describes the module division of the project .
spider.py For crawler files , Crawling the data we need , The logic is ： establish csv, establish url Post traversal access , Extract the data , write in csv.
In the csv There is a question , Open it and it will be a mess , Set to utf8,gbk Can't work normally wps Show , But with txt Open is normal display , After testing , stay ui The interface display is normal , This is because there are some emoticons in the ingredients , Acquired csv No processing required ：
Next up ui Interface , Used page Tools to generate interface code , Refer to for the installation and configuration of this tool ：
Xiaobian, it's designed here , Just a little bit more ：
From left side “Widget Toolbar” Control bar , Select the corresponding control to the middle window , For button controls , We need to add trigger command , Click on “ generate menu ” It will run the corresponding logic .
Choose “ Menu generation ” Control , Choose again “Attribute Editor” Hurdles “Attribute” , stay “command” Write trigger function name ,“text” "tooltip" Display for text , Prompt label ：
After design , First save , The name of the saved file is ui, It is saved as ui.tcl file , Now save the interface code ：
Click the respectively “Save” Save these two files , Will be saved in and ui.tcl Same directory for .
“python GUI” It's interface logic , The saved file name is ui.py, No need to move .
“Support Module” Is the trigger event code , Our corresponding logic is to add ：
open ui_support.py , Found set “command”, Function name ：
clean Function is click 【 eliminate 】 After button , Clear text box ：
creat_menu Function is click 【 Generate recipes 】 Logic after button , from csv Randomly selected three dishes and one soup in the text box , Show word cloud in tab bar .
It is mainly ： Read csv,DataFrame Turn into list, Merge 【 Three dishes and one soup 】, Make menu text , Preservation of food words , Menu text box insert , Word cloud generation , Parenthesis cloud ：
So all the logic is done , function ui_support.py You can start the recipe generation ~
The source code for **
author[Programming small code farmer],Please bring the original link to reprint, thank you.
The sidebar is recommended
- [recalling the 1970s] using Python to repair the wonderful memories of parents' generation, black-and-white photos become color photos
- You used to know Python advanced
- Pyinstaller package Python project
- 2021 IEEE programming language rankings: Python tops the list!
- Implementation of Python automatic test control
- Python advanced: [Baidu translation reverse] graphic and video teaching!!!
- Do you know the fuzzy semantics in Python syntax?
- [Python from introduction to mastery] (XXVII) learn more about pilot!
- Playing excel office automation with Python
- Some applications of heapq module of Python module
guess what you like
Python and go languages are so popular, which is more suitable for you?
Python practical skills task segmentation
Python simulated Login, numpy module, python simulated epidemic spread
Python opencv contour discovery function based on image edge extraction
Application of Hoff circle detection in Python opencv
Python reptile test ox knife (I)
Day 1: learn the Django framework of Python development
django -- minio_ S3 file storage service
[algorithm learning] 02.03 Delete intermediate nodes (Java / C / C + + / Python / go)
Similarities and differences of five pandas combinatorial functions
- Learning in Python + opencv -- extracting corners
- Python beginner's eighth day ()
- Necessary knowledge of Python: take you to learn regular expressions from zero
- Get your girlfriend's chat records with Python and solve the paranoia with one move
- My new book "Python 3 web crawler development practice (Second Edition)" has been recommended by the father of Python!
- From zero to familiarity, it will take you to master the use of Python len() function
- Python type hint type annotation guide
- leetcode 108. Convert Sorted Array to Binary Search Tree（python）
- For the geometric transformation of Python OpenCV image, let's first talk about the extraordinary resize function
- leetcode 701. Insert into a Binary Search Tree （python）
- For another 3 days, I sorted out 80 Python datetime examples, which must be collected!
- Python crawler actual combat | using multithreading to crawl lol HD Wallpaper
- Complete a python game in 28 minutes, "customer service play over the president card"
- The universal Python praise machine (commonly known as the brushing machine) in the whole network. Do you want to know the principle? After reading this article, you can write one yourself
- How does Python compare file differences between two paths
- Common OS operations for Python
- [Python data structure series] linear table - explanation of knowledge points + code implementation
- How Python parses web pages using BS4
- How do Python Network requests pass parameters
- Python core programming - decorator
- Python Network Programming -- create a simple UPD socket to realize mutual communication between two processes
- leetcode 110. Balanced Binary Tree（python）
- Django uses Django celery beat to dynamically add scheduled tasks
- The bear child said "you haven't seen Altman" and hurriedly studied it in Python. Unexpectedly
- Optimization iteration of nearest neighbor interpolation and bilinear interpolation algorithm for Python OpenCV image
- Bilinear interpolation algorithm for Python OpenCV image, the most detailed algorithm description in the whole network
- Use of Python partial()
- Python game development, pyGame module, python implementation of angry birds
- leetcode 1104. Path In Zigzag Labelled Binary Tree（python）
- Save time and effort. 10 lines of Python code automatically clean up duplicate files in the computer
- Learn python, know more meat, and be a "meat expert" in the technical circle. One article is enough
- [Python data structure series] "stack (sequential stack and chain stack)" -- Explanation of knowledge points + code implementation
- Datetime module of Python time series
- Python encrypts and decrypts des to solve the problem of inconsistency with Java results
- Chapter 1: introduction to Python programming-4 Hello World
- Summary of Python technical points
- 11.5K Star！ An open source Python static type checking Library
- Chapter 2: Fundamentals of python-1 grammar
- [Python daily homework] day4: write a function to count the number of occurrences of each number in the incoming list and return the corresponding dictionary.
- Python uses turtle to express white