Skip to content

Commit

Permalink
Add app icon
Browse files Browse the repository at this point in the history
  • Loading branch information
bicobus committed Feb 5, 2024
1 parent 3845c75 commit 80302d3
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 12 deletions.
76 changes: 76 additions & 0 deletions resources/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 103 additions & 12 deletions src/pycestorieseditor/wxlaunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from itertools import count

import wx
import wx.svg
import wx.lib.stattext as wxst
from wx.lib.agw.multidirdialog import MultiDirDialog
from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin
Expand All @@ -29,6 +30,95 @@
logger = logging.getLogger(__name__)
LAUNCH_SETTINGS = False

svgicon = b"""\
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="128"
height="128"
viewBox="0 0 128 128"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="icon.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#999999"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="px"
showgrid="false"
inkscape:zoom="5.6568543"
inkscape:cx="52.679455"
inkscape:cy="69.826794"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="40"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:groupmode="layer"
id="layer4"
inkscape:label="Layer 2">
<rect
style="fill:#f1e9f1;fill-rule:evenodd;stroke:#f1e9f1;stroke-width:1.00779;stroke-linejoin:round;stroke-dasharray:none"
id="rect6787"
width="127.06355"
height="127.07146"
x="0.60600376"
y="0.57624954" />
</g>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
id="path6326"
style="fill:#4b2d83;fill-rule:evenodd;stroke:#281845;stroke-width:1.44735;stroke-linejoin:round;stroke-dasharray:none"
inkscape:transform-center-x="-0.19999032"
inkscape:transform-center-y="-0.52014708"
d="m 27.969293,-20.36815 a 52.031013,52.031013 0 0 0 -4.450902,0.319851 l -1.633049,9.419875 a 42.728813,42.728813 0 0 0 -8.404006,2.2119368 L 7.629391,-16.135738 a 52.031013,52.031013 0 0 0 -4.9486996,2.484485 l 2.3448323,9.2914833 a 42.728813,42.728813 0 0 0 -6.6560814,5.3631572 l -8.4625693,-4.6581309 a 52.031013,52.031013 0 0 0 -3.565677,4.34728767 l 5.9352859,7.55256913 a 42.728813,42.728813 0 0 0 -3.8179549,7.4376906 l -9.600072,-0.813145 a 52.031013,52.031013 0 0 0 -1.531687,5.51182 l 8.518881,4.498205 a 42.728813,42.728813 0 0 0 -0.590149,6.79123 42.728813,42.728813 0 0 0 0.09685,1.36275 l -9.075245,3.153473 a 52.031013,52.031013 0 0 0 0.831166,5.755089 l 9.638364,0.646461 a 42.728813,42.728813 0 0 0 2.745775,7.512024 l -6.989448,6.556971 a 52.031013,52.031013 0 0 0 3.103918,4.996002 l 9.0910129,-3.338176 a 42.728813,42.728813 0 0 0 5.42622604,5.728059 l -3.70983604,8.813957 a 52.031013,52.031013 0 0 0 4.8743679,3.35845 l 6.9669235,-6.766453 a 42.728813,42.728813 0 0 0 7.2214537,3.034091 l 0.195966,9.611334 a 52.031013,52.031013 0 0 0 5.800138,1.132996 l 3.624242,-9.043706 a 42.728813,42.728813 0 0 0 2.892184,0.207227 42.728813,42.728813 0 0 0 4.955458,-0.355891 l 4.117536,8.764403 a 52.031013,52.031013 0 0 0 5.723553,-1.268148 L 42.4167,71.767324 a 42.728813,42.728813 0 0 0 7.210191,-3.360702 l 7.367865,6.367764 a 52.031013,52.031013 0 0 0 4.63561,-3.468821 l -4.286471,-8.728363 a 42.728813,42.728813 0 0 0 5.324865,-6.126747 l 9.365815,2.83362 a 52.031013,52.031013 0 0 0 2.732262,-5.005012 l -7.419675,-6.189817 a 42.728813,42.728813 0 0 0 2.412407,-7.95351 l 9.737475,-1.22535 a 52.031013,52.031013 0 0 0 0.398685,-5.590657 l -9.248682,-2.62414 a 42.728813,42.728813 0 0 0 -1.090201,-8.435541 l 8.388242,-5.074838 a 52.031013,52.031013 0 0 0 -1.903345,-5.187464 l -9.487455,1.360498 a 42.728813,42.728813 0 0 0 -4.55001,-7.3678649 l 5.5839,-8.0233363 a 52.031013,52.031013 0 0 0 -3.82246,-3.919316 l -8.102174,5.09511069 A 42.728813,42.728813 0 0 0 48.408303,-5.7472979 l 1.831268,-9.5685381 a 52.031013,52.031013 0 0 0 -5.072587,-2.004708 l -5.324865,7.9445003 a 42.728813,42.728813 0 0 0 -8.640517,-1.4596073 l -2.211935,-9.46042 a 52.031013,52.031013 0 0 0 -1.020374,-0.07208 z m 0.01352,41.87587 a 10.154132,10.154132 0 0 1 10.156436,10.149679 v 0.0045 A 10.154132,10.154132 0 0 1 27.985062,41.81608 10.154132,10.154132 0 0 1 17.830878,31.664149 10.154132,10.154132 0 0 1 27.982809,21.507714 Z"
inkscape:label="Gear" />
<path
id="path6328"
style="fill:#05285b;fill-rule:evenodd;stroke:#073984;stroke-width:1.44735;stroke-linejoin:round;stroke-dasharray:none"
inkscape:transform-center-x="-0.19999032"
inkscape:transform-center-y="-0.52014708"
d="m 101.64248,42.299103 a 52.031013,52.031013 0 0 0 -4.450899,0.319851 l -1.633049,9.419875 a 42.728813,42.728813 0 0 0 -8.404006,2.211937 l -5.851945,-7.719251 a 52.031013,52.031013 0 0 0 -4.9487,2.484485 l 2.344833,9.291483 a 42.728813,42.728813 0 0 0 -6.656082,5.363157 l -8.462569,-4.658131 a 52.031013,52.031013 0 0 0 -3.565677,4.347288 l 5.935286,7.552569 a 42.728813,42.728813 0 0 0 -3.817955,7.437691 l -9.600072,-0.813145 a 52.031013,52.031013 0 0 0 -1.531687,5.51182 l 8.518881,4.498205 a 42.728813,42.728813 0 0 0 -0.590149,6.79123 42.728813,42.728813 0 0 0 0.09685,1.36275 l -9.075245,3.153473 a 52.031013,52.031013 0 0 0 0.831166,5.75509 l 9.638364,0.64646 a 42.728813,42.728813 0 0 0 2.745775,7.51202 l -6.989448,6.55697 a 52.031013,52.031013 0 0 0 3.103918,4.99601 l 9.091013,-3.33818 a 42.728813,42.728813 0 0 0 5.426226,5.72806 l -3.709836,8.81396 a 52.031013,52.031013 0 0 0 4.874368,3.35845 l 6.966923,-6.76646 a 42.728813,42.728813 0 0 0 7.221454,3.03409 l 0.195966,9.61134 a 52.031013,52.031013 0 0 0 5.800138,1.13299 l 3.624242,-9.0437 a 42.728813,42.728813 0 0 0 2.892186,0.20723 42.728813,42.728813 0 0 0 4.95546,-0.3559 l 4.11753,8.76441 a 52.031013,52.031013 0 0 0 5.72356,-1.26815 l -0.36941,-9.7645 a 42.728813,42.728813 0 0 0 7.21019,-3.36071 l 7.36787,6.36777 a 52.031013,52.031013 0 0 0 4.63561,-3.46882 l -4.28647,-8.72837 a 42.728813,42.728813 0 0 0 5.32486,-6.12674 l 9.36582,2.83362 a 52.031013,52.031013 0 0 0 2.73226,-5.00501 l -7.41968,-6.18982 a 42.728813,42.728813 0 0 0 2.41241,-7.95351 l 9.73747,-1.22535 a 52.031013,52.031013 0 0 0 0.39869,-5.590658 l -9.24868,-2.62414 a 42.728813,42.728813 0 0 0 -1.0902,-8.435541 l 8.38824,-5.074838 a 52.031013,52.031013 0 0 0 -1.90335,-5.187464 l -9.48745,1.360498 a 42.728813,42.728813 0 0 0 -4.55001,-7.367865 l 5.5839,-8.023336 a 52.031013,52.031013 0 0 0 -3.82246,-3.919316 l -8.10218,5.09511 a 42.728813,42.728813 0 0 0 -7.25524,-4.890135 l 1.83127,-9.568538 a 52.031013,52.031013 0 0 0 -5.07259,-2.004708 l -5.32486,7.9445 a 42.728813,42.728813 0 0 0 -8.64052,-1.459607 l -2.21193,-9.46042 a 52.031013,52.031013 0 0 0 -1.02038,-0.07208 z m 0.0135,41.87587 a 10.154132,10.154132 0 0 1 10.15644,10.149679 v 0.0045 A 10.154132,10.154132 0 0 1 101.65825,104.48333 10.154132,10.154132 0 0 1 91.504068,94.331402 10.154132,10.154132 0 0 1 101.656,84.174967 Z"
inkscape:label="Gear" />
<rect
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;paint-order:normal"
id="rect7373"
width="123.34502"
height="123.35346"
x="2.3274918"
y="2.3232689" />
</g>
</svg>
"""


