Skip to content

Commit

Permalink
Ignore self as a command line argument when opening documents.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Sep 27, 2019
1 parent a3732b4 commit 0a868e5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cocoa/toga_cocoa/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import inspect
import os
import sys
from urllib.parse import unquote, urlparse
Expand Down Expand Up @@ -49,6 +50,13 @@ def applicationShouldOpenUntitledFile_(self, sender) -> bool:
def application_openFiles_(self, app, filenames) -> None:
for i in range(0, len(filenames)):
filename = filenames[i]
# If you start your Toga application as `python myapp.py` or
# `myapp.py`, the name of the Python script is included as a
# filename to be processed. Inspect the stack, and ignore any
# "document" that matches the file doing the executing
if filename == inspect.stack(-1)[-1].filename:
continue

if isinstance(filename, NSString):
fileURL = NSURL.fileURLWithPath(filename)

Expand Down

0 comments on commit 0a868e5

Please sign in to comment.