@@ -234,6 +234,7 @@ def __init__(self, pipe_name):
234234 self .pipe_name = pipe_name
235235 self .original_image = None
236236 self .current_pixmap = None
237+ self .last_dot_data = ''
237238 self .setup_ui ()
238239
239240 def setup_ui (self ):
@@ -282,27 +283,30 @@ def on_resize(self, event):
282283 self .resize_timer .start (100 )
283284
284285 def update_graph (self , dot_data ):
285- try :
286- # Render DOT data using Graphviz
287- proc = subprocess .Popen (
288- ['dot' , '-Tpng' ],
289- stdin = subprocess .PIPE ,
290- stdout = subprocess .PIPE
291- )
292- output , _ = proc .communicate (dot_data .encode ())
286+ if dot_data != self .last_dot_data :
287+ self .last_dot_data = dot_data
288+
289+ try :
290+ # Render DOT data using Graphviz
291+ proc = subprocess .Popen (
292+ ['dot' , '-Tpng' ],
293+ stdin = subprocess .PIPE ,
294+ stdout = subprocess .PIPE
295+ )
296+ output , _ = proc .communicate (dot_data .encode ())
293297
294- # Convert to PIL Image
295- self .original_image = Image .open (BytesIO (output ))
298+ # Convert to PIL Image
299+ self .original_image = Image .open (BytesIO (output ))
296300
297- # Update timestamp
298- current_time = datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" )
299- self .timestamp_label .setText (current_time )
301+ # Update image display
302+ self .update_image ()
300303
301- # Update image display
302- self . update_image ( )
304+ except Exception as e :
305+ print ( f"Error rendering graph: { e } " )
303306
304- except Exception as e :
305- print (f"Error rendering graph: { e } " )
307+ # Update timestamp
308+ current_time = datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" )
309+ self .timestamp_label .setText (current_time )
306310
307311 def update_image (self ):
308312 if self .original_image is None :
0 commit comments