{"id":2378,"date":"2022-12-10T10:05:41","date_gmt":"2022-12-10T02:05:41","guid":{"rendered":"https:\/\/qaqaq.top\/?p=2378"},"modified":"2023-01-10T22:07:20","modified_gmt":"2023-01-10T14:07:20","slug":"python-tkinter-ip%e5%9c%b0%e5%9d%80%e6%9f%a5%e8%af%a2%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=2378","title":{"rendered":"python tkinter IP\u5730\u5740\u67e5\u8be2\u7a0b\u5e8f"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/qaqaq.top\/wp-content\/uploads\/2023\/01\/image-220-1024x359.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"359\" data-original=\"https:\/\/qaqaq.top\/wp-content\/uploads\/2023\/01\/image-220-1024x359.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-3536\"  sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>import socket\nfrom tkinter import *\n\n\nclass ipAddress:\n    def __init__(self):\n        window = Tk()\n        window.title(\"ipAddress\")\n\n        frame = Frame(window)\n        frame.pack()\n\n        Label(frame, text=\"\u57df\u540d:\").grid(row=1, column=1)\n\n        self.ipName = StringVar()\n        Entry(frame, textvariable=self.ipName).grid(row=1, column=2)\n\n        Button(frame, text=\"\u67e5\u627e\", command=self.getIpAddress).grid(row=1, column=3)\n\n        self.toString = StringVar()\n        label = Label(window, textvariable=self.toString, anchor=NW, font=(\"consolas\", 15), bg=\"white\", height=15,\n                      width=60)\n        label.pack()\n\n        window.mainloop()\n\n    def getIpAddress(self):\n        try:\n            ipAddress = socket.gethostbyname(self.ipName.get())\n            self.toString.set(str(self.ipName.get()) + \"\u7684IP\u5730\u5740\u4e3a\uff1a\" + str(ipAddress))\n        except:\n            self.toString.set(\"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u57df\u540d\uff01\")\n\n\nipAddress()\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[50],"class_list":["post-2378","post","type-post","status-publish","format-standard","hentry","category-python-code","tag-python"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/2378"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2378"}],"version-history":[{"count":2,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/2378\/revisions"}],"predecessor-version":[{"id":3537,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/2378\/revisions\/3537"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}