简体   繁体   English

Gtk.TreeView:Python如何设置失去树形视图焦点时选择的背景色行

[英]Gtk.TreeView:Python How to set background color row selected when lost focus of treeview

I have trouble in python gtk.TreeView: when a row selected on treeview it has background Blue, and then after that I changed focus to another object (example textbox) then the row was selected changed color to gray. 我在python gtk.TreeView中遇到麻烦:当在树视图上选择的行具有背景蓝色时,然后将焦点更改为另一个对象(例如文本框),然后选择该行将颜色更改为灰色。 I don't want change it to gray, I want it to still Blue. 我不想将其更改为灰色,我希望将其更改为蓝色。 Is there any help. 有什么帮助吗? Could you please help me? 请你帮助我好吗? Thanks you, 谢谢,

I had the same problem. 我有同样的问题。 I've solved it with the CSS feature of gtk programs. 我已经使用gtk程序的CSS功能解决了它。 the css to manage the selection of row is 用于管理行选择的css是

GtkTreeView row:selected {\
        background: #f07746;\
        color: #ffffff;\
    }\

The background will override the gray effect when you lose the focus. 失去焦点时,背景将覆盖灰色效果。 In your program you can apply the custom style with 在您的程序中,您可以使用

gtk_css_provider_load_from_data(provider, CSS, -1, NULL);

(C language, but I can imagine you can find the equivalent in python) (C语言,但我可以想象您可以在python中找到等效项)

Hope it helps even if it is a late answer. 希望它能对您有所帮助,即使答案太晚。 Can 能够

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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