class ArtProvider(wx.ArtProvider):
def CreateBitmap(self, id_art, client, size):
if size == wx.DefaultSize:
size = wx.Size(32, 32)
if id_art == 'ICON':
svg = wx.svg.SVGimage.CreateFromBytes(svgicon)
return svg.ConvertToScaledBitmap(size)
return wx.NullBitmap


class CeListPathItem(wx.ListItem):
_wid = count()
Expand Down Expand Up @@ -356,24 +446,25 @@ def _show_warning(self, txt: str):

class CeStoriesViewer(wx.App):
def OnInit(self):
global LAUNCH_SETTINGS
self.SetAppName(APPNAME)
if PORTABLE:
conf = get_config("settings")
if os.path.exists(conf) and not LAUNCH_SETTINGS:
window = MainWindow(conf)
else:
window = CeSettingsWindow(None, conf)
else:
raise Exception("Non portable version not written yet.")

window.Show()
self.SetTopWindow(window)
return True


def launch(settings=False):
global LAUNCH_SETTINGS
LAUNCH_SETTINGS = settings
app = CeStoriesViewer()
wx.ArtProvider.Push(ArtProvider())

if PORTABLE:
conf = get_config("settings")
if os.path.exists(conf) and not LAUNCH_SETTINGS:
window = MainWindow(conf)
else:
window = CeSettingsWindow(None, conf)
else:
raise Exception("Non portable version not written yet.")

window.Show()
app.SetTopWindow(window)
app.MainLoop()
2 changes: 2 additions & 0 deletions src/pycestorieseditor/wxui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@ class MainWindow(wx.Frame):
def __init__(self, conffile, *args, **kwds):
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
super().__init__(None, wx.ID_ANY, *args, title="CE Events Visualizer", **kwds)
self.SetIcon(wx.ArtProvider.GetIcon('ICON'))
self._conffile = conffile
self._load_conf()
bbx = get_bigbadxml()
Expand Down Expand Up @@ -1674,6 +1675,7 @@ def _load_conf(self):
maximum=1,
style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_SMOOTH,
)
dialog.SetIcon(wx.ArtProvider.GetIcon('ICON'))

def pulse(m=None):
if not m:
Expand Down

0 comments on commit 80302d3

Please sign in to comment.