Files
mt5-tools/__pycache__/view_settings.cpython-314.pyc
T

277 lines
32 KiB
Plaintext
Raw Normal View History

2026-04-12 18:25:46 +10:00
+
i]åi_ãóRt^RIt^RIt^RIt]P
P
]P
P]P
P] 44R4t
]P
P
]
R4t Rt Rt
RRlt]P!RR 7R
R l4t]P!RR 7R0R R
ll4tRtRRRRRRRRRRRRR/RRRRRRRRR RR!RR//tR"R#ltR$R%ltR&R'ltR(R)ltR*R+ltR,R-ltR.tR/tR#)1uW
view_settings.py
================
Settings page — theme, custom colours, font size.
Nz
.streamlitz config.tomlzalphapapi-ctrl/mt5-toolsÚmastercó$V^8„dQhR\/#©éÚreturn©Ústr)Úformats"Ú%C:\Users\pc\MT5Tools\view_settings.pyÚ __annotate__r s÷ñœñócóB\PP\PP\PP \
44RR4p\PP
V4'gR#\V4P4P4pVPR4'VPR^4^,p\PP\PP\PP \
44RV4p\PP
V4'd(\V4P4P4#R#V# \dR#i;i)z?Return the current local git HEAD SHA, or '' if not a git repo.z.gitÚHEADÚzref:Ú )
ÚosÚpathÚjoinÚdirnameÚabspathÚ__file__ÚisfileÚopenÚreadÚstripÚ
startswithÚsplitÚ Exception)Úgit_headÚrefÚref_pathÚsha_files r
Ú_get_local_shar"sð
Ü—77—<‘<¤§¡§¡´·±·±ÄÓ0IÓ JÈFÐTZÓ[ˆÜw‰w~‰~˜h×Ü8n×#×+ˆØ >‰>˜&× —yy  Õ+ˆHÜ—w‘w—|‘|ܤ§¡§¡´Ó 9Ó:¸FÀHóˆHôw‰w~‰~˜hטH“~×,× ðˆJøÜ ô
Ø Ù
ð
ús%BFÂCFÅ#&FÆ
FÆ FÆFi)Úttlcó$V^8„dQhR\/#r©Údict)r s"r
r r +s÷bñbœ$ñbr cóœ^RIp^RIpR\ R\ 2pVPP VRR/R7pVPP
V^R7;_uu_4pVPVP4P44pRRR4RXR,R VR,R
,R VR ,R ,PR
4^,RVR ,R,R,RVR ,R,R,R,RR/# +'giLˆ;i \d"pRRR RR RRRRRR\T4/uRp?#Rp?ii;i)zt
Fetch the latest commit SHA and message from GitHub API.
Returns dict with keys: sha, message, author, date, error
https://api.github.com/repos/z /commits/ú
User-AgentÚMT5Tools©Úheaders©ÚtimeoutÚshaÚshortºNémessageÚcommitÚ
ÚauthorÚnameÚdateºNé
errorr)
Úurllib.requestÚjsonÚ GITHUB_REPOÚ
GITHUB_BRANCHÚrequestÚRequestÚurlopenÚloadsrÚdecoderrr)Úurllibr=ÚurlÚreqÚdataÚes r
Ú_get_remote_inforK*s,÷  Ø )¬+¨°iÄ
¸Ð
O€Cð
bØn‰n×$ S°<ÀÐ2LÐMˆØ
^‰^×
# Ð
#×
3°qØ—:‘:˜aŸf™f›hŸo™oÓ0ˆD÷
t˜E•{Ø t˜E•{ 2•Ø t˜H•~ 0×6°tÓ<¸ t˜H•~ Õ t˜H•~ Õ7¸Õ 

ð
÷4×
3ûô ôbØr˜7 B¨ °2°xÀÀVÈRÐQXÔZ]Ð^_ÓZ`Ðaûðbús7šADÁ.D Â A?DÄ D ÄDÄ E Ä*EÅE ÅE có$V^8„dQhR\/#r)Úlist)r s"r
r r Cs÷ñ¤ñr c óR^RIp^RIpR\ R\ RV 2pVPP VRR/R7pVPP
V^R7;_uu_4pVPVP4P44pRRR4XUu.uFZpR VR ,R
,R VR ,R ,R
VR ,R,R
,R,RVR ,R,R,/NK\ up# +'giLw;iuupi \d.u#i;i)z+Fetch the last n commits for the changelog.Nr(z
/commits?sha=z
&per_page=r)r*r+r-r/r1r3r4r8r6r9r7) r<r=r>r?r@rArBrCrrDr)ÚnrEr=rFrGrHrIÚcs& r
Ú_get_recent_commitsrQBs÷ Ø )¬+¨°mÄMÀ?ÐR\Ð]^Ð\_Ð
`€CðØn‰n×$ S°<ÀÐ2LÐMˆØ
^‰^×
# Ð
#×
3°qØ—:‘:˜aŸf™f›hŸo™oÓ0ˆD÷ó
ñð ˜1˜U8 B˜1˜X; ˜1˜X; xÕÕÕ˜1˜X; xÕÕ
ñ ñ
ð
÷4×
3üò
øô ôØŠ ðús7ADÁ!.C>Â DÂA DÃ;DÃ> D Ä
DÄ
D&Ä%D&c óN\4pV'gR#\4pVR,'gVR,'gR#VR,PV4'gIWR,8wd:\P!RVR, RVR, RVR , R
2R R 7R#R#R#)
Call from app.py on every page render.
Shows a top-of-page banner if a newer version is available on GitHub.
Silently does nothing if offline or not a git repo.
Nr;r/u-🔄 **Update available** — latest commit `r0z` on r8z: *r3u-* · Run `git pull` then restart to update.u🔄)Úicon)r"rKrÚstÚinfo)Ú local_shaÚremotes r
Úcheck_for_update_bannerrXXsô Ó €Iß Ùä
Ó
€FØ
ˆg‡˜f UŸmœmÙà %=× # I× .°9ÀuÅ
Ô3MÜ
ŠðØ$ W.¨e°F¸6µNÐ3CðDØ#5ð
÷ 
ñ4NÑ .r ÚDarkÚbaseÚdarkÚ primaryColorú#7c6af7ÚbackgroundColorú#0e1117ÚsecondaryBackgroundColorú#1a1f2eÚ textColorú#fafafaÚfontú
sans serifÚLightÚlightz#2E75B6z#ffffffú#f0f2f6z#1a1a1acó$V^8„dQhR\/#rr%)r s"r
r r ƒs÷$”dñ$r có¸\PP\4'g\ \
R,4#\
\4P4p/pRF>p\P!VR,V4pV'gK+VP^4W&K@ /\
R,CVC# \d\ \
R,4u#i;i)z7Read .streamlit/config.toml, return dict of theme keys.rYz\s*=\s*"([^"]*)")rZr\r^r`rbrdÚcardBackgroundColor) rrrÚ CONFIG_FILEr&ÚTHEMESrrÚreÚsearchÚgroupr)ÚtextÚfoundÚkeyÚms r
Ú _read_configruƒs­ä
7‰7>‰>œ+× ”F˜6•NÓ
”[Ó!×(ˆØˆóYˆCä— ’ ˜#Ð 3Õ3°TÓ:ˆA߉qØŸW™W Q›Z
ñ Yð
+”&˜•.Ð* *øÜ ô”F˜6•NÓ$úsÁAB5Â
'B5Â5!CÃCcó$V^8„dQhR\/#rr)r s"r
r r s÷ñ”Sñr cóô^RIpVP4pVPVR4pVF.pV^,^,pVPR4'gK,Vu# VPVP
VP 4pVPR4VP4^,pVP4VPR4'dV#R# \dLˆi;i \dR#i;i)zJReturn the first 192.168.x.x address found on this machine, or '' if none.Nz192.168.r)ú 192.168.1.1éP)
ÚsocketÚ gethostnameÚ getaddrinforrÚAF_INETÚ
SOCK_DGRAMÚconnectÚ getsocknameÚclose)rzÚhostnameÚaddrsÚaddrÚipÚss r
Ú _get_lan_ipr‡ãð 
à×'ˆØ×" 8¨TÓ2ˆÛˆa•˜ˆBØ}‰}˜Z×’ ñð
Ø M‰M˜&Ÿ.™.¨&×*;Ñ*;Ó <ˆØ ‰ Ð
]‰]_˜
ˆØ Œ Ø
=‰=˜× ˆIð  øô ô
Ù ð
ûô ô
Ø Ù
ð
ús1†A CÁCÁCÁA6C(Ã C%Ã$C%Ã( C7Ã6C7có$V^8„dQhR\/#rr%)r s"r
r r ®s÷
ñ
œTñ
r có \PP\4'g/#\ \4P 4p/p\ P!RV4pV'dVP^4VR&\ P!RV4pV'd\VP^44VR&V# \d/u#i;i)z'Read [server] section from config.toml.zaddress\s*=\s*"([^"]*)"Úaddresszport\s*=\s*(\d+)Úport) rrrrlrrrnrorpÚintr)rqrrrts r
Ú_read_server_configr®sä
7‰7>‰>œ+× ˆ ð Ü”KÓ ×ØˆÜ IŠIÐ0°$Ó ß  §¡¨£ˆeÜ IŠIÐ)¨4Ó 0ˆß œc !§'¡'¨!£*oˆeF‰m؈ øÜ ôØŠ ðús­A0B=ÂB=Â=
C
à C
có$V^8„dQhR\/#)rÚthemer%)r s"r
r r ¾s÷ñœñr có¨\P!\RR7Rp\PP \
4'dy\
\
4P4p\P!RV\P4pV'd.RVP^4P4,R,pR.pVP4FwrVVPV RV R24K V'dVPV4\
\
R4;_uu_4pVPV4R R R 4R # +'giR #;i)
Úexist_okrú\[server\].*?(?=\[|\Z)r5z[theme]
z = "z"
ÚwN)rÚmakedirsÚ
CONFIG_DIRrrrlrrrnroÚDOTALLrprÚitemsÚappendÚ
writelines)rÚ server_blockÚexistingrtÚlinesÚfs& r
Ú
_write_configr¡¾Ü‡K‚K”
 €LÜ ‡ww‡~~”kל Ó$×Ü IŠIм2¿9¹9Ó Eˆß Ø !§'¡'¨!£*×"2Ñ"2Ó"4Õ4°tÕ;ˆ
