繁体   English   中英

如何检测调用了我的 python 脚本的终端的当前背景颜色?

[英]How do I detect the current background color of the terminal in which my python script was invoked?

我正在使用 xfce4 终端,我希望能够检测背景颜色是设置为黑色还是白色(或者可能是其他颜色)

我的代码如下所示:

def print_color(string, style, textColor, background):  
     string = "\033[{};{};{}m{}\033[m ".format(style,textColor,background,string)  
     print(string)

我想检测当前的背景颜色并使用它而不是传入它。

我试过不设置它,像这样:

def print_color(string, style, textColor):  
     string = "\033[{};{};m{}\033[m ".format(style,textColor,string)  
     print(string)

但这并没有像我预期的那样奏效。

XFCE4终端使用VTE,对colors的查询缺乏响应能力。 那将是DECRQSS的 SGR 风格,这在 VTE 中大多未实现。

(显示的示例无论如何都不起作用)。 这与 GTK+ 工具包无关。

暂无
暂无

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

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