Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to design a multi-functional office gadget

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use Python to design a multi-functional office gadget". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use Python to design a multi-functional office gadget.

UI typesetting layout

The home page divides different interfaces into pages, as well as minimizing, maximizing, and turning off functions.

The direct page of the application and web page is composed of simple buttons, front and back alignment, left and right alignment.

Weather query bar, with a simple "button, input box, label box" composition.

The interface beautification uses the element of "illustration", because putting a whole photo will not only fill the whole interface, but also very ugly.

The Design idea of graphical Interface

Graphical interface I use Python comes with the tkinter library, I think the graphical interface learning is not difficult, when you are skilled, you will find that he is a "window + widget + function" of a process, window for our further design to provide a good "container", components for our implementation of the function to lay the "foundation", and the function is our trigger through the button to achieve the "function".

Implement step interface layout from tkinter import * from tkinter import messageboxfrom tkinter import ttkimport osimport webbrowserimport urllib.request # send network request Get data import gzip # Compression and decompression module import json # parse the data import tkinter as tkimport randomfrom PIL import Image, ImageTkimport globimport shutil TOP6 = Tk () TOP6.geometry ("630x775") TOP6.iconbitmap ('Ningning Icon tool .ico') # specify icon TOP6.title ('Ningning Little Assistant') tab_main=ttk.Notebook (TOP6) # create paging bar tab_main.place (relx=0, rely=0, width=630, height=774) tab1=Frame (tab_main,width=400 Height=300) # create the first page frame tab1.place (tab1,text=' Learning ⚡ Newsletter') # insert the first page into the paging bar image1 = Image.open ('Card Payment_Outline (1). Png') pyt1 = ImageTk.PhotoImage (image1) label2 = Label (tab1, image=pyt1) label2.place (Xerox) image2 = Image.open (' CPU_Two Color.png') pyt2 = ImageTk.PhotoImage (image2) label2 = Label (tab1, image=pyt2) label2.place Yellow100) image3 = Image.open ('AR_Outline.png') pyt3 = ImageTk.PhotoImage (image3) label2 = Label (tab1, image=pyt3) label2.place (tab1, fg='black',bd=5, text= "ℒ QQ", width = 20 command = QQ, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (xylene 30jin50) BUTTON = Button (tab1, bd=5, fg='black',text= "ℒ Wechat", width = 20) Command = WeChat, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (Xero380 Magnum 50) BUTTON = Button (tab1, fg='black', bd=5, text= "✎ AE", width = 10 Button command = AE, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (Xanth450 Magnum 200) BUTTON = Button (tab1, fg='black', bd=5, text= "✎ PR", width = 10 Command = PR, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (tab1 250, fg='black', bd=5, text= "✎ clip") BUTTON = Button (tab1, fg='black', bd=5, text= "✎ cut", width = 10 command = jian_ying, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (xylene 50, Art 200) BUTTON = Button (tab1, fg='black', bd=5, text= "✎ WPS") Width = 10 ✎ command = WPS, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (xhammer 50 Eng 280) BUTTON = Button (tab1, fg='black', bd=5, text= "✎ clip", width = 10 dagger command = jian_ying, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (xylene 250 dint 280) BUTTON = Button (tab1, fg='black', bd=5) Text= "✎ Baidu Network disk", width = 10 Magi command = wangpan, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (x = tab1, fg='black', bd=5, text= "✎ BiBili") BUTTON = Button (tab1, fg='black', bd=5, text= "Baidu BiBili", width = 10 pari command = bili, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (x = Button 450 prime280) BUTTON = Button (tab1, fg='black') Bd=5, text= "✎ Baidu C", width = 10 Magi command = baidu, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (Xuan 250 Magi Yue 360) BUTTON = Button (tab1, fg='black', bd=5, text= "✎ Learner", width = 10 Magi command = xue_tong, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (Xerox 50) ) BUTTON = Button (tab1, fg='black', bd=5, text= "✎ Hunan University Education", width = 10 Magi command = xiangda, font= ("boldface", 14)) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (row=5, column=0, sticky=W) BUTTON = Button (tab1, fg='black', bd=5, text= "QQ Game", width = 10, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place ) BUTTON = Button (tab1, fg='black', bd=5, text= "NetEyun Music", width = 10, font= ("boldface", 14)) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (Xerox 50 department Yanz500) BUTTON = Button (tab1, fg='black', bd=5, text= "Tencent Video", width = 10, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (Xerox 450) Row=5 500) BUTTON = Button (tab1, fg='black', bd=5, text= "iqiyi", width = 10, font= ("boldface", 14) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (tab2=Frame (tab_main) tab2.place) tab_main.add (tab2,text=' Weather Assistant') image4 = Image.open ('Weather_Isometric.png') pyt4 = ImageTk.PhotoImage (image4) label2 = Label (tab2, image=pyt4) label2.place Yellow0) size_str=StringVar () habits = tk.LabelFrame (tab2, text= "compared to the blue sky I prefer Yang dish ", padx=0, pady=0) # level The margins in the vertical direction are all 10habits.place (xonal 45) habits_Window = Label (habits,textvariable=size_str, width=60, height=15, font= ('italic', 13)) habits_Window.grid () label1 = StringVar () input_name = Label (tab2, text=' ☼☁❅, please enter the city you want to query ☼☁❅', font= ('italic', 14). Place (xylene 160, yearly 20) entry = Entry (tab2, bg='#ffffff', width=20, textvariable=label1, font= ('italic') (13) .place (tab2,fg='#696969', text= 223, yellow72) right_data_button = Button (tab2,fg='#696969', text= "under C", width = 10 command = show_data, font= ('boldface', 13)) .place (Xerox 260,125) tab3=Frame (tab_main) tab3.place (Xerox 200 Art Yidong 30) tab_main.add (tab3,text=' files ✪ finishing') BUTTON = Button (tab3, fg='#696969', bd=5, text= "Desktop filing", width = 20 command = zhengli Font= ("boldface", 14)) BUTTON.grid (row=5, column=0, sticky=W) BUTTON.place (Xuan 200menyang50) TOP6.mainloop ()

