From 85b9c79c7a3ccd55d0d6d00744172ef4687fd5e7 Mon Sep 17 00:00:00 2001 From: CMDR-Kiel42 Date: Mon, 10 Jun 2019 22:18:13 +0200 Subject: [PATCH] Prevent clipboard from not being properly updated on Linux --- load.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/load.py b/load.py index c7ee74e..53289ca 100644 --- a/load.py +++ b/load.py @@ -6,6 +6,9 @@ import csv import os from monitor import monitor +if sys.platform.startswith('linux'): + import subprocess + this = sys.modules[__name__] this.next_stop = "No route planned" @@ -44,9 +47,13 @@ def update_gui(): this.waypoint_btn["text"] = this.next_wp_label + this.next_stop def copy_waypoint(self=None): - this.parent.clipboard_clear() - this.parent.clipboard_append(this.next_stop) - this.parent.update() + if sys.platform == "win32": + this.parent.clipboard_clear() + this.parent.clipboard_append(this.next_stop) + this.parent.update() + else: + command = subprocess.Popen(["echo", "-n", this.next_stop], stdout=subprocess.PIPE) + subprocess.Popen(["xclip", "-selection", "c"], stdin=command.stdout) def new_route(self=None): filename = filedialog.askopenfilename(filetypes = (("csv files", "*.csv"),)) # show an "Open" dialog box and return the path to the selected file