2018/02/28

wxPython の SetBackgroundColour に RGB を指定する方法

SetBackgroundColour1 の引数に文字列や Colour オブジェクトを指定している例はよく見かけるのですが、RGB でしたい時はどうするのだろうと思っていました。

1
2
panel.SetBackgroundColour('blue')
panel.SetBackgroundColour(wx.Blue)

調べてみると、単純にタプル、もしくは配列を指定すれば良いだけでした。

1
2
3
4
# タプル
panel.SetBackgroundColour((r, g, b))
# 配列
panel.SetBackgroundColour([r, g, b])

参考

static text - Change the colour of a StaticText, wxPython - Stack Overflow

  1. Colour とイギリスのスペルなので注意 
?

0 件のコメント: