style fixes + reference fix (IDE complains)

This commit is contained in:
Jan Vansteenkiste 2019-06-20 10:04:58 +02:00
parent 103069c852
commit fcf8f85849

10
load.py
View File

@ -17,6 +17,7 @@ this.next_wp_label = "Next waypoint: "
this.parent = None
this.save_route_path = ""
def plugin_start():
if sys.platform == 'win32':
this.save_route_path = os.path.expandvars(r'%LOCALAPPDATA%\EDMarketConnector\plugins\SpanshRouter\route.csv')
@ -41,9 +42,11 @@ def plugin_stop():
with open(this.save_route_path, 'w') as csvfile:
csvfile.write('\n'.join(this.route))
def update_gui():
this.waypoint_btn["text"] = this.next_wp_label + this.next_stop
def copy_waypoint(self=None):
if sys.platform == "win32":
this.parent.clipboard_clear()
@ -53,6 +56,7 @@ def copy_waypoint(self=None):
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
@ -70,6 +74,7 @@ def new_route(self=None):
copy_waypoint()
update_gui()
def update_route():
del(this.route[1])
if this.route.__len__() == 0:
@ -82,6 +87,7 @@ def update_route():
update_gui()
copy_waypoint(this.parent)
def journal_entry(cmdr, is_beta, system, station, entry, state):
if (entry['event'] == 'FSDJump' or entry['event'] == 'Location') and entry["StarSystem"] == this.next_stop:
update_route()
@ -90,8 +96,8 @@ def plugin_app(parent):
this.parent = parent
this.frame = tk.Frame(parent)
this.waypoint_btn = tk.Button(frame, text= this.next_wp_label + this.next_stop)
this.upload_route_btn = tk.Button(frame, text= "Upload new route")
this.waypoint_btn = tk.Button(this.frame, text=this.next_wp_label + this.next_stop)
this.upload_route_btn = tk.Button(this.frame, text="Upload new route")
this.waypoint_btn.bind("<ButtonRelease-1>", copy_waypoint)
this.upload_route_btn.bind("<ButtonRelease-1>", new_route)