{"id":296035,"date":"2019-12-18T21:00:08","date_gmt":"2019-12-18T21:00:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296035"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296035","title":{"rendered":"\u041a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 \u043d\u0430 python"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/481074\/\">\n<h2>\u041d\u0430\u0447\u0430\u043b\u043e<\/h2>\n<p>  <\/p>\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/480906\/\">\u0438\u0433\u0440\u0443 \u043d\u0430 python<\/a>, \u0430 \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 \u043d\u0430 <a href=\"https:\/\/docs.python.org\/3\/library\/tkinter.html\" rel=\"nofollow\">python tkinter<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ig\/xp\/qd\/igxpqdy-b6yqaklndeuc7ieadwq.png\"><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u043a\u043d\u043e 485 \u043d\u0430 550. \u0420\u0430\u0437\u043c\u0435\u0440\u044b \u043d\u0435 \u0432\u0430\u0436\u043d\u044b, \u043c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u0438\u0435. \u0422\u0430\u043a \u0436\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043a\u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">from tkinter import *   class Main(Frame):     def __init__(self, root):         super(Main, self).__init__(root)         self.build()      def build(self):         pass       def logicalc(self, operation):         pass      def update():        pass   if __name__ == '__main__':     root = Tk()     root[\"bg\"] = \"#000\"     root.geometry(\"485x550+200+200\")     root.title(\"\u041a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\")     root.resizable(False, False)     app = Main(root)     app.pack()     root.mainloop() <\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0438\u0434\u0451\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<\/p>\n<h2>\u0414\u0435\u043b\u0430\u0435\u043c \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0438<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <i>build<\/i> \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">btns = [             \"C\", \"DEL\", \"*\", \"=\",             \"1\", \"2\", \"3\", \"\/\",             \"4\", \"5\", \"6\", \"+\",             \"7\", \"8\", \"9\", \"-\",             \"+\/-\", \"0\", \"%\", \"X^2\"         ] <\/code><\/pre>\n<p>\u041e\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0441\u0435 \u043a\u043d\u043e\u043f\u043a\u0438, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0443 \u043d\u0430\u0441 \u0432 \u043e\u043a\u043d\u0435.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0446\u0438\u043a\u043b\u043e\u043c \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u044d\u0442\u0438 \u043a\u043d\u043e\u043f\u043a\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0442\u043e\u043c \u0436\u0435 \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u0438\u0448\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"python\">x = 10         y = 140         for bt in btns:             com = lambda x=bt: self.logicalc(x)             Button(text=bt, bg=\"#FFF\",                    font=(\"Times New Roman\", 15),                    command=com).place(x=x, y=y,                                       width=115,                                       height=79)             x += 117             if x &gt; 400:                 x = 10                 y += 81 <\/code><\/pre>\n<p>\u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043d\u043e\u043f\u043e\u0447\u043a\u0438. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0434\u043f\u0438\u0441\u044c \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u042f \u0445\u043e\u0447\u0443 \u0447\u0442\u043e \u0431\u044b \u0442\u0435\u043a\u0441\u0442 \u0431\u044b\u043b \u0441\u043b\u0435\u0432\u0430, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<pre><code class=\"python\">self.formula = \"0\" self.lbl = Label(text=self.formula, font=(\"Times New Roman\", 21, \"bold\"),                  bg=\"#000\", foreground=\"#FFF\") self.lbl.place(x=11, y=50) <\/code><\/pre>\n<h2>\u041f\u0438\u0448\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443<\/h2>\n<pre><code class=\"python\">def logicalc(self, operation):     if operation == \"C\":         self.formula = \"\"     elif operation == \"DEL\":         self.formula = self.formula[0:-1]     elif operation == \"X^2\":         self.formula = str((eval(self.formula))**2)     elif operation == \"=\":         self.formula = str(eval(self.formula))     else:         if self.formula == \"0\":             self.formula = \"\"         self.formula += operation     self.update()  def update(self):     if self.formula == \"\":         self.formula = \"0\"     self.lbl.configure(text=self.formula) <\/code><\/pre>\n<p>\u0422\u0430\u043a, \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0432\u0432\u043e\u0434\u0430 \u0441 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u0441\u043f\u0435\u0446. \u043a\u043d\u043e\u043f\u043a\u0438 (C, DEL, =) \u0438 \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e \u043a \u0444\u043e\u0440\u043c\u0443\u043b\u0435.<\/p>\n<p>\u0423 \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u0434\u043e\u0447\u0435\u0442\u043e\u0432, \u043d\u043e \u043c\u044b \u0438 \u043d\u0435 \u0441\u0442\u0440\u0438\u043c\u0438\u043b\u0438\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<blockquote><p>\u041f\u0440\u043e\u0448\u0443 \u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0437\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u0438\u0448\u0438\u0442\u0435, \u044f \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044e\u0441\u044c.<\/p><\/blockquote>\n<h1>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\u0430:<\/h1>\n<p>  <\/p>\n<pre><code class=\"python\">from tkinter import *   class Main(Frame):     def __init__(self, root):         super(Main, self).__init__(root)         self.build()      def build(self):         self.formula = \"0\"         self.lbl = Label(text=self.formula, font=(\"Times New Roman\", 21, \"bold\"), bg=\"#000\", foreground=\"#FFF\")         self.lbl.place(x=11, y=50)          btns = [             \"C\", \"DEL\", \"*\", \"=\",             \"1\", \"2\", \"3\", \"\/\",             \"4\", \"5\", \"6\", \"+\",             \"7\", \"8\", \"9\", \"-\",             \"(\", \"0\", \")\", \"X^2\"         ]          x = 10         y = 140         for bt in btns:             com = lambda x=bt: self.logicalc(x)             Button(text=bt, bg=\"#FFF\",                    font=(\"Times New Roman\", 15),                    command=com).place(x=x, y=y,                                       width=115,                                       height=79)             x += 117             if x &gt; 400:                 x = 10                 y += 81      def logicalc(self, operation):         if operation == \"C\":             self.formula = \"\"         elif operation == \"DEL\":             self.formula = self.formula[0:-1]         elif operation == \"X^2\":             self.formula = str((eval(self.formula))**2)         elif operation == \"=\":             self.formula = str(eval(self.formula))         else:             if self.formula == \"0\":                 self.formula = \"\"             self.formula += operation         self.update()      def update(self):         if self.formula == \"\":             self.formula = \"0\"         self.lbl.configure(text=self.formula)   if __name__ == '__main__':     root = Tk()     root[\"bg\"] = \"#000\"     root.geometry(\"485x550+200+200\")     root.title(\"\u041a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440\")     root.resizable(False, False)     app = Main(root)     app.pack()     root.mainloop() <\/code><\/pre>\n<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <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\/post\/481074\/\"> https:\/\/habr.com\/ru\/post\/481074\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/481074\/\">\n<h2>\u041d\u0430\u0447\u0430\u043b\u043e<\/h2>\n<p>  <\/p>\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/post\/480906\/\">\u0438\u0433\u0440\u0443 \u043d\u0430 python<\/a>, \u0430 \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u0430\u043b\u044c\u043a\u0443\u043b\u044f\u0442\u043e\u0440 \u043d\u0430 <a href=\"https:\/\/docs.python.org\/3\/library\/tkinter.html\" rel=\"nofollow\">python tkinter<\/a>.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ig\/xp\/qd\/igxpqdy-b6yqaklndeuc7ieadwq.png\">  <\/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-296035","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296035","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=296035"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296035\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}