Skip to content

Commit

Permalink
Hopefully platform agnostic opening of settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Vhou-Atroph committed May 9, 2024
1 parent 6f76a14 commit 08be809
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/tt_damage_calculator/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
TT-Damage-Calculator
Copyright (C) 2022-2024 Vhou-Atroph
"""
import os, pathlib, sys, webbrowser
import os, pathlib, platform, sys
from tkinter import IntVar, BooleanVar, DoubleVar, Tk, Frame, Label, Text, Button, PhotoImage, Menu, NORMAL, DISABLED, WORD, END

from . import tt_damage_calculator
Expand Down Expand Up @@ -175,13 +175,22 @@ def build_ui(self):

self.results = CalculationResults(self.column_0)

def file(self, filepath):
match platform.system():
case "Windows":
os.startfile(filepath)
case "Darwin":
os.system(("open " + filepath))
case "Linux":
os.system(("xdg-open " + filepath))

def toolbar(self):
"""Creates the program's toolbar."""

toolbar = Menu(self)

program_menu = Menu(toolbar, tearoff=0)
program_menu.add_command(label="Settings", command=lambda:webbrowser.open(self.asset_path + "/assets/settings.toml"))
program_menu.add_command(label="Settings", command=lambda:self.file(self.asset_path + "/assets/settings.toml"))
program_menu.add_checkbutton(label="Pin window", command=self.pin, variable=self.pinned, onvalue=True, offvalue=False, accelerator="Placeholder")
program_menu.add_separator()
program_menu.add_command(label="Exit", command=lambda:window.destroy(), accelerator="Alt-F4")
Expand Down

0 comments on commit 08be809

Please sign in to comment.