{"id":360313,"date":"2024-05-21T00:50:48","date_gmt":"2024-05-21T00:50:48","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=360313"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=360313","title":{"rendered":"<span>\u0423\u0447\u0435\u0431\u043d\u043e\u0435 \u043f\u043e\u0441\u043e\u0431\u0438\u0435 \u043f\u043e Textual<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/5b\/ji\/si\/5bjisipww1fznqiomojxi2mmbyk.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/5b\/ji\/si\/5bjisipww1fznqiomojxi2mmbyk.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043f\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f TUI (\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432). \u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u0432\u0435\u0431, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043b\u0434\u0441\u043a\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 \u0443\u0447\u0435\u0431\u043d\u043e\u0435 \u043f\u043e\u0441\u043e\u0431\u0438\u0435 \u043f\u043e Textual!<\/p>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043d\u0446\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Textual.<\/p>\n<p>  <\/p>\n<blockquote><p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435, \u0447\u0442\u043e\u0431\u044b \u043b\u044e\u0434\u0438 \u0447\u0442\u043e-\u0442\u043e \u0434\u0435\u043b\u0430\u043b\u0438, \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u044d\u0442\u043e \u0432\u0435\u0441\u0451\u043b\u044b\u043c.<br \/>  \u2014 Will McGugan (\u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c <a href=\"https:\/\/github.com\/Textualize\/rich\" rel=\"nofollow noopener noreferrer\">Rich<\/a> \u0438 <a href=\"https:\/\/textual.textualize.io\/\" rel=\"nofollow noopener noreferrer\">Textual<\/a>)<\/p><\/blockquote>\n<p>  <\/p>\n<h1 id=\"videouroki\">\u0412\u0438\u0434\u0435\u043e\u0443\u0440\u043e\u043a\u0438<\/h1>\n<p>  <\/p>\n<p>\u041a \u044d\u0442\u043e\u043c\u0443 \u0443\u0447\u0435\u0431\u043d\u043e\u043c\u0443 \u043f\u043e\u0441\u043e\u0431\u0438\u044e \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f <a href=\"https:\/\/www.youtube.com\/playlist?list=PLHhDR_Q5Me1MxO4LmfzMNNQyKfwa275Qe\" rel=\"nofollow noopener noreferrer\">\u0432\u0438\u0434\u0435\u043e\u0443\u0440\u043e\u043a\u0438<\/a>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u043d\u0442\u0435\u043d\u0442.<\/p>\n<p>  <\/p>\n<h1 id=\"prilozhenie-sekundomer\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435-\u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440<\/h1>\n<p>  <\/p>\n<p>\u041c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435-\u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440 (stopwatch). \u041e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u043e\u0432 \u0441 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0441\u0431\u0440\u043e\u0441\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0442\u0430\u043a\u0436\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u044b \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u043d\u043e <strong>\u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/strong> \u2014 \u043c\u043e\u0436\u0435\u0442\u0435 \u0435\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435!<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ok\/8r\/op\/ok8ropcqcfrihl2tate48algkrw.png\" data-src=\"https:\/\/habrastorage.org\/webt\/ok\/8r\/op\/ok8ropcqcfrihl2tate48algkrw.png\"\/><\/p>\n<p>  <\/p>\n<h2 id=\"poprobuyte\">\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435!<\/h2>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u044d\u0442\u043e \u043d\u0435 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442, \u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Textual, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 online.<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u0412 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435 \u0442\u0443\u0442 \u0431\u044b\u043b <code>&lt;iframe><\/code> \u043d\u043e \u0432\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u0435 \u0445\u0430\u0431\u0440\u0430\u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u044f \u043e\u0441\u0442\u0430\u0432\u0438\u043b \u043e\u0442 \u043d\u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0441\u044b\u043b\u043a\u0443:<\/p>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/textual-web.io\/textualize\/tutorial?delay=y&amp;fontsize=12&amp;ping=https:\/\/textual-web-demos.fly.dev\/health-check\/\" rel=\"nofollow noopener noreferrer\">\u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 online.<\/a><\/li>\n<\/ul>\n<\/div><\/div>\n<p>  <\/p>\n<blockquote><p><strong>\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430:<\/strong> \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Textual \u0432 \u0432\u0435\u0431\u0435, \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 <a href=\"https:\/\/github.com\/Textualize\/textual-web\" rel=\"nofollow noopener noreferrer\">textual-web<\/a>.<\/p><\/blockquote>\n<p>  <\/p>\n<h2 id=\"poluchaem-kod\">\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u0434<\/h2>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Stopwatch \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u0434, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 <a href=\"https:\/\/textual.textualize.io\/getting_started\/\" rel=\"nofollow noopener noreferrer\">\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 Textual<\/a>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0439\u0442\u0435 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <a href=\"https:\/\/github.com\/Textualize\/textual\" rel=\"nofollow noopener noreferrer\">Textual<\/a>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">git clone https:\/\/github.com\/Textualize\/textual.git<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 <code>docs\/examples\/tutorial<\/code> \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>stopwatch.py<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">cd textual\/docs\/examples\/tutorial python stopwatch.py<\/code><\/pre>\n<p>  <\/p>\n<h1 id=\"annotacii-tipov-kratko\">\u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 (\u043a\u0440\u0430\u0442\u043a\u043e)<\/h1>\n<p>  <\/p>\n<blockquote><p><strong>\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430:<\/strong> \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u0432 Textual \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b. \u041c\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0438\u0445 \u0432 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u043b\u0438 \u0432\u044b \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u2014 \u0440\u0435\u0448\u0430\u0439\u0442\u0435 \u0441\u0430\u043c\u0438.<\/p><\/blockquote>\n<p>\u041c\u044b \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u0438 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0439 \u0442\u0438\u043f\u043e\u0432 Python \u0432 Textualize. \u0415\u0441\u043b\u0438 \u0432\u044b \u0441 \u043d\u0438\u043c\u0438 \u0435\u0449\u0451 \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c, \u043a\u0440\u0430\u0442\u043a\u043e \u0441\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u0410\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u0442\u0438\u043f\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0442\u0430\u043a\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c, \u043a\u0430\u043a <a href=\"https:\/\/mypy.readthedocs.io\/en\/stable\/\" rel=\"nofollow noopener noreferrer\">mypy<\/a>, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">def repeat(text: str, count: int) -> str:     \"\"\"Repeat a string a given number of times.\"\"\"     return text * count<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0438\u043f\u044b \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f. \u0422\u0430\u043a, <code>text: str<\/code> \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e <code>text<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u043e\u0439, \u0430 <code>count: int<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e <code>count<\/code> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0446\u0435\u043b\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c.<\/p>\n<p>  <\/p>\n<p>\u0422\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 <code>-><\/code>. \u0422\u0430\u043a, <code>-> str:<\/code> \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>  <\/p>\n<h1 id=\"klass-app\">\u041a\u043b\u0430\u0441\u0441 <code>App<\/code><\/h1>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0448\u0430\u0433 \u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Textual \u2014 \u044d\u0442\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <code>App<\/code> \u0438 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043d\u0435\u0433\u043e. \u0412\u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<p><code>stopwatch01.py<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from textual.app import App, ComposeResult from textual.widgets import Header, Footer  class StopwatchApp(App):     \"\"\"A Textual app to manage stopwatches.\"\"\"      BINDINGS = [(\"d\", \"toggle_dark\", \"Toggle dark mode\")]      def compose(self) -> ComposeResult:         \"\"\"Create child widgets for the app.\"\"\"         yield Header()         yield Footer()      def action_toggle_dark(self) -> None:         \"\"\"An action to toggle dark mode.\"\"\"         self.dark = not self.dark  if __name__ == \"__main__\":     app = StopwatchApp()     app.run()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/r3\/js\/fn\/r3jsfnyofo-jjnaij_iba5xjkdg.png\" data-src=\"https:\/\/habrastorage.org\/webt\/r3\/js\/fn\/r3jsfnyofo-jjnaij_iba5xjkdg.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0443 <code>D<\/code> \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u0432\u0435\u0442\u043b\u044b\u043c \u0438 \u0442\u0451\u043c\u043d\u044b\u043c \u0440\u0435\u0436\u0438\u043c\u043e\u043c.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/c6\/tk\/wo\/c6tkwofyjgtfxvbkc2x4prl8ql8.png\" data-src=\"https:\/\/habrastorage.org\/webt\/c6\/tk\/wo\/c6tkwofyjgtfxvbkc2x4prl8ql8.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 <code>Ctrl+C<\/code>, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0439\u0442\u0438 \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>  <\/p>\n<h2 id=\"rassmotrim-klass-app-poblizhe\">\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>App<\/code> \u043f\u043e\u0431\u043b\u0438\u0436\u0435<\/h2>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u043c <code>stopwatch01.py<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from textual.app import App, ComposeResult from textual.widgets import Header, Footer<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 <code>App<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412\u0442\u043e\u0440\u0430\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0434\u0432\u0430 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u0430: <code>Footer<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u043a\u0440\u0430\u043d\u0430 \u043f\u0430\u043d\u0435\u043b\u044c \u0441 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0432\u0438\u0448\u0430\u043c\u0438, \u0438 <code>Header<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u043a\u0440\u0430\u043d\u0430. \u0412\u0438\u0434\u0436\u0435\u0442\u044b \u2014 \u044d\u0442\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0435 \u0437\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0430\u0441\u0442\u044c\u044e \u044d\u043a\u0440\u0430\u043d\u0430. \u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u0441\u0430\u043c\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">class StopwatchApp(App):     \"\"\"A Textual app to manage stopwatches.\"\"\"      BINDINGS = [(\"d\", \"toggle_dark\", \"Toggle dark mode\")]      def compose(self) -> ComposeResult:         \"\"\"Create child widgets for the app.\"\"\"         yield Header()         yield Footer()      def action_toggle_dark(self) -> None:         \"\"\"An action to toggle dark mode.\"\"\"         self.dark = not self.dark<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>App<\/code> \u2014 \u044d\u0442\u043e \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 Textual. \u041e\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043a\u043b\u044e\u0447\u0435\u0439 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u0432 \u043d\u0451\u043c \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>BINDINGS<\/code> \u044d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 (\u0438\u043b\u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0442) \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u044d\u0442\u043e \u043a\u043b\u0430\u0432\u0438\u0448\u0430, \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u0438\u043c\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u2014 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0430\u044f \u043a\u043b\u0430\u0432\u0438\u0448\u0443 <code>D<\/code> \u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 <code>\"toggle_dark\"<\/code>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u043c. <a href=\"https:\/\/textual.textualize.io\/guide\/input\/#bindings\" rel=\"nofollow noopener noreferrer\">key bindings<\/a> \u0432 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435.<\/li>\n<li><code>compose()<\/code> \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434, \u0433\u0434\u0435 \u0438\u0437 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0412\u043e\u043e\u0431\u0449\u0435, \u043c\u0435\u0442\u043e\u0434 compose() \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u043d\u043e \u043f\u0440\u043e\u0449\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0438\u0445 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 <em>yield<\/em> (\u0447\u0442\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440). \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043e\u0431\u0430 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430, \u0442.\u0435. <code>Header()<\/code> \u0438 <code>Footer()<\/code>.<\/li>\n<li><code>action_toggle_dark()<\/code> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 <code>action_<\/code>, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438\u0434\u0451\u0442 \u0438\u043c\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u041f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0441\u043f\u0438\u0441\u043e\u043a <code>BINDINGS<\/code> \u043f\u0440\u0438\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 Textual \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0436\u043c\u0451\u0442 \u043a\u043b\u0430\u0432\u0438\u0448\u0443 <code>D<\/code>. \u0417\u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0439\u0442\u0435\u0441\u044c \u043a <a href=\"https:\/\/textual.textualize.io\/guide\/actions\/\" rel=\"nofollow noopener noreferrer\">actions<\/a> \u0432 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435.<\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"python\">if __name__ == \"__main__\":     app = StopwatchApp()     app.run()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/textual.textualize.io\/api\/app\/#textual.app.App.run\" rel=\"nofollow noopener noreferrer\">run()<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u0432\u0430\u0448 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0432 \u0440\u0435\u0436\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0436\u0434\u0451\u0442 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0432\u044b \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>Ctrl+C<\/code>. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0431\u043b\u043e\u043a\u0435 <code>__name__ == \"__main__\"<\/code>, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043a\u0430\u043a \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>python stopwatch01.py<\/code> \u0442\u0430\u043a \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u043f\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>  <\/p>\n<h1 id=\"proektirovanie-ui-s-pomoschyu-vidzhetov\">\u041f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 UI \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432<\/h1>\n<p>  <\/p>\n<p>\u0412 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 \u0441 Textual \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a <code>Header<\/code> \u0438 <code>Footer<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b \u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e. \u0414\u043b\u044f \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432. \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u044d\u0442\u0438\u043c \u0437\u0430\u0439\u043c\u0451\u043c\u0441\u044f, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0431\u0440\u043e\u0441\u0430\u0435\u043c \u0434\u0438\u0437\u0430\u0439\u043d \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c, \u043a \u0447\u0435\u043c\u0443 \u043c\u044b \u0441\u0442\u0440\u0435\u043c\u0438\u043c\u0441\u044f.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/mh\/ge\/tc\/mhgetcbszppdq7l5g-4-id06gq0.png\" data-src=\"https:\/\/habrastorage.org\/webt\/mh\/ge\/tc\/mhgetcbszppdq7l5g-4-id06gq0.png\"\/><\/p>\n<p>  <\/p>\n<h2 id=\"polzovatelskie-vidzhety\">\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0432\u0438\u0434\u0436\u0435\u0442 <code>Stopwatch<\/code>, \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041a\u043d\u043e\u043f\u043a\u0430 \u00abStart\u00bb<\/li>\n<li>\u041a\u043d\u043e\u043f\u043a\u0430 \u00abStop\u00bb<\/li>\n<li>\u041a\u043d\u043e\u043f\u043a\u0430 \u00abReset\u00bb<\/li>\n<li>\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412 Textual \u0435\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432\u0438\u0434\u0436\u0435\u0442 <code>Button<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u0442\u0440\u0451\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445. \u0412\u0441\u0451, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u044d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u0443 \u0438 \u0441\u0430\u043c \u0432\u0438\u0434\u0436\u0435\u0442 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0445 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u0435\u043b\u0435\u0442, \u043d\u043e \u043f\u043e \u0445\u043e\u0434\u0443 \u0434\u0435\u043b\u0430 \u043e\u043d \u043e\u0431\u0440\u0430\u0441\u0442\u0451\u0442 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438.<\/p>\n<p>  <\/p>\n<p><code>stopwatch02.py<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from textual.app import App, ComposeResult from textual.containers import ScrollableContainer from textual.widgets import Button, Footer, Header, Static  class TimeDisplay(Static):     \"\"\"A widget to display elapsed time.\"\"\"  class Stopwatch(Static):     \"\"\"A stopwatch widget.\"\"\"      def compose(self) -> ComposeResult:         \"\"\"Create child widgets of a stopwatch.\"\"\"         yield Button(\"Start\", id=\"start\", variant=\"success\")         yield Button(\"Stop\", id=\"stop\", variant=\"error\")         yield Button(\"Reset\", id=\"reset\")         yield TimeDisplay(\"00:00:00.00\")  class StopwatchApp(App):     \"\"\"A Textual app to manage stopwatches.\"\"\"      BINDINGS = [(\"d\", \"toggle_dark\", \"Toggle dark mode\")]      def compose(self) -> ComposeResult:         \"\"\"Create child widgets for the app.\"\"\"         yield Header()         yield Footer()         yield ScrollableContainer(Stopwatch(), Stopwatch(), Stopwatch())      def action_toggle_dark(self) -> None:         \"\"\"An action to toggle dark mode.\"\"\"         self.dark = not self.dark  if __name__ == \"__main__\":     app = StopwatchApp()     app.run()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u0430: <code>Button<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 <code>Static<\/code>, \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0439\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 <code>ScrollableContainer<\/code> \u0438\u0437 <code>textual.containers<\/code> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 (\u043a\u0430\u043a \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0438\u043c\u044f) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u043c, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u043f\u0443\u0441\u0442\u043e\u0439 \u0432\u0438\u0434\u0436\u0435\u0442 <code>TimeDisplay<\/code>, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 <code>Static<\/code>. \u041d\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0435\u0433\u043e \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 <code>Stopwatch<\/code> \u0442\u0430\u043a\u0436\u0435 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d \u043e\u0442 <code>Static<\/code>. \u0423 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>compose()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0437 \u0442\u0440\u0451\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <code>Button<\/code> \u0438 \u043e\u0434\u043d\u043e\u0433\u043e <code>TimeDisplay<\/code>. \u042d\u0442\u0438 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440, \u043a\u0430\u043a \u0432 \u043d\u0430\u0448\u0435\u043c \u043d\u0430\u0431\u0440\u043e\u0441\u043a\u0435.<\/p>\n<p>  <\/p>\n<h3 id=\"knopki\">\u041a\u043d\u043e\u043f\u043a\u0438<\/h3>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>Button<\/code> \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 <em>(label),<\/em> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0435 (<code>\"Start\"<\/code>, <code>\"Stop\"<\/code> \u0438\u043b\u0438 <code>\"Reset\"<\/code>). \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li><code>id<\/code> \u044d\u0442\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a \u043d\u0435\u0439 \u0441\u0442\u0438\u043b\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0437\u0436\u0435.<\/li>\n<li><code>variant<\/code> \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0449\u0430\u044f \u0441\u0442\u0438\u043b\u044c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0412\u0430\u0440\u0438\u0430\u043d\u0442 <code>\"success\"<\/code> \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 \u0437\u0435\u043b\u0451\u043d\u043e\u0439, \u0430 <code>\"error\"<\/code> \u2014 \u043a\u0440\u0430\u0441\u043d\u043e\u0439.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"kompoziciya-vidzhetov\">\u041a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432<\/h2>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0432 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u0430\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0445 \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 <code>compose()<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 <code>StopwatchApp.compose()<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <code>ScrollableContainer<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u043e\u0432. \u041a\u043e\u0433\u0434\u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>ScrollableContainer<\/code>), \u043e\u043d\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0441\u0432\u043e\u0438 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0442\u0440\u0435\u043c\u044f \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0440\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <code>Stopwatch<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<h2 id=\"prilozhenie-bez-stiley\">\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u0441\u0442\u0438\u043b\u0435\u0439<\/h2>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c <code>stopwatch02.py<\/code>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/qu\/qh\/ud\/quqhudpx6utusz-qce9zqnkq3ys.png\" data-src=\"https:\/\/habrastorage.org\/webt\/qu\/qh\/ud\/quqhudpx6utusz-qce9zqnkq3ys.png\"\/><\/p>\n<p>  <\/p>\n<p>\u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f-\u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c. \u041a\u043d\u043e\u043f\u043a\u0438 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b, \u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u043d\u0430\u0448 \u043d\u0430\u0431\u0440\u043e\u0441\u043e\u043a. \u042d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0430\u043c \u0435\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a \u043d\u0430\u0448\u0438\u043c \u043d\u043e\u0432\u044b\u043c \u0432\u0438\u0434\u0436\u0435\u0442\u0430\u043c <em>\u0441\u0442\u0438\u043b\u0438<\/em>.<\/p>\n<p>  <\/p>\n<h1 id=\"napisanie-css-dlya-textual\">\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 CSS \u0434\u043b\u044f Textual<\/h1>\n<p>  <\/p>\n<p>\u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <code>styles<\/code> \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0435\u0433\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434. \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0431\u0435\u043b\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430 \u0441\u0438\u043d\u0435\u043c \u0444\u043e\u043d\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">self.styles.background = \"blue\" self.styles.color = \"white\"<\/code><\/pre>\n<p>  <\/p>\n<p>\u0425\u043e\u0442\u044f \u0441\u0442\u0438\u043b\u0438 \u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0440\u0435\u0434\u043a\u043e. Textual \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 CSS (Cascading Style Sheets): \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0443\u044e \u0432 \u0432\u0435\u0431-\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445. CSS-\u0444\u0430\u0439\u043b\u044b \u044d\u0442\u043e \u0444\u0430\u0439\u043b\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0435 \u0432\u0430\u0448\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0442\u0438\u043b\u044f\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043a \u0432\u0430\u0448\u0438\u043c \u0432\u0438\u0434\u0436\u0435\u0442\u0430\u043c.<\/p>\n<p>  <\/p>\n<blockquote><p><strong>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f:<\/strong> \u0414\u0438\u0430\u043b\u0435\u043a\u0442 CSS, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 Textual, \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0449\u0435 \u0432\u0435\u0431\u043e\u0432\u0441\u043a\u043e\u0433\u043e CSS \u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0435\u0433\u0447\u0435 \u0438\u0437\u0443\u0447\u0430\u0435\u0442\u0441\u044f.<\/p><\/blockquote>\n<p>CSS \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0434\u0438\u0437\u0430\u0439\u043d \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c <a href=\"https:\/\/textual.textualize.io\/guide\/devtools\/#live-editing\" rel=\"nofollow noopener noreferrer\">\u0436\u0438\u0432\u043e\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a> \u2014 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c CSS \u0438 \u0432\u0438\u0434\u0435\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f!<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c CSS-\u0444\u0430\u0439\u043b \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e.<\/p>\n<p>  <\/p>\n<p><code>stopwatch03.py<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from textual.app import App, ComposeResult from textual.containers import ScrollableContainer from textual.widgets import Button, Footer, Header, Static  class TimeDisplay(Static):     \"\"\"A widget to display elapsed time.\"\"\"  class Stopwatch(Static):     \"\"\"A stopwatch widget.\"\"\"      def compose(self) -> ComposeResult:         \"\"\"Create child widgets of a stopwatch.\"\"\"         yield Button(\"Start\", id=\"start\", variant=\"success\")         yield Button(\"Stop\", id=\"stop\", variant=\"error\")         yield Button(\"Reset\", id=\"reset\")         yield TimeDisplay(\"00:00:00.00\")  class StopwatchApp(App):     \"\"\"A Textual app to manage stopwatches.\"\"\"      CSS_PATH = \"stopwatch03.tcss\"     BINDINGS = [(\"d\", \"toggle_dark\", \"Toggle dark mode\")]      def compose(self) -> ComposeResult:         \"\"\"Create child widgets for the app.\"\"\"         yield Header()         yield Footer()         yield ScrollableContainer(Stopwatch(), Stopwatch(), Stopwatch())      def action_toggle_dark(self) -> None:         \"\"\"An action to toggle dark mode.\"\"\"         self.dark = not self.dark  if __name__ == \"__main__\":     app = StopwatchApp()     app.run()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>CSS_PATH<\/code> \u043f\u0440\u0438\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 Textual \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"css\">stopwatch03.tcss  Stopwatch {     layout: horizontal;     background: $boost;     height: 5;     margin: 1;     min-width: 50;     padding: 1; }  TimeDisplay {     content-align: center middle;     text-opacity: 60%;     height: 3; }  Button {     width: 16; }  #start {     dock: left; }  #stop {     dock: left;     display: none; }  #reset {     dock: right; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0435\u0439\u0447\u0430\u0441, \u043e\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c <em>\u0441\u043e\u0432\u0441\u0435\u043c<\/em> \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/n2\/-5\/ft\/n2-5ftfd38fvvzy_l_xa6qfrrta.png\" data-src=\"https:\/\/habrastorage.org\/webt\/n2\/-5\/ft\/n2-5ftfd38fvvzy_l_xa6qfrrta.png\"\/><\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0443\u0436\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u043d\u0430\u0448 \u043d\u0430\u0431\u0440\u043e\u0441\u043e\u043a. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a Textual \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>stopwatch03.tcss<\/code> \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0438\u043b\u0435\u0439.<\/p>\n<p>  <\/p>\n<h2 id=\"osnovy-css\">\u041e\u0441\u043d\u043e\u0432\u044b CSS<\/h2>\n<p>  <\/p>\n<p>CSS-\u0444\u0430\u0439\u043b\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043b\u043e\u043a\u043e\u0432 <em>\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439.<\/em> \u0412\u043e\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0430\u043a\u043e\u0439 \u0431\u043b\u043e\u043a \u0438\u0437 <code>stopwatch03.tcss<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"css\">Stopwatch {     layout: horizontal;     background: $boost;     height: 5;     margin: 1;     min-width: 50;     padding: 1; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 Textual, \u0447\u0442\u043e \u0441\u0442\u0438\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043a \u0432\u0438\u0434\u0436\u0435\u0442\u0443 <code>Stopwatch<\/code>. \u0421\u0442\u0440\u043e\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u043c\u0438 \u0441\u043a\u043e\u0431\u043a\u0430\u043c\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0442\u0438\u043b\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e\u0442 CSS-\u043a\u043e\u0434 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 <code>Stopwatch<\/code>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/_2\/6v\/1q\/_26v1q8xqfstodnkthityvrutmw.png\" data-src=\"https:\/\/habrastorage.org\/webt\/_2\/6v\/1q\/_26v1q8xqfstodnkthityvrutmw.png\"\/><\/p>\n<p>  <\/p>\n<ul>\n<li><code>layout: horizontal<\/code> \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e.<\/li>\n<li><code>background: $boost<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>$boost<\/code>. \u041f\u0440\u0435\u0444\u0438\u043a\u0441 <code>$<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0446\u0432\u0435\u0442 \u0438\u0437 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u044b. \u0426\u0432\u0435\u0442 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>\"blue\"<\/code> \u0438\u043b\u0438 <code>rgb(20,46,210)<\/code>.<\/li>\n<li><code>height: 5<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u044b\u0441\u043e\u0442\u0443 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0440\u0430\u0432\u043d\u043e\u0439 5 \u0441\u0442\u0440\u043e\u043a\u0430\u043c \u0442\u0435\u043a\u0441\u0442\u0430.<\/li>\n<li><code>margin: 1<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043e\u0442\u0441\u0442\u0443\u043f \u0432\u043e\u043a\u0440\u0443\u0433 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 <code>Stopwatch<\/code> \u0432 1 \u0437\u043d\u0430\u043a\u043e\u043c\u0435\u0441\u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0436\u0434\u0443 \u0432\u0438\u0434\u0436\u0435\u0442\u0430\u043c\u0438 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/li>\n<li><code>min-width: 50<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0448\u0438\u0440\u0438\u043d\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0432 50 \u0437\u043d\u0430\u043a\u043e\u043c\u0435\u0441\u0442.<\/li>\n<li><code>padding: 1<\/code> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043e\u0442\u0441\u0442\u0443\u043f \u0432\u043e\u043a\u0440\u0443\u0433 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 \u0432 1 \u0437\u043d\u0430\u043a\u043e\u043c\u0435\u0441\u0442\u043e.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043e\u0441\u0442\u0430\u0442\u043e\u043a <code>stopwatch03.tcss<\/code>, \u0441 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u043c\u0438\u0441\u044f \u0431\u043b\u043e\u043a\u0430\u043c\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"css\">TimeDisplay {     content-align: center middle;     opacity: 60%;     height: 3; }  Button {     width: 16; }  #start {     dock: left; }  #stop {     dock: left;     display: none; }  #reset {     dock: right; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0411\u043b\u043e\u043a <code>TimeDisplay<\/code> \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 (<code>content-align<\/code>), \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0433\u043b\u0443\u0448\u0430\u0435\u0442 \u0435\u0433\u043e (<code>opacity<\/code>), \u0438 \u0437\u0430\u0434\u0430\u0451\u0442 \u0435\u043c\u0443 \u0432\u044b\u0441\u043e\u0442\u0443 (<code>height<\/code>) \u0432 3 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0411\u043b\u043e\u043a <code>Button<\/code> \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0448\u0438\u0440\u0438\u043d\u0443 (<code>width<\/code>) \u043a\u043d\u043e\u043f\u043e\u043a \u0432 16 \u0437\u043d\u0430\u043a\u043e\u043c\u0435\u0441\u0442.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 \u0438\u043c\u0435\u044e\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. \u0415\u0441\u043b\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 <code>#<\/code>, \u0442\u043e \u0441\u0442\u0438\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043a \u0432\u0438\u0434\u0436\u0435\u0442\u0430\u043c \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <code>id<\/code>. \u041c\u044b \u0437\u0430\u0434\u0430\u043b\u0438 ID \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432 <code>Button<\/code>, \u043a\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0438 \u0438\u0445 \u0432 compose. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043f\u0435\u0440\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 <code>id=\"start\"<\/code>, \u0447\u0435\u043c\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 <code>#start<\/code> \u0432 CSS.<\/p>\n<p>  <\/p>\n<p>\u0423 \u043a\u043d\u043e\u043f\u043e\u043a \u0435\u0441\u0442\u044c \u0441\u0442\u0438\u043b\u044c <code>dock<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0436\u0435\u0442 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u0440\u0430\u044e. \u041a\u043d\u043e\u043f\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u0438\u0441\u0442\u044b\u043a\u043e\u0432\u0430\u043d\u044b \u043a \u043b\u0435\u0432\u043e\u043c\u0443 \u043a\u0440\u0430\u044e, \u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u0441\u0431\u0440\u043e\u0441\u0430 \u043f\u0440\u0438\u0441\u0442\u044b\u043a\u043e\u0432\u0430\u043d\u0430 \u043a \u043f\u0440\u0430\u0432\u043e\u043c\u0443 \u043a\u0440\u0430\u044e.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b \u043c\u043e\u0433\u043b\u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 (<code>#stop<\/code> \u0432 CSS) \u0437\u0430\u0434\u0430\u043d\u043e <code>display: none;<\/code>. \u042d\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 Textual \u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043d\u0435 \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043a\u043d\u043e\u043f\u043a\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u043b\u0430\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0435 \u0437\u0430\u043f\u0443\u0449\u0435\u043d. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u043d\u043e\u043f\u043a\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u043b\u0430\u0441\u044c, \u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u0439\u043c\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d. \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u0438\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435.<\/p>\n<p>  <\/p>\n<h2 id=\"dinamicheskiy-css\">\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 CSS<\/h2>\n<p>  <\/p>\n<p>\u041c\u044b \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u0432\u0438\u0434\u0436\u0435\u0442 <code>Stopwatch<\/code> \u0438\u043c\u0435\u043b \u0434\u0432\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f: \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438 Start \u0438 Reset; \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 <em>started<\/em> \u0441 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 Stop. \u0422\u0430\u043a\u0436\u0435, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0437\u0435\u043b\u0451\u043d\u044b\u0439 \u0444\u043e\u043d \u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0436\u0438\u0440\u043d\u044b\u043c \u0448\u0440\u0438\u0444\u0442\u043e\u043c \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/q_\/fe\/ev\/q_feevrawodtbg8jpfqbg0_yxqu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/q_\/fe\/ev\/q_feevrawodtbg8jpfqbg0_yxqu.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u044d\u0442\u043e\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 CSS. \u041d\u0435 \u043f\u0443\u0442\u0430\u0439\u0442\u0435 \u0441 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 Python, \u043a\u043b\u0430\u0441\u0441 CSS \u044d\u0442\u043e \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u0442\u0435\u0433\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u0432\u0438\u0434\u0436\u0435\u0442\u0443, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u0442\u0438\u043b\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043d\u043e\u0432\u044b\u0439 CSS:<\/p>\n<p>  <\/p>\n<p><code>stopwatch04.tcss<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"css\">Stopwatch {     layout: horizontal;     background: $boost;     height: 5;     margin: 1;     min-width: 50;     padding: 1; }  TimeDisplay {     content-align: center middle;     text-opacity: 60%;     height: 3; }  Button {     width: 16; }  #start {     dock: left; }  #stop {     dock: left;     display: none; }  #reset {     dock: right; }  .started {     text-style: bold;     background: $success;     color: $text; }  .started TimeDisplay {     text-opacity: 100%; }  .started #start {     display: none }  .started #stop {     display: block }  .started #reset {     visibility: hidden }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u0438 \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 <code>.started<\/code>. \u0421\u0438\u043c\u0432\u043e\u043b <code>.<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e <code>.started<\/code> \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043a\u043b\u0430\u0441\u0441\u0443 CSS \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>\"started\"<\/code>. \u041d\u043e\u0432\u044b\u0435 \u0441\u0442\u0438\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0432\u0438\u0434\u0436\u0435\u0442\u0430\u043c, \u0438\u043c\u0435\u044e\u0449\u0438\u043c \u044d\u0442\u043e\u0442 CSS-\u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u0438\u043b\u0435\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u043c. \u041f\u0440\u043e\u0431\u0435\u043b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0443, \u0435\u0441\u043b\u0438 \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u0442\u0438\u0445 \u0441\u0442\u0438\u043b\u0435\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"css\">.started #start {     display: none }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440 <code>.started<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u044e\u0431\u043e\u043c\u0443 \u0432\u0438\u0434\u0436\u0435\u0442\u0443 \u0441 CSS-\u043a\u043b\u0430\u0441\u0441\u043e\u043c <code>\"started\"<\/code>. \u0410 <code>#start<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c\u0443 \u0432\u0438\u0434\u0436\u0435\u0442\u0443 \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c <code>\"start\"<\/code>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0435 Start \u0434\u043b\u044f \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u043e\u0432 \u0432 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u0440\u0430\u0432\u043d\u043e <code>\"display: none\"<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c, Textual \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443.<\/p>\n<p>  <\/p>\n<h2 id=\"manipulirovanie-klassami\">\u041c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438<\/h2>\n<p>  <\/p>\n<p>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 CSS-\u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u2014 \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0431\u0435\u0437 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0431\u0435\u0441\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b CSS \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 <a href=\"https:\/\/textual.textualize.io\/api\/dom_node\/#textual.dom.DOMNode.add_class\" rel=\"nofollow noopener noreferrer\">add_class()<\/a> \u0438 <a href=\"https:\/\/textual.textualize.io\/api\/dom_node\/#textual.dom.DOMNode.remove_class\" rel=\"nofollow noopener noreferrer\">remove_class()<\/a>. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f started \u043a \u043a\u043d\u043e\u043f\u043a\u0430\u043c Start \u0438 Stop.<\/p>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0438\u043b\u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u044b \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043d\u043e\u043f\u043a\u0438.<\/p>\n<p>  <\/p>\n<p><code>stopwatch04.py<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from textual.app import App, ComposeResult from textual.containers import ScrollableContainer from textual.widgets import Button, Footer, Header, Static  class TimeDisplay(Static):     \"\"\"A widget to display elapsed time.\"\"\"  class Stopwatch(Static):     \"\"\"A stopwatch widget.\"\"\"      def on_button_pressed(self, event: Button.Pressed) -> None:         \"\"\"Event handler called when a button is pressed.\"\"\"         if event.button.id == \"start\":             self.add_class(\"started\")         elif event.button.id == \"stop\":             self.remove_class(\"started\")      def compose(self) -> ComposeResult:         \"\"\"Create child widgets of a stopwatch.\"\"\"         yield Button(\"Start\", id=\"start\", variant=\"success\")         yield Button(\"Stop\", id=\"stop\", variant=\"error\")         yield Button(\"Reset\", id=\"reset\")         yield TimeDisplay(\"00:00:00.00\")  class StopwatchApp(App):     \"\"\"A Textual app to manage stopwatches.\"\"\"      CSS_PATH = \"stopwatch04.tcss\"     BINDINGS = [(\"d\", \"toggle_dark\", \"Toggle dark mode\")]      def compose(self) -> ComposeResult:         \"\"\"Create child widgets for the app.\"\"\"         yield Header()         yield Footer()         yield ScrollableContainer(Stopwatch(), Stopwatch(), Stopwatch())      def action_toggle_dark(self) -> None:         \"\"\"An action to toggle dark mode.\"\"\"         self.dark = not self.dark  if __name__ == \"__main__\":     app = StopwatchApp()     app.run()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>on_button_pressed<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u044f.<\/em> \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 Textual \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 <em>\u0441\u043e\u0431\u044b\u0442\u0438\u0435,<\/em> \u0442\u0430\u043a\u043e\u0435 \u043a\u0430\u043a \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043b\u0430\u0432\u0438\u0448\u0438, \u0449\u0435\u043b\u0447\u043e\u043a \u043c\u044b\u0448\u0438 \u0438 \u0442.\u0434. \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442\u0441\u044f \u0441 <code>on_<\/code>, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, <code>on_button_pressed<\/code> \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>stopwatch04.py<\/code> \u0441\u0435\u0439\u0447\u0430\u0441, \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438 \u043f\u043e \u043d\u0430\u0436\u0430\u0442\u0438\u044e \u043f\u0435\u0440\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/xj\/jl\/kf\/xjjlkfrtjfg6hr1rymhb2_bexdw.png\" data-src=\"https:\/\/habrastorage.org\/webt\/xj\/jl\/kf\/xjjlkfrtjfg6hr1rymhb2_bexdw.png\"\/><\/p>\n<p>  <\/p>\n<h1 id=\"reaktivnye-atributy\">\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b<\/h1>\n<p>  <\/p>\n<p>\u0412 Textual \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e \u0432\u0441\u043f\u043b\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043c\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0432\u0440\u0435\u043c\u044f \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u042d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e: \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>refresh()<\/code> \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445<\/em> \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"https:\/\/textual.textualize.io\/api\/reactive\/#textual.reactive.reactive\" rel=\"nofollow noopener noreferrer\">reactive<\/a>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u044e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0435\u0433\u043e.<\/p>\n<p>  <\/p>\n<p><code>stopwatch05.py<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from time import monotonic  from textual.app import App, ComposeResult from textual.containers import ScrollableContainer from textual.reactive import reactive from textual.widgets import Button, Footer, Header, Static  class TimeDisplay(Static):     \"\"\"A widget to display elapsed time.\"\"\"      start_time = reactive(monotonic)     time = reactive(0.0)      def on_mount(self) -> None:         \"\"\"Event handler called when widget is added to the app.\"\"\"         self.set_interval(1 \/ 60, self.update_time)      def update_time(self) -> None:         \"\"\"Method to update the time to the current time.\"\"\"         self.time = monotonic() - self.start_time      def watch_time(self, time: float) -> None:         \"\"\"Called when the time attribute changes.\"\"\"         minutes, seconds = divmod(time, 60)         hours, minutes = divmod(minutes, 60)         self.update(f\"{hours:02,.0f}:{minutes:02.0f}:{seconds:05.2f}\")  class Stopwatch(Static):     \"\"\"A stopwatch widget.\"\"\"      def on_button_pressed(self, event: Button.Pressed) -> None:         \"\"\"Event handler called when a button is pressed.\"\"\"         if event.button.id == \"start\":             self.add_class(\"started\")         elif event.button.id == \"stop\":             self.remove_class(\"started\")      def compose(self) -> ComposeResult:         \"\"\"Create child widgets of a stopwatch.\"\"\"         yield Button(\"Start\", id=\"start\", variant=\"success\")         yield Button(\"Stop\", id=\"stop\", variant=\"error\")         yield Button(\"Reset\", id=\"reset\")         yield TimeDisplay()  class StopwatchApp(App):     \"\"\"A Textual app to manage stopwatches.\"\"\"      CSS_PATH = \"stopwatch04.tcss\"     BINDINGS = [(\"d\", \"toggle_dark\", \"Toggle dark mode\")]      def compose(self) -> ComposeResult:         \"\"\"Create child widgets for the app.\"\"\"         yield Header()         yield Footer()         yield ScrollableContainer(Stopwatch(), Stopwatch(), Stopwatch())      def action_toggle_dark(self) -> None:         \"\"\"An action to toggle dark mode.\"\"\"         self.dark = not self.dark  if __name__ == \"__main__\":     app = StopwatchApp()     app.run()<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432 \u0432\u0438\u0434\u0436\u0435\u0442 <code>TimeDisplay<\/code> \u0434\u0432\u0430 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430: <code>start_time<\/code> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f (\u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445) \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430, \u0430 <code>time<\/code> \u2014 \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0430 <code>Stopwatch<\/code>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 <code>self<\/code>, \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0438\u0445 \u0432 <code>__init__<\/code>. \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043b\u044e\u0431\u043e\u043c\u0443 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0432\u0438\u0434\u0436\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.<\/p>\n<p>  <\/p>\n<blockquote><p><strong>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f:<\/strong> \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>monotonic<\/code> \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f <code>time<\/code> \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u041e\u043d\u0430 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 <code>time.time<\/code>, \u043d\u043e \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u0430\u0434, \u0435\u0441\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p><\/blockquote>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>reactive<\/code> \u2014 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0438\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f <code>start_time<\/code> \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>monotonic<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 <code>TimeDisplay<\/code> \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0410\u0442\u0440\u0438\u0431\u0443\u0442 <code>time<\/code> \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 <code>self.time<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c 0.<\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>on_mount<\/code> \u2014 \u044d\u0442\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432\u0438\u0434\u0436\u0435\u0442\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (<em>\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438<\/em> \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0438 Textual). \u0412 \u044d\u0442\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c <a href=\"https:\/\/textual.textualize.io\/api\/message_pump\/#textual.message_pump.MessagePump.set_interval\" rel=\"nofollow noopener noreferrer\">set_interval()<\/a>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 <code>self.update_time<\/code> \u0448\u0435\u0441\u0442\u044c\u0434\u0435\u0441\u044f\u0442 \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0432\u0440\u0435\u043c\u044f, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0435 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0438\u0434\u0436\u0435\u0442\u0430, \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 <code>self.time<\/code>, \u0447\u0442\u043e \u043f\u043e\u0434\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0441 \u043a \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0441\u0432\u0435\u0440\u0445\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439 Reactive.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0435 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 <code>watch_<\/code>, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u043c\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430, \u0442\u043e \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0437\u0432\u0430\u043d. \u0422\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u043a\u0430\u043a <em>\u0441\u043b\u0435\u0434\u044f\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b.<\/em><\/p>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c <code>self.time<\/code> 60 \u0440\u0430\u0437 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u044f\u0432\u043d\u043e\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u0443 <code>watch_time<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0432\u0438\u0434\u0436\u0435\u0442 \u0432\u044b\u0437\u043e\u0432\u043e\u043c <code>self.update<\/code>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0432 <code>TimeDisplay<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b <code>Stopwatch<\/code> \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u0440\u0435\u043c\u044f, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0435 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u0430:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/j6\/47\/bi\/j647bijeymbtr0cmuosfml4gmj0.png\" data-src=\"https:\/\/habrastorage.org\/webt\/j6\/47\/bi\/j647bijeymbtr0cmuosfml4gmj0.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u043a\u0430\u043a \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u0439\u043c\u0435\u0440\u0430, \u043d\u043e \u0435\u0449\u0451 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<p>  <\/p>\n<h2 id=\"podklyuchenie-knopok\">\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u043d\u043e\u043f\u043e\u043a<\/h2>\n<p>  <\/p>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u043c\u0435\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c, \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0438 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445. \u042d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 <code>TimeDisplay<\/code>.<\/p>\n<p>  <\/p>\n<p><code>stopwatch06.py<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from time import monotonic  from textual.app import App, ComposeResult from textual.containers import ScrollableContainer from textual.reactive import reactive from textual.widgets import Button, Footer, Header, Static  class TimeDisplay(Static):     \"\"\"A widget to display elapsed time.\"\"\"      start_time = reactive(monotonic)     time = reactive(0.0)     total = reactive(0.0)      def on_mount(self) -> None:         \"\"\"Event handler called when widget is added to the app.\"\"\"         self.update_timer = self.set_interval(1 \/ 60, self.update_time, pause=True)      def update_time(self) -> None:         \"\"\"Method to update time to current.\"\"\"         self.time = self.total + (monotonic() - self.start_time)      def watch_time(self, time: float) -> None:         \"\"\"Called when the time attribute changes.\"\"\"         minutes, seconds = divmod(time, 60)         hours, minutes = divmod(minutes, 60)         self.update(f\"{hours:02,.0f}:{minutes:02.0f}:{seconds:05.2f}\")      def start(self) -> None:         \"\"\"Method to start (or resume) time updating.\"\"\"         self.start_time = monotonic()         self.update_timer.resume()      def stop(self) -> None:         \"\"\"Method to stop the time display updating.\"\"\"         self.update_timer.pause()         self.total += monotonic() - self.start_time         self.time = self.total      def reset(self) -> None:         \"\"\"Method to reset the time display to zero.\"\"\"         self.total = 0         self.time = 0  class Stopwatch(Static):     \"\"\"A stopwatch widget.\"\"\"      def on_button_pressed(self, event: Button.Pressed) -> None:         \"\"\"Event handler called when a button is pressed.\"\"\"         button_id = event.button.id         time_display = self.query_one(TimeDisplay)         if button_id == \"start\":             time_display.start()             self.add_class(\"started\")         elif button_id == \"stop\":             time_display.stop()             self.remove_class(\"started\")         elif button_id == \"reset\":             time_display.reset()      def compose(self) -> ComposeResult:         \"\"\"Create child widgets of a stopwatch.\"\"\"         yield Button(\"Start\", id=\"start\", variant=\"success\")         yield Button(\"Stop\", id=\"stop\", variant=\"error\")         yield Button(\"Reset\", id=\"reset\")         yield TimeDisplay()  class StopwatchApp(App):     \"\"\"A Textual app to manage stopwatches.\"\"\"      CSS_PATH = \"stopwatch04.tcss\"     BINDINGS = [(\"d\", \"toggle_dark\", \"Toggle dark mode\")]      def compose(self) -> ComposeResult:         \"\"\"Called to add widgets to the app.\"\"\"         yield Header()         yield Footer()         yield ScrollableContainer(Stopwatch(), Stopwatch(), Stopwatch())      def action_toggle_dark(self) -> None:         \"\"\"An action to toggle dark mode.\"\"\"         self.dark = not self.dark  if __name__ == \"__main__\":     app = StopwatchApp()     app.run()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0434\u0435\u043b\u0430\u043d\u044b \u0432 <code>TimeDisplay<\/code>.<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <code>total<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0435\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0436\u0430\u0442\u0438\u044f\u043c\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430.<\/li>\n<li>\u0412 \u0432\u044b\u0437\u043e\u0432 <code>set_interval<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 <code>pause=True<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0442\u0430\u0439\u043c\u0435\u0440 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0430\u0443\u0437\u044b (\u043a\u043e\u0433\u0434\u0430 \u0442\u0430\u0439\u043c\u0435\u0440 \u043d\u0430 \u043f\u0430\u0443\u0437\u0435, \u043e\u043d \u043d\u0435 \u0438\u0434\u0451\u0442, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/textual.textualize.io\/api\/timer\/#textual.timer.Timer.resume\" rel=\"nofollow noopener noreferrer\">resume()<\/a>). \u042d\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u043e\u0441\u044c, \u043f\u043e\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u043d\u0430\u0436\u043c\u0451\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 \u0441\u0442\u0430\u0440\u0442\u0430.<\/li>\n<li>\u041c\u0435\u0442\u043e\u0434 <code>update_time<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 total \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0435\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043c\u0435\u0436\u0434\u0443 \u043b\u044e\u0431\u044b\u043c\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u044f\u043c\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0438 \u0441\u0442\u0430\u0440\u0442\u0430 \u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0430.<\/li>\n<li>\u041c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <code>set_interval<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0430\u0439\u043c\u0435\u0440\u0430. \u041f\u043e\u0437\u0434\u043d\u0435\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b <em>\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c<\/em> \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u0430\u0439\u043c\u0435\u0440\u0430 \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430.<\/li>\n<li>\u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u044b <code>start()<\/code>, <code>stop()<\/code> \u0438 <code>reset()<\/code>.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a \u043c\u0435\u0442\u043e\u0434\u0443 <code>on_button_pressed<\/code> \u043a\u043b\u0430\u0441\u0441\u0430 <code>Stopwatch<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0443. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0433\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">    def on_button_pressed(self, event: Button.Pressed) -> None:         \"\"\"Event handler called when a button is pressed.\"\"\"         button_id = event.button.id         time_display = self.query_one(TimeDisplay)         if button_id == \"start\":             time_display.start()             self.add_class(\"started\")         elif button_id == \"stop\":             time_display.stop()             self.remove_class(\"started\")         elif button_id == \"reset\":             time_display.reset()<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0432\u0448\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c. \u041c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 <code>id<\/code> \u043d\u0430\u0436\u0430\u0442\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c.<\/li>\n<li>\u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <code>query_one<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0432\u0438\u0434\u0436\u0435\u0442 <code>TimeDisplay<\/code>.<\/li>\n<li>\u041c\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>TimeDisplay<\/code>, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0436\u0430\u0442\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0435.<\/li>\n<li>\u041c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <code>\"started\"<\/code>, \u0435\u0441\u043b\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d (<code>self.add_class(\"started\")<\/code>), \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0435\u0433\u043e (<code>self.remove_class(\"started\")<\/code>), \u0435\u0441\u043b\u0438 \u043e\u043d \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d. \u042d\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430 \u0447\u0435\u0440\u0435\u0437 CSS.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>stopwatch06.py<\/code>, \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u044b \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/m9\/jg\/hs\/m9jghsp3t1ebxpvafcadtgeo-9a.png\" data-src=\"https:\/\/habrastorage.org\/webt\/m9\/jg\/hs\/m9jghsp3t1ebxpvafcadtgeo-9a.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u044b.<\/p>\n<p>  <\/p>\n<h1 id=\"dinamicheskie-vidzhety\">\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b<\/h1>\n<p>  <\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Stopwatch \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <code>compose<\/code>. \u041d\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438\u0445, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0432\u044b\u0437\u0432\u0430\u0432 <a href=\"https:\/\/textual.textualize.io\/api\/widget\/#textual.widget.Widget.mount\" rel=\"nofollow noopener noreferrer\">mount()<\/a>, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0438\u0434\u0436\u0435\u0442 \u0438 <a href=\"https:\/\/textual.textualize.io\/api\/widget\/#textual.widget.Widget.remove\" rel=\"nofollow noopener noreferrer\">remove()<\/a>, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0440\u0430\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u0442\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u043e\u0432 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>  <\/p>\n<p><code>stopwatch.py<\/code><\/p>\n<p>  <\/p>\n<pre><code class=\"python\">from time import monotonic  from textual.app import App, ComposeResult from textual.containers import ScrollableContainer from textual.reactive import reactive from textual.widgets import Button, Footer, Header, Static  class TimeDisplay(Static):     \"\"\"A widget to display elapsed time.\"\"\"      start_time = reactive(monotonic)     time = reactive(0.0)     total = reactive(0.0)      def on_mount(self) -> None:         \"\"\"Event handler called when widget is added to the app.\"\"\"         self.update_timer = self.set_interval(1 \/ 60, self.update_time, pause=True)      def update_time(self) -> None:         \"\"\"Method to update time to current.\"\"\"         self.time = self.total + (monotonic() - self.start_time)      def watch_time(self, time: float) -> None:         \"\"\"Called when the time attribute changes.\"\"\"         minutes, seconds = divmod(time, 60)         hours, minutes = divmod(minutes, 60)         self.update(f\"{hours:02,.0f}:{minutes:02.0f}:{seconds:05.2f}\")      def start(self) -> None:         \"\"\"Method to start (or resume) time updating.\"\"\"         self.start_time = monotonic()         self.update_timer.resume()      def stop(self):         \"\"\"Method to stop the time display updating.\"\"\"         self.update_timer.pause()         self.total += monotonic() - self.start_time         self.time = self.total      def reset(self):         \"\"\"Method to reset the time display to zero.\"\"\"         self.total = 0         self.time = 0  class Stopwatch(Static):     \"\"\"A stopwatch widget.\"\"\"      def on_button_pressed(self, event: Button.Pressed) -> None:         \"\"\"Event handler called when a button is pressed.\"\"\"         button_id = event.button.id         time_display = self.query_one(TimeDisplay)         if button_id == \"start\":             time_display.start()             self.add_class(\"started\")         elif button_id == \"stop\":             time_display.stop()             self.remove_class(\"started\")         elif button_id == \"reset\":             time_display.reset()      def compose(self) -> ComposeResult:         \"\"\"Create child widgets of a stopwatch.\"\"\"         yield Button(\"Start\", id=\"start\", variant=\"success\")         yield Button(\"Stop\", id=\"stop\", variant=\"error\")         yield Button(\"Reset\", id=\"reset\")         yield TimeDisplay()  class StopwatchApp(App):     \"\"\"A Textual app to manage stopwatches.\"\"\"      CSS_PATH = \"stopwatch.tcss\"      BINDINGS = [         (\"d\", \"toggle_dark\", \"Toggle dark mode\"),         (\"a\", \"add_stopwatch\", \"Add\"),         (\"r\", \"remove_stopwatch\", \"Remove\"),     ]      def compose(self) -> ComposeResult:         \"\"\"Called to add widgets to the app.\"\"\"         yield Header()         yield Footer()         yield ScrollableContainer(Stopwatch(), Stopwatch(), Stopwatch(), id=\"timers\")      def action_add_stopwatch(self) -> None:         \"\"\"An action to add a timer.\"\"\"         new_stopwatch = Stopwatch()         self.query_one(\"#timers\").mount(new_stopwatch)         new_stopwatch.scroll_visible()      def action_remove_stopwatch(self) -> None:         \"\"\"Called to remove a timer.\"\"\"         timers = self.query(\"Stopwatch\")         if timers:             timers.last().remove()      def action_toggle_dark(self) -> None:         \"\"\"An action to toggle dark mode.\"\"\"         self.dark = not self.dark  if __name__ == \"__main__\":     app = StopwatchApp()     app.run()<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0441\u0443\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0423 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>ScrollableContainer<\/code> \u0432 <code>StopWatchApp<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0441\u044f id <code>\"timers\"<\/code>.<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043c\u0435\u0442\u043e\u0434 <code>action_add_stopwatch<\/code> \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430.<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043c\u0435\u0442\u043e\u0434 <code>action_remove_stopwatch<\/code> \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430.<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430 \u0433\u043e\u0440\u044f\u0447\u0438\u0445 \u043a\u043b\u0430\u0432\u0438\u0448 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>action_add_stopwatch<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438 \u043c\u043e\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 <a href=\"https:\/\/textual.textualize.io\/api\/dom_node\/#textual.dom.DOMNode.query_one\" rel=\"nofollow noopener noreferrer\">query_one()<\/a> \u0441 CSS-\u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u043c <code>\"#timers\"<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u0430\u0439\u043c\u0435\u0440\u043e\u0432 \u043f\u043e \u0435\u0433\u043e ID. \u041f\u043e\u0441\u043b\u0435 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u0432 <code>action_add_stopwatch<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <a href=\"https:\/\/textual.textualize.io\/api\/widget\/#textual.widget.Widget.scroll_visible\" rel=\"nofollow noopener noreferrer\">scroll_visible()<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 <code>Stopwatch<\/code> \u0432\u0438\u0434\u0438\u043c\u044b\u043c (\u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e).<\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>action_remove_stopwatch<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 <a href=\"https:\/\/textual.textualize.io\/api\/dom_node\/#textual.dom.DOMNode.query\" rel=\"nofollow noopener noreferrer\">query()<\/a> \u0441 CSS-\u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u043e\u043c <code>\"Stopwatch\"<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u0438\u0434\u0436\u0435\u0442\u044b Stopwatch. \u0415\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c, \u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/textual.textualize.io\/api\/query\/#textual.css.query.DOMQuery.last\" rel=\"nofollow noopener noreferrer\">last()<\/a> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u0430 \u0438 <a href=\"https:\/\/textual.textualize.io\/api\/query\/#textual.css.query.DOMQuery.remove\" rel=\"nofollow noopener noreferrer\">remove()<\/a> \u0434\u043b\u044f \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 <code>stopwatch.py<\/code>, \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u043e\u043c\u0435\u0440\u044b \u043a\u043b\u0430\u0432\u0438\u0448\u0435\u0439 <code>A<\/code> \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438\u0445 \u043a\u043b\u0430\u0432\u0438\u0448\u0435\u0439 <code>R<\/code>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/oy\/ak\/ir\/oyakirqa95qenbywdceuv-rkkb8.png\" data-src=\"https:\/\/habrastorage.org\/webt\/oy\/ak\/ir\/oyakirqa95qenbywdceuv-rkkb8.png\"\/><\/p>\n<p>  <\/p>\n<h1 id=\"chto-dalshe\">\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435?<\/h1>\n<p>  <\/p>\n<p>\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0430\u0441 \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Textual! \u0412 \u044d\u0442\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435 \u0431\u044b\u043b\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 \u0432\u044b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u0441\u044c \u043a \u0442\u043e\u043c\u0443 \u0442\u0438\u043f\u0443 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e\u0442 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0439\u0442\u0435\u0441\u044c. \u041c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c <code>stopwatch.py<\/code> \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b.<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0447\u0442\u0438\u0442\u0435 <a href=\"https:\/\/textual.textualize.io\/guide\/\" rel=\"nofollow noopener noreferrer\">\u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e<\/a> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f TUI \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Textual.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/774254\/\"> https:\/\/habr.com\/ru\/articles\/774254\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/5b\/ji\/si\/5bjisipww1fznqiomojxi2mmbyk.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/5b\/ji\/si\/5bjisipww1fznqiomojxi2mmbyk.png\"\/><\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0432\u043e\u0434 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043f\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0443 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f TUI (\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u0432). \u041a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u0430 \u0432 \u0432\u0435\u0431, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043b\u0434\u0441\u043a\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-360313","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/360313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=360313"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/360313\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=360313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=360313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=360313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}