def save_angle(key, new_angle): global last_angle if new_angle > last_angle: sound.fx_blockable('raise_' + random.choice('123')) elif new_angle < last_angle: sound.fx_blockable('lower_' + random.choice('123')) last_angle = new_angle out_values[key] = 'ramp_' + str(new_angle) + '_deg_open'
def save_angle(key: str, new_angle: int) -> None: """Change callback for angle properties.""" global last_angle if new_angle > last_angle: sound.fx_blockable('raise_' + random.choice('123')) elif new_angle < last_angle: sound.fx_blockable('lower_' + random.choice('123')) last_angle = new_angle out_values[key] = 'ramp_' + str(new_angle) + '_deg_open'
def save_tim(key, val): global enable_tim_callback if enable_tim_callback: new_val = round(float(val)) # Lock to whole numbers enable_tim_callback = False widgets[key].set(new_val) enable_tim_callback = True labels[key]['text'] = ('Timer Delay:\n ({})'.format( '∞' if new_val == 0 else str(new_val))) if new_val > values[key]: sound.fx_blockable('add') elif new_val < values[key]: sound.fx_blockable('subtract') values[key] = new_val out_values[key] = str(new_val)
def save_pist(key: str, val: str) -> None: """The top and bottom positions are closely interrelated.""" global enable_pist_callback if not enable_pist_callback: return try: top_wid: ttk.Scale = widgets['toplevel'] btm_wid: ttk.Scale = widgets['bottomlevel'] except KeyError: return # Both don't exist yet. # The ttk Scale widget doesn't snap to integers, so we need to do that. prev_top = top_wid.get() new_top = round(prev_top) prev_btm = btm_wid.get() new_btm = round(prev_btm) enable_pist_callback = False top_wid.set(new_top) btm_wid.set(new_btm) enable_pist_callback = True if top_wid.get() == btm_wid.get(): # user moved them to match, switch the other one around sound.fx_blockable('swap') (top_wid if key == 'bottomlevel' else btm_wid).set(values[key]) elif prev_top != new_top or prev_btm != new_btm: # Only play when we've actually changed. sound.fx_blockable('move') values['toplevel'] = start_pos = int(top_wid.get()) values['bottomlevel'] = end_pos = int(btm_wid.get()) values['startup'] = srctools.bool_as_int(start_pos > end_pos) out_values['toplevel'] = str(max(start_pos, end_pos)) out_values['bottomlevel'] = str(min(start_pos, end_pos))
def widget_sfx(*args): """Play sounds when interacting.""" sound.fx_blockable('config')
def set_check(key: str) -> None: """Generic change callback for checkboxes.""" sound.fx_blockable('config') out_values[key] = str(values[key].get())
def save_paint(key: str, val: str) -> None: """Save callback for paint options.""" sound.fx_blockable('config') out_values[key] = val
def set_check(key): sound.fx_blockable('config') out_values[key] = str(values[key].get())
def save_paint(key, val): sound.fx_blockable('config') out_values[key] = val