{"id":2079,"date":"2019-06-01T06:18:02","date_gmt":"2019-06-01T04:18:02","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=2079"},"modified":"2019-06-01T06:19:43","modified_gmt":"2019-06-01T04:19:43","slug":"tkinter-canvas","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/tkinter-canvas\/","title":{"rendered":"Tkinter: Canvas"},"content":{"rendered":"<h1>Create a window with tkinter<\/h1>\n<p>This is the code to create a window:<\/p>\n<pre class=\"lang:default decode:true \">import tkinter as tk\r\n\r\nroot = tk.Tk()\r\n\r\nroot.mainloop()<\/pre>\n<h2>Add a title to the window<\/h2>\n<pre class=\"lang:default decode:true \">root.title(\"My App\")<\/pre>\n<h2>Dimensions<\/h2>\n<pre class=\"lang:default decode:true \">root.geometry(\"400x300+100+100\")<\/pre>\n<p>400&#215;300 = width and height<\/p>\n<p>+100+100 = x, y vertex of the window on the computer screen<\/p>\n<h1>Canvas<\/h1>\n<p>To add a canvas:<\/p>\n<pre class=\"lang:default decode:true \">canvas = tk.Canvas(root, width=800, height=400, bg='green')<\/pre>\n<p>The bg is the backgroind color.<\/p>\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/canvas3.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2080\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/canvas3.gif\" alt=\"\" width=\"320\" height=\"180\" \/><\/a><\/p>\n<p><iframe loading=\"lazy\" title=\"Python, tkinter: canvas 4, make a slide\" width=\"747\" height=\"420\" src=\"https:\/\/www.youtube.com\/embed\/qgGu1pBI1co?feature=oembed&amp;enablejsapi=1\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"Create a window with tkinter This is the code to create a window: import tkinter as tk root = tk.Tk() root.mainloop() Add a \n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/tkinter-canvas\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-2079","post","type-post","status-publish","format-standard","hentry","category-examples"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":false,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=2079"}],"version-history":[{"count":5,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2079\/revisions"}],"predecessor-version":[{"id":2085,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/2079\/revisions\/2085"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=2079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=2079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=2079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}