TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #62 · 4 апр.

Когда разрабатываете свой GUI с помощью PyQt для какого-либо софта бывает необходимо позаимствовать цвета из текущего стиля интерфейса. Например, чтобы правильно раскрасить свои виджеты, подогнав их по цвету. Ведь бывает, что ваш GUI используется в разных софтах. Причём некоторые со светлой темой а другие с тёмной. По умолчанию стили наследуются, но если вы задаёте какую-либо раскраску для части виджета через свой styleSheet, то требуется ссылаться на цвета текущего стиля. Как это сделать? Как получить нужный цвет из палитры имеющегося стиля? Это достаточно просто, нужно использовать класс QPalette и его роли. Например, мне нужно достать цвет текста из одного виджета и применить его в другом как цвет фона (не важно зачем именно так, просто захотелось😊). Получаем палитру виджета и сразу достаём нужный цвет, указав его роль. from PySide2.QtGui import QPalette color = main_window.palette().color(QPalette.Text) теперь можем использовать этот цвет в стилях my_widget.setStyleSheet(f'background-color: {color.name()};') Готово, мы динамически переопределили дефолтный стиль используя текущий стиль окна! На самом деле есть запись покороче, в одну строку и без лишних переменных. Не очень-то по правилам CSS, но Qt это понимает. my_widget.setStyleSheet('background-color: palette(Text);') Этот способ не подходит если вам нужно как-то модифицировать цвет перед применением в своих стилях. В этом случае потребуется первый способ. Зато он прекрасно сработает в файле .qss, то есть не придётся в коде прописывать раскраску отдельных элементов через ссылки на палитру, всё красиво сохранится в отдельном файле .qss! QListView#my_widget::item:selected { background: palette(Midlight); } Про имеющиеся роли можно почитать здесь🌍 #qt#tricks

Hashtags

Резултати

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

Пребарај: #basics

当前筛选 #basics清除筛选
Go

@golang · Post #67 · 20.07.2018 г., 18:47

Generally I don’t like aliases but in some cases they might be helpful 😀 #development#basics https://codeburst.io/learn-how-to-create-custom-bash-commands-in-less-than-4-minutes-6d4ceadd9590

Go

@golang · Post #26 · 27.01.2018 г., 16:15

In the GoLang we use interfaces everywhere. But we also should understand the rules and idioms how GoLang interfaces works. Let’s read about them 😉; part one: #development#basics https://medium.com/golangspec/interfaces-in-go-part-i-4ae53a97479c

Go

@golang · Post #69 · 24.08.2018 г., 10:05

A good reading list with a knowledge base about Golang, based on blog posts and Golang books. Inside of the link: - 3 categories of stages: Beginner, Intermediate, Advanced; - Common questions like “Why should you learn Go?” and “How to Write Go Code” - Web, Concurrency, Code style, Testing and other GoLang related topics. #language#development#basics Add to bookmarks and enjoy the reading! https://github.com/enocom/gopher-reading-list

Go

@golang · Post #46 · 05.03.2018 г., 20:39

Simple and good for understanding tutorial about Golang’s channels. It can help beginners to meet with them and learn to use it without problems 🙂 Keys of the article: - What is a channel, goals, and functions of it; - Deadlocks and other problems; - Channel ranging and closing. When, why and how? #development#basics#language http://guzalexander.com/2013/12/06/golang-channels-tutorial.html

Go

@golang · Post #52 · 22.03.2018 г., 14:57

How to work and use field tags in GoLang? Inside of this article Michał Łowicki from Opera company explains basics and features of tagging; include examples and best practices 🙂 #development#practice#basics https://medium.com/golangspec/tags-in-golang-3e5db0b8ef3e

Go

@golang · Post #47 · 07.03.2018 г., 07:42

One of popularly questions is: How to handle errors correctly? GoLang best practices on the Medium will help with it. Of course, code examples are included 🙂 #development#practice#basics https://medium.com/@sebdah/go-best-practices-error-handling-2d15e1f0c5ee?source=linkShare-b636419a57de-1520408380

Go

@golang · Post #61 · 21.05.2018 г., 19:17

Hi 👋 there! This article is meant for those who’re new to Go and want to start learning about Go’s concurrency primitives: go routines and channels. #development#manual#basics https://medium.com/@trevor4e/learning-gos-concurrency-through-illustrations-8c4aff603b3

Go

@golang · Post #27 · 28.01.2018 г., 12:44

Everybody use dependencies and third-party packages but what is the best way to use it? GopherAcademy helps to understand best practice for the vendor folder organization. Of course, code examples and theory points are included 🙂 #development#basics#manual https://blog.gopheracademy.com/advent-2015/vendor-folder/

Go

@golang · Post #34 · 05.02.2018 г., 08:41

New post about concurrency problems and solutions. Main points with examples: - Blocking Channels; - Blocking Channels Buffer; - Wait Group (run multiple async tasks and wait for them execution); #development#basics#algorithms https://hackernoon.com/concurrency-how-it-can-help-you-and-how-you-can-use-golang-to-reach-it-easily-ae3e070b3d2c

Go

@golang · Post #49 · 11.03.2018 г., 11:39

Top GoLang features that you don’t know or don’t hear so much 🙂 If you want some main points of this article they are here: - GoDoc; - Static code analysis; - Built-in testing and profiling framework; - Race condition detection; - Learning curve; - Reflection; - Opinionatedness; - Culture. #manual#development#basics#language https://medium.freecodecamp.org/here-are-some-amazing-advantages-of-go-that-you-dont-hear-much-about-1af99de3b23a?source=linkShare-b636419a57de-1520768034

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