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

Резултати

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

Пребарај: #feature

当前筛选 #feature清除筛选
America 🇺🇸 News & Politics

@America · Post #10074 · 08.11.2025 г., 02:31

😄Feature ➖➖➖➖➖➖ 🔘A feature is an element of something interesting or important. 🔜The number of parks is an important feature of the city. It it also used as a general label for the parts of our faces. 🔘My big nose is my least favourite feature. 🔜When we want to say what is included in something, we use feature. Often it's important that they're there. 🔘This phone features an amazing camera. 🔜Just remember, we use the word feature to talk about interesting or important things. #feature👨‍🏫@America ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Hashtags

😄Feature ➖➖➖➖➖➖ 🔘A feature is an element of something interesting or important. 🔜The number of parks is an important feature of the city. It it also used as a general label for the parts of our faces. 🔘My big nose is my least favourite feature. 🔜When we want to say what is included in something, we use feature. Often it's important that they're there. 🔘This phone features an amazing camera. 🔜Just remember, we use the word feature to talk about interesting or important things. #feature👨‍🏫@America ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Hashtags

TGhaber

@TGhaber · Post #208 · 02.03.2019 г., 15:24

Grup ve kanallarda , 'Mesaj Sabitleme' ayrıcalığına sahip olan yöneticiler, 48 saatten daha eski olan iletileri düzenleyebilir: Android ✅ Android X ✅ iOS ❌ Masaüstü ✅ macOS ✅ Webogram ❌ @Telegram#feature 02.03.2019

Hashtags

Pensive|

@PensivePost · Post #5835 · 23.06.2022 г., 18:40

I asked ! Why are you breaking my heart into pieces ? She replied ! I will make a big monument from the broken pieces of your heart , I asked ! why will you make a monument from the pieces of my broken heart ? She replied ! Because it is the symbol of unconditional love , I asked ! Then why you wanna break it ? She replied ! As , i wanna share this infinite love with whole world , © Ch.Irfan . #review #feature

Pensive|

@PensivePost · Post #5824 · 10.06.2022 г., 21:01

The last time we met The last words you Said were not just words , But bullets in my lungs . These beautiful clouds and cold Wheather , Reminds me of the moments we spent together . Celebrating first Eid in your absence , Makes me guilty for my existence. Scrolling through my WhatsApp these days, feels that life has left me no ways I always felt happy whenever we met , But now , Your name forces me to regret , Your wait compels me to forget , And , even your thoughts pierces my heart. -CH.Irfan. #review #poem #feature

Pensive|

@PensivePost · Post #5804 · 05.06.2022 г., 08:56

It was 3am back then I was laying on the bed The Mullioned windows were open The stars above in the night were gleaming Suddenly onshore breeze had started I turned off my phone and Started Thinking of a dazzling Lady I was devising a Scenario of me and the graceful Lady The scenario doesn't exist in real But, it gives peace In real It gives me the Inner endearments It gives a feeling that is forthcoming I was fully Shifted to palace with her That place was completely Magical We were creating an album of Our life And in an instant, it started Thundering I Woke up from my pleasant Dream The high wind started, The birds were Moving from one tree to another I closed my Windows Gradually Heavy Downpour started The Dream was left incomplete But I made a Smile And Thanked that period For making me contented in Today's Selfish World. #review #poem #feature

Pensive|

@PensivePost · Post #5803 · 05.06.2022 г., 04:42

The last time we met The last words you Said were not just words , But bullets in my lungs . These beautiful clouds and cold Wheather , Reminds me of the moments we spent together . Celebrating first Eid in your absence , Makes me guilty for my existence. Scrolling through my WhatsApp these days, feels that life has left me no ways I always felt happy whenever we met , But now , Your name forces me to regret , Your wait compels me to forget , And , even your thoughts pierces my heart. -CH.Irfan. #review #poem #feature

Grasscutter CN

@Grasscutter_CN · Post #41 · 18.05.2022 г., 11:51

#feature#test 试用大世界宝箱 步骤: - 1. 下载文件到服务端解压并且替换 - 3. 删除 config.json 并且运行 grasscutter-1.1.2-dev.jar - 2. 在新生成的 config.json 中设置 enableScriptInBigWorld 为 true - 4. 重新启动服务器并且进入游戏体验

Suxrob Xurramov | Blog

@suxrobblog · Post #1126 · 16.09.2025 г., 15:59

📱Figma AI orqali yangi featureʼni ishga tushirmoqda Avtomatik o‘lchamni o‘zgartirish, tarjima qilish, variantlar yaratish, shriftlarni o‘zgartirish va bularning barchasi to‘g‘ridan-to‘g‘ri kanvasda bo‘lishi va’dasi berilmoqda. Yangi featureʼlarni sinash uchun Alfa versiyasiga yozilmoqchiman. Agar qiziqarli narsa bo‘lsa, kanalimda yozaman. @suxrobblog » #figma#feature#AI

Suxrob Xurramov | Blog

@suxrobblog · Post #906 · 21.06.2025 г., 14:32

🟢Paynet uchun elektr limitini funksiyasini qo'shish uchun taklif dizayn — Shunchaki, Paynetdan foydalanganim uchun taklif sifatida chizdim) P.s. Dizayn paynet dasturining dizayn tizimiga asoslangan holda chizilgan. UI'dagi kamchiliklar ustida detalniy to'xtalmaganman. #paynet#feature » @suxrobblog

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