Direct function

-Application Direct

Def QQ (): def open_app (app_dir): os.startfile (app_dir) if _ _ name__ = "_ _ main__": app_dir = r'"C:\ Program Files (x86)\ Tencent\ QQ\ Bin\ QQScLauncher.exe" 'open_app (app_dir)

You just need to replace the link in "app_dir = 'link". Let me tell you how to get the target location of the native application.

First of all, left-click to apply "Properties", find the "Target" in the "Shortcut" column, and paste the path completely.

-webpage direct access

Def xue_tong (): webbrowser.open ('http://passport2.chaoxing.com/login?fid=&newversion=true&refer=http%3A%2F%2Fi.chaoxing.com')

Just replace the link in "webbrowser.open ()."

Weather function

"I prefer Yang cuisine to blue sky."

Def show_data (): # shows data my_heart= ['it's so nice to meet you','I just want to meet you on a sunny or rainy day','I just want to see you again', 'wherever you are, I'll try my best to see you','I never knew there were so many people longing for the blue sky', '100% sunny girls?' That summer, we in that sky completely changed the appearance of the world. The weather is really incredible and the appearance of the sky alone is very touching.' Thank you for finding the meaning of my existence. Life is not plain sailing. There are always tribulations ahead. We should learn to be strong and work hard to live in this world. When I meet you, I have to rely on you and understand the value of existence. Thank you for your company. Sometimes there are dark clouds on the horizon, and the clouds are very thick, the sun comes out and the human eye cannot see it, but the light emitted by the sun in the dark clouds, through the tight encirclement of the black clouds, the black clouds are inlaid with a glowing gilt.' Later, the sun slowly burst out of the encirclement and appeared in the sky. The black clouds were even dyed purple or red. At this time, not only the sun, clouds and sea water, but also myself became bright.'] Index= random.randint (0Len (my_heart)-1) size_content = my_ heartbeat [index] size_str.set (size_content) city_name1 = get_city_name1 () url1 = 'http://wthrcdn.etouch.cn/weather_mini?city='+urllib.parse.quote(city_name1) url2 =' http://wthrcdn.etouch.cn/weather_mini?citykey=101010100' # URL 1 only need to enter the city name URL 2 needs to enter the city code # print (url1) weather_data = urllib.request.urlopen (url1). Read () # read web page data weather_data = gzip.decompress (weather_data) .decode ('utf-8') # decompress web page data weather_dict = json.loads (weather_data) # convert json data to dict data if weather_dict.get (' desc') = = 'invilad -citykey': print (messagebox.askokcancel ("prompt") "you entered the wrong city name. Or your city is not included in the weather center ") else: forecast = weather_dict.get ('data'). Get (' forecast') # get data block root1=Tk () # pair window root1.iconbitmap ('Ningning Icon tool .ico') # specify icon root1.geometry ('650x280') # modify window size root1.title (city_name1 + 'weather condition Case') # window title # set date list for i in range (5): # put the data for each day in the list LANGS = [(update [I] .get ('date')) Date), (str [I]. Get ('fengxiang'),' wind direction'), (str (wind [I]. Get ('wind)),' wind scale'), (low' [I]. Get ('high'),' highest temperature'), (wind [I]. Get ('wind) 'lowest temperature'), (group [I]. Get ('type'),' weather')] group = LabelFrame (root1,text = 'weather condition', padx= 0) # frame group.pack (padx=11,pady=0,side = LEFT) # place frame for lang, value in LANGS:# put data into the frame c = Label (group) Text = value +':'+ lang) c.pack (anchor = W) Label (root1,text = 'Today' + weather_dict.get ('data'). Get (' ganmao'), fg = 'green') .place (the weather is reversed because of you, the world is fine because of you. , fg = "green", bg = "yellow") .place ()

Realization of Random copy selection through random function

My_heart= ['it's so nice to meet you','I just want to meet you in sunny or rainy days','I just want to see you again', 'wherever you are, I will try my best to see you','I never knew there were so many people longing for the blue sky', '100% sunny girls?' That summer, we in that sky completely changed the appearance of the world. The weather is really incredible and the appearance of the sky alone is very touching.' Thank you for finding the meaning of my existence. Life is not plain sailing. There are always tribulations ahead. We should learn to be strong and work hard to live in this world. When I meet you, I have to rely on you and understand the value of existence. Thank you for your company. Sometimes there are dark clouds on the horizon, and the clouds are very thick, the sun comes out and the human eye cannot see it, but the light emitted by the sun in the dark clouds, through the tight encirclement of the black clouds, the black clouds are inlaid with a glowing gilt.' Later, the sun slowly burst out of the encirclement and appeared in the sky. The black clouds were even dyed purple or red. At this time, not only the sun, clouds and sea water, but also myself became bright.'] Index= random.randint (0Len (my_heart)-1) size_content = my_ heartbeat [index] size_str.set (size_content)

Thank you for reading, the above is the content of "how to use Python to design a multi-functional office gadget". After the study of this article, I believe you have a deeper understanding of how to use Python to design a multi-functional office gadget, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report