{"id":420,"date":"2022-07-16T16:17:04","date_gmt":"2022-07-16T16:17:04","guid":{"rendered":"http:\/\/fanaticboy.com\/?p=420"},"modified":"2022-07-16T16:17:06","modified_gmt":"2022-07-16T16:17:06","slug":"python%e4%b9%8btkinter%e8%bf%9b%e9%98%b6-%e6%89%b9%e9%87%8f%e5%b0%86word%e6%a0%bc%e5%bc%8f%e8%bd%ac%e5%8c%96%e6%88%90pdf%e6%a0%bc%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/fanaticboy.com\/?p=420","title":{"rendered":"python\u4e4btkinter\u8fdb\u9636-\u6279\u91cf\u5c06word\u683c\u5f0f\u8f6c\u5316\u6210pdf\u683c\u5f0f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u200b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;\u4e0a\u4e00\u7bc7\u8bb2\u4e86tkinter\u5173\u4e8e\u6587\u4ef6\u7684\u64cd\u4f5c\u662f\u6279\u91cf\u4fee\u6539\u6587\u4ef6\u7684\u540e\u7f00\u540d\uff0c\u8fd9\u4e00\u7bc7\u8bf4\u4e00\u4e0b\u7ecf\u5e38\u7528\u5230\u7684\u64cd\u4f5c\uff0c\u5c31\u662f\u5c06word\u8f6c\u5316\u6210pdf\u683c\u5f0f\u3002\u5982\u679c\u662f\u4e00\u4e2a\u4e24\u4e2a\u7684\u6587\u4ef6\u624b\u52a8\u64cd\u4f5c\u8d77\u6765\u6ca1\u6709\u4ec0\u4e48\uff0c\u4f46\u5982\u679c\u8fc7\u591a\u624b\u52a8\u5c31\u663e\u5f97\u90a3\u4e48\u4e0d\u65b9\u4fbf\u4e86\u3002\u63a5\u4e0b\u6765\u5c31\u770b\u4ee3\u7801\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e00\u6b65\uff0c\u4e0b\u8f7d\u5e76\u5bfc\u5165\u6240\u9700\u7684\u5305<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install docx2pdf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:http:\/\/fanaticboy.com\/544d0941-38e9-4432-a163-0dc62bbd300a\" width=\"15\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5148\u4e0b\u8f7d\uff0c\u540e\u5bfc\u5165<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import tkinter.filedialog\n\nfrom tkinter import *\n\n# \u8fd9\u4e2a\u5305\u662f\u7b2c\u4e09\u65b9\u5305\uff0c\u9700\u8981install\n\nfrom docx2pdf import convert<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:http:\/\/fanaticboy.com\/6e9d077f-adc5-4470-bf15-04ace5416a2d\" width=\"15\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e8c\u6b65\uff0c\u521b\u5efa\u64cd\u4f5c\u754c\u9762<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Change:\n    def __init__(self):\n        root = Tk()\n        root.geometry(\"600x400+450+150\")\n\n        btn = Button(root, text=\"\u70b9\u51fb\u8f6c\u5316pdf\", command=self.change)\n        btn.place(x=280, y=150)\n        root.mainloop()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:http:\/\/fanaticboy.com\/8925bd8d-0f09-4e64-87b8-7966cf52c0cb\" width=\"15\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7b2c\u4e09\u6b65\uff0c\u5199\u5b9e\u73b0\u903b\u8f91<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> def change(self):\n        a = tkinter.filedialog.askopenfilenames()  # \u53ef\u4ee5\u8fd4\u56de\u591a\u4e2a\u6587\u4ef6\u540d\n        print(a)\n        for i in a:\n            convert(i, f\"{i.split('.')&#91;0]}.pdf\")\n            pass<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:http:\/\/fanaticboy.com\/b449d197-5c4e-43c9-868d-2058dc4b23ac\" width=\"15\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u586b\u4e0amain<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if __name__ == '__main__':\n    ch = Change()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:http:\/\/fanaticboy.com\/c9e2a2a4-1946-4020-bfe3-cacc5c46087f\" width=\"15\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u6f14\u793a\u4e00\u4e0b\u64cd\u4f5c\u6548\u679c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u663e\u793a\u754c\u9762\uff0c\u70b9\u51fb\u201c\u201d\u70b9\u51fb\u8f6c\u5316pdf<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/b42b735c97d1621a2cc97b374f8c8ef9.png\">\u200b<img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:http:\/\/fanaticboy.com\/dd82b8b7-3b6c-4bd9-8eb2-eda02757f0c0\" width=\"15\">\u7f16\u8f91<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u4f4fctrl\u9009\u62e9\u591a\u4e2a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/336d554c08b7f6c84e501a4433cded12.png\">\u200b<img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:http:\/\/fanaticboy.com\/770b5070-daec-4b2f-9313-cdd5fcdb51ae\" width=\"15\">\u7f16\u8f91<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u70b9\u51fb\u6253\u5f00\u5c31\u53ef\u4ee5\u4e86\uff0c\u63a7\u5236\u53f0\u663e\u793a\u662f\u8fd9\u6837\u7684\uff0c\u5982\u679c\u6587\u4ef6\u6bd4\u8f83\u591a\u7684\u8bdd\u9700\u8981\u7b49\u4e00\u6bb5\u65f6\u95f4\uff0c\u8fd9\u6bb5\u65f6\u95f4\u54b1\u4eec\u5c31\u53ef\u4ee5\u5b89\u6392\u522b\u7684\u4e8b\u60c5\u4e86\uff0c\u76f8\u5bf9\u624b\u5de5\u6765\u8bf4\u8fd9\u5f88\u65b9\u4fbf\u4e86\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/93924449acce962095f2ec2444263650.png\">\u200b<img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:http:\/\/fanaticboy.com\/bf3a674b-320e-4dbe-8377-b6f39180f904\" width=\"15\">\u7f16\u8f91<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u770b\u770b\u6210\u679c\u5427<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/745469e5a95621a729d4eee771c83835.png\">\u200b<img loading=\"lazy\" decoding=\"async\" height=\"15\" src=\"blob:http:\/\/fanaticboy.com\/050297ab-1e32-4f38-a14d-5e5db03bb6f4\" width=\"15\">\u7f16\u8f91<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\u5c31\u662f\u5168\u90e8\u5185\u5bb9\u5566 \u200b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u200b &nbsp;\u4e0a\u4e00\u7bc7\u8bb2\u4e86tkinter\u5173\u4e8e\u6587\u4ef6\u7684\u64cd\u4f5c\u662f\u6279\u91cf\u4fee\u6539\u6587\u4ef6\u7684\u540e\u7f00\u540d\uff0c\u8fd9\u4e00\u7bc7\u8bf4\u4e00\u4e0b\u7ecf\u5e38\u7528\u5230\u7684\u64cd\u4f5c\uff0c\u5c31\u662f &#8230; <a title=\"python\u4e4btkinter\u8fdb\u9636-\u6279\u91cf\u5c06word\u683c\u5f0f\u8f6c\u5316\u6210pdf\u683c\u5f0f\" class=\"read-more\" href=\"https:\/\/fanaticboy.com\/?p=420\" aria-label=\"\u9605\u8bfb python\u4e4btkinter\u8fdb\u9636-\u6279\u91cf\u5c06word\u683c\u5f0f\u8f6c\u5316\u6210pdf\u683c\u5f0f\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,16],"tags":[],"class_list":["post-420","post","type-post","status-publish","format-standard","hentry","category-python","category-tkinter"],"_links":{"self":[{"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/posts\/420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=420"}],"version-history":[{"count":1,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/posts\/420\/revisions"}],"predecessor-version":[{"id":421,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=\/wp\/v2\/posts\/420\/revisions\/421"}],"wp:attachment":[{"href":"https:\/\/fanaticboy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fanaticboy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}