単一の Gtk.DrawingArea で描画できますが、たとえば 50 などの多くの描画領域で描画しようとすると、描画でエラーが発生しました。
チェックアウトする必要があるコードは次のとおりです。
def aggiorna(self, args=()):
import random
import time
while True:
for i in self.indirizzi_ip:
self.r=random.randint(0,10)/10.0
self.g=random.randint(0,10)/10.0
self.b=random.randint(0,10)/10.0
self.cpu_info[i]['drawing_area'].show() #the drawing happens here
time.sleep(1)
def __draw(self, widget, context): #connected to Gtk.DrawingArea.show()
context.set_source_rgb(self.r, self.g, self.b) #random
context.rectangle(0, 0, widget.get_allocated_width(), widget.get_allocated_height())
context.fill()
1) 描画でエラーが発生するのはなぜですか?
2) なぜ Gtk.DrawingArea(s) は、ウィンドウを更新したときにのみ色が変わるのですか (たとえば、プログラムから Gtk.DrawingArea ウィンドウに切り替えます)?
3) Gtk.DrawingArea ごとにランダムな色を取得しないのはなぜですか?