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

Резултати

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

Пребарај: #potential

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

@America · Post #10036 · 29.10.2025 г., 02:38

😄Potential ➖➖➖➖➖➖ 🔘 The noun potential refers to the qualities that someone or something has that may be developed and lead to future success. 🔜 He only started the job this year but he has a lot of potential. 🔜 This recipe has potential. It could be perfect if you make some small changes. 🔘 We can also use the noun potential to mean the possibility of something happening. 🔜 These chemicals have the potential to cause lung damage. 🔜 There is potential for further housing developments in the area. 🔘 Potential as an adjective can be used to describe something that could be possible if certain conditions are met. 🔜 Potential customers are waiting for the price to fall before buying it. 🔜 Be careful near the ocean! There's potential danger. #Potential👨‍🏫: @america#americanews ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Bahrom Djalilov | Blog

@bahromjon_djalilov · Post #23 · 18.01.2024 г., 09:51

#Ferghana#Potential#IT_Hub Farg'ona viloyati barhavo ob-havosi hamda tirbandsiz yo'llaridan tashqari quyidagi salohiyatga ham ega: - Aholi soni 4 mln. dan ziyod; - Universitetlar soni 13 ta, shundan 3 tasi xorijiy; - AyTi yo'nalishlari mavjud universitetlar soni 7 ta; - Yillik bitiruvchi yoshlar 16 000 nafar; - 17 000 nafardan ortiq yoshlar ingliz tilida, 7 000 dan ortiq yoshlar koreys, 3 000 dan ortig'i xitoy, 2000 dan ortig'i yapon hamda 1600 nafardan ziyod yoshlar nemis tillarini o'rganishga erishgan; - 2000 dan ziyod AyTi sohasidagi hodimlar hamda 70 dan ziyod IT Park rezident korxonalari; - 2,2 million aktiv internet foydalanuvchilarga ega. Yana qanday sohamizga oid zaruriy ma'lumotlar kerak bo'lsa doimiy aloqadabiz. O'sha gap - "Farg'ona oilasiga xush kelibsiz" deb qolaman.

Alien‘s Best Friend

@aliensbestfriend · Post #10563 · 12.03.2026 г., 08:44

Wir sind darauf konditioniert, dass wir dann belohnt werden, wenn wir uns bestmöglich anpassen. Das geht in der Erziehung los, in der Schule wird dann die Anpassung benotet und führt sich fort im gesamten systemischen Leben. Daraus ergibt sich häufig das starke Bedürfnis, anderen gefallen zu wollen oder Wert auf die Meinung anderer zu legen. Aber das ist ein Programm, das uns begrenzt. Wir sollten herausfinden, was WIR wollen, wie WIR zu uns stehen und abprallen lassen, was andere über uns denken. Dann haben wir eine größere Chance, unser Potential auszuschöpfen. Was andere denken, ist nicht Dein Problem. Es ist ihres. Alles Liebe 💜 Nathalie | Alien’s Best Friend @aliensbestfriend #Selbstwert #DeinDing #Potential #Erkenntnis

StartupBase

@startupbaseuz · Post #4702 · 26.10.2024 г., 07:36

Uzbekistan is the right place now to look for growing your business - this message was given by many distinguished panelists at International partnership initiatives week. Only this year the number of companies with foreign capital, who decided to utilize these opportunities to grow their business increased by 250! You can also get the best tax regime upuntil 2040 for ITES companies, affordable talents and low cost of starting your business with the Zero Risk programme in the regions of Uzbekistan: https://outsource.gov.uz Guest Insights: 📌Boris Tadić - former president of Serbia: "Uzbekistan is one of the most #favorable countries for business operations and investments for European companies and IT firms." 📌Raimonds Vejonis - former president of Latvia: "The extension of #benefits for IT Park residents until 2040 will increase investor #confidence." 📌Hamadoun Toure - former head of ITU: “Uzbekistan has taken the leading position in the International Telecommunication Union’s ranking for the most #affordable internet prices.” 📌Akihiro Sakurai: "Uzbekistan has the #potential to supply 300,000 young specialists to the international IT market, generating high incomes." 📌Seán McEllin: “Uzbekistan is becoming the #ideal_location for major IT companies to open their regional offices.” With its forward-looking #digitalstrategy and #commitment to innovation, Uzbekistan is emerging as a dynamic regional hub for international businesses and tech #startups alike. Exciting times ahead for #partnerships and #growth! Uzbekistan is shaping up to be a vibrant regional hub, creating countless opportunities for innovation and foreign partnerships. Follow in Linkedin: https://www.linkedin.com/in/sherzod-shermatov/ #Uzbekistan#ITES#DigitalTransformation#GlobalBusiness#Investment