简体   繁体   中英

Styling GTK Switch with PyGObject

I'm trying to custom style a GTKSwitch in my PyGObject project and it's incredibly frustrating. The docs for PyGObject and GTK alike are terrible and tell you basically nothing. The only reference I've been able to find for anything style related with switches specifically is here which mentions slider-height and slider-width but says both are deprecated.

I have successfully connected a CSS stylesheet to my project and have been using it to style other widgets. I have figured out how to change the color of the switch's gutter (track? the part that is not the slider), but can't for the life of me figure out how to do anything else, like change the color of the slider itself or the dimensions of the switch. Using the height and width CSS properties throws screen.css:83:8'height' is not a valid property name (3) when I run the file. So among other frustrating things about GTK, many of the normal CSS properties I'm used to from web development just aren't supported.

I'm new to GTK and the documentation is utterly unhelpful. I've learned something about how CSS selectors work in GTK and can reference the switch node, but I still don't know how to reference the slider because I don't actually know what it's called. I've tried slider and handle but neither works. If anyone could offer some explanation for how to change the style of the slider, dimensions of the switch, etc. that would be very helpful, along with any tips on styling in general.

As a secondary issue, does anyone know of a good inspector tool for GTK applications? I'm thinking of something similar to the Elements tab in the Google Chrome devtools. That would make it much simpler to actually figure out how styling works.

For testing CSS changes in GTK you want to use GtkInspector , which comes included with newer versions of GTK+.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM