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

Резултати

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

Пребарај: #scale

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

@America · Post #10099 · 14.11.2025 г., 02:03

😄Scale ➖➖➖➖➖➖ 🔘 Scale is a measurement used for number and amounts. 🔜 Rate this course on a scale of 1 to 10. 🔘It can also be used to mean the size or extent of something. 🔜 They like to party on a huge scale. 🔘Scale can mean climb. 🔜 The prisoner scaled the prison wall and escaped. 🔘 Fish and reptiles have scales on their body. 🔜 I carefully removed the scales before cooking the fish. #Scale👨‍🏫@America ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Hashtags

Пример фармилки жетонов в сети TON. Это пока единственное место куда я закинул свои жетоны #SCALE в стек. Шаг 1. Свапнуть #TON на #SCALE. https://dedust.io/swap Шаг 2. Добавить в стек #SCALE. https://tonraffles.app/jetton/staking Таким образом можно 14 дней фармить жетон #RAFF. APR: 1000% на текущий момент. Не финансовый совет. Риски есть, гарантий нет.

🤔Introducing $DUST, the new name for DeDust.io token $SCALE ➡️$DUST One of the most frequent questions we've been asked in chats and personal conversations over the past year is, "Why doesn't DeDust.io have its own token yet?" and "Why is DeDust.io's token called SCALE?" A long time ago, we planned to name the exchange "Scaleton," but eventually, we came up with a better name—DeDust. While this has created some confusion, $SCALE has still become one of the most popular and well-known tokens in the ecosystem. This rebranding aims to make our token even more recognizable and widely known, improving its branding and strengthening its connection to our product. Today, we are thrilled to announce the rebranding of $SCALE to $DUST. Holders don’t need to take any action— the contract address and on-chain data will remain the same; only the name will change. We will reach out to all analytics platforms and ask them to update the token display accordingly. Additionally, we plan to highlight $DUST more prominently on the homepage of our exchange. The complete rebranding process will take some time, but in the meantime, share your thoughts on this update in the comments, and of course, tell all your frens about the update. We all knew this would happen sooner or later. Sincerely, Scaleton team #TON#DeDust#Scale#DUST

Venture Village Wall 🦄

@venturevillagewall · Post #3347 · 18.12.2024 г., 12:06

Revi Secures $500K Funding Revi has successfully raised $500K in funding as of December 4, 2024. The platform offers precise and scalable workflows for identifying, researching, and tracking M&A targets. #Funding#M&A #Startups#Investment#AI#Tech#Research#Workflows#Revi#Business#Innovation#Scalable#Tracking#Targets#Finance#Growth#Scale#Market#Analysis #2024

Venture Village Wall 🦄

@venturevillagewall · Post #3618 · 21.12.2024 г., 10:22

New Wave Biotech Secures $1.25M Investment New Wave Biotech has raised $1.25M to enhance its Bioprocess Foresight software, which aids biomanufacturing innovations in scaling processes, accelerating commercialization, and promoting sustainability. The software offers bioprocess modeling, operation simulations, and economic analysis tools to optimize biomanufacturing efficiency and sustainability. Learn more at New Wave Biotech. #Biotech#Funding#Bioprocessing#Sustainability#Software#Investment#SupplyChain#Innovation#TechAnalysis#Manufacturing#Commercialization#Scale#AnalysisTools#ProcessModeling#Downstream#TechEconomic#ProcessOptimization#GlobalSupplyChain