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

Пребарај: #nos

当前筛选 #nos清除筛选
Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #211 · 15.12.2023 г., 10:44

Nothing OS 2.5.1 for Phone (2) based on Android 14 is Rolling Out 🚀 "It is to be noted that the update is rolling out in stages. This approach allows the team to monitor for any issues and ensure a smooth and stable deployment. Users on open beta 2 are much likely to get it first followed by those on 2.0.4. Don't worry if you haven't received it yet; it's on its way to you gradually." Update: (25/12/23) 2.0.4 users are finally getting the 2.5.1 stable update via OTA ⬇️ Downloads: Incremental from [ 2.0.4 | OB 2 2.5 ] > 2.5.1 | Full Ota Package has been uploaded to the Community Archive (Type #downloads in group chat. Can be found in Stock roms > full ota folder) ⚙️Offline Sideload Guide : Here 📺Official Intro : Here 🏷Tags: #NOS#A14#Official ————————————————- » VIDEO TUTORIAL : By Techticks « ————————————————- 🗒Detailed Changelogs: Customisation ✨ Redesigned a joint Home Screen and Lock Screen customisation page and improved the edit wallpaper flow for a more comprehensive view of options. 🌌 New Atmosphere wallpaper effect: Transform your background photo into a dynamic wallpaper that brings motion to colours on your home screen. A seamless transition between your lock and home screens. 🔮 New Glass wallpaper effect: Add a Glass filter to give your favourite wallpaper a unique appearance. 🎨 Introduced solid colour wallpapers for a cleaner Home Screen appearance. ⚪️ Added a monochrome colour theme in the basic colour section. Glyph Interface 📅 Glyph Progress integration for Google Calendar. Keep track of your upcoming events with a 5-minute countdown on the Glyph Interface. ⏲ Glyph Timer now supports time presets, allowing you to quickly set your desired duration. 🔓 You can now access Glyph Timer directly from the lock screen without unlocking the device. 🚀 Added an option to open the Glyph Timer popup by tapping instead of holding to accommodate for the Quick Settings widget. 💫 Added a new Glyph animation for when NFC is being used. 🔄 Improved the experience of Flip to Glyph. Gesture 💡Customisable double-press power button to quickly access a chosen feature. Just head to Settings > System > Gestures. 🤖 More Lock Screen shortcut options like: Do Not Disturb, Mute, QR code scanner, video camera. 📸 Capture screenshots quickly with a three-finger swipe gesture. ✏️ New screenshot editor and menu, allowing for more advanced editing features and quick deletions. More improvements 🌥 Optimised the experience of the Weather app and improved the notification of weather alerts. ⬅️ Refreshed the back gesture arrow visual to be more in line with Nothing’s style. 🔔 Made it possible to set ringtone and notification sound volumes separately, with an updated volume control interface. ⚙️ Updated Quick Settings layout and support to show more devices icons. 📷 Improved the stability of the camera. 👾 Enhanced overall system stability for a more reliable and smooth experience. New Widgets 🚶 Pedometer Widget: Track your daily steps directly from your home screen. Set goals and monitor your progress to stay motivated. 🎵 Media Player Widget: Displays the currently playing song. Control your music easily while on-the-move. ⏳ Screen Time Widget: Monitor and manage your daily screen time to maintain a healthy digital lifestyle. ✍️Note: - To use these new widgets, please update your Nothing Launcher and Nothing Widgets app to the latest versions available on the Play Store. - Data loss is not expected, whether you update from 2.0.4 / Open Beta 2 to 2.5.1 stable. But always keep backups if something wrong happens in rare scenarios! 🔔 Updates : @NothingPhone2Updates 🐙 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #481 · 04.12.2024 г., 16:42

🐍 Snake Game Widget is now available! A community co-creation initiative with Rapidzapper & Rahul https://play.google.com/store/apps/details?id=com.nothing.communitywidgets Note: If you're running an NOS 3.0 Beta, you may need to reboot after installation to see the new widget #Widget#Community#NOS Explore the Nothing TG Community: @Nothing_Archive

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #184 · 09.11.2023 г., 12:05

Nothing OS 2.5 Open Beta 2 | Phone (2) | Android 14 📝 Details: - Version: 2.5 Beta 2 - Type: #NOS#OBT#A14#Beta - Codename: #Pong - Released: 02/11/23 Links: ⬇️ Download : Beta tool | Beta Package (Full) | Incremental (from beta 1) | Rollback (to 2.0.4) | TG Community Archive ⚙️ Changelogs | Official Intro 🏛Nothing Community Website 📸 Screenshots 🗒To-Do List Disclaimer: - Keep checking system updates (if you are already on beta 1). - Since this is a Beta version, there’s a very small chance the test software may interfere with your data and require a factory reset. In this instance, your data will be lost. We strongly recommend backing up all your data before accessing the software. - Rollback to NOS 2.0.4 Involves data loss, backup prior proceeding - For those getting error "ENOENT" during Android 14 Beta update: Make sure you have a folder named Documents in your storage 🔔 Updates : @NothingPhone2Updates 🐙 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #173 · 11.10.2023 г., 12:26

Nothing OS 2.5 Open Beta 1 | Phone (2) | Android 14 📝 Details: - Version: 2.5 Beta 1 - Type: #NOS#OBT#A14#Beta - Codename: #Pong - Released: 07/10/23 Links: ⬇️ Download : Beta tool | Beta Package | Rollback | Gdrive 🏛Nothing Community Website (Installation & Changelogs) 📸 Screenshots 🗒To-Do List Disclaimer: - Since this is a Beta version, there’s a very small chance the test software may interfere with your data and require a factory reset. In this instance, your data will be lost. We strongly recommend backing up all your data before accessing the software. - Rollback to NOS 2.0.3 Involves data loss, backup prior proceeding - For those getting error "ENOENT" during Android 14 Beta update: Make sure you have a folder named Documents in your storage 🔔 Updates : @NothingPhone2Updates 🐙 Chat : @NothingPhone2

Nothing Phone (2) | Updates

@NothingPhone2Updates · Post #201 · 30.11.2023 г., 14:16

NothingMuchROM | Android 13 | Nothing Phone (2) Nothing OS with some handful modifications for a better experience 📝 Details: - Version: r4 (NOS 2.0.4) - Type: #ROM#NOS - Status: #Stable - Codename: #Pong - Released: 30/11/23 Links: ⬇️ Download : Here 📲 Support group : Here 👀 Visual Guide : Here (By Techticks in Hindi, use auto translate / follow visuals along with written instructions) 🏛 XDA: Here ( features and More Info ) 🏷Tags : #Stock#ROM#arter97#T ✨Changelogs: - Replaced LMKD (low memory killer daemon) from Paranoid Android. This reduces app kills by about 56%. - Removed Dirac services to avoid stock firmware bugs causing massive CPU and memory hogs. ✍️ Note: - Flash to Slot-A Only. Wont boot if you are on slot-b. (Reason > Here) 👤 Maintainer : @arter97 🔔 Updates : @NothingPhone2Updates 🐙 Chat : @NothingPhone2