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

Резултати

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

Пребарај: #stability

当前筛选 #stability清除筛选
科技&趣闻&杂记

@kejiqu · Post #3443 · 18.05.2025 г., 08:20

Stability AI 发布可在移动设备上运行的紧凑型开放文本到音频模型 Stability AI 和 Arm 发布了一款在智能手机上运行的紧凑型文本转音频模型,能够在大约 7 秒内生成长达 11 秒的立体声音频片段。 该模型名为“稳定音频开放小型”(Stable Audio Open Small),基于加州大学伯克利分校等研究人员开发的“对抗相对对比”(Adversarial Relativistic-Contrastive,ARC)技术。在 Nvidia H100 GPU 等高端硬件上,它可以在短短 75 毫秒内生成 44 kHz 立体声音频,速度之快足以实现近乎实时的生成。THE DECODER 🏷#Stability#AI#文本到音频#移动设备 📢频道👥群组📝投稿

C U R V E S / Under Magnitude by Marc Fornes / THEVERYMANY The strength of #undermagnitude is achieved by 'Intensive Curvature,' which is the maximization of double #curvature across the project while constraining maximum radii. The result is a #structure that has much tighter curvature with constant change of direction, and results in more structurally performance. 'Intensive Curvature' leads to the curly, tubular branching characteristics consistent across the studio's body of work. In order to achieve structural #stability , each stripe assumes high degrees of curvature individually and high degrees of double curvature in accumulation -- amounting to extreme structural #rigidity throughout the project. #arch_shovel#archdaily

Crypto M - Crypto News

@CryptoM · Post #64619 · 09.04.2026 г., 11:35

🚀 Iranian Parliament Speaker Warns of Consequences for Ceasefire Violations On April 9, Iranian Parliament Speaker Mohammad Bagher Ghalibaf stated that any breach of the ceasefire agreement will result in clear consequences. According to BlockBeats, Ghalibaf emphasized the importance of adhering to the terms of the agreement to avoid potential repercussions. The statement underscores the significance of maintaining peace and stability in the region. #Iran#Parliament#Ceasefire#Consequences#Peace#Stability#MiddleEast

Crypto M - Crypto News

@CryptoM · Post #64966 · 10.04.2026 г., 12:33

🚀 Canada's March Unemployment Rate Matches Previous Value at 6.7% Canada's unemployment rate for March was reported at 6.7%, according to Jin10. This figure aligns with the previous month's rate and is slightly better than the anticipated 6.80%. The data suggests stability in the Canadian labor market during this period. #Canada#unemploymentrate#March2026#labor market #stability#Jin10

Crypto M - Crypto News

@CryptoM · Post #65148 · 11.04.2026 г., 12:31

🚀 Bitcoin's Stability Amid Institutional Buying and Whale Selling Bitcoin has maintained a price range between $65,000 and $73,000 over the past six weeks. According to NS3.AI, this stability is due to institutional buying counterbalancing selling activities from whales, miners, medium-sized holders, and Bhutan. U.S. spot ETFs have absorbed approximately 50,000 BTC monthly. Meanwhile, miners have sold over 19,000 BTC in the past week, and whale holdings have shifted from an annual accumulation of 200,000 BTC to a reduction of 188,000 BTC. #Bitcoin#Stability#InstitutionalBuying#WhaleSelling#NS3AI#USSpotETFs#BTC#Miners#WhaleHoldings#PriceRange#Crypto

Crypto M - Crypto News

@CryptoM · Post #64930 · 10.04.2026 г., 10:28

🚀 Finland to Restrict Nuclear Weapons Deployment During Peacetime Finland has announced plans to declare its intention not to station nuclear weapons on its territory during peacetime, despite ongoing legislative changes that would permit such a deployment. Bloomberg posted on X, highlighting Finland's strategic decision amid evolving security dynamics in the Nordic region. The move comes as Finland reassesses its defense policies in response to regional security concerns. The country's government is working on legal amendments that would enable the deployment of nuclear weapons if deemed necessary in the future. However, Finland remains committed to maintaining a nuclear-free stance during times of peace, reflecting its cautious approach to national security. This decision aligns with Finland's broader defense strategy, which prioritizes stability and peace in the region. The legislative changes are part of Finland's efforts to enhance its defense capabilities while ensuring transparency and adherence to international norms. Finland's stance on nuclear weapons deployment underscores its commitment to regional security and diplomatic engagement. #Finland#NuclearWeapons#Peacetime#DefensePolicy#RegionalSecurity#NordicRegion#NationalSecurity#Diplomacy#LegislativeChanges#NuclearFree#InternationalNorms#Stability

Venture Village Wall 🦄

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

Bay Harbor Re Secures $50M Funding Bay Harbor Re, a reinsurance firm, has announced a funding round of $50 million, set for December 13, 2024. The company focuses on delivering stability and protection tailored to meet the specific needs of its partners. #Reinsurance#Funding#Investment#BayHarborRe#FinancialServices#Insurance#Stability#Protection#Partners#BusinessDevelopment#MarketInsights#RiskManagement#Capital #2024 #Profitability#Growth#InsuranceMarket#CorporateNews#FundingRound

Venture Village Wall 🦄

@venturevillagewall · Post #3903 · 17.01.2025 г., 13:00

Market Trends Impact Developer Salaries Developers face salary stagnation as the job market grows competitive. With more candidates than job openings, mid-senior professionals find job switches yield minimal salary increases. Becoming a tech lead is rare and corporations limit hiring senior candidates. Stability may lie in entrepreneurship or pet projects instead. Consider exploring these options for long-term financial health. #JobMarket#DeveloperSalaries#Entrepreneurship#PetProject#IT#CareerGrowth#TechIndustry#EmploymentTrends#SalaryTrends#BusinessModel#Stability#Competition#JobSwitch#MidCareer#SeniorDevelopers#MarketAnalysis#ITCareers#FinancialPlanning#TechJobs#Startup#TechLeadership