TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #381 · 23 окт.

Установить свойства виджета в PySide можно не только через соответствующие методы и конструктор класса. Можно их изменять с помощью метода setProperty по имени. btn = QPushButton("Click Me") btn.setProperty("flat", True) Это аналогично вызову btn.setFlat(True) Если указать несуществующее свойство, то оно просто создается btn.setProperty("btnType", "super") Получить его значение можно методом .property(name) btn_type = btn.property("btnType") Когда это может быть полезно? ▫️Можно просто хранить какие то данные в виджете и потом их доставать обратно widget = QWidget() widget.setProperty('my_data', 123) print(widget.property('my_data')) ▫️ Назначая эти свойства разным виджетам можно потом отличить виджеты во время итераци по ним. Например, найти все кнопки со свойством my_data="superbtn". Но ведь вместо кастомного свойства можно использовать objectName, будет тот же результат. Да, но y ObjectName есть ограничение - только строки. ▫️ Если нам потребуется не просто поиск а, например, сортировка по числу, то свойства позволяют нам это сделать. Поддерживается любой тип данных widget.setProperty('my_data', {'Key': 'value'}) widget.setProperty('order', 1) all_widgets.sort(key=w: w.property('order')) Но ведь Python позволяет всё вышеперечисленное сделать простым созданием атрибута у объекта widget.order = 1 widget.my_data = 123 Да, но я думаю что не надо объяснять почему не стоит так делать. К тому же, если у виджета нет свойства то метод .property(name) вернет None, а отсутствующий атрибут выбросит исключение. ▫️ Действительно полезное применение кастомным свойствам - контроль стилей. Здесь атрибутами не обойтись, нужны именно свойства. Дело в том, что в селекторах стилей можно указывать конкретные свойства виджетов на которые следует назначать стиль. Просто запустите этот код from PySide2.QtWidgets import * if __name__ == "__main__": app = QApplication([]) widget = QWidget(minimumWidth=300) layout = QVBoxLayout(widget) btn1 = QPushButton("Action 1") btn2 = QPushButton("Action 2") btn3 = QPushButton("Action 3", flat=True) layout.addWidget(btn1) layout.addWidget(btn2) layout.addWidget(btn3) # добавим кастомное свойство одной кнопке btn1.setProperty("btnType", "super") # добавляем стили widget.setStyleSheet( """ QPushButton[btnType="super"] { background-color: yellow; color: red; } QPushButton[flat="true"] { color: yellow; } """ ) widget.show() app.exec_() С помощью селектора мы избирательно назначили стили на конкретные кнопки. Как получить список всех кастомный свойств? Функция получения списка кастомных свойств отличается от получения дефолтных. def print_widget_dyn_properties(widget): for prop_name in widget.dynamicPropertyNames(): property_name = prop_name.data().decode() property_value = widget.property(property_name) print(f"{property_name}: {property_value}") #tricks#qt

Hashtags

Резултати

Пронајдени 31 слични објави

Пребарај: #herramienta

当前筛选 #herramienta清除筛选
BotsGram®

@botsgram_cu · Post #5063 · 28.12.2024 г., 01:38

¿Que puede hacer este bot? 🤖@siteshot_bot 📎El bot crea capturas de pantalla web Envía un enlace web y obtén una captura de pantalla de la página. • comprobar enlaces sospechosos (iploggers, sitios web de phishing, estafadores, etc.) • el bot se puede agregar a grupos #Herramienta ( Visto en: @BotsGram_Cu )

Hashtags

BotsGram®

@botsgram_cu · Post #5060 · 27.12.2024 г., 00:58

¿Qué puede hacer este bot? 🤖@ooSearchBot 📎Este bot es una extensión del motor de búsqueda nativo de Telegram. Aquí puedes buscar grupos, canales y bots activos de Telegram. Cada búsqueda te dará hasta 10 000 enlaces. Incluso puedes buscar enlaces privados y publicaciones de mensajes de Telegram. Envíame cualquier palabra clave que te interese y ¡pruébalo ahora! #Herramienta 📌Opinión personal: Una vez que lo uses, no volverás a usar el buscador nativo de Telegram. 10/10⭐️ ( Visto en: @BotsGram_Cu )

