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

Резултати

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

Пребарај: #microservices

当前筛选 #microservices清除筛选
Go

@golang · Post #40 · 17.02.2018 г., 22:40

Very interesting article calls “From monoliths to microservices: an architectural strategy.” The structure of this post: - Adopting Microservices; - Microservices Architectural Patterns; - Architectural & Implementation Considerations; - Developer Productivity During Microservices Adoption; #architecture#development#microservices https://thenewstack.io/from-monolith-to-microservices

Go

@golang · Post #38 · 12.02.2018 г., 19:51

The article by Paul Dix calls “The Decomposable Monolith: Long Live the Monolith, Long Live Services!” Code examples are available but without a code highlighting 🙂 #architecture#development#microservices https://www.influxdata.com/blog/decomposable-monolith-long-live-monolith-long-live-services/

Go

@golang · Post #31 · 31.01.2018 г., 20:13

Great article about the architecture inside of Golang microservice, based on the Bob's Clean Architecture Concept (https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html) Main points: Your GoLang microservice has 4 layers: - Models, data structures, and their methods; - Repository, the provider of DB operations and data management, - Usecase for business logic implementation; - Delivery, protocol, and algorithms for message handling (HTTP, gRPC, etc). Each layer should be independent and be available for mocking, for internal communications between application layers. An example project here: https://github.com/bxcodec/go-clean-arch Full article on the Hackernoon website: https://hackernoon.com/golang-clean-archithecture-efd6d7c43047 #development#microservices#architecture

Go

@golang · Post #37 · 11.02.2018 г., 15:25

How can we track our microservice activity and monitor some processes inside of the service? The Prometheus can helps us in it: the next following article discovers an step-by-step flow for set up, configure and usage this excellent product: #development#microservices#monitoring https://www.google.ru/amp/s/blog.alexellis.io/prometheus-monitoring/amp/

Go

@golang · Post #23 · 25.01.2018 г., 20:13

Are you a beginner in GoLang? Then it requires your attention 🙂. Good and simple for understanding article about microservice-based API development; just simple and work solution with code examples and couple of advices #development#microservices#architecture#practice https://medium.com/@thedevsaddam/build-restful-api-service-in-golang-using-gin-gonic-framework-85b1a6e176f3?source=linkShare-b636419a57de-1516910445

Go

@golang · Post #19 · 22.01.2018 г., 21:32

Do you think about gRPC usage? Here is a great post about step-by-step guide to gRPC framework development. You’ll find here code examples, theory introductions and useful tips. Enjoy learning! 🙂 #manual#development#microservices#examples https://medium.com/@shijuvar/building-high-performance-apis-in-go-using-grpc-and-protocol-buffers-2eda5b80771b?source=linkShare-b636419a57de-1516656055

Go

@golang · Post #28 · 28.01.2018 г., 20:33

Interesting step-by-step guide about design and development API with Docker containers, Swarm cluster and Traefik (HTTP reverse proxy and load balancer). In this article you’ll know how to configure the Traefik in the Docker environment with 3 following nodes: one manager and two workers #architecture#configuration#docker#microservices https://hackernoon.com/architecting-a-highly-scalable-golang-api-with-docker-swarm-traefik-875d1871cc1f?source=linkShare-b636419a57de-1517171008

Go

@golang · Post #18 · 22.01.2018 г., 11:56

Up-to-date article about data-stream processing: Apache Kafka, microservices, JVM to GoLang migrations, ES & Cassandra. What they did when they got 6x traffic increasing in 6 month #design#cases#microservices#scalability https://medium.com/@magicpineng/in-depth-look-at-a-scalable-robust-data-stream-processing-pipeline-using-golang-processing-500k-9e68310a0675

IT Events RU

@iteventsru · Post #257 · 03.03.2018 г., 16:13

✅ Завтра JBreak 2018 📅 4 марта / 10:00 (время Новосибирское, МСК+4) / Новосибирск, Станционная ул., 104 + онлайн-трансляция 💵 Платно 📝 Регистрация тут: https://goo.gl/J22JGQ JBreak — единственная сибирская технологическая Java-конференция для опытных разработчиков. Все доклады будут посвящены только востребованным Java-технологиям и проблемам: производительность, concurrency, тестирование, распределённые системы и высокие нагрузки в мире Java, а также будущее платформы. Спикеры: ~ Simon Ritter ~ Sebastian Daschner ~ Никита Липский ~ Алексей Зиновьев ~ Дмитрий Бугайченко и другие 🔗 Программа: https://goo.gl/tYhuCR #backend#java#spring#JDK#Hibernate#microservices#Новосибирск#онлайн

12
ПретходнаСтраница 1 од 2Следна