Skip to content

Commit

Permalink
re-added window chrome (macOS style guide violation), removed some lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Willner committed Nov 7, 2021
1 parent 9ca17bf commit a777de2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions .vulture-whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ _.closed # unused attribute (things3/things3_app.py:69)
_.row_factory # unused attribute (things3/things3.py:727)
cls # unused variable (things3/things3_cli.py:54)
cls # unused variable (things3/things3_cli.py:59)
NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess # unused variable (things3_appstore.py:55)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def package_files(directory):
AUTHOR_MAIL = "alex@willner.ws"
DESCRIPTON = "A simple read-only Kanban App for Things 3"
URL = "https://kanbanview.app"
VERSION = "2.7.0"
VERSION = "2.7.1"
DATA_FILES = package_files("resources")
OPTIONS = {
"argv_emulation": False,
Expand Down
2 changes: 1 addition & 1 deletion things3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__copyright__ = "2020 Alexander Willner"
__credits__ = ["Alexander Willner"]
__license__ = "Apache License 2.0"
__version__ = "2.7.0"
__version__ = "2.7.1"
__maintainer__ = "Alexander Willner"
__email__ = "alex@willner.ws"
__status__ = "Development"
4 changes: 2 additions & 2 deletions things3/things3.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def __init__(
# Automated migration to new database location in Things 3.12.6/3.13.1
# --------------------------------
try:
with open(self.database) as f_d:
with open(self.database, encoding="utf-8") as f_d:
if "Your database file has been moved there" in f_d.readline():
self.database = f"/Users/{self.user}/{self.FILE_DB}"
except (UnicodeDecodeError, FileNotFoundError, PermissionError):
Expand All @@ -151,7 +151,7 @@ def set_config(self, key, value, domain="DATABASE"):
self.config.add_section(domain)
if value is not None and key is not None:
self.config.set(domain, str(key), str(value))
with open(self.FILE_CONFIG, "w+") as configfile:
with open(self.FILE_CONFIG, "w+", encoding="utf-8") as configfile:
self.config.write(configfile)

def get_config(self, key, domain="DATABASE"):
Expand Down
19 changes: 15 additions & 4 deletions things3/things3_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,24 @@ def main(self, appstore=False):

print(f"Using database 1: {self.database}")

window = webview.create_window(
self.window = webview.create_window(
title="KanbanView",
url=f"http://{things3_api.Things3API.host}:"
+ f"{things3_api.Things3API.port}/{self.FILE}",
width=1280,
height=650,
min_size=(1280, 650),
frameless=True,
frameless=False,
)

if not appstore:
window.closed += advertise
self.window.closed += advertise
self.window.closing += self.closing
self.api_thread = Thread(target=self.open_api)

try:
self.api_thread.start()
webview.start() # blocking
webview.start(self.closing, self.window) # blocking
self.api.flask_context.shutdown()
self.api_thread.join()
except KeyboardInterrupt:
Expand All @@ -70,6 +72,15 @@ def main(self, appstore=False):
self.api_thread.join()
sys.exit(0)

def closing(self, _window=None):
"""Close the app"""
if not _window:
self.window.destroy()
# self.api.flask_context.shutdown()
# self.api_thread.join()
else:
print(f"Registering close function for: {_window}")


def advertise():
"""Show a hint to buy the app"""
Expand Down
4 changes: 2 additions & 2 deletions things3/things3_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ def get_parser(cls):
parser.add_argument(
"--version",
action="version",
version="%(prog)s (version {version})".format(version=things3.__version__),
version=f"%(prog)s (version {things3.__version__})",
)

argcomplete.autocomplete(parser)

return parser

def main(self, args=None):
""" Main entry point of the app """
"""Main entry point of the app"""

if args is None:
self.main(Things3CLI.get_parser().parse_args())
Expand Down

0 comments on commit a777de2

Please sign in to comment.