Hashtags

BotsGram®

@botsgram_cu · Post #5159 · 29.01.2025 г., 22:38

¿Que puede hacer este bot? 🤖@BHButtons_bot 📎Bot utilizado para crear publicaciones con todo tipo de botones y compartirlas en canales o grupos. También funciona en línea. Soporta texto y multimedia. #Herramienta#Edición ( Visto en: @BotsGram_Cu )

BotsGram®

@botsgram_cu · Post #5066 · 28.12.2024 г., 22:45

¿Que puede hacer este bot? 🤖@ImageResizerNewBot 📎Cambia el tamaño de las imágenes para alcanzar el tamaño de archivo o imagen deseado. #Herramienta#Edición ( Visto en: @BotsGram_Cu )

BotsGram®

@botsgram_cu · Post #5556 · 15.08.2025 г., 14:27

¿Qué puede hacer este bot? 🤖@BajarVideosBot 📎 Este es un potente bot para descargar videos de diferentes plataformas ▪️Sitios soportados: Youtube.com Facebook.com (Cuentas Publicas) TikTok.com Twitter.com Vimeo.comPinterest.com Otros Sitios #Herramienta#Descargar ( Visto en: @BotsGram_Cu )

BotsGram®

@botsgram_cu · Post #5161 · 29.01.2025 г., 22:38

¿Que puede hacer este bot? 🤖@ttloaderbot 📎El bot descarga vídeos de TikTok en la mejor calidad y sin marca de agua. #Descargar#Herramienta ( Visto en: @BotsGram_Cu )

BotsGram®

@botsgram_cu · Post #5145 · 23.01.2025 г., 23:57

¿Que puede hacer este bot? 🤖@VideoDownloadBot 📎El bot te permite descargar vídeos de TikTok, YouTube, VK, Instagram, Twitter y de otros 700 sitios. #Descargar#Herramienta ( Visto en: @BotsGram_Cu )

BotsGram®

@botsgram_cu · Post #5109 · 10.01.2025 г., 19:31

¿Que puede hacer este bot? 🤖@YtbDownBot 📎Soy YTBdownbot . Puedo descargar videos de YouTube y TikTok . El bot funciona directamente y en los chats . Agrega el bot a un grupo, luego envía el enlace del video y el bot enviará el video al chat. #Descargar#Herramienta ( Visto en: @BotsGram_Cu )

BotsGram®

@botsgram_cu · Post #5082 · 01.01.2025 г., 22:15

¿Que puede hacer este bot? 🤖@TGStoryXBot 📎Puede descargar fácilmente historias de Telegram y publicaciones archivadas de cualquier usuario en alta calidad y velocidad a través de su enlace. #Descargar#Herramienta ( Visto en: @BotsGram_Cu )

BotsGram®

@botsgram_cu · Post #5075 · 30.12.2024 г., 22:25

¿Que puede hacer este bot? 🤖@Kitefileupbot 📎Con este bot podrás descargar contenido de múltiples sitios en varios formatos y escucharlo en cualquier momento sitios web compatibles: (youtube, instagram, facebook, twitter, tiktok, likee, pinterest, snapchat). #Descargar#Herramienta ( Visto en: @BotsGram_Cu )

BotsGram®

@botsgram_cu · Post #5073 · 30.12.2024 г., 22:25

¿Que puede hacer este bot? 🤖@instaAnalysisBot 📎El bot te enviará historias de los usuarios que sigues en Instagram. Sin una VPN, de forma anónima, todas las publicaciones permanecerán en tu chat y podrás volver a ellas en cualquier momento. #Instagram#Herramienta ( Visto en: @BotsGram_Cu )

BotsGram®

@botsgram_cu · Post #5044 · 23.12.2024 г., 23:02

🤖@Pdot_ru_bot 📎chatbot GPT gratuito Características del robot: ✅ genera fotos y videos ✅ escribe códigos, textos, compone poesía ✅ trabaja con documentos ✅ reconoce lo que hay en la imagen Desarrollado por GPT-4o y DALLE #IA#Herramienta ( Visto en: @BotsGram_Cu )

ПретходнаСтраница 1 од 3Следна