簡體   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