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

Резултати

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

Пребарај: #tradingbots

当前筛选 #tradingbots清除筛选
SLEX NEWS

@slex_io · Post #69 · 19.07.2023 г., 12:32

🚀Are you ready to elevate into a crypto trading game?🤖 SLEX will bring an array of bots designed to supercharge your trading strategies and maximize your profits. Let us introduce to you the different types of SLEX trading bots: 1️⃣ Grid Bot: This intelligent bot follows a buy-low, sell-high approach by strategically placing orders at predefined price intervals 🌊📈📉 2️⃣ Arbitrage Bot: Say hello to the Arbitrage Bot, which hunts for pricing inefficiencies and swiftly executes trades to exploit them 💸💱 3️⃣ DCA Bot: The DCA Bot allows you to gradually build your crypto position over time by spreading out your orders at regular intervals📉🔄📈 4️⃣ AI Bot: Experience the future of trading with our AI Bot, which executes trades, identifies patterns, and develops robust trading strategies 🤖📊 👉Open the window to the future with the prospects of SLEX trading bots: SLEX.io/registration #SLEX#TradingBots#CryptoTrading#AutomatedTrading Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter

SLEX NEWS

@slex_io · Post #73 · 01.08.2023 г., 13:32

🚀 Hello, SLEXians! 🤖As you already know SLEX platform will launch an Automatic Trading Feature along with AI-Powered Trading Bots! 💻Trading around the clock, analyzing market trends, executing trades, and even learning from market shifts – that's what our Automatic Trading Feature ensures. 🤔But we're curious... What's your trading style? Are you ready to use Trading Bots and AI? Or do you prefer a hands-on approach to navigating the crypto world? 🌊 Jump into the comments and let us know! 🗣️ We're excited to hear how you plan to use (or not use) these advanced features on the SLEX platform! 💬👥 #SLEX#CryptoTrading#AutomatedTrading#AI#TradingBots Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter

Crypto M - Crypto News

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

🚀 Crypto Sector Performance: MVB Leads Gains, Moltbook & OpenClaw Theme Declines The cryptocurrency market witnessed varied sector performances recently, with MVB emerging as the top rising sector, recording a 38.54% increase. According to NS3.AI, the Moltbook & OpenClaw Theme sector experienced the most significant decline, falling by 18.56%. Additionally, Trading Bots saw a notable rise of 30.41%, while Solana Token-2022 decreased by 8.27%. These fluctuations highlight the dynamic nature of the crypto market, with sectors experiencing both gains and losses. #Crypto#CryptocurrencyMarket#MVB#Moltbook#OpenClaw#TradingBots#Solana#OPN