update convert_coordinate in editor.py

This commit is contained in:
Pavel 2021-10-19 23:05:56 +02:00
parent ba6bc63cad
commit dba5f26264
1 changed files with 8 additions and 12 deletions

View File

@ -174,30 +174,26 @@ def motion(event):
def convert_coordinate(x):
i = int(x)
f = x % 1
if f < 0.25: f = 0.1
elif f < 0.5: f = 0.3
elif f < 0.75: f = 0.5
elif f < 0.9: f = 0.7
else: f = 0.9
return i + f
if f < 0.5: return i, 1
else: return i + 1, -1
def append_step(event):
global text, cell_w, cell_h
x, y = (event.x - 1) / cell_w, (event.y - 1) / cell_h
if x >= 146 or y >= 91: return
x = convert_coordinate(x)
y = convert_coordinate(y)
x, a = convert_coordinate(x)
y, b = convert_coordinate(y)
text.edit_separator()
text.insert('end', '%7.3f 0 %6.3f 0\n' % (x, y))
text.insert('end', '%7.3f %2d %6.3f %2d\n' % (x, a, y, b))
def insert_step(event):
global text, cell_w, cell_h
x, y = (event.x - 1) / cell_w, (event.y - 1) / cell_h
if x >= 146 or y >= 91: return
x = convert_coordinate(x)
y = convert_coordinate(y)
x, a = convert_coordinate(x)
y, b = convert_coordinate(y)
text.edit_separator()
text.insert('insert linestart', '%7.3f 0 %6.3f 0\n' % (x, y))
text.insert('insert linestart', '%7.3f %2d %6.3f %2d\n' % (x, a, y, b))
def select_all(event):
global text