ˆM€EØ
ˆØ
˜s˜$˜q˜c ÐçØ

Œk˜3× Ô  1Ø ÷
× × Ò ús Ä$EÅ E có0V^8„dQhR\R\/#)rr)r)r s"r
r r Ðs÷)¤#ð)¬Sñ)r cóä\P!\RR7\PP \
4'd\
\
4P4MRp\P!RRV\PR7P4pRV RV R2p\
\
R 4;_uu_4pVPW#,4R
R
R
4R
# +'giR
#;i) z4Write or update the [server] section in config.toml.Trrr“)Úflagsz
[server]
address = "z "
port = r5r”N)
rr•rrrrlrrrnÚsubr—rÚwrite)rrr s&& r
Ú_write_server_configr§Ðä‡K‚K”
 *ä+-¯7©7¯>©>¼+×+FÒ+FŒt”KÓ ×'ÈB€HÜvŠvаXÄRÇYÁYÔW€HØ.¨w¨i°zÀ$ÀÀrÐJ€LÜ
Œk˜3× Ô   Õ
× × Ò ús Â<CÃ C/ có0V^8„dQhR\R\/#)rÚcfgr)r&Úbool)r s"r
r r Ûs÷ñ”DðœTñr cóüa\P4Fbp\;QJd-V3RlVP44F 'dK RM" RM!V3RlVP444'gKaR# R#)zBReturn True if the saved config differs from both standard themes.c3óP<"TFwrSPV4V8HxK R#5i)N)Úget)Ú.0ržs& €r
Ú <genexpr>Ú_is_custom.<locals>.<genexpr>ÞsøéÐ5©9¡4 1ˆsw‰wqz˜«9ùsƒ#&FT)rmÚvaluesÚallr˜)Útsf r
Ú
_is_customr´ÛsHø€ä
]‰]Ž_ˆß 5¨1¯7©7¬9Ó533Š3Ô5¨1¯7©7¬9Ó ññ r c
óþR^R^R^/pVP\PPRR4^4p\4pVPRR4pVPRR4pVPR R
4pV'g VR 8XdR MR
pVR 8XdRMRpVR 8XdRMRpVR 8XdRMRpVR 8XdRMRp VR 8XdRMRp
Tp Tp RP .RNV NRNV NRNV NRNV NRNV NRNV NRNV
NRNV NRNV NRNV NR NV NR!NV NR"NV NR#NV NR$NV NR%NV NR&NV NR'NV NR(N4p
\P
!V
R)R*7V^8”d+\P
!R+V R,V R-V R.V R/V R02 R)R*7R1#R1#)2zJCall from app.py on every page to apply font size and card theme globally.ÚNormalú Large (+2px)úExtra Large (+4px)Ú st_font_sizerZr[rkrrbrcrgrhú#131720zrgba(0,0,0,0.10)z#1E2535z#555e70z#6C7A9Az#4a5568z#7A8898zrgba(0,0,0,0.07)z#141820z"<style>
.stat-card{background:z !important;border:1px solid z„ !important;
border-radius:8px;padding:14px 16px;text-align:center;height:100%}
.stat-label{font-size:11px;color:z“ !important;text-transform:uppercase;
letter-spacing:.08em;margin-bottom:4px}
.stat-value{font-size:22px;font-weight:700;color:z¹ !important}
.stat-value.pos{color:#34C27A !important}.stat-value.neg{color:#E05555 !important}
.stat-value.neutral{color:#7BA4DC !important}
.stat-sub{font-size:11px;color:zI !important;margin-top:2px}
.sh{font-size:11px;font-weight:600;color:zu !important;text-transform:uppercase;
letter-spacing:.1em;margin:18px 0 6px;
border-bottom:1px solid zŠ !important;padding-bottom:4px}
.kv-row{display:flex;justify-content:space-between;padding:5px 0;
border-bottom:1px solid z}
.kk{font-size:13px;color:z< !important}
.kv-v{font-size:13px;font-weight:600;color:zá !important}
.kv-v.pos{color:#34C27A !important}.kv-v.neg{color:#E05555 !important}
.chip{display:inline-block;padding:3px 10px;border-radius:12px;font-size:11px;
font-weight:600;margin:2px;border:1px solid z5}
.pb-title{font-size:22px;font-weight:700;color:z8;letter-spacing:.04em}
.pb-sub{font-size:13px;color:z+;margin-bottom:14px}
.mt th{background:z !important;color:zR !important;
padding:5px 8px;text-align:center;border-bottom:1px solid z5}
.mt td{padding:4px 8px;text-align:center;color:z%;
border-bottom:1px solid z}
</style>T©Úunsafe_allow_htmlzD<style>
html, body, [class*="css"] { font-size: calc(1rem + z¸px) !important; }
.stMarkdown p, .stMarkdown li, .stCaption, label,
.stMetric label, .stMetric div[data-testid="metric-container"] {
font-size: calc(1rem + z@px) !important;
}
h1 { font-size: calc(2rem + z8px) !important; }
2026-04-12 18:25:46 +10:00
h2 { font-size: calc(1.5rem + z9px) !important; }
h3 { font-size: calc(1.25rem + z"px) !important; }
2026-04-12 18:25:46 +10:00
</style>N)r­rTÚ
session_staterurÚmarkdown)Ú _size_mapÚ_deltar©rZÚcard_bgÚtext_colÚ card_borderÚ label_colÚkk_colÚ
row_borderÚ sh_borderÚth_bgÚtd_colÚcsss r
Úinject_theme_cssrËãà˜1˜n¨aÐ1EÀqÐI€IØ
œb×.×2°>À8ÓLÈaÓP€Fô~€CØw‰wv˜&€DØw‰wÐ,¨bÓ1€GØw‰w{ .€H÷ Ø# wœ‘)°IˆØ(,°¬Ñ$¸Y€KØ(,°¬‘)¸Y€IØ(,°¬‘)¸Y€FØ(,°¬Ñ$¸Y€JØ(,°¬Ñ$¸Y€IØ€EØ€F÷ ó ðð Ø#˜9ð Ø$Að ØBMÀð ðO ð(1  ð27ð ð
8@°jð  ð
A  ð&/  ð0/ð ð09¨kð ð:!ð ð"+  ð ð,%ð ð&0  ð1ð ð &˜ ð'1ð ð2:°
ð ð;7ð ð$8C°mð% ð$D5ð% ð&6>°Jð' ð&?#ð' ð($- +ð) ð(.ð) ð*wð+ ð*1ð+ ð*2;° ð+ ð*<Fð+ ð,GRÀ]ð- ð,S5ð- ð.6<°Hð/ ð.=$ð/ ð0%/ <ð1 ð00
ô1 €Cô4‡KK 
„zÜ
Š ð>Ø>D¸F%+ ,(à(. 0(Ø(. 0)Ø)/¨ð1ð ð(,÷r có˜\P!R4\P!R4\4p\ V4'dRpMVP R4R8XdRpMRp.R¡Op\P !RTRRW9dVPV4M^R 7pVR¢9dh\P!R
V R 2R R
R7'dE\\V,4\P!V R24\P!4VR8XEd\P!R4\P!R4\P!^4wrEpV;_uu_4\P !RVP RR4RRR7p\P !RVP RR4RRR7pRRR4V;_uu_4\P !RVP RR 4R!R"7p \P !R#VP R$R%4R&R"7p
RRR4T;_u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, RV- V0 24;_uu_4V/'dV/p.V.Pc4P[R—4'd'\P!V.Pc44KNV.Pc4'gKf\P!V.Pc44 M\P!R˜4RRR4EK~ M\P!R™4\P8!4\P!Rš4\P!R4\P!Rœ4\P*!RRžRK7\P!RŸ4\P*!R RžRK7R# +'giE
Lƒ;i +'giE
L2;i +'giE L;i \$d%p\P&!RCT 24Rp?ELÉRp?ii;i +'giEL¶;iuup.i +'giE;i)¦ÚSettingsÚThemeÚCustomrZrgrfrY
st_theme_pick)Ú
horizontalrsÚindexzApply z ThemeÚprimaryÚ
st_apply_base)Útypersu theme applied — reloading...z:Customise colours below then click **Apply Custom Theme**.z---z
Accent colourr\r]Ú
st_primaryzButtons, links, highlights)ÚvaluersÚhelpzCard / stat block backgroundrkÚ
st_card_bgz$Background for stat cards and tablesNzPage backgroundr^r_Úst_bg)r×rszSidebar / widget backgroundr`raÚ
st_sidebar_bgz Text colourrbrcÚst_textÚFontrerdÚst_font)rsÚBaser[Úst_custom_basez5Underlying dark or light base for your custom colours)rsz **Preview**zPage BGz
Sidebar BGÚAccentÚTextz<div style="background:zn;padding:14px 8px;border-radius:6px;text-align:center;font-size:12px;border:1px solid rgba(128,128,128,0.25)">z!<br><code style="font-size:10px">z
</code></div>r»rzApply Custom ThemeÚst_applyu#Custom theme saved — reloading...zCould not write config: zDiscard / Reset to DarkÚst_reset)rsuReset to Dark — reloading...z/Select **Custom** to adjust individual colours.z Config fileÚtoml)Úlanguageu.No config.toml yet — created on first Apply.z Text Sizeu:Applies immediately across all pages — no reload needed.z Text sizer¹)rszNetwork AccesszTControls which network interface Streamlit binds to. Restart the app after changing.ÚAccesszLocalhost onlyzLocal network (LAN)Ú st_net_moderŠú 127.0.0.1zILocalhost = this PC only. LAN = all devices on your 192.168.x.x network.ÚPortiiÿÿri5!Ú st_net_port)Ú min_valueÚ max_valuer×ÚsteprszDetected LAN address: **u4** → other devices can reach the app at `http://Ú`uBNo 192.168.x.x address found — are you connected to your router?z 192.168.x.xz2**Use a custom hostname instead of an IP address**u•Add an entry to the hosts file on each device that needs to access the app. No extra software required — works on Windows, macOS, iOS, and Android.zHostname to useÚmt5toolsÚst_custom_hostnameu(e.g. mt5tools → http://mt5tools:8501z=Once set, devices on your LAN can access the app at: `http://ÚWindowsu
<details>
<summary><b>Windows — edit the hosts file on each client device</b></summary>
1. Open **Notepad as Administrator** (right-click Notepad → Run as administrator)
2. Open the file: `C:\Windows\System32\drivers\etc\hosts`
3. Add this line at the bottom:
```
z z;
```
4. Save the file
5. Open a browser and go to `http://u`
**Note:** You need to do this on every Windows device that will access the app.
No restart required — the change takes effect immediately.
</details>
ÚDarwinu·
<details>
<summary><b>macOS — edit /etc/hosts on each client device</b></summary>
1. Open **Terminal**
2. Run:
```
sudo nano /etc/hosts
```