Add only csv files in file explorer + avoid dirty exception if no file is chosen

This commit is contained in:
CMDR-Kiel42 committed 2019-06-01 00:25:03 +02:00
1 parent 5334e3320e
commit 74da851997
1 file changed
+12 -10
+12 -10
View File
@@ -49,19 +49,21 @@ def copy_waypoint(self=None):
this.parent.update() this.parent.update()
def new_route(self=None): def new_route(self=None):
filename = filedialog.askopenfilename() # show an "Open" dialog box and return the path to the selected file filename = filedialog.askopenfilename(filetypes = (("csv files", "*.csv"),)) # show an "Open" dialog box and return the path to the selected file
this.next_route = filename
with open(filename, 'r') as csvfile: if filename.__len__() > 0:
route_reader = csv.reader(csvfile) this.next_route = filename
this.route = [row for row in route_reader]
if monitor.system == this.route[1][0]: with open(filename, 'r') as csvfile:
del this.route[1] route_reader = csv.reader(csvfile)
this.route = [row for row in route_reader]
this.next_stop = this.route[1][0] if monitor.system == this.route[1][0]:
copy_waypoint() del this.route[1]
update_gui()
this.next_stop = this.route[1][0]
copy_waypoint()
update_gui()
def update_route(): def update_route():
del(this.route[1]) del(this.route[1])