def make_pane(tool_frame): """Create the compiler options pane. """ global window window = SubPane( TK_ROOT, options=GEN_OPTS, title='Compile Options', name='compiler', resize_x=False, resize_y=False, tool_frame=tool_frame, tool_img=png.png('icons/win_compiler'), tool_col=3, ) window.columnconfigure(0, weight=1) thumb_frame = ttk.LabelFrame( window, text='Thumbnail', labelanchor=N, ) thumb_frame.grid(row=0, column=0, sticky=EW) thumb_frame.columnconfigure(0, weight=1) UI['thumb_auto'] = ttk.Radiobutton( thumb_frame, text='Auto', value='AUTO', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_peti'] = ttk.Radiobutton( thumb_frame, text='PeTI', value='PETI', variable=chosen_thumb, command=set_screen_type, ) cust_frame = ttk.Frame(thumb_frame) cust_frame.columnconfigure(1, weight=1) UI['thumb_custom'] = ttk.Radiobutton( cust_frame, text='', value='CUST', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_custom_file'] = ttk.Entry( cust_frame, cursor='arrow', textvariable=cust_file_loc_var, width=15, ) UI['thumb_custom_file'].bind("<Button-1>", find_screenshot) UI['thumb_custom_file'].bind("<Key>", set_screenshot_text) UI['thumb_custom_btn'] = ttk.Button( cust_frame, text="...", width=1.5, command=find_screenshot, ) UI['thumb_auto'].grid(row=0, column=0, sticky=W) UI['thumb_peti'].grid(row=0, column=1, sticky=W) cust_frame.grid(row=1, column=0, columnspan=2, sticky=EW) UI['thumb_custom'].grid(row=0, column=0, sticky=W) UI['thumb_custom_file'].grid(row=0, column=1, sticky=EW) UI['thumb_custom_btn'].grid(row=0, column=2, sticky=EW) elev_frame = ttk.LabelFrame( window, text='Spawn at:', labelanchor=N, ) elev_frame.grid(row=1, column=0, sticky=EW) UI['elev_preview'] = ttk.Radiobutton( elev_frame, text='Entry Door', value=0, variable=start_in_elev, command=set_elev_type, ) UI['elev_elevator'] = ttk.Radiobutton( elev_frame, text='Elevator', value=1, variable=start_in_elev, command=set_elev_type, ) UI['elev_preview'].grid(row=0, column=0, sticky=W) UI['elev_elevator'].grid(row=0, column=1, sticky=W) model_frame = ttk.LabelFrame( window, text='Player Model (SP):', labelanchor=N, ) model_frame.grid(row=2, column=0, sticky=EW) UI['player_mdl'] = ttk.Combobox( model_frame, exportselection=0, textvariable=player_model_var, values=PLAYER_MODEL_ORDER, ) # Users can only use the dropdown UI['player_mdl'].state(['readonly']) UI['player_mdl'].grid(row=0, column=0, sticky=EW) UI['player_mdl'].bind('<<ComboboxSelected>>', set_model) count_frame = ttk.LabelFrame( window, text='Last Compile:', labelanchor=N, ) count_frame.grid(row=3, column=0) ttk.Label( count_frame, text='Entity', anchor=N, ).grid(row=0, column=0, columnspan=3, sticky=EW) UI['count_ent'] = ttk.Progressbar( count_frame, maximum=MAX_ENTS, variable=count_ents, length=120, ) UI['count_ent'].grid( row=1, column=0, columnspan=3, sticky=EW, padx=5, ) ttk.Label( count_frame, text='Overlay', anchor=CENTER, ).grid(row=2, column=0, sticky=EW) UI['count_over'] = ttk.Progressbar( count_frame, maximum=MAX_OVERLAY, variable=count_overlay, length=50, ) UI['count_over'].grid(row=3, column=0, sticky=EW, padx=5) ttk.Button( count_frame, image=png.png('icons/tool_sub'), command=refresh_counts, ).grid(row=3, column=1) ttk.Label( count_frame, text='Brush', anchor=CENTER, ).grid(row=2, column=2, sticky=EW) UI['count_brush'] = ttk.Progressbar( count_frame, maximum=MAX_BRUSH, variable=count_brush, length=50, ) UI['count_brush'].grid(row=3, column=2, sticky=EW, padx=5) UI['view_logs'] = ttk.Button( count_frame, text='View Logs', ) UI['view_logs'].grid(row=4, column=0, columnspan=3, sticky=EW) refresh_counts(reload=False)
def make_pane(tool_frame): """Create the styleVar pane. """ global window window = SubPane( TK_ROOT, options=GEN_OPTS, title='Style Properties', name='style', resize_y=True, tool_frame=tool_frame, tool_img=png.png('icons/win_stylevar'), tool_col=2, ) UI['style_can'] = Canvas(window, highlightthickness=0) # need to use a canvas to allow scrolling UI['style_can'].grid(sticky='NSEW') window.rowconfigure(0, weight=1) UI['style_scroll'] = ttk.Scrollbar( window, orient=VERTICAL, command=UI['style_can'].yview, ) UI['style_scroll'].grid(column=1, row=0, rowspan=2, sticky="NS") UI['style_can']['yscrollcommand'] = UI['style_scroll'].set canvas_frame = ttk.Frame(UI['style_can']) frame_all = ttk.Labelframe(canvas_frame, text="All:") frame_all.grid(row=0, sticky='EW') frm_chosen = ttk.Labelframe(canvas_frame, text="Selected Style:") frm_chosen.grid(row=1, sticky='EW') ttk.Separator( canvas_frame, orient=HORIZONTAL, ).grid(row=2, sticky='EW', pady=(10, 5)) frm_other = ttk.Labelframe(canvas_frame, text="Other Styles:") frm_other.grid(row=3, sticky='EW') UI['stylevar_chosen_none'] = ttk.Label( frm_chosen, text='No Options!', font='TkMenuFont', justify='center', ) UI['stylevar_other_none'] = ttk.Label( frm_other, text='None!', font='TkMenuFont', justify='center', ) for pos, (var_id, name, default) in enumerate(styleOptions): # Add the special stylevars which apply to all styles tk_vars[var_id] = IntVar( value=GEN_OPTS.get_bool('StyleVar', var_id, default) ) checkbox_special[var_id] = ttk.Checkbutton( frame_all, variable=tk_vars[var_id], text=name, command=functools.partial(set_stylevar, var_id) ) checkbox_special[var_id].grid(row=pos, column=0, sticky="W", padx=3) for var in var_list: tk_vars[var.id] = IntVar(value=var.default) args = { 'variable': tk_vars[var.id], 'text': var.name, 'command': functools.partial(set_stylevar, var.id) } checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args) checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args) UI['style_can'].create_window(0, 0, window=canvas_frame, anchor="nw") UI['style_can'].update_idletasks() UI['style_can'].config( scrollregion=UI['style_can'].bbox(ALL), width=canvas_frame.winfo_reqwidth(), ) ttk.Sizegrip( window, cursor="sb_v_double_arrow", ).grid(row=1, column=0) UI['style_can'].bind('<Configure>', flow_stylevar) # Scroll globally even if canvas is not selected. window.bind( "<MouseWheel>", lambda e: scroll(int(-1*(e.delta/120))), ) window.bind( "<Button-4>", lambda e: scroll(1), ) window.bind( "<Button-5>", lambda e: scroll(-1), )
def make_pane(tool_frame): """Create the styleVar pane. """ global window window = SubPane( TK_ROOT, options=GEN_OPTS, title=_('Style Properties'), name='style', resize_y=True, tool_frame=tool_frame, tool_img=png.png('icons/win_stylevar'), tool_col=3, ) UI['style_can'] = Canvas(window, highlightthickness=0) # need to use a canvas to allow scrolling UI['style_can'].grid(sticky='NSEW') window.rowconfigure(0, weight=1) UI['style_scroll'] = ttk.Scrollbar( window, orient=VERTICAL, command=UI['style_can'].yview, ) UI['style_scroll'].grid(column=1, row=0, rowspan=2, sticky="NS") UI['style_can']['yscrollcommand'] = UI['style_scroll'].set utils.add_mousewheel(UI['style_can'], window) canvas_frame = ttk.Frame(UI['style_can']) frame_all = ttk.Labelframe(canvas_frame, text=_("All:")) frame_all.grid(row=0, sticky='EW') frm_chosen = ttk.Labelframe(canvas_frame, text=_("Selected Style:")) frm_chosen.grid(row=1, sticky='EW') ttk.Separator( canvas_frame, orient=HORIZONTAL, ).grid(row=2, sticky='EW', pady=(10, 5)) frm_other = ttk.Labelframe(canvas_frame, text=_("Other Styles:")) frm_other.grid(row=3, sticky='EW') UI['stylevar_chosen_none'] = ttk.Label( frm_chosen, text=_('No Options!'), font='TkMenuFont', justify='center', ) UI['stylevar_other_none'] = ttk.Label( frm_other, text=_('None!'), font='TkMenuFont', justify='center', ) all_pos = 0 for all_pos, var in enumerate(styleOptions): # Add the special stylevars which apply to all styles tk_vars[var.id] = IntVar( value=GEN_OPTS.get_bool('StyleVar', var.id, var.default)) checkbox_all[var.id] = ttk.Checkbutton(frame_all, variable=tk_vars[var.id], text=var.name, command=functools.partial( set_stylevar, var.id)) checkbox_all[var.id].grid(row=all_pos, column=0, sticky="W", padx=3) tooltip.add_tooltip( checkbox_all[var.id], make_desc(var, is_hardcoded=True), ) for var in VAR_LIST: tk_vars[var.id] = IntVar(value=var.enabled) args = { 'variable': tk_vars[var.id], 'text': var.name, 'command': functools.partial(set_stylevar, var.id) } desc = make_desc(var) if var.applies_to_all(): # Available in all styles - put with the hardcoded variables. all_pos += 1 checkbox_all[var.id] = check = ttk.Checkbutton(frame_all, **args) check.grid(row=all_pos, column=0, sticky="W", padx=3) tooltip.add_tooltip(check, desc) else: # Swap between checkboxes depending on style. checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args) checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args) tooltip.add_tooltip( checkbox_chosen[var.id], desc, ) tooltip.add_tooltip( checkbox_other[var.id], desc, ) UI['style_can'].create_window(0, 0, window=canvas_frame, anchor="nw") UI['style_can'].update_idletasks() UI['style_can'].config( scrollregion=UI['style_can'].bbox(ALL), width=canvas_frame.winfo_reqwidth(), ) if utils.USE_SIZEGRIP: ttk.Sizegrip( window, cursor=utils.CURSORS['stretch_vert'], ).grid(row=1, column=0) UI['style_can'].bind('<Configure>', flow_stylevar)
def make_pane(tool_frame): """Create the styleVar pane. """ global window window = SubPane( TK_ROOT, options=GEN_OPTS, title='Style Properties', name='style', resize_y=True, tool_frame=tool_frame, tool_img=png.png('icons/win_stylevar'), tool_col=3, ) UI['style_can'] = Canvas(window, highlightthickness=0) # need to use a canvas to allow scrolling UI['style_can'].grid(sticky='NSEW') window.rowconfigure(0, weight=1) UI['style_scroll'] = ttk.Scrollbar( window, orient=VERTICAL, command=UI['style_can'].yview, ) UI['style_scroll'].grid(column=1, row=0, rowspan=2, sticky="NS") UI['style_can']['yscrollcommand'] = UI['style_scroll'].set utils.add_mousewheel(UI['style_can'], window) canvas_frame = ttk.Frame(UI['style_can']) frame_all = ttk.Labelframe(canvas_frame, text="All:") frame_all.grid(row=0, sticky='EW') frm_chosen = ttk.Labelframe(canvas_frame, text="Selected Style:") frm_chosen.grid(row=1, sticky='EW') ttk.Separator( canvas_frame, orient=HORIZONTAL, ).grid(row=2, sticky='EW', pady=(10, 5)) frm_other = ttk.Labelframe(canvas_frame, text="Other Styles:") frm_other.grid(row=3, sticky='EW') UI['stylevar_chosen_none'] = ttk.Label( frm_chosen, text='No Options!', font='TkMenuFont', justify='center', ) UI['stylevar_other_none'] = ttk.Label( frm_other, text='None!', font='TkMenuFont', justify='center', ) for pos, var in enumerate(styleOptions): # Add the special stylevars which apply to all styles tk_vars[var.id] = IntVar( value=GEN_OPTS.get_bool('StyleVar', var.id, var.default) ) checkbox_special[var.id] = ttk.Checkbutton( frame_all, variable=tk_vars[var.id], text=var.name, command=functools.partial(set_stylevar, var.id) ) checkbox_special[var.id].grid(row=pos, column=0, sticky="W", padx=3) tooltip.add_tooltip( checkbox_special[var.id], make_desc(var, is_hardcoded=True), ) for var in VAR_LIST: tk_vars[var.id] = IntVar(value=var.enabled) args = { 'variable': tk_vars[var.id], 'text': var.name, 'command': functools.partial(set_stylevar, var.id) } checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args) checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args) desc = make_desc(var) tooltip.add_tooltip( checkbox_chosen[var.id], desc, ) tooltip.add_tooltip( checkbox_other[var.id], desc, ) UI['style_can'].create_window(0, 0, window=canvas_frame, anchor="nw") UI['style_can'].update_idletasks() UI['style_can'].config( scrollregion=UI['style_can'].bbox(ALL), width=canvas_frame.winfo_reqwidth(), ) if utils.USE_SIZEGRIP: ttk.Sizegrip( window, cursor=utils.CURSORS['stretch_vert'], ).grid(row=1, column=0) UI['style_can'].bind('<Configure>', flow_stylevar)
def make_pane(tool_frame): """Create the styleVar pane. """ global window window = SubPane( TK_ROOT, options=GEN_OPTS, title='Style Properties', name='style', resize_y=True, tool_frame=tool_frame, tool_img=png.png('icons/win_stylevar'), tool_col=3, ) UI['style_can'] = Canvas(window, highlightthickness=0) # need to use a canvas to allow scrolling UI['style_can'].grid(sticky='NSEW') window.rowconfigure(0, weight=1) UI['style_scroll'] = ttk.Scrollbar( window, orient=VERTICAL, command=UI['style_can'].yview, ) UI['style_scroll'].grid(column=1, row=0, rowspan=2, sticky="NS") UI['style_can']['yscrollcommand'] = UI['style_scroll'].set canvas_frame = ttk.Frame(UI['style_can']) frame_all = ttk.Labelframe(canvas_frame, text="All:") frame_all.grid(row=0, sticky='EW') frm_chosen = ttk.Labelframe(canvas_frame, text="Selected Style:") frm_chosen.grid(row=1, sticky='EW') ttk.Separator( canvas_frame, orient=HORIZONTAL, ).grid(row=2, sticky='EW', pady=(10, 5)) frm_other = ttk.Labelframe(canvas_frame, text="Other Styles:") frm_other.grid(row=3, sticky='EW') UI['stylevar_chosen_none'] = ttk.Label( frm_chosen, text='No Options!', font='TkMenuFont', justify='center', ) UI['stylevar_other_none'] = ttk.Label( frm_other, text='None!', font='TkMenuFont', justify='center', ) for pos, var in enumerate(styleOptions): # Add the special stylevars which apply to all styles tk_vars[var.id] = IntVar( value=GEN_OPTS.get_bool('StyleVar', var.id, var.enabled)) checkbox_special[var.id] = ttk.Checkbutton(frame_all, variable=tk_vars[var.id], text=var.name, command=functools.partial( set_stylevar, var.id)) checkbox_special[var.id].grid(row=pos, column=0, sticky="W", padx=3) if var.desc: tooltip.add_tooltip( checkbox_special[var.id], var.desc, ) for var in var_list: tk_vars[var.id] = IntVar(value=var.default) args = { 'variable': tk_vars[var.id], 'text': var.name, 'command': functools.partial(set_stylevar, var.id) } checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args) checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args) if var.desc: tooltip.add_tooltip( checkbox_chosen[var.id], var.desc, ) tooltip.add_tooltip( checkbox_other[var.id], var.desc, ) UI['style_can'].create_window(0, 0, window=canvas_frame, anchor="nw") UI['style_can'].update_idletasks() UI['style_can'].config( scrollregion=UI['style_can'].bbox(ALL), width=canvas_frame.winfo_reqwidth(), ) ttk.Sizegrip( window, cursor=utils.CURSORS['stretch_vert'], ).grid(row=1, column=0) UI['style_can'].bind('<Configure>', flow_stylevar) # Scroll globally even if canvas is not selected. if utils.WIN: window.bind( "<MouseWheel>", lambda e: scroll(int(-1 * (e.delta / 120))), ) elif utils.MAC: window.bind( "<Button-4>", lambda e: scroll(1), ) window.bind( "<Button-5>", lambda e: scroll(-1), )
def make_pane(tool_frame): """Create the styleVar pane. """ global window window = SubPane( TK_ROOT, options=GEN_OPTS, title="Style Properties", name="style", resize_y=True, tool_frame=tool_frame, tool_img=png.png("icons/win_stylevar"), tool_col=3, ) UI["style_can"] = Canvas(window, highlightthickness=0) # need to use a canvas to allow scrolling UI["style_can"].grid(sticky="NSEW") window.rowconfigure(0, weight=1) UI["style_scroll"] = ttk.Scrollbar(window, orient=VERTICAL, command=UI["style_can"].yview) UI["style_scroll"].grid(column=1, row=0, rowspan=2, sticky="NS") UI["style_can"]["yscrollcommand"] = UI["style_scroll"].set canvas_frame = ttk.Frame(UI["style_can"]) frame_all = ttk.Labelframe(canvas_frame, text="All:") frame_all.grid(row=0, sticky="EW") frm_chosen = ttk.Labelframe(canvas_frame, text="Selected Style:") frm_chosen.grid(row=1, sticky="EW") ttk.Separator(canvas_frame, orient=HORIZONTAL).grid(row=2, sticky="EW", pady=(10, 5)) frm_other = ttk.Labelframe(canvas_frame, text="Other Styles:") frm_other.grid(row=3, sticky="EW") UI["stylevar_chosen_none"] = ttk.Label(frm_chosen, text="No Options!", font="TkMenuFont", justify="center") UI["stylevar_other_none"] = ttk.Label(frm_other, text="None!", font="TkMenuFont", justify="center") for pos, var in enumerate(styleOptions): # Add the special stylevars which apply to all styles tk_vars[var.id] = IntVar(value=GEN_OPTS.get_bool("StyleVar", var.id, var.enabled)) checkbox_special[var.id] = ttk.Checkbutton( frame_all, variable=tk_vars[var.id], text=var.name, command=functools.partial(set_stylevar, var.id) ) checkbox_special[var.id].grid(row=pos, column=0, sticky="W", padx=3) if var.desc: tooltip.add_tooltip(checkbox_special[var.id], var.desc) for var in var_list: tk_vars[var.id] = IntVar(value=var.default) args = {"variable": tk_vars[var.id], "text": var.name, "command": functools.partial(set_stylevar, var.id)} checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args) checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args) if var.desc: tooltip.add_tooltip(checkbox_chosen[var.id], var.desc) tooltip.add_tooltip(checkbox_other[var.id], var.desc) UI["style_can"].create_window(0, 0, window=canvas_frame, anchor="nw") UI["style_can"].update_idletasks() UI["style_can"].config(scrollregion=UI["style_can"].bbox(ALL), width=canvas_frame.winfo_reqwidth()) ttk.Sizegrip(window, cursor=utils.CURSORS["stretch_vert"]).grid(row=1, column=0) UI["style_can"].bind("<Configure>", flow_stylevar) # Scroll globally even if canvas is not selected. if utils.WIN: window.bind("<MouseWheel>", lambda e: scroll(int(-1 * (e.delta / 120)))) elif utils.MAC: window.bind("<Button-4>", lambda e: scroll(1)) window.bind("<Button-5>", lambda e: scroll(-1))
def make_pane(tool_frame): """Create the styleVar pane. """ global window window = SubPane( TK_ROOT, options=BEE2_config.GEN_OPTS, title=_('Style/Item Properties'), name='style', resize_y=True, tool_frame=tool_frame, tool_img=img.png('icons/win_stylevar'), tool_col=3, ) UI['nbook'] = nbook = ttk.Notebook(window) nbook.grid(row=0, column=0, sticky=NSEW) window.rowconfigure(0, weight=1) window.columnconfigure(0, weight=1) nbook.enable_traversal() stylevar_frame = ttk.Frame(nbook) stylevar_frame.rowconfigure(0, weight=1) stylevar_frame.columnconfigure(0, weight=1) nbook.add(stylevar_frame, text=_('Styles')) UI['style_can'] = Canvas(stylevar_frame, highlightthickness=0) # need to use a canvas to allow scrolling UI['style_can'].grid(sticky='NSEW') window.rowconfigure(0, weight=1) UI['style_scroll'] = ttk.Scrollbar( stylevar_frame, orient=VERTICAL, command=UI['style_can'].yview, ) UI['style_scroll'].grid(column=1, row=0, rowspan=2, sticky="NS") UI['style_can']['yscrollcommand'] = UI['style_scroll'].set utils.add_mousewheel(UI['style_can'], stylevar_frame) canvas_frame = ttk.Frame(UI['style_can']) frame_all = ttk.Labelframe(canvas_frame, text=_("All:")) frame_all.grid(row=0, sticky='EW') frm_chosen = ttk.Labelframe(canvas_frame, text=_("Selected Style:")) frm_chosen.grid(row=1, sticky='EW') ttk.Separator( canvas_frame, orient=HORIZONTAL, ).grid(row=2, sticky='EW', pady=(10, 5)) frm_other = ttk.Labelframe(canvas_frame, text=_("Other Styles:")) frm_other.grid(row=3, sticky='EW') UI['stylevar_chosen_none'] = ttk.Label( frm_chosen, text=_('No Options!'), font='TkMenuFont', justify='center', ) UI['stylevar_other_none'] = ttk.Label( frm_other, text=_('None!'), font='TkMenuFont', justify='center', ) all_pos = 0 for all_pos, var in enumerate(styleOptions): # Add the special stylevars which apply to all styles tk_vars[var.id] = int_var = IntVar(value=var.default) checkbox_all[var.id] = ttk.Checkbutton( frame_all, variable=int_var, text=var.name, ) checkbox_all[var.id].grid(row=all_pos, column=0, sticky="W", padx=3) # Special case - this needs to refresh the filter when swapping, # so the items disappear or reappear. if var.id == 'UnlockDefault': def cmd(): update_filter() checkbox_all[var.id]['command'] = cmd tooltip.add_tooltip( checkbox_all[var.id], make_desc(var, is_hardcoded=True), ) for var in VAR_LIST: tk_vars[var.id] = IntVar(value=var.enabled) args = { 'variable': tk_vars[var.id], 'text': var.name, } desc = make_desc(var) if var.applies_to_all(): # Available in all styles - put with the hardcoded variables. all_pos += 1 checkbox_all[var.id] = check = ttk.Checkbutton(frame_all, **args) check.grid(row=all_pos, column=0, sticky="W", padx=3) tooltip.add_tooltip(check, desc) else: # Swap between checkboxes depending on style. checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args) checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args) tooltip.add_tooltip( checkbox_chosen[var.id], desc, ) tooltip.add_tooltip( checkbox_other[var.id], desc, ) UI['style_can'].create_window(0, 0, window=canvas_frame, anchor="nw") UI['style_can'].update_idletasks() UI['style_can'].config( scrollregion=UI['style_can'].bbox(ALL), width=canvas_frame.winfo_reqwidth(), ) if utils.USE_SIZEGRIP: ttk.Sizegrip( window, cursor=utils.CURSORS['stretch_vert'], ).grid(row=1, column=0) UI['style_can'].bind('<Configure>', flow_stylevar) item_config_frame = ttk.Frame(nbook) nbook.add(item_config_frame, text=_('Items')) itemconfig.make_pane(item_config_frame)
def make_pane(tool_frame): """Create the compiler options pane. """ global window window = SubPane( TK_ROOT, options=GEN_OPTS, title='Compile Opt', name='compiler', resize_x=True, resize_y=False, tool_frame=tool_frame, tool_img=png.png('icons/win_compiler'), tool_col=4, ) window.columnconfigure(0, weight=1) thumb_frame = ttk.LabelFrame( window, text='Thumbnail', labelanchor=N, ) thumb_frame.grid(row=0, column=0, sticky=EW) thumb_frame.columnconfigure(0, weight=1) UI['thumb_auto'] = ttk.Radiobutton( thumb_frame, text='Auto', value='AUTO', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_peti'] = ttk.Radiobutton( thumb_frame, text='PeTI', value='PETI', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_custom'] = ttk.Radiobutton( thumb_frame, text='Custom:', value='CUST', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_label'] = ttk.Label( thumb_frame, anchor=CENTER, cursor=utils.CURSORS['link'], ) UI['thumb_label'].bind( utils.EVENTS['LEFT'], find_screenshot, ) UI['thumb_cleanup'] = ttk.Checkbutton( thumb_frame, text='Cleanup old screenshots', variable=cleanup_screenshot, command=set_screenshot_cleanup, ) UI['thumb_auto'].grid(row=0, column=0, sticky='W') UI['thumb_peti'].grid(row=0, column=1, sticky='W') UI['thumb_custom'].grid(row=1, column=0, columnspan=2, sticky='NEW') UI['thumb_cleanup'].grid(row=3, columnspan=2, sticky='W') add_tooltip( UI['thumb_auto'], "Override the map image to use a screenshot automatically taken" "from the beginning of a chamber. Press F5 to take a new " "screenshot. If the map has not been previewed recently " "(within the last few hours), the default PeTI screenshot " "will be used instead.") add_tooltip(UI['thumb_peti'], "Use the normal editor view for the map preview image.") custom_tooltip = ( "Use a custom image for the map preview image. Click the " "screenshot to select.\n" "Images will be converted to JPEGs if needed.") add_tooltip( UI['thumb_custom'], custom_tooltip, ) add_tooltip(UI['thumb_label'], custom_tooltip) add_tooltip( UI['thumb_cleanup'], 'Automatically delete unused Automatic screenshots. ' 'Disable if you want to keep things in "portal2/screenshots". ') if chosen_thumb.get() == 'CUST': # Show this if the user has set it before UI['thumb_label'].grid(row=2, column=0, columnspan=2, sticky='EW') set_screenshot() # Load the last saved screenshot vrad_frame = ttk.LabelFrame( window, text='Lighting:', labelanchor=N, ) vrad_frame.grid(row=1, column=0, sticky=EW) UI['light_fast'] = ttk.Radiobutton( vrad_frame, text='Fast', value=0, variable=vrad_light_type, command=set_vrad_type, ) UI['light_fast'].grid(row=0, column=0) UI['light_full'] = ttk.Radiobutton( vrad_frame, text='Full', value=1, variable=vrad_light_type, command=set_vrad_type, ) UI['light_full'].grid(row=0, column=1) add_tooltip( UI['light_fast'], "Compile with lower-quality, fast lighting. This speeds " "up compile times, but does not appear as good. Some " "shadows may appear wrong.\n" "When publishing, this is ignored.") add_tooltip( UI['light_full'], "Compile with high-quality lighting. This looks correct, " "but takes longer to compute. Use if you're arranging lights." "When publishing, this is always used.") elev_frame = ttk.LabelFrame( window, text='Spawn at:', labelanchor=N, ) elev_frame.grid(row=2, column=0, sticky=EW) elev_frame.columnconfigure(0, weight=1) elev_frame.columnconfigure(1, weight=1) UI['elev_preview'] = ttk.Radiobutton( elev_frame, text='Entry Door', value=0, variable=start_in_elev, command=set_elev_type, ) UI['elev_elevator'] = ttk.Radiobutton( elev_frame, text='Elevator', value=1, variable=start_in_elev, command=set_elev_type, ) UI['elev_preview'].grid(row=0, column=0, sticky=W) UI['elev_elevator'].grid(row=0, column=1, sticky=W) add_tooltip( UI['elev_preview'], "When previewing in SP, spawn inside the entry elevator. " "This also disables the map restarts when you reach the " "exit door. Use this to examine the entry and exit corridors.") add_tooltip( UI['elev_elevator'], "When previewing in SP, spawn just before the entry door. " "When you reach the exit door, the map will restart.") corr_frame = ttk.LabelFrame( window, text='Corridor:', labelanchor=N, ) corr_frame.grid(row=3, column=0, sticky=EW) corr_frame.columnconfigure(0, weight=1) corr_frame.columnconfigure(1, weight=1) UI['corr_sp_entry'] = make_corr_combo( corr_frame, 'sp_entry', width=9, ) UI['corr_sp_exit'] = make_corr_combo( corr_frame, 'sp_exit', width=9, ) UI['corr_coop'] = make_corr_combo( corr_frame, 'coop', width=9, ) UI['corr_sp_entry'].grid(row=1, column=0, sticky=EW) UI['corr_sp_exit'].grid(row=1, column=1, sticky=EW) UI['corr_coop'].grid(row=2, column=1, sticky=EW) ttk.Label( corr_frame, text='SP Entry:', anchor=CENTER, ).grid(row=0, column=0, sticky=EW) ttk.Label( corr_frame, text='SP Exit:', anchor=CENTER, ).grid(row=0, column=1, sticky=EW) ttk.Label( corr_frame, text='Coop:', anchor=CENTER, ).grid(row=2, column=0, sticky=EW) model_frame = ttk.LabelFrame( window, text='Player Model (SP):', labelanchor=N, ) model_frame.grid(row=4, column=0, sticky=EW) UI['player_mdl'] = ttk.Combobox( model_frame, exportselection=0, textvariable=player_model_var, values=PLAYER_MODEL_ORDER, width=20, ) # Users can only use the dropdown UI['player_mdl'].state(['readonly']) UI['player_mdl'].grid(row=0, column=0, sticky=EW) UI['player_mdl'].bind('<<ComboboxSelected>>', set_model) model_frame.columnconfigure(0, weight=1) count_frame = ttk.LabelFrame( window, text='Last Compile:', labelanchor=N, ) count_frame.grid(row=5, column=0, sticky=EW) count_frame.columnconfigure(0, weight=1) count_frame.columnconfigure(2, weight=1) ttk.Label( count_frame, text='Entity', anchor=N, ).grid(row=0, column=0, columnspan=3, sticky=EW) UI['count_ent'] = ttk.Progressbar( count_frame, maximum=MAX_ENTS, variable=count_ents, length=120, ) UI['count_ent'].grid( row=1, column=0, columnspan=3, sticky=EW, padx=5, ) ttk.Label( count_frame, text='Overlay', anchor=CENTER, ).grid(row=2, column=0, sticky=EW) UI['count_over'] = ttk.Progressbar( count_frame, maximum=MAX_OVERLAY, variable=count_overlay, length=50, ) UI['count_over'].grid(row=3, column=0, sticky=EW, padx=5) ttk.Button( count_frame, image=png.png('icons/tool_sub'), command=refresh_counts, ).grid(row=3, column=1) ttk.Label( count_frame, text='Brush', anchor=CENTER, ).grid(row=2, column=2, sticky=EW) UI['count_brush'] = ttk.Progressbar( count_frame, maximum=MAX_BRUSH, variable=count_brush, length=50, ) UI['count_brush'].grid(row=3, column=2, sticky=EW, padx=5) UI['view_logs'] = ttk.Button( count_frame, text='View Logs', ) UI['view_logs'].grid(row=4, column=0, columnspan=3, sticky=EW) refresh_counts(reload=False)
def make_pane(tool_frame: Frame, menu_bar: Menu): """Create the styleVar pane. """ global window window = SubPane( TK_ROOT, title=_('Style/Item Properties'), name='style', menu_bar=menu_bar, resize_y=True, tool_frame=tool_frame, tool_img=img.png('icons/win_stylevar'), tool_col=3, ) UI['nbook'] = nbook = ttk.Notebook(window) nbook.grid(row=0, column=0, sticky=NSEW) window.rowconfigure(0, weight=1) window.columnconfigure(0, weight=1) nbook.enable_traversal() stylevar_frame = ttk.Frame(nbook) stylevar_frame.rowconfigure(0, weight=1) stylevar_frame.columnconfigure(0, weight=1) nbook.add(stylevar_frame, text=_('Styles')) UI['style_can'] = Canvas(stylevar_frame, highlightthickness=0) # need to use a canvas to allow scrolling UI['style_can'].grid(sticky='NSEW') window.rowconfigure(0, weight=1) UI['style_scroll'] = ttk.Scrollbar( stylevar_frame, orient=VERTICAL, command=UI['style_can'].yview, ) UI['style_scroll'].grid(column=1, row=0, rowspan=2, sticky="NS") UI['style_can']['yscrollcommand'] = UI['style_scroll'].set utils.add_mousewheel(UI['style_can'], stylevar_frame) canvas_frame = ttk.Frame(UI['style_can']) frame_all = ttk.Labelframe(canvas_frame, text=_("All:")) frame_all.grid(row=0, sticky='EW') frm_chosen = ttk.Labelframe(canvas_frame, text=_("Selected Style:")) frm_chosen.grid(row=1, sticky='EW') ttk.Separator( canvas_frame, orient=HORIZONTAL, ).grid(row=2, sticky='EW', pady=(10, 5)) frm_other = ttk.Labelframe(canvas_frame, text=_("Other Styles:")) frm_other.grid(row=3, sticky='EW') UI['stylevar_chosen_none'] = ttk.Label( frm_chosen, text=_('No Options!'), font='TkMenuFont', justify='center', ) UI['stylevar_other_none'] = ttk.Label( frm_other, text=_('None!'), font='TkMenuFont', justify='center', ) all_pos = 0 for all_pos, var in enumerate(styleOptions): # Add the special stylevars which apply to all styles tk_vars[var.id] = int_var = IntVar(value=var.default) checkbox_all[var.id] = ttk.Checkbutton( frame_all, variable=int_var, text=var.name, ) checkbox_all[var.id].grid(row=all_pos, column=0, sticky="W", padx=3) # Special case - this needs to refresh the filter when swapping, # so the items disappear or reappear. if var.id == 'UnlockDefault': def cmd(): update_filter() checkbox_all[var.id]['command'] = cmd tooltip.add_tooltip( checkbox_all[var.id], make_desc(var, is_hardcoded=True), ) for var in VAR_LIST: tk_vars[var.id] = IntVar(value=var.enabled) args = { 'variable': tk_vars[var.id], 'text': var.name, } desc = make_desc(var) if var.applies_to_all(): # Available in all styles - put with the hardcoded variables. all_pos += 1 checkbox_all[var.id] = check = ttk.Checkbutton(frame_all, **args) check.grid(row=all_pos, column=0, sticky="W", padx=3) tooltip.add_tooltip(check, desc) else: # Swap between checkboxes depending on style. checkbox_chosen[var.id] = ttk.Checkbutton(frm_chosen, **args) checkbox_other[var.id] = ttk.Checkbutton(frm_other, **args) tooltip.add_tooltip( checkbox_chosen[var.id], desc, ) tooltip.add_tooltip( checkbox_other[var.id], desc, ) UI['style_can'].create_window(0, 0, window=canvas_frame, anchor="nw") UI['style_can'].update_idletasks() UI['style_can'].config( scrollregion=UI['style_can'].bbox(ALL), width=canvas_frame.winfo_reqwidth(), ) if utils.USE_SIZEGRIP: ttk.Sizegrip( window, cursor=utils.CURSORS['stretch_vert'], ).grid(row=1, column=0) UI['style_can'].bind('<Configure>', flow_stylevar) item_config_frame = ttk.Frame(nbook) nbook.add(item_config_frame, text=_('Items')) itemconfig.make_pane(item_config_frame)
def make_pane(tool_frame): """Create the compiler options pane. """ global window window = SubPane( TK_ROOT, options=GEN_OPTS, title='Compile Opt', name='compiler', resize_x=True, resize_y=False, tool_frame=tool_frame, tool_img=png.png('icons/win_compiler'), tool_col=4, ) window.columnconfigure(0, weight=1) thumb_frame = ttk.LabelFrame( window, text='Thumbnail', labelanchor=N, ) thumb_frame.grid(row=0, column=0, sticky=EW) thumb_frame.columnconfigure(0, weight=1) UI['thumb_auto'] = ttk.Radiobutton( thumb_frame, text='Auto', value='AUTO', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_peti'] = ttk.Radiobutton( thumb_frame, text='PeTI', value='PETI', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_custom'] = ttk.Radiobutton( thumb_frame, text='Custom:', value='CUST', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_label'] = ttk.Label( thumb_frame, anchor=CENTER, cursor=utils.CURSORS['link'], ) UI['thumb_label'].bind( utils.EVENTS['LEFT'], find_screenshot, ) UI['thumb_cleanup'] = ttk.Checkbutton( thumb_frame, text='Cleanup old screenshots', variable=cleanup_screenshot, command=set_screenshot_cleanup, ) UI['thumb_auto'].grid(row=0, column=0, sticky='W') UI['thumb_peti'].grid(row=0, column=1, sticky='W') UI['thumb_custom'].grid(row=1, column=0, columnspan=2, sticky='NEW') UI['thumb_cleanup'].grid(row=3, columnspan=2, sticky='W') add_tooltip( UI['thumb_auto'], "Override the map image to use a screenshot automatically taken" "from the beginning of a chamber. Press F5 to take a new " "screenshot. If the map has not been previewed recently " "(within the last few hours), the default PeTI screenshot " "will be used instead." ) add_tooltip( UI['thumb_peti'], "Use the normal editor view for the map preview image." ) custom_tooltip = ( "Use a custom image for the map preview image. Click the " "screenshot to select.\n" "Images will be converted to JPEGs if needed." ) add_tooltip( UI['thumb_custom'], custom_tooltip, ) add_tooltip( UI['thumb_label'], custom_tooltip ) add_tooltip( UI['thumb_cleanup'], 'Automatically delete unused Automatic screenshots. ' 'Disable if you want to keep things in "portal2/screenshots". ' ) if chosen_thumb.get() == 'CUST': # Show this if the user has set it before UI['thumb_label'].grid(row=2, column=0, columnspan=2, sticky='EW') set_screenshot() # Load the last saved screenshot vrad_frame = ttk.LabelFrame( window, text='Lighting:', labelanchor=N, ) vrad_frame.grid(row=1, column=0, sticky=EW) UI['light_fast'] = ttk.Radiobutton( vrad_frame, text='Fast', value=0, variable=vrad_light_type, command=set_vrad_type, ) UI['light_fast'].grid(row=0, column=0) UI['light_full'] = ttk.Radiobutton( vrad_frame, text='Full', value=1, variable=vrad_light_type, command=set_vrad_type, ) UI['light_full'].grid(row=0, column=1) add_tooltip( UI['light_fast'], "Compile with lower-quality, fast lighting. This speeds " "up compile times, but does not appear as good. Some " "shadows may appear wrong.\n" "When publishing, this is ignored." ) add_tooltip( UI['light_full'], "Compile with high-quality lighting. This looks correct, " "but takes longer to compute. Use if you're arranging lights." "When publishing, this is always used." ) elev_frame = ttk.LabelFrame( window, text='Spawn at:', labelanchor=N, ) elev_frame.grid(row=2, column=0, sticky=EW) elev_frame.columnconfigure(0, weight=1) elev_frame.columnconfigure(1, weight=1) UI['elev_preview'] = ttk.Radiobutton( elev_frame, text='Entry Door', value=0, variable=start_in_elev, command=set_elev_type, ) UI['elev_elevator'] = ttk.Radiobutton( elev_frame, text='Elevator', value=1, variable=start_in_elev, command=set_elev_type, ) UI['elev_preview'].grid(row=0, column=0, sticky=W) UI['elev_elevator'].grid(row=0, column=1, sticky=W) add_tooltip( UI['elev_preview'], "When previewing in SP, spawn inside the entry elevator. " "This also disables the map restarts when you reach the " "exit door. Use this to examine the entry and exit corridors." ) add_tooltip( UI['elev_elevator'], "When previewing in SP, spawn just before the entry door. " "When you reach the exit door, the map will restart." ) corr_frame = ttk.LabelFrame( window, text='Corridor:', labelanchor=N, ) corr_frame.grid(row=3, column=0, sticky=EW) corr_frame.columnconfigure(0, weight=1) corr_frame.columnconfigure(1, weight=1) UI['corr_sp_entry'] = make_corr_combo( corr_frame, 'sp_entry', width=9, ) UI['corr_sp_exit'] = make_corr_combo( corr_frame, 'sp_exit', width=9, ) UI['corr_coop'] = make_corr_combo( corr_frame, 'coop', width=9, ) UI['corr_sp_entry'].grid(row=1, column=0, sticky=EW) UI['corr_sp_exit'].grid(row=1, column=1, sticky=EW) UI['corr_coop'].grid(row=2, column=1, sticky=EW) ttk.Label( corr_frame, text='SP Entry:', anchor=CENTER, ).grid(row=0, column=0, sticky=EW) ttk.Label( corr_frame, text='SP Exit:', anchor=CENTER, ).grid(row=0, column=1, sticky=EW) ttk.Label( corr_frame, text='Coop:', anchor=CENTER, ).grid(row=2, column=0, sticky=EW) model_frame = ttk.LabelFrame( window, text='Player Model (SP):', labelanchor=N, ) model_frame.grid(row=4, column=0, sticky=EW) UI['player_mdl'] = ttk.Combobox( model_frame, exportselection=0, textvariable=player_model_var, values=PLAYER_MODEL_ORDER, width=20, ) # Users can only use the dropdown UI['player_mdl'].state(['readonly']) UI['player_mdl'].grid(row=0, column=0, sticky=EW) UI['player_mdl'].bind('<<ComboboxSelected>>', set_model) model_frame.columnconfigure(0, weight=1) count_frame = ttk.LabelFrame( window, text='Last Compile:', labelanchor=N, ) count_frame.grid(row=5, column=0, sticky=EW) count_frame.columnconfigure(0, weight=1) count_frame.columnconfigure(2, weight=1) ttk.Label( count_frame, text='Entity', anchor=N, ).grid(row=0, column=0, columnspan=3, sticky=EW) UI['count_ent'] = ttk.Progressbar( count_frame, maximum=MAX_ENTS, variable=count_ents, length=120, ) UI['count_ent'].grid( row=1, column=0, columnspan=3, sticky=EW, padx=5, ) ttk.Label( count_frame, text='Overlay', anchor=CENTER, ).grid(row=2, column=0, sticky=EW) UI['count_over'] = ttk.Progressbar( count_frame, maximum=MAX_OVERLAY, variable=count_overlay, length=50, ) UI['count_over'].grid(row=3, column=0, sticky=EW, padx=5) ttk.Button( count_frame, image=png.png('icons/tool_sub'), command=refresh_counts, ).grid(row=3, column=1) ttk.Label( count_frame, text='Brush', anchor=CENTER, ).grid(row=2, column=2, sticky=EW) UI['count_brush'] = ttk.Progressbar( count_frame, maximum=MAX_BRUSH, variable=count_brush, length=50, ) UI['count_brush'].grid(row=3, column=2, sticky=EW, padx=5) UI['view_logs'] = ttk.Button( count_frame, text='View Logs', ) UI['view_logs'].grid(row=4, column=0, columnspan=3, sticky=EW) refresh_counts(reload=False)