@@ -234,6 +234,7 @@ def __init__(self, pipe_name):
234
234
self .pipe_name = pipe_name
235
235
self .original_image = None
236
236
self .current_pixmap = None
237
+ self .last_dot_data = ''
237
238
self .setup_ui ()
238
239
239
240
def setup_ui (self ):
@@ -282,27 +283,30 @@ def on_resize(self, event):
282
283
self .resize_timer .start (100 )
283
284
284
285
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 ())
293
297
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 ))
296
300
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 ()
300
303
301
- # Update image display
302
- self . update_image ( )
304
+ except Exception as e :
305
+ print ( f"Error rendering graph: { e } " )
303
306
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 )
306
310
307
311
def update_image (self ):
308
312
if self .original_image is None :
0 commit comments