- Set up a new Python project based on the following pyproject.toml:
[project] name = "python-mpv-gtk4" version = "0.1.0" description = "Description" readme = "README.md"
requires-python = ">=3.13"
# One CLI to format the code tree - https://github.com/numtide/treefmt | |
# Do not exit with error if a configured formatter is missing | |
# Env $TREEFMT_ALLOW_MISSING_FORMATTER | |
# allow-missing-formatter = false | |
# The file into which a cpu profile will be written | |
# Env $TREEFMT_CPU_PROFILE | |
# cpu-profile = ./cpu.pprof |
#!/usr/bin/env python3 | |
import ctypes | |
import gi | |
gi.require_version('Gtk', '3.0') | |
from gi.repository import Gtk, Gdk | |
gi.require_version('GL', '1.0') | |
from OpenGL import GL, GLX |
from PyQt5.QtCore import QModelIndex, QPoint, QSize, Qt | |
from PyQt5.QtGui import QTextDocument, QAbstractTextDocumentLayout, QPainter, QLinearGradient, QColor, QPalette | |
from PyQt5.QtWidgets import QStyledItemDelegate, QStyle, QStyleOptionViewItem | |
def find_colors(option: QStyleOptionViewItem, even_row: bool): | |
if option.state & QStyle.State_Active and option.state & QStyle.State_Selected: | |
text_color = option.palette.color(QPalette.Active, QPalette.HighlightedText) | |
bg_color = option.palette.color(QPalette.Active, QPalette.Highlight) | |
elif option.state & QStyle.State_Selected: |