#! /usr/bin/python3 # =================================================================== # test converting center/window coordinates # =================================================================== import coordinate_conversion as cc import user_interface as ui import sys wheight = 800 # window height wwidth = 800 # window width # ------------------------------------------------------------------- # ---- main # ------------------------------------------------------------------- # ---- running Python3? if not ui.running_python3(): print() print('Error: you must run Python3 - exit program') print() sys.exit() # ---- print title print() print('Convert Center/Window Coordinates') # ---- user input loop while True: # ---- get X coordinate print() x = ui.get_user_input('Enter X coord: ') if not x: break if not ui.is_a_number(x): print() print("Error, bad X coordinate") continue x = float(x) # ---- get Y coordinate print() y = ui.get_user_input('Enter Y coord: ') if not y: break if not ui.is_a_number(y): print() print("Error, bad Y coordinate") continue y = float(y) # ---- get selection print() print('[wW] Convert center to window coordinates') print('[cC] convert window to center coordinates') print('[eE] Exit') print('Enter anything else to continue') print() s = ui.get_user_input('Enter selection: ') if not s: continue elif s[0] == 'e' or s[0] == 'E': break elif s[0] == 'w' or s[0] == 'W': print() print('Converted center coordinates to window coordinates') x,y = cc.center_to_win_coords(x,y,wwidth,wheight) elif s[0] == 'c' or s[0] == 'C': print() print('Converted window coordinates to center coordinates') x,y = cc.win_to_center_coords(x,y,wwidth,wheight) else: continue # ---- print conversion results print() print(f'X = {x}, Y = {y}') ui.pause() print()