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

Резултати

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

Пребарај: #tashkentevents

当前筛选 #tashkentevents清除筛选
GAMEFEST.UZ

@gamefestuz · Post #274 · 07.04.2026 г., 05:08

O‘zbekiston o‘yin sanoati tarixida yangi sahifa! Biz Game Fest 2026 doirasida navbatdagi maxsus mehmonimizni e’lon qilishdan faxrlanamiz. 🌍HOMA GAMES — ENDI TOSHKENTDA! Homa Games - bu dunyo miqyosidagi mobil o‘yinlar nashriyoti (publisher) bo‘lib, ularning portfelidagi o‘yinlar 1 milliarddan ortiq marta yuklab olingan! Ular "Hyper-casual" va "Hybrid-casual" yo‘nalishlarida dunyo yetakchilari hisoblanadi. Nega bu siz uchun muhim? 📌 Direct Pitching: O‘z o‘yiningizni dunyodagi eng kuchli nashriyotlardan biriga shaxsan taqdim etish imkoniyati. 📌 Market Insights: Homa Lab texnologiyalari va o‘yinlarni global darajaga olib chiqish sirlari haqida eksklyuziv bilimlar. 📌 ScaleUp: Loyihangizni jahon bozoriga olib chiqish va investitsiya jalb qilish uchun eng qisqa yo‘l. Creative Tech va Game Fest 2026 - bu shunchaki festival emas, bu sizning global karyerangiz boshlanish nuqtasidir. 📅Sana: 2026-yil, 15-16 may 📍Manzil: Renaissance Hall, Toshkent 🏛Tashkilotchi: O‘zbekiston Kreativ uyushmasi 🚀O‘z o‘yiningizni dunyoga ko‘rsatishga tayyormisiz?🌐 Batafsil va ro‘yxatdan o‘tish: CreativeTech.uz 📢 Kanalimiz: @creative_tech_official 📞 Aloqa: +998-95-474-19-19 ————————— A New Chapter for Uzbekistan’s Gaming Industry! 🚀🎮 We are thrilled to announce our next special guest for Game Fest 2026 ! Join us as we welcome a global powerhouse to Tashkent: 🌍 HOMA GAMES — NOW IN UZBEKISTAN! Homa Games is a world-class mobile games publisher with over 1 billion downloads across their portfolio. They are undisputed global leaders in the "Hyper-casual" and "Hybrid-casual" sectors. Why is this a game-changer for you? 📌 Direct Pitching: A rare opportunity to present your game personally to one of the world’s most influential publishers. 📌 Market Insights: Gain exclusive knowledge on Homa Lab technologies and the secrets to scaling games to a global audience. 📌 ScaleUp & Funding: The fastest route to taking your project to the international market and securing professional backing. Creative Tech & Game Fest 2026 is more than just a festival—it is the launchpad for your global career. 📅 Date: May 15-16, 2026 📍 Venue: Renaissance Hall, Tashkent 🏛 Organizer: Uzbekistan Creative Association 🚀 Ready to show your game to the world? 🌐 Details & Registration: CreativeTech.uz 📢 Follow us: @creative_tech_official 📞 Contact: +998-95-474-19-19 #GameFest2026#HomaGames#GamedevUzbekistan#CreativeTech#AnimationUz#GameDev#TashkentEvents

Yoshlar Markazi | Ziyo Forum

@YouthCenterZiyo · Post #293 · 24.05.2024 г., 07:32

Hey ziyocommunity fam! ✌️ On May 23rd, we had an incredible event with the legendary Professor Randall Abate from George Washington University! 🌎📚 He shared his extensive knowledge on climate change governance and how nations tackle this global issue. 🚀 Check out these amazing photos from the event and relive the moments of enlightenment! 📸✨ @YouthCenterZiyo #ZiyoCommunity#ZiyoForum#YouthCenter#TerritoryOfYourDevelopment #EcoHub#ClimateChange#TashkentEvents#ProfessorAbate#YouthEngagement

GAMEFEST.UZ

@gamefestuz · Post #272 · 06.04.2026 г., 10:21

Kokko - Game Fest 2026 da! 🎮✨ O‘yin sanoati va animatsiya olamining eng kutilgan voqeasiga tayyormisiz? Bizda ajoyib yangilik bor! O‘zining kreativ loyihalari bilan tanilgan Kokko studiyasi bu yilgi Game Fest 2026 festivalida ishtirok etadi. Bu - soha mutaxassislari, geymerlar va vizual san’at ishqibozlari uchun haqiqiy bayram bo‘ladi. Festivalda bizni nimalar kutyapti? Kokko studiyasining eng so‘nggi loyihalari taqdimoti; 🔹 Animatsiya va Gamedev olamidagi yangi trendlar; 🔹 Sanoat yetakchilari bilan networking va tajriba almashish. 🗓Sana: 15-16 may, 2026-yil 📍Manzil: Renaissance Hall, Toshkent O‘tkazib yubormang! Biz bilan birga o‘yinlar va animatsiya olamiga sho‘ng‘ing. 🚀 ———————— O‘tkazib yubormang! Biz bilan birga o‘yinlar va animatsiya olamiga sho‘ng‘ing. 🚀 #GameFest2026#Kokko#GamedevUz#Animation#TashkentEvents#CreativeEconomy#KokkoStudio Kokko at Game Fest 2026! 🎮✨ Are you ready for the most anticipated event in the gaming and animation industry? We have some exciting news to share! Kokko Studio , renowned for its creative projects, is officially joining Game Fest 2026 . This is going to be a true celebration for industry professionals, gamers, and visual arts enthusiasts alike. What can you expect at the festival? 🔹 Presentation of the latest projects from Kokko Studio; 🔹 Insights into the newest trends in Animation and GameDev; 🔹 Exclusive networking and knowledge sharing with industry leaders. 🗓 Date: May 15-16, 2026 📍 Venue: Renaissance Hall, Tashkent Don’t miss out! Come and dive into the world of gaming and animation with us. 🚀 #GameFest2026#Kokko#GamedevUz#Animation#TashkentEvents#CreativeEconomy#KokkoStudio#GameDev#DigitalArts