Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update multi-position controller #912

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def set_positions(self, positions):
for i, name in enumerate(axis_dict.keys()):
data[axis_dict[name]] = list(pos[i] for pos in positions)
self.table.model.df = pd.DataFrame(data)
self.table.currentrow = 0
self.table.redraw()
self.table.tableChanged()
self.show_verbose_info("loaded new positions")

def get_positions(self):
Expand Down Expand Up @@ -152,13 +154,21 @@ def handle_double_click(self, event):
event : tkinter event
event that triggers the function
"""
# it is calculated based on the GUI position
rowclicked = self.table.get_row_clicked(event)
# make sure a valid row is clicked
if rowclicked >= self.table.model.df.shape[0]:
return
df = self.table.model.df
temp = list(df.loc[rowclicked])
# df.loc uses key index
# df.iloc uses position index
temp = list(df.iloc[rowclicked])
# validate position
if list(filter(lambda v: type(v) != int and type(v) != float, temp)):
# TODO: show error: position is invalid
print("position is invalid")
messagebox.showwarning(
title="Warning",
message="The selected position is invalid, can't go to this position!"
)
logger.info("position is invalid")
return
position = {
Expand Down Expand Up @@ -212,7 +222,9 @@ def load_positions(self):
logger.info("The csv file isn't right, it should contain [X, Y, Z, R, F]")
return
self.table.model.df = df
self.table.update_rowcolors()
self.table.currentrow = 0
# reset index
self.table.resetColors()
self.table.redraw()
self.table.tableChanged()
self.show_verbose_info("loaded csv file", filename)
Expand Down
2 changes: 1 addition & 1 deletion src/navigate/tools/multipos_table_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,6 @@ def update_table(table, pos, append=False):
else:
table.model.df = frame
table.currentrow = table.model.df.shape[0] - 1
table.update_rowcolors()
table.resetColors()
table.redraw()
table.tableChanged()
Loading