icon="voices/glados", authors=["TeamSpen210"], desc='The dark constuction and office areas of Aperture. ' 'Catwalks extend between different buildings, with ' 'vactubes and cranes carrying objects throughout ' 'the facility. \n' 'Abandoned offices can often be found here.\n\n' '* This is a bullet point, with a\n second line' '> white-on-black text', ), ] window = selWin(TK_ROOT, test_list, has_none=True, has_def=True, callback=functools.partial( LOGGER.info, 'Selected:', )) window.widget(TK_ROOT).grid(row=1, column=0, sticky='EW') window.set_suggested("SKY_BLACK") def swap_read(): window.readonly = not window.readonly ttk.Button(TK_ROOT, text='Readonly', command=swap_read).grid() TK_ROOT.deiconify() TK_ROOT.mainloop()
'vactubes and cranes carrying objects throughout ' 'the facility.'), ('rule', ''), ('line', 'Abandoned offices can often be found here.'), ('bullet', 'This is a bullet point, with a\n second line'), ('invert', 'white-on-black text') ], ), ] window = selWin( TK_ROOT, test_list, has_none=True, has_def=True, callback=functools.partial( LOGGER.info, 'Selected:', ) ) window.widget(TK_ROOT).grid(row=1, column=0, sticky='EW') window.set_suggested("SKY_BLACK") def swap_read(): window.readonly = not window.readonly ttk.Button(TK_ROOT, text='Readonly', command=swap_read).grid() TK_ROOT.deiconify() TK_ROOT.mainloop()
def _test() -> None: """Test the GUI.""" from srctools.logger import init_logging from tk_tools import TK_ROOT from BEE2_config import GEN_OPTS from packageLoader import find_packages, PACKAGE_SYS init_logging() # Setup images to read from packages. print('Loading packages for images.') GEN_OPTS.load() find_packages(GEN_OPTS['Directories']['package']) img.load_filesystems(PACKAGE_SYS.values()) print('Done.') left_frm = ttk.Frame(TK_ROOT) right_canv = tkinter.Canvas(TK_ROOT) left_frm.grid(row=0, column=0, sticky='NSEW', padx=8) right_canv.grid(row=0, column=1, sticky='NSEW', padx=8) TK_ROOT.rowconfigure(0, weight=1) TK_ROOT.columnconfigure(1, weight=1) slot_dest = [] slot_src = [] class TestItem: def __init__( self, name: str, icon: str, group: str=None, group_icon: str=None, ) -> None: self.name = name self.dnd_icon = img.png('items/clean/{}.png'.format(icon)) self.dnd_group = group if group_icon: self.dnd_group_icon = img.png('items/clean/{}.png'.format(group_icon)) def __repr__(self) -> str: return '<Item {}>'.format(self.name) manager = Manager[TestItem](TK_ROOT, config_icon=True) def func(ev): def call(slot): print('Cback: ', ev, slot) return call for event in Event: manager.reg_callback(event, func(event)) items = [ TestItem('Dropper', 'dropper'), TestItem('Entry', 'entry_door'), TestItem('Exit', 'exit_door'), TestItem('Large Obs', 'large_obs_room'), TestItem('Faith Plate', 'faithplate'), TestItem('Standard Cube', 'cube', 'ITEM_CUBE', 'cubes'), TestItem('Companion Cube', 'companion_cube', 'ITEM_CUBE', 'cubes'), TestItem('Reflection Cube', 'reflection_cube', 'ITEM_CUBE', 'cubes'), TestItem('Edgeless Cube', 'edgeless_safety_cube', 'ITEM_CUBE', 'cubes'), TestItem('Franken Cube', 'frankenturret', 'ITEM_CUBE', 'cubes'), TestItem('Repulsion Gel', 'paintsplat_bounce', 'ITEM_PAINT_SPLAT', 'paints'), TestItem('Propulsion Gel', 'paintsplat_speed', 'ITEM_PAINT_SPLAT', 'paints'), TestItem('Reflection Gel', 'paintsplat_reflection', 'ITEM_PAINT_SPLAT', 'paints'), TestItem('Conversion Gel', 'paintsplat_portal', 'ITEM_PAINT_SPLAT', 'paints'), TestItem('Cleansing Gel', 'paintsplat_water', 'ITEM_PAINT_SPLAT', 'paints'), ] for y in range(8): for x in range(4): slot = manager.slot(left_frm, source=False, label=(format(x + 4*y, '02') if y < 3 else '')) slot.grid(column=x, row=y, padx=1, pady=1) slot_dest.append(slot) for i, item in enumerate(items): slot = manager.slot(right_canv, source=True, label=format(i+1, '02')) slot_src.append(slot) slot.contents = item def configure(e): manager.flow_slots(right_canv, slot_src) configure(None) right_canv.bind('<Configure>', configure) ttk.Button( TK_ROOT, text='Debug', command=lambda: print('Dest:', [slot.contents for slot in slot_dest]) ).grid(row=2, column=0) ttk.Button( TK_ROOT, text='Debug', command=lambda: print('Source:', [slot.contents for slot in slot_src]) ).grid(row=2, column=1) name_lbl = ttk.Label(TK_ROOT, text='') name_lbl.grid(row=3, column=0) def enter(slot): if slot.contents is not None: name_lbl['text'] = 'Name: ' + slot.contents.name def exit(slot): name_lbl['text'] = '' manager.reg_callback(Event.HOVER_ENTER, enter) manager.reg_callback(Event.HOVER_EXIT, exit) manager.reg_callback(Event.CONFIG, lambda slot: messagebox.showinfo('Hello World', str(slot.contents))) TK_ROOT.deiconify() TK_ROOT.mainloop()