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

Резултати

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

Пребарај: #company

当前筛选 #company清除筛选
NEWS 鏈新聞-ABMedia

@abmedia_news · Post #24168 · 27.04.2026 г., 13:31

【🚀 AI 人工智慧|YC 合夥人分享如何用 AI 從頭開始建立公司,新創應將 AI 當作業系統而非工具 】 #AI#Company#YC 📍 請見報導: https://abmedia.io/yc-partner-building-ai-native-company 📍 訂閱鏈新聞頻道:https://linktr.ee/abmedia.io

🇺🇿Biznes va tadbirkorlik oliy maktabi tinglovchilari ishonchlilik va samaradorlik bo‘yicha yetakchi sifatida e’tirof etilgan maishiy texnika ishlab chiqaruvchi “Artel” kompaniyasiga tashrif buyurishdi. 🏙 Kompaniyada nafaqat ishlab chiqarish faoliyati, shuningdek, kompaniyaning operatsion jarayonlari va uning strategik maqsadlari bilan ham yaqindan tanishdilar. #GraduateSchool#Artel#Technology#Company 🔝Web-site |🔝Facebook | 🔝Instagram | 🔝Youtube

Art Photo Projects

@artphotoproject · Post #72 · 04.01.2023 г., 19:51

📣🥁Celebration Shooting Day! 27 February 2023 Very important day for me as art-director!! Our 5 year of official existence as Art Photo Projects is going to be a big shooting party at a gorgeous royal location ❤️😍 in The Netherlands. 👑We reserved ALL rooms for 8 hours long in a castle Slot Zeist for you. 👑You can join as #model#photographer#designer#company and shoot together what you like. 👑Experience is NOT mandatory. it's an extremely unique chance to use location and boost your portfolio with amazing results 😀 👑We will bring dresses and props from Holland Dress Rental and we will work with our best team. 💎Entrance is 195 pp inclusive taxes. EARLY BIRD IS ON WEBSITE NOW https://www.artphotoprojects.world/event-details/slot-zeist-castle-portfolio-shooting-day-all-rooms 💎Places are limited, because we don't want chaos and rush, we want comfortable collaborations. 💎Only this day ANY style can be shot, even wedding. However entry counts for every model/photographer place. Assistance can join free. 💎Interested ? See link and claim your spot immediately.

Startup: A Primer A startup is a company designed to grow fast. Being newly founded does not in itself make a company a startup. Nor is it necessary for a startup to work on technology, or take venture funding, or have some sort of "exit." The only essential thing is growth. Startups are so hard that you can't be pointed off to the side and hope to succeed. You have to know that growth is what you're after. The good news is, that if you get growth, everything else tends to fall into place. This means you can use growth like a compass to make almost every decision you face. #Monday#Day -1 #Startup#Business#Entrepreneur#Marketing#Founders#Company Read :- https://t.me/startup_Unicon_EdusCommunity

Venture Village Wall 🦄

@venturevillagewall · Post #3415 · 18.12.2024 г., 12:11

Turn Therapeutics Secures $75M Funding Turn Therapeutics, specializing in advanced wound and dermatologic care, has raised $75 million in funding. The investment aims to boost their innovative pharmaceutical and medical device offerings using proprietary technology. For more details, visit their website: Turn Therapeutics. #Funding#Biotech#Healthcare#Pharmaceuticals#MedicalDevices#WoundCare#Dermatology#Investment#Innovation#Technology#TurnTherapeutics#Proprietary#AdvancedCare#Medical#Company#Therapeutics#Research#Development#Startups