Skip to content

Commit

Permalink
Add option to create desktop shortcut.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianzhu Qiao committed Sep 29, 2024
1 parent 9a0fa0b commit 9de81f2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
15 changes: 14 additions & 1 deletion bsmplot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import sys
import os
import traceback
import multiprocessing
import ctypes
import wx
import click
from bsmutility.utility import create_shortcut
from .mainframe import MainFrame
from .version import __version__, PROJECT_NAME
try:
ctypes.windll.shcore.SetProcessDpiAwareness(True)
wx.PyApp.IsDisplayAvailable = lambda _: True
except:
pass

Expand Down Expand Up @@ -48,10 +53,18 @@ def OnInit(self):
@click.option('--debug',
is_flag=True,
help='Run in debug mode.')
@click.option('--init', is_flag=True)
@click.argument('module', nargs=-1)
def main(config, path, ignore_perspective, spawn, debug,module):
def main(config, path, ignore_perspective, spawn, debug, module, init):
if spawn and hasattr(multiprocessing, 'set_start_method'):
multiprocessing.set_start_method('spawn')
if init:
folder, _ = os.path.split(__file__)
icns = f'{folder}/ico/mainframe.icns'
ico = f'{folder}/ico/mainframe.ico'
svg = f'{folder}/ico/mainframe.svg'
create_shortcut(PROJECT_NAME, icns, ico, svg)
return
app = RunApp(config=config,
ignore_perspective=ignore_perspective,
path=path,
Expand Down
Binary file added bsmplot/ico/mainframe.icns
Binary file not shown.
Binary file added bsmplot/ico/mainframe.ico
Binary file not shown.
1 change: 1 addition & 0 deletions bsmplot/ico/mainframe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion bsmplot/mainframexpm.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mainframe_svg = '<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="#F2F2F7" x="2" y="2" height="20" width="20" rx="4"/><g transform="translate(2.4, 2.4) scale(0.8)><path fill="#FF4530" d="M14.06,9.94L12,9l2.06-0.94L15,6l0.94,2.06L18,9l-2.06,0.94L15,12L14.06,9.94z"/> <path fill="#34C759" d="M4,14l0.94-2.06L7,11l-2.06-0.94L4,8 l-0.94,2.06L1,11l2.06,0.94L4,14z"/> <path fill="#FF9500" d="M8.5,9l1.09-2.41L12,5.5L9.59,4.41L8.5,2L7.41,4.41L5,5.5l2.41,1.09L8.5,9z"/> <path fill="#0A84FF" d="M4.5,20.5l6-6.01l4,4 L23,8.93l-1.41-1.41l-7.09,7.97l-4-4L3,19L4.5,20.5z"/></g></svg>'
mainframe_svg = '<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="#F2F2F7" x="2" y="2" height="20" width="20" rx="4"/><g transform="translate(2.4, 2.4) scale(0.8)"><path fill="#FF4530" d="M14.06,9.94L12,9l2.06-0.94L15,6l0.94,2.06L18,9l-2.06,0.94L15,12L14.06,9.94z"/> <path fill="#34C759" d="M4,14l0.94-2.06L7,11l-2.06-0.94L4,8 l-0.94,2.06L1,11l2.06,0.94L4,14z"/> <path fill="#FF9500" d="M8.5,9l1.09-2.41L12,5.5L9.59,4.41L8.5,2L7.41,4.41L5,5.5l2.41,1.09L8.5,9z"/> <path fill="#0A84FF" d="M4.5,20.5l6-6.01l4,4 L23,8.93l-1.41-1.41l-7.09,7.97l-4-4L3,19L4.5,20.5z"/></g></svg>'
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ bsmplot = "bsmplot.__main__:main"
[tool.setuptools.packages]
find = {}

[tool.setuptools.package-data]
bsmplot = ["ico/*.icns", "ico/*.ico", "ico/*.svg"]

[options]
include_package_data = true

0 comments on commit 9de81f2

Please sign in to comment.