Skip to content

Commit 87ce958

Browse files
authored
bpo-37778: Fixes the icons used for file associations to the Microsoft Store package (GH-15150)
1 parent 1fab9cb commit 87ce958

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes the icons used for file associations to the Microsoft Store package.

PC/icons/py.png

13.8 KB
Loading

PC/layout/support/appxmanifest.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
BackgroundColor="transparent",
6666
)
6767

68+
PY_PNG = '_resources/py.png'
69+
6870
APPXMANIFEST_NS = {
6971
"": "http://schemas.microsoft.com/appx/manifest/foundation/windows10",
7072
"m": "http://schemas.microsoft.com/appx/manifest/foundation/windows10",
@@ -278,12 +280,16 @@ def add_alias(xml, appid, alias, subsystem="windows"):
278280
e = find_or_add(e, "uap5:ExecutionAlias", ("Alias", alias))
279281

280282

281-
def add_file_type(xml, appid, name, suffix, parameters='"%1"'):
283+
def add_file_type(xml, appid, name, suffix, parameters='"%1"', info=None, logo=None):
282284
app = _get_app(xml, appid)
283285
e = find_or_add(app, "m:Extensions")
284286
e = find_or_add(e, "uap3:Extension", ("Category", "windows.fileTypeAssociation"))
285287
e = find_or_add(e, "uap3:FileTypeAssociation", ("Name", name))
286288
e.set("Parameters", parameters)
289+
if info:
290+
find_or_add(e, "uap:DisplayName").text = info
291+
if logo:
292+
find_or_add(e, "uap:Logo").text = logo
287293
e = find_or_add(e, "uap:SupportedFileTypes")
288294
if isinstance(suffix, str):
289295
suffix = [suffix]
@@ -399,7 +405,7 @@ def get_appxmanifest(ns):
399405
["python", "python{}".format(VER_MAJOR), "python{}".format(VER_DOT)],
400406
PYTHON_VE_DATA,
401407
"console",
402-
("python.file", [".py"]),
408+
("python.file", [".py"], '"%1"', 'Python File', PY_PNG),
403409
)
404410

405411
add_application(
@@ -410,7 +416,7 @@ def get_appxmanifest(ns):
410416
["pythonw", "pythonw{}".format(VER_MAJOR), "pythonw{}".format(VER_DOT)],
411417
PYTHONW_VE_DATA,
412418
"windows",
413-
("python.windowedfile", [".pyw"]),
419+
("python.windowedfile", [".pyw"], '"%1"', 'Python File (no console)', PY_PNG),
414420
)
415421

416422
if ns.include_pip and ns.include_launchers:
@@ -422,7 +428,7 @@ def get_appxmanifest(ns):
422428
["pip", "pip{}".format(VER_MAJOR), "pip{}".format(VER_DOT)],
423429
PIP_VE_DATA,
424430
"console",
425-
("python.wheel", [".whl"], 'install "%1"'),
431+
("python.wheel", [".whl"], 'install "%1"', 'Python Wheel'),
426432
)
427433

428434
if ns.include_idle and ns.include_launchers:
@@ -459,16 +465,15 @@ def get_appx_layout(ns):
459465
yield "AppxManifest.xml", ("AppxManifest.xml", get_appxmanifest(ns))
460466
yield "_resources.xml", ("_resources.xml", get_resources_xml(ns))
461467
icons = ns.source / "PC" / "icons"
462-
yield "_resources/pythonx44.png", icons / "pythonx44.png"
463-
yield "_resources/pythonx44$targetsize-44_altform-unplated.png", icons / "pythonx44.png"
464-
yield "_resources/pythonx50.png", icons / "pythonx50.png"
465-
yield "_resources/pythonx50$targetsize-50_altform-unplated.png", icons / "pythonx50.png"
466-
yield "_resources/pythonx150.png", icons / "pythonx150.png"
467-
yield "_resources/pythonx150$targetsize-150_altform-unplated.png", icons / "pythonx150.png"
468-
yield "_resources/pythonwx44.png", icons / "pythonwx44.png"
469-
yield "_resources/pythonwx44$targetsize-44_altform-unplated.png", icons / "pythonwx44.png"
470-
yield "_resources/pythonwx150.png", icons / "pythonwx150.png"
471-
yield "_resources/pythonwx150$targetsize-150_altform-unplated.png", icons / "pythonwx150.png"
468+
for px in [44, 50, 150]:
469+
src = icons / "pythonx{}.png".format(px)
470+
yield f"_resources/pythonx{px}.png", src
471+
yield f"_resources/pythonx{px}$targetsize-{px}_altform-unplated.png", src
472+
for px in [44, 150]:
473+
src = icons / "pythonwx{}.png".format(px)
474+
yield f"_resources/pythonwx{px}.png", src
475+
yield f"_resources/pythonwx{px}$targetsize-{px}_altform-unplated.png", src
476+
yield f"_resources/py.png", icons / "py.png"
472477
sccd = ns.source / SCCD_FILENAME
473478
if sccd.is_file():
474479
# This should only be set for side-loading purposes.

0 commit comments

Comments
 (0)