Skip to content

Commit 0d0c724

Browse files
Merge pull request #30 from jinwandalaohu66/submission/script_mmx2zhqn
2 parents 6f03959 + 0b66cef commit 0d0c724

2 files changed

Lines changed: 121 additions & 2 deletions

File tree

script_library/index.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 1,
3-
"data_version": 8,
4-
"updated": "2026-03-18T16:49:17.705Z",
3+
"data_version": 9,
4+
"updated": "2026-03-19T06:20:23.291Z",
55
"announcement": null,
66
"categories": [
77
{
@@ -380,6 +380,29 @@
380380
"updated": null,
381381
"status": "active",
382382
"lines": 95
383+
},
384+
{
385+
"id": "script_mmx2zhqn",
386+
"name": "汇率转换器",
387+
"name_en": "汇率转换器",
388+
"desc": "硬编码的,可以自己换api",
389+
"desc_en": "硬编码的,可以自己换api",
390+
"category": "widgets",
391+
"file": "scripts/widgets/script_mmx2zhqn.py",
392+
"thumbnail": null,
393+
"version": 1,
394+
"file_type": "py",
395+
"author": "今晚打老虎",
396+
"author_en": "今晚打老虎",
397+
"tags": [
398+
"community"
399+
],
400+
"requires": [],
401+
"min_app_version": "1.5.0",
402+
"added": "2026-03-19",
403+
"updated": null,
404+
"status": "active",
405+
"lines": 96
383406
}
384407
]
385408
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# 欢迎使用 PythonIDE!如果觉得好用,请给个好评哦~
2+
# -*- coding: utf-8 -*-
3+
"""汇率转换器 — major currencies with flags and trend arrows."""
4+
5+
from widget import Widget, family, SMALL, MEDIUM, LARGE
6+
import time
7+
8+
currencies = [
9+
("🇺🇸", "USD", 1.0000, "up"),
10+
("🇪🇺", "EUR", 0.9182, "down"),
11+
("🇯🇵", "JPY", 149.85, "up"),
12+
("🇬🇧", "GBP", 0.7923, "down"),
13+
("🇨🇳", "CNY", 7.2450, "up"),
14+
]
15+
16+
now = time.strftime("%H:%M")
17+
18+
bg = ("#F8FAFC", "#0F172A")
19+
card_bg = ("#F1F5F9", "#1E293B")
20+
txt_main = ("#0F172A", "#F8FAFC")
21+
txt_sub = ("#64748B", "#94A3B8")
22+
up_clr = ("#10B981", "#34D399")
23+
down_clr = ("#EF4444", "#F87171")
24+
accent = "#3B82F6"
25+
26+
w = Widget(background=bg, padding=14)
27+
28+
if family == SMALL:
29+
with w.vstack(spacing=0, align="center"):
30+
w.spacer()
31+
w.icon("dollarsign.circle.fill", size=18, color=accent)
32+
w.spacer(6)
33+
w.text("1 USD", size=22, weight="bold", design="rounded", color=txt_main)
34+
w.spacer(4)
35+
with w.hstack(spacing=4):
36+
w.text("🇺🇸", size=14)
37+
w.text("USD", size=12, weight="semibold", color=txt_main)
38+
w.spacer()
39+
w.text("基准", size=10, color=txt_sub)
40+
w.spacer()
41+
with w.hstack(spacing=6):
42+
clr = up_clr
43+
arrow = "arrow.up.right"
44+
w.icon(arrow, size=8, color=clr)
45+
w.text("EUR 0.92", size=11, weight="medium", color=clr)
46+
w.spacer()
47+
clr = down_clr
48+
arrow = "arrow.down.right"
49+
w.icon(arrow, size=8, color=clr)
50+
w.text("JPY 149.9", size=11, weight="medium", color=clr)
51+
w.spacer()
52+
53+
elif family == MEDIUM:
54+
with w.vstack(spacing=0):
55+
with w.hstack(spacing=6):
56+
w.icon("dollarsign.circle.fill", size=14, color=accent)
57+
w.text("汇率", size=14, weight="semibold", color=txt_main)
58+
w.spacer()
59+
w.text(f"更新 {now}", size=11, color=txt_sub)
60+
w.spacer()
61+
with w.hstack(spacing=0):
62+
for flag, code, rate, trend in currencies[:4]:
63+
with w.vstack(spacing=2, align="center"):
64+
clr = up_clr if trend == "up" else down_clr
65+
arrow = "arrow.up.right" if trend == "up" else "arrow.down.right"
66+
w.text(flag, size=16)
67+
w.text(code, size=11, weight="semibold", color=txt_main)
68+
with w.hstack(spacing=2):
69+
w.icon(arrow, size=8, color=clr)
70+
w.text(f"{rate:.2f}" if rate < 10 else f"{rate:.1f}", size=12, weight="medium", color=clr)
71+
w.spacer()
72+
w.spacer()
73+
74+
else:
75+
with w.vstack(spacing=6):
76+
with w.hstack(spacing=6, align="center"):
77+
w.icon("dollarsign.circle.fill", size=18, color=accent)
78+
w.text("汇率转换器", size=17, weight="bold", color=txt_main)
79+
w.spacer()
80+
w.icon("clock", size=12, color=txt_sub)
81+
w.text(f"更新于 {now}", size=12, color=txt_sub)
82+
w.divider(color=("#E2E8F0", "#334155"))
83+
for flag, code, rate, trend in currencies:
84+
with w.hstack(spacing=6, align="center"):
85+
w.text(flag, size=16)
86+
w.text(code, size=14, weight="bold", color=txt_main)
87+
w.spacer()
88+
clr = up_clr if trend == "up" else down_clr
89+
arrow = "arrow.up.right" if trend == "up" else "arrow.down.right"
90+
w.icon(arrow, size=11, color=clr)
91+
w.text(f"{rate:.4f}" if rate < 10 else f"{rate:.2f}",
92+
size=15, weight="semibold", color=clr)
93+
if code != "CNY":
94+
w.divider(color=("#F1F5F9", "#1E293B"))
95+
96+
w.render()

0 commit comments

Comments
 (0)