In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the use of Label in python, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Description
1. Label is one of the PythonTkinter tag components, which mainly displays the text and images in the specified window.
2. Inherit the Label of Widget class.
3. Only displayed text and images can be used to display one or more lines of text, and users are not allowed to modify them.
Grammar
W = Label (master,option)
Master: parent container
Options: optional, set attributes of tags in the form of key-value pairs, separated by semicolons
Example
From tkinter import * class Application (Frame): def _ _ init__ (self,master=None): # super () represents the definition of the parent class Instead of the parent object super (). _ init__ (master) self.master = master self.pack () # self.createwidget () self.createWidget () def createwidget (self): self.but1 = Button (self) self.but1 ["text"] = "add" self.but1.pack () self.but1 ["command"] = Self.addinfo def addinfo (self): messagebox.showinfo ("prompt" "added successfully") def createWidget (self): self.lab1 = Label (self,text= "this is tag 1", width = 10 self.lab2 height = 2 white bg = "pink", fg= "white") self.lab1.pack () self.lab2 = Label (self,text= "this is tag 2", width = 10 camera height = 2 Label bg = "orange", fg= "black", font= ("boldface") 30) self.lab2.pack () global photo photo = PhotoImage (file= "heart.gif") self.lab3 = Label (self,image = photo) self.lab3.pack () root = Tk () root.geometry ("400x200+200+300") root.title ("MyfirstAPP") app = Application (master=root) root.mainloop () Thank you for reading this article carefully I hope the article "what is the use of Label in python" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.