Skip to content

Commit

Permalink
Merge pull request #912 from annie-xd-wang/911-low-frequency-multi-po…
Browse files Browse the repository at this point in the history
…sition-table-error
  • Loading branch information
AdvancedImagingUTSW authored Jun 5, 2024
2 parents 871c859 + 6a767dc commit 072e9bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
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()

0 comments on commit 072e9bc

Please sign in to comment.