Skip to content

Commit

Permalink
Fix pasting of coordinates for port
Browse files Browse the repository at this point in the history
Make more pythonic and reliable; closes #83
  • Loading branch information
ibell committed Aug 26, 2023
1 parent 6d14ba5 commit 4f18291
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions GUI/panels/scroll_panels.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from math import pi, cos, sin
import textwrap
import textwrap, io

import wx
import wx.grid
Expand Down Expand Up @@ -267,20 +267,15 @@ def OnPaste(self, event):
success = wx.TheClipboard.GetData(do)
wx.TheClipboard.Close()

data = do.GetText()
if '\r' in data and '\n' not in data:
data = data.replace('\r','\n')
elif '\r\n' in data:
data = data.replace('\r\n','\n')
rows = data.strip().split('\n')
rows = [row.split('\t') for row in rows]
rows = io.StringIO(do.GetText()).readlines()
rows = [row.split('\t') for row in rows if row.strip()]

try:
for row in rows:
for el in row:
float(el)
self.update_from_configfile(zip(*rows))
except ValueError:
self.update_from_configfile(list(zip(*rows)))
except (ValueError, TypeError):
dlg = wx.MessageDialog(None, "Unable to paste from clipboard - bad format")
dlg.ShowModal()
dlg.Close()
Expand Down

0 comments on commit 4f18291

Please sign in to comment.