@@ -145,7 +145,8 @@ def __init__(
145145 self .create_menu (menu_name , options , menu_commands )
146146
147147 # Bind to parent to close dropdowns when clicking outside
148- self .parent .bind ("<Button-1>" , self .close_dropdown )
148+ self .parent .bind ("<Button-1>" , self .close_dropdown , add = "+" )
149+ self .canvas .bind ("<Button-1>" , self .close_dropdown , add = "+" )
149150
150151 def select_microcontroller (self , microcontroller_name ):
151152 """Handler for microcontroller selection."""
@@ -251,12 +252,12 @@ def create_menu(self, menu_name, options, menu_commands):
251252 btn .pack (side = "left" )
252253
253254 # Create the dropdown frame
254- dropdown = tk .Frame (self .parent , bg = "#333333" , bd = 1 , relief = "solid" )
255+ dropdown = tk .Frame (self .parent , bg = "#333333" , bd = 1 , relief = "solid" , width = 200 )
255256
256257 # Calculate dropdown height based on number of options
257258 button_height = 30 # Approximate height of each dropdown button
258259 dropdown_height = button_height * len (options )
259- dropdown .place (x = 0 , y = 0 , width = 150 , height = dropdown_height ) # Initial size based on options
260+ dropdown .place (x = 0 , y = 0 , width = 200 , height = dropdown_height ) # Initial size based on options
260261 dropdown .place_forget () # Hide initially
261262
262263 # Populate the dropdown with menu options
@@ -270,12 +271,13 @@ def create_menu(self, menu_name, options, menu_commands):
270271 activeforeground = "white" ,
271272 bd = 0 ,
272273 anchor = "w" ,
274+ width = 200 ,
273275 padx = 20 ,
274276 pady = 5 ,
275277 font = ("FiraCode-Bold" , 12 ),
276278 command = menu_commands .get (option , lambda opt = option : print (f"{ opt } selected" )),
277279 )
278- option_btn .pack (fill = "x " )
280+ option_btn .pack (fill = "both " )
279281
280282 # Attach the dropdown to the button
281283 btn .dropdown = dropdown
@@ -297,7 +299,7 @@ def toggle_dropdown(self, menu_name):
297299 # Position the dropdown below the button
298300 btn_x = child .winfo_rootx () - self .parent .winfo_rootx ()
299301 btn_y = child .winfo_rooty () - self .parent .winfo_rooty () + child .winfo_height ()
300- child .dropdown .place (x = btn_x , y = btn_y , width = 150 )
302+ child .dropdown .place (x = btn_x , y = btn_y , width = 200 )
301303 print (f"Opened dropdown for { menu_name } " )
302304 child .dropdown .lift () # Ensure dropdown is on top
303305 else :
@@ -388,6 +390,18 @@ def open_file(self):
388390 )
389391 ]
390392 self .board .sketcher .circuit (x_o , y_o , model = model_wire )
393+ elif "io" in key :
394+ model_io = [
395+ (
396+ self .board .sketcher .draw_pin_io ,
397+ 1 ,
398+ {
399+ ** val ,
400+ "matrix" : self .board .sketcher .matrix ,
401+ },
402+ )
403+ ]
404+ self .board .sketcher .circuit (x_o , y_o , model = model_io )
391405 else :
392406 # TODO add IO
393407 print (f"Unspecified component: { key } " )
0 commit comments