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 слични објави

Пребарај: #gdpgrowth

当前筛选 #gdpgrowth清除筛选

አይ ኤምኤፍ የ2026 የኢኮኖሚ ዕድገት ትንበያውን ይፋ አደረገ፤ ኢትዮጵያ በከፍተኛ ዕድገት ቀዳሚነቱን ይዛለች ************************** ዓለም አቀፉ የገንዘብ ድርጅት (IMF) በአውሮፓውያኑ 2026 የሰሃራ በታች አፍሪካ ሀገራትን የኢኮኖሚ ዕድገት ትንበያ ይፋ አድርጓል። በዚህ ትንበያ መሠረት ኢትዮጵያ በ9.2 በመቶ ከፍተኛ ዕድገት በማስመዝገብ ከቀጣናው ሀገራት ቀዳሚነቱን እንደምትይዝ ተመልክቷል። እንደ አይኤምኤፍ ሪፖርት፣ ኡጋንዳ በ7.5 በመቶ፣ ሩዋንዳ በ7.2 በመቶ እንዲሁም ቤኒን በ7.0 በመቶ ዕድገት እንደሚያስመዘግቡ ተተንብዮላቸዋል። በሌላ በኩል እንደ ናይጄሪያ (4.1 በመቶ) እና ደቡብ አፍሪካ (1.0 በመቶ) ያሉ የክፍለ አህጉሩ ግዙፍ ኢኮኖሚዎች ዝቅተኛ የዕድገት ትንበያ ተቀምጦላቸዋል። በመካከለኛው ምስራቅ ያለው ግጭት የነዳጅ እና የማዳበሪያ ዋጋን በመጨመር በበርካታ ሀገራት ላይ የኢኮኖሚ ጫና ቢፈጥርም፣ እንደ ኢትዮጵያ ያሉ ሀገራት ግን አሁንም ጠንካራ የኢኮኖሚ እንቅስቃሴ እንደሚያሳዩ የአይኤምኤፍ ትንበያ ያመላክታል። #IMF#EconomicProjections#Africa#Ethiopia#GDPGrowth#EBC

Crypto M - Crypto News

@CryptoM · Post #64524 · 09.04.2026 г., 06:06

🚀 Thailand's Central Bank Governor Projects GDP Growth for 2026 Thailand's Central Bank Governor has projected the country's GDP growth rate to be between 1.3% and 1.7% in 2026. According to Jin10, this forecast reflects the economic outlook for Thailand as it navigates various domestic and international challenges. The central bank's projection aims to provide guidance for policymakers and investors as they plan for the future economic landscape. #Thailand#CentralBank#GDPgrowth#economicoutlook #2026 #policy#investors

Crypto M - Crypto News

@CryptoM · Post #65385 · 13.04.2026 г., 03:45

🚀 Indonesia's Central Bank Projects 5.2% GDP Growth in Q1 Indonesia's central bank has projected a GDP growth rate of 5.2% for the first quarter, according to Jin10. This forecast reflects the country's economic outlook as it navigates various domestic and international challenges. The central bank's projection aligns with efforts to maintain economic stability and growth amid global uncertainties. The anticipated growth rate is seen as a positive indicator for Indonesia's economic performance in the early part of the year. #Indonesia#CentralBank#GDPGrowth#EconomicForecast#Q12026#EconomicStability#GlobalEconomy#EconomicOutlook

Crypto M - Crypto News

@CryptoM · Post #65152 · 11.04.2026 г., 13:10

🚀 AI TRENDS | Faster AI Progress May Impact U.S. Labor Force Participation by 2050 A recent study conducted by multiple universities suggests that accelerated advancements in artificial intelligence could significantly affect U.S. labor force participation. According to NS3.AI, the research predicts a decline from 62% to 54% by 2050 under a rapid AI development scenario. This scenario also anticipates an annual GDP growth rate of 3.5% between 2045 and 2049. The focus of the debate has shifted to whether AI will generate sufficient new employment opportunities to counterbalance the displacement of existing jobs. #AI#AItrends#USlaborforce#AIdisplacement#GDPgrowth#laborforceparticipation #2050 #futureofwork

Crypto M - Crypto News

@CryptoM · Post #65391 · 13.04.2026 г., 04:34

🚀 Middle East Conflict Could Severely Impact Australia's Economy, Expert Warns Calculations and analyses are currently underway regarding the potential impact of the ongoing Middle East conflict on Australia's fuel prices and economic growth. According to Jin10, David Rumbens, a partner at Deloitte Access Economics, has stated that the worst-case scenario would severely affect Australia. A prolonged conflict could drive oil prices up to $175 per barrel, with inflation rates reaching 7.5% by the end of the year. The ultimate outcome could see Australia's unemployment rate rise to 6.8%, while the GDP growth rate could decline by 2.8%. Notably, none of the proposed scenarios indicate an unemployment rate below 5.0%. #MiddleEastConflict#AustraliaEconomy#FuelPrices#EconomicGrowth#Inflation#Unemployment#GDPGrowth#OilPrices#DavidRumbens#DeloitteAccessEconomics

Crypto M - Crypto News

@CryptoM · Post #64907 · 10.04.2026 г., 08:51

🚀 Austrian Economic Institutes Lower Growth Forecasts Amid Iran Conflict Impact On April 10, two major Austrian economic research institutes announced that the ongoing conflict in Iran is threatening Austria's economic recovery in 2026. According to Jin10, the Institute for Advanced Studies (IHS) has revised its growth forecast for Austria's economy in 2026 down to 0.5% and in 2027 to 0.8%, from previous estimates of 1.0% and 1.1%, respectively. The revision is attributed to soaring energy prices and increased uncertainty. Similarly, the Austrian Institute of Economic Research (WIFO) has adjusted its GDP forecast, projecting growth between 0.2% and 1.1% for 2026, and between 0.4% and 1.5% for 2027, down from earlier predictions of 1.2% and 1.4%. WIFO noted that the current uncertain international environment complicates forecasting efforts. WIFO also anticipates Austria's inflation rate to range between 2.5% and 4.1% in 2026, and between 2.2% and 3.5% in 2027. Meanwhile, IHS forecasts this year's inflation rate at 2.9%, with a decrease to 2.4% in 2027. #Austria#economicforecast#Iranconflict#energyprices#GDPgrowth#inflation#IHS#WIFO#economicrecovery#2026growth#2027forecast#internationaluncertainty