@@ -60,6 +60,16 @@ def __init__(self, switch_to_expanded_callback=None):
6060 self .root .title ("PC Workman – HCK_Labs v1.4.0" )
6161 self .root .configure (bg = THEME ["bg_main" ])
6262
63+ # UI Layout Constants
64+ self .LED_SEGMENTS = 18
65+ self .LED_HEIGHT = 18
66+ self .TOP_BAR_HEIGHT = 60
67+ self .CHART_HEIGHT = 190
68+ self .RIGHT_PANEL_WIDTH = 220
69+ self .CONTENT_PADDING = 8
70+ self .TOP_BAR_OFFSET = 64
71+ self .PANEL_SPACING = 6
72+
6373 # Window settings
6474 self .window_width = THEME ['win_width' ]
6575 self .window_height = THEME ['win_height' ]
@@ -704,18 +714,21 @@ def _build_top_bars(self, parent):
704714 top_frame .place (x = 8 , y = 8 , width = THEME ["win_width" ] - THEME ["sidebar_expanded" ] - 16 , height = 60 )
705715
706716 # LED bars
707- self .cpu_led = LEDSegmentBar (top_frame , "CPU" , LED_CPU_MAP , segments = 18 , height = 18 )
708- self .gpu_led = LEDSegmentBar (top_frame , "GPU" , LED_GPU_MAP , segments = 18 , height = 18 )
709- self .ram_led = LEDSegmentBar (top_frame , "RAM" , LED_RAM_MAP , segments = 18 , height = 18 )
717+ self .cpu_led = LEDSegmentBar (top_frame , "CPU" , LED_CPU_MAP ,
718+ segments = self .LED_SEGMENTS , height = self .LED_HEIGHT )
719+ self .gpu_led = LEDSegmentBar (top_frame , "GPU" , LED_GPU_MAP ,
720+ segments = self .LED_SEGMENTS , height = self .LED_HEIGHT )
721+ self .ram_led = LEDSegmentBar (top_frame , "RAM" , LED_RAM_MAP ,
722+ segments = self .LED_SEGMENTS , height = self .LED_HEIGHT )
710723
711- self .cpu_led .frame .place (relx = 0 , rely = 0 , relwidth = 0.33 , height = 60 )
712- self .gpu_led .frame .place (relx = 0.33 , rely = 0 , relwidth = 0.33 , height = 60 )
713- self .ram_led .frame .place (relx = 0.66 , rely = 0 , relwidth = 0.34 , height = 60 )
724+ self .cpu_led .frame .place (relx = 0 , rely = 0 , relwidth = 0.33 , height = self . TOP_BAR_HEIGHT )
725+ self .gpu_led .frame .place (relx = 0.33 , rely = 0 , relwidth = 0.33 , height = self . TOP_BAR_HEIGHT )
726+ self .ram_led .frame .place (relx = 0.66 , rely = 0 , relwidth = 0.34 , height = self . TOP_BAR_HEIGHT )
714727
715728 def _build_center_area (self , parent ):
716729 content_w = THEME ["win_width" ] - THEME ["sidebar_expanded" ] - 26
717- chart_h = 190
718- right_w = 220
730+ chart_h = self . CHART_HEIGHT
731+ right_w = self . RIGHT_PANEL_WIDTH
719732
720733 # Chart frame with click event
721734 self .chart_frame = tk .Frame (parent , bg = THEME ["bg_panel" ])
@@ -1028,15 +1041,79 @@ def _update_process_lists_for_time(self, timestamp):
10281041 })
10291042
10301043 # Update lists using existing render methods
1031- self ._render_user_processes (user_procs )
1032- self ._render_system_processes (system_procs )
1044+ def _render_process_list (self , procs , container , widgets_storage ):
1045+ """Shared rendering logic for both user and system processes"""
1046+ # Clear old widgets
1047+ for widget in widgets_storage :
1048+ widget .destroy ()
1049+ widgets_storage .clear ()
10331050
1034- print (f"[TimeTravel] Updated lists for { time .strftime ('%H:%M:%S' , time .localtime (timestamp ))} " )
1051+ # Gradient backgrounds for TOP 1-5
1052+ row_gradients = ["#1c1f26" , "#1e2128" , "#20232a" , "#22252c" , "#24272e" ]
10351053
1036- except Exception as e :
1037- print (f"[TimeTravel] Error updating process lists: { e } " )
1038- import traceback
1039- traceback .print_exc ()
1054+ for i , proc in enumerate (procs [:5 ], start = 1 ):
1055+ # Get process info
1056+ if self .classifier and 'classification' in proc :
1057+ cls = proc ['classification' ]
1058+ display_name = cls .get ('display_name' , proc ['name' ])
1059+ proc_name = proc .get ('name' , 'unknown' )
1060+ else :
1061+ display_name = proc .get ('name' , 'unknown' )
1062+ proc_name = proc .get ('name' , 'unknown' )
1063+
1064+ cpu = proc .get ('cpu_percent' , 0 )
1065+ ram_mb = proc .get ('ram_MB' , 0 )
1066+
1067+ # Row with gradient background
1068+ row_bg = row_gradients [i - 1 ] if i <= len (row_gradients ) else THEME ["bg_panel" ]
1069+ row = tk .Frame (container , bg = row_bg , cursor = "hand2" , height = 20 )
1070+ row .pack (fill = "x" , pady = 1 , padx = 2 )
1071+ row .pack_propagate (False )
1072+
1073+ # Process name (left side)
1074+ name_lbl = tk .Label (
1075+ row ,
1076+ text = f"{ i } . { display_name [:18 ]} " ,
1077+ font = ("Segoe UI" , 8 ),
1078+ bg = row_bg ,
1079+ fg = THEME ["text" ],
1080+ anchor = "w"
1081+ )
1082+ name_lbl .pack (side = "left" , padx = 6 , fill = "y" )
1083+
1084+ # Right side - CPU and RAM SIDE BY SIDE
1085+ bars_frame = tk .Frame (row , bg = row_bg )
1086+ bars_frame .pack (side = "right" , padx = 4 )
1087+
1088+ # CPU bar and value (LEFT)
1089+ cpu_container = tk .Frame (bars_frame , bg = row_bg )
1090+ cpu_container .pack (side = "left" , padx = 2 )
1091+
1092+ cpu_lbl = tk .Label (cpu_container , text = "CPU" , font = ("Segoe UI" , 6 ),
1093+ bg = row_bg , fg = "#6b7280" , width = 3 )
1094+ cpu_lbl .pack (side = "left" , padx = (0 ,2 ))
1095+
1096+ self ._create_inline_bar (cpu_container , cpu , "#3b82f6" , f"{ cpu :.0f} %" , bg = row_bg )
1097+
1098+ # RAM bar and value (RIGHT)
1099+ ram_container = tk .Frame (bars_frame , bg = row_bg )
1100+ ram_container .pack (side = "left" , padx = 2 )
1101+
1102+ ram_lbl = tk .Label (ram_container , text = "RAM" , font = ("Segoe UI" , 6 ),
1103+ bg = row_bg , fg = "#6b7280" , width = 3 )
1104+ ram_lbl .pack (side = "left" , padx = (0 ,2 ))
1105+
1106+ ram_pct = min ((ram_mb / self .total_ram_mb ) * 100 , 100 )
1107+ self ._create_inline_bar (ram_container , ram_pct , "#fbbf24" , f"{ ram_mb :.0f} MB" , bg = row_bg )
1108+
1109+ # Click to show info
1110+ row .bind ("<Button-1>" , lambda e , p = proc_name : self ._show_process_info_click (e , p ))
1111+
1112+ widgets_storage .append (row )
1113+ self ._render_user_processes (user_procs )
1114+ def _render_user_processes (self , procs ):
1115+ """Modern minimalist process display - side by side CPU/RAM bars with gradient shading"""
1116+ self ._render_process_list (procs , self .top5_container , self .top5_widgets )
10401117
10411118 def show_page (self , page_name ):
10421119 """Switch to a different page"""
0 commit comments