{"id":1286,"date":"2020-11-27T02:52:03","date_gmt":"2020-11-27T02:52:03","guid":{"rendered":"https:\/\/www.pythontutorial.net\/?page_id=1286"},"modified":"2025-04-03T08:28:56","modified_gmt":"2025-04-03T08:28:56","slug":"tkinter-pack","status":"publish","type":"page","link":"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-pack\/","title":{"rendered":"Tkinter Pack"},"content":{"rendered":"\r\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn about the Tkinter pack geometry manager and how to use it to arrange widgets on a window.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='introduction-to-the-tkinter-pack-geometry-manager'>Introduction to the Tkinter pack geometry manager <a href=\"#introduction-to-the-tkinter-pack-geometry-manager\" class=\"anchor\" id=\"introduction-to-the-tkinter-pack-geometry-manager\" title=\"Anchor for Introduction to the Tkinter pack geometry manager\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>Tkinter uses the geometry manager to arrange widgets on a window or <a href=\"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-frame\/\">frame<\/a>. Tkinter supports three geometry managers:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>pack<\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-grid\/\">grid<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-place\/\">place<\/a><\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>You use the pack geometry manager to arrange widgets in one direction, either vertically or horizontally.<\/p>\r\n\r\n\r\n\r\n<p>The pack geometry manager has many options:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Side<\/li>\r\n\r\n\r\n\r\n<li>Expand<\/li>\r\n\r\n\r\n\r\n<li>Fill<\/li>\r\n\r\n\r\n\r\n<li>ipadx, ipady<\/li>\r\n\r\n\r\n\r\n<li>padx, pady<\/li>\r\n\r\n\r\n\r\n<li>Anchor<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>Before diving into each option, you need to understand the <code>x<\/code> and <code>y<\/code> coordinates of the window:<\/p>\r\n\r\n\r\n<div class=\"wp-block-image\">\r\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"466\" height=\"356\" class=\"wp-image-4583\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/09\/tkinter-pack-coordinates.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/09\/tkinter-pack-coordinates.png 466w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/09\/tkinter-pack-coordinates-300x229.png 300w\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" \/><\/figure>\r\n<\/div>\r\n\r\n\r\n<p>The top left corner of the window is the origin with the coordinate <code>(0,0)<\/code>. The x-coordinate increments from left to right, and the y-coordinate increments from top to bottom.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='tkinter-pack-parameters'>Tkinter pack parameters <a href=\"#tkinter-pack-parameters\" class=\"anchor\" id=\"tkinter-pack-parameters\" title=\"Anchor for Tkinter pack parameters\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>We&#8217;ll create a simple program to illustrate how the pack geometry manager works:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Tkinter'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root,text=<span class=\"hljs-string\">'Pack Layout'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Demo'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack()\r\nlabel2.pack()\r\nlabel3.pack()\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>The program has a main window with three <code>Label<\/code> widgets with red, green, and blue background colors.<\/p>\r\n\r\n\r\n\r\n<p>To use the pack geometry manager, you call the <code>pack()<\/code> method of the widget. By default, the pack geometry manager places widgets in one direction vertically from top to bottom.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6807\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-top.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-top.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-top-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='side'>Side <a href=\"#side\" class=\"anchor\" id=\"side\" title=\"Anchor for Side\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>The <code>side<\/code> parameter determines the direction of the widgets in the layout. The <code>side<\/code> parameter has four options:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><code>'top'<\/code>: arrange widgets from top to bottom vertically.<\/li>\r\n\r\n\r\n\r\n<li><code>'bottom'<\/code>: arrange widgets from bottom to top vertically.<\/li>\r\n\r\n\r\n\r\n<li><code>'left'<\/code>: arrange widgets from left to right horizontally.<\/li>\r\n\r\n\r\n\r\n<li><code>'right'<\/code>: arrange widgets from right to left horizontally.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>The <code>side<\/code> defaults to <code>'top'<\/code>, arranging the widget vertically from top to bottom.<\/p>\r\n\r\n\r\n\r\n<p>In addition to the string constants, you can use the predefined constants provided by the Tkinter module:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><code>tk.TOP<\/code><\/li>\r\n\r\n\r\n\r\n<li><code>tk.BOTTOM<\/code><\/li>\r\n\r\n\r\n\r\n<li><code>tk.LEFT<\/code><\/li>\r\n\r\n\r\n\r\n<li><code>tk.RIGHT<\/code><\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>Note that <code>tk<\/code> is the alias of the <code>Tkinter<\/code> module.<\/p>\r\n\r\n\r\n\r\n<p>The following program explicitly sets the side to <code>'top'<\/code> that arranges the labels vertically from top to bottom:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Tkinter'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root,text=<span class=\"hljs-string\">'Pack Layout'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Demo'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack(side=tk.TOP)\r\nlabel2.pack(side=tk.TOP)\r\nlabel3.pack(side=tk.TOP)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>When you change the side to <code>tk.BOTTOM<\/code>, the pack arranges the labels from bottom to top vertically:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Tkinter'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root,text=<span class=\"hljs-string\">'Pack Layout'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Demo'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack(side=tk.BOTTOM)\r\nlabel2.pack(side=tk.BOTTOM)\r\nlabel3.pack(side=tk.BOTTOM)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6808\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-bottom.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-bottom.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-bottom-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>The side <code>tk.LEFT<\/code> arranges the labels from left to right:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6809\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-left.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-left.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-left-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>The side <code>tk.RIGHT<\/code> arranges the labels from right to left:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6810\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-right.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-right.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-right-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>The following program shows how to use the pack to create a simple form that includes a label, an entry, and a button:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n<span class=\"hljs-keyword\">from<\/span> tkinter <span class=\"hljs-keyword\">import<\/span> ttk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'300x200'<\/span>)\r\n\r\n\r\nname_label = ttk.Label(root, text=<span class=\"hljs-string\">\"Name:\"<\/span>)\r\nname_label.pack(side=tk.LEFT)\r\n\r\nname_entry = ttk.Entry(root)\r\nname_entry.pack(side=tk.LEFT)\r\n\r\n\r\nbutton = ttk.Button(root, text=<span class=\"hljs-string\">\"Submit\"<\/span>)\r\nbutton.pack(side=tk.LEFT)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"306\" height=\"236\" class=\"wp-image-7422\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-side-demo.png\" alt=\"tkinter pack side demo\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-side-demo.png 306w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-side-demo-300x231.png 300w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>In this example, we arrange three widgets horizontally from left to right.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='widget-spaces'>Widget spaces <a href=\"#widget-spaces\" class=\"anchor\" id=\"widget-spaces\" title=\"Anchor for Widget spaces\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>In Tkinter, there are two kinds of spaces:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>The space a widget <strong>can<\/strong> occupy<\/li>\r\n\r\n\r\n\r\n<li>The space a widget <strong>will<\/strong> occupy.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>By default, a widget takes only the\u00a0<strong>necessary space<\/strong> to display its content. However, it <strong>can<\/strong> occupy more space.<\/p>\r\n\r\n\r\n\r\n<p>For example, a Label widget <strong><em>will<\/em> <\/strong>be only as big as the text. The background color shows that each label has a different width because the length of its text is different.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='expand'>Expand <a href=\"#expand\" class=\"anchor\" id=\"expand\" title=\"Anchor for Expand\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>The <code>expand<\/code> determines whether the widget should expand to occupy any extra spaces allocated to the container.<\/p>\r\n\r\n\r\n\r\n<p>If the <code>expand<\/code> is set to <code>True<\/code>, the widget will expand. If it is set to <code>False<\/code>, the widget will take only the necessary space. The <code>expand<\/code> parameter defaults to <code>False<\/code>.<\/p>\r\n\r\n\r\n\r\n<p>The <code>expand<\/code> parameter is dependent on the <code>side<\/code> parameter.<\/p>\r\n\r\n\r\n\r\n<p>The following table illustrates the dependencies between the <code>side<\/code> and the <code>expand<\/code> parameters when it comes to the space of the widget.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table>\r\n<thead>\r\n<tr>\r\n<th>Side<\/th>\r\n<th>Expand<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>Top (or Bottom)<\/td>\r\n<td>The widget can be as <strong>wide<\/strong> as the container, the <code>expand<\/code> will determine the <strong>height<\/strong> of the widget.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>Left (or Right)<\/td>\r\n<td>The widget can be as <strong>high<\/strong> as the container, the <code>expand<\/code> will determine the <strong>width<\/strong> of the widget.<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>The following program places the <code>Label<\/code> widgets vertically from top to bottom and sets the expand parameter of the first Label widget to <code>True<\/code> and the other two <code>Label<\/code> widgets to <code>False<\/code>:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Tkinter'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root,text=<span class=\"hljs-string\">'Pack Layout'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Demo'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack(side=tk.TOP, expand=<span class=\"hljs-keyword\">True<\/span>)\r\nlabel2.pack(side=tk.TOP, expand=<span class=\"hljs-keyword\">False<\/span>)\r\nlabel3.pack(side=tk.TOP, expand=<span class=\"hljs-keyword\">False<\/span>)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Since we set the <code>expand<\/code> parameter of the first <code>Label<\/code> to <code>True<\/code>, it occupies the entirely vertical space and pushes the other two <code>Label<\/code> widgets down to the bottom:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6811\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-top-expand-true.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-top-expand-true.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-top-expand-true-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>The following program places the Label widgets horizontally from left to right and sets the expand parameter of the first Label widget to True and the other two Label widgets to False:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Tkinter'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root, text=<span class=\"hljs-string\">'Pack Layout'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Demo'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack(side=tk.LEFT, expand=<span class=\"hljs-keyword\">True<\/span>)\r\nlabel2.pack(side=tk.LEFT, expand=<span class=\"hljs-keyword\">False<\/span>)\r\nlabel3.pack(side=tk.LEFT, expand=<span class=\"hljs-keyword\">False<\/span>)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Since we set the <code>expand<\/code> parameter of the first <code>Label<\/code> to <code>True<\/code>, it occupies the entirely horizontal space and pushes the other two <code>Label<\/code> widgets to the right:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"603\" height=\"446\" class=\"wp-image-6812\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-left-expand-true.png\" alt=\"tkinter pack layout side left, expand true\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-left-expand-true.png 603w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-side-left-expand-true-300x222.png 300w\" sizes=\"auto, (max-width: 603px) 100vw, 603px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>If you set the expand parameter of the three Label widgets to <code>True<\/code>, they will take up even horizontal spaces:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Tkinter'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root,text=<span class=\"hljs-string\">'Pack Layout'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Demo'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack(side=tk.LEFT, expand=<span class=\"hljs-keyword\">True<\/span>)\r\nlabel2.pack(side=tk.LEFT, expand=<span class=\"hljs-keyword\">True<\/span>)\r\nlabel3.pack(side=tk.LEFT, expand=<span class=\"hljs-keyword\">True<\/span>)\r\n\r\nroot.mainloop()\r\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6813\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-even-horizontal-spaces.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-even-horizontal-spaces.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-even-horizontal-spaces-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>The following program illustrates how to use the expand option to expand the <code>Entry<\/code> widget:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n<span class=\"hljs-keyword\">from<\/span> tkinter <span class=\"hljs-keyword\">import<\/span> ttk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'300x200'<\/span>)\r\n\r\n\r\nname_label = ttk.Label(root, text=<span class=\"hljs-string\">\"Name:\"<\/span>)\r\nname_label.pack(side=tk.LEFT)\r\n\r\nname_entry = ttk.Entry(root)\r\nname_entry.pack(side=tk.LEFT, expand=True)\r\n\r\n\r\nbutton = ttk.Button(root, text=<span class=\"hljs-string\">\"Submit\"<\/span>)\r\nbutton.pack(side=tk.LEFT)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"306\" height=\"236\" class=\"wp-image-7423\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-expand.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-expand.png 306w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-expand-300x231.png 300w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/figure>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='fill'>Fill <a href=\"#fill\" class=\"anchor\" id=\"fill\" title=\"Anchor for Fill\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The fill determines if a widget will occupy the <strong>available space<\/strong>. It accepts the following values: &#8216;x&#8217;, &#8216;y&#8217;, &#8216;both&#8217;, and &#8216;none&#8217;. By default, the fill is &#8216;none&#8217;.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table>\r\n<thead>\r\n<tr>\r\n<th>fill<\/th>\r\n<th>Effect<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>&#8216;none&#8217;<\/td>\r\n<td>The widget will not expand to fill any extra space. It only takes up space that fits the content.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;x&#8217;<\/td>\r\n<td>The widget will expand horizontally to fill any extra space along the x-axis.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;y&#8217;<\/td>\r\n<td>The widget will expand vertically to fill any extra space along the y-axis.<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;both&#8217;<\/td>\r\n<td>The widget will expand both horizontally and vertically to fill any extra space in both directions.<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>The following program illustrates how the <code>fill<\/code> parameter works:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Tkinter'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root,text=<span class=\"hljs-string\">'Pack Layout'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Fill'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel4 = tk.Label(root, text=<span class=\"hljs-string\">'Demo'<\/span>,bg=<span class=\"hljs-string\">'purple'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack(side=tk.TOP, expand=<span class=\"hljs-keyword\">True<\/span>, fill=tk.X)\r\nlabel2.pack(side=tk.TOP, expand=<span class=\"hljs-keyword\">True<\/span>, fill=tk.Y)\r\nlabel3.pack(side=tk.TOP, expand=<span class=\"hljs-keyword\">True<\/span>, fill=tk.NONE)\r\nlabel4.pack(side=tk.TOP, expand=<span class=\"hljs-keyword\">True<\/span>, fill=tk.BOTH)\r\n\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6815\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-fill-demo.png\" alt=\"tkinter pack fill demo\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-fill-demo.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-fill-demo-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>In this example, we arrange the <code>Label<\/code> widgets vertically from top to bottom and set the <code>expand<\/code> option for them to <code>True<\/code>.<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>The first <code>Label<\/code> widget has the fill value of <code>tk.X<\/code>, allowing it to fill extra spaces along the x-axis.<\/li>\r\n\r\n\r\n\r\n<li>The second <code>Label<\/code> widget has the fill value of <code>tk.Y<\/code>, allowing it to fill extra spaces along the y-axis.<\/li>\r\n\r\n\r\n\r\n<li>The third <code>Label<\/code> widget has the fill value of <code>tk.NONE<\/code>, indicating that it does not expand to fill any extra space.<\/li>\r\n\r\n\r\n\r\n<li>The fourth <code>Label<\/code> widget has the fill value of <code>tk.BOTH<\/code>, enabling it to occupy any additional space in both horizontal and vertical directions.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>The following program shows how to use the fill option to force the Entry widget to take up all available spaces of the main window:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n<span class=\"hljs-keyword\">from<\/span> tkinter <span class=\"hljs-keyword\">import<\/span> ttk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'300x200'<\/span>)\r\n\r\n\r\nname_label = ttk.Label(root, text=<span class=\"hljs-string\">\"Name:\"<\/span>)\r\nname_label.pack(side=tk.LEFT)\r\n\r\nname_entry = ttk.Entry(root)\r\nname_entry.pack(side=tk.LEFT, expand=True, fill=tk.X)\r\n\r\n\r\nbutton = ttk.Button(root, text=<span class=\"hljs-string\">\"Submit\"<\/span>)\r\nbutton.pack(side=tk.LEFT)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"306\" height=\"236\" class=\"wp-image-7425\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-fill.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-fill.png 306w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-fill-300x231.png 300w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>If you maximize the main window, the <code>Entry<\/code> widget will take up all horizontal spaces.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='internal-paddings-ipadx-ipady'>Internal paddings: ipadx &amp; ipady <a href=\"#internal-paddings-ipadx-ipady\" class=\"anchor\" id=\"internal-paddings-ipadx-ipady\" title=\"Anchor for Internal paddings: ipadx &amp; ipady\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>The <code>ipadx<\/code> and <code>ipady<\/code> parameters create internal paddings for widgets:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><code>ipadx<\/code> creates padding left and right, or padding along the x-axis.<\/li>\r\n\r\n\r\n\r\n<li><code>ipady<\/code> creates padding top and bottom, or padding along the y-axis.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>For example, the following program uses <code>ipadx<\/code> and <code>ipady<\/code> parameters to set the internal paddings of each Label widget:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root,text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel4 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'purple'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack(side=tk.LEFT)\r\nlabel2.pack(side=tk.LEFT, ipadx=<span class=\"hljs-number\">40<\/span>)\r\nlabel3.pack(side=tk.LEFT, ipady=<span class=\"hljs-number\">40<\/span>)\r\nlabel4.pack(side=tk.LEFT, ipadx=<span class=\"hljs-number\">80<\/span>, ipady=<span class=\"hljs-number\">80<\/span>)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6816\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-ipadx-ipady.png\" alt=\"tkinter pack ipadx ipady\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-ipadx-ipady.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-ipadx-ipady-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='external-paddings-padx-and-pady'>External paddings: padx and pady <a href=\"#external-paddings-padx-and-pady\" class=\"anchor\" id=\"external-paddings-padx-and-pady\" title=\"Anchor for External paddings: padx and pady\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>The <code>padx<\/code> and <code>pady<\/code> parameters allow you to specify padding to be added horizontally and vertically, respectively:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><code>padx<\/code> &#8211; represents the horizontal padding that adds space to the left and right of the widget.<\/li>\r\n\r\n\r\n\r\n<li><code>pady<\/code> &#8211; represents the vertical padding that adds space above or below the widget.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>The following example illustrates how to use the pady:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel4 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'purple'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack(side=tk.TOP, fill=tk.X, pady=<span class=\"hljs-number\">10<\/span>)\r\nlabel2.pack(side=tk.TOP, fill=tk.X, pady=<span class=\"hljs-number\">20<\/span>)\r\nlabel3.pack(side=tk.TOP, fill=tk.X ,pady=<span class=\"hljs-number\">40<\/span>)\r\nlabel4.pack(side=tk.TOP, fill=tk.X, pady=<span class=\"hljs-number\">60<\/span>)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6817\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-pady.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-pady.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-pady-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>The following program illustrates how to use the padx:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'600x400'<\/span>)\r\n\r\nlabel1 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'red'<\/span>,fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel2 = tk.Label(root,text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'green'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel3 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'blue'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\nlabel4 = tk.Label(root, text=<span class=\"hljs-string\">'Pack'<\/span>,bg=<span class=\"hljs-string\">'purple'<\/span>, fg=<span class=\"hljs-string\">'white'<\/span>)\r\n\r\nlabel1.pack(side=tk.LEFT, fill=tk.X, padx=<span class=\"hljs-number\">10<\/span>)\r\nlabel2.pack(side=tk.LEFT, fill=tk.X, padx=<span class=\"hljs-number\">20<\/span>)\r\nlabel3.pack(side=tk.LEFT, fill=tk.X ,padx=<span class=\"hljs-number\">40<\/span>)\r\nlabel4.pack(side=tk.LEFT, fill=tk.X, padx=<span class=\"hljs-number\">60<\/span>)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"446\" class=\"wp-image-6818\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-padx.png\" alt=\"tkinter pack padx\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-padx.png 602w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2023\/11\/tkinter-pack-padx-300x222.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>For example, you can use padx and pady to create horizontal and vertical paddings between widgets:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n<span class=\"hljs-keyword\">from<\/span> tkinter <span class=\"hljs-keyword\">import<\/span> ttk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Tkinter Pack Layout'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">'300x200'<\/span>)\r\n\r\n\r\nname_label = ttk.Label(root, text=<span class=\"hljs-string\">\"Name:\"<\/span>)\r\nname_label.pack(side=tk.LEFT, padx=<span class=\"hljs-number\">5<\/span>)\r\n\r\nname_entry = ttk.Entry(root)\r\nname_entry.pack(side=tk.LEFT, expand=True, fill=tk.X, padx=<span class=\"hljs-number\">5<\/span>)\r\n\r\n\r\nbutton = ttk.Button(root, text=<span class=\"hljs-string\">\"Submit\"<\/span>)\r\nbutton.pack(side=tk.LEFT, padx=<span class=\"hljs-number\">5<\/span>)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"306\" height=\"236\" class=\"wp-image-7426\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-padx.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-padx.png 306w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-padx-300x231.png 300w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>In this example, we set the horizontal padding between the label, entry, and button widget using the <code>padx<\/code> option.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='anchor'>Anchor <a href=\"#anchor\" class=\"anchor\" id=\"anchor\" title=\"Anchor for Anchor\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>The <code>anchor<\/code> parameter allows you to anchor the widget to the edge of the allocated space. It accepts one of the following values:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table>\r\n<thead>\r\n<tr>\r\n<th>Sticky<\/th>\r\n<th>Description<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>&#8216;n&#8217;<\/td>\r\n<td>North or Top Center<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;s&#8217;<\/td>\r\n<td>South or Bottom Center<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;e&#8217;<\/td>\r\n<td>East or Right Center<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;w&#8217;<\/td>\r\n<td>West or Left Center<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;nw&#8217;<\/td>\r\n<td>North West or Top Left<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;ne&#8217;<\/td>\r\n<td>North East or Top Right<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;se&#8217;<\/td>\r\n<td>South East or Bottom Right<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;sw&#8217;<\/td>\r\n<td>South West or Bottom Left<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&#8216;center&#8217;<\/td>\r\n<td>Center<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>The following picture illustrates the anchor options:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"411\" height=\"241\" class=\"wp-image-4614\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/09\/tkinter-pack-anchor-illustration.png\" alt=\"tkinter pack anchor illustration\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/09\/tkinter-pack-anchor-illustration.png 411w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/09\/tkinter-pack-anchor-illustration-300x176.png 300w\" sizes=\"auto, (max-width: 411px) 100vw, 411px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>For example, the following program shows widgets that use <code>E<\/code> and <code>W<\/code> anchors:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">import tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Pack Demo'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">\"350x200\"<\/span>)\r\n\r\n<span class=\"hljs-comment\"># box 1<\/span>\r\nbox1 = tk.Label(root, text=<span class=\"hljs-string\">\"Box 1\"<\/span>, bg=<span class=\"hljs-string\">\"green\"<\/span>, fg=<span class=\"hljs-string\">\"white\"<\/span>)\r\nbox1.pack(ipadx=<span class=\"hljs-number\">20<\/span>, ipady=<span class=\"hljs-number\">20<\/span>, anchor=tk.E,  expand=<span class=\"hljs-keyword\">True<\/span>)\r\n\r\n<span class=\"hljs-comment\"># box 2<\/span>\r\nbox2 = tk.Label(root, text=<span class=\"hljs-string\">\"Box 2\"<\/span>, bg=<span class=\"hljs-string\">\"red\"<\/span>, fg=<span class=\"hljs-string\">\"white\"<\/span>)\r\nbox2.pack(ipadx=<span class=\"hljs-number\">20<\/span>, ipady=<span class=\"hljs-number\">20<\/span>, anchor=tk.W, expand=<span class=\"hljs-keyword\">True<\/span>)\r\n\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"352\" height=\"246\" class=\"wp-image-4599\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/09\/tkinter-pack-anchor-demo.png\" alt=\"\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/09\/tkinter-pack-anchor-demo.png 352w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2022\/09\/tkinter-pack-anchor-demo-300x210.png 300w\" sizes=\"auto, (max-width: 352px) 100vw, 352px\" \/><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='using-tkinter-pack-to-create-a-login-form'>Using Tkinter pack to create a login form <a href=\"#using-tkinter-pack-to-create-a-login-form\" class=\"anchor\" id=\"using-tkinter-pack-to-create-a-login-form\" title=\"Anchor for Using Tkinter pack to create a login form\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>The following example uses the pack() method to create a login form:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> tkinter <span class=\"hljs-keyword\">as<\/span> tk\r\n<span class=\"hljs-keyword\">from<\/span> tkinter <span class=\"hljs-keyword\">import<\/span> ttk\r\n\r\nroot = tk.Tk()\r\nroot.title(<span class=\"hljs-string\">'Login'<\/span>)\r\nroot.geometry(<span class=\"hljs-string\">\"320x200\"<\/span>)\r\n\r\n\r\nfields = {}\r\n\r\nfields&#91;<span class=\"hljs-string\">'username_label'<\/span>] = ttk.Label(root, text=<span class=\"hljs-string\">'Username:'<\/span>)\r\nfields&#91;<span class=\"hljs-string\">'username'<\/span>] = ttk.Entry(root)\r\n\r\nfields&#91;<span class=\"hljs-string\">'password_label'<\/span>] = ttk.Label(root, text=<span class=\"hljs-string\">'Password:'<\/span>)\r\nfields&#91;<span class=\"hljs-string\">'password'<\/span>] = ttk.Entry(root, show=<span class=\"hljs-string\">\"*\"<\/span>)\r\n\r\n\r\n<span class=\"hljs-keyword\">for<\/span> field <span class=\"hljs-keyword\">in<\/span> fields.values():\r\n    field.pack(anchor=tk.W, padx=<span class=\"hljs-number\">10<\/span>, pady=<span class=\"hljs-number\">5<\/span>, fill=tk.X)\r\n\r\nttk.Button(text=<span class=\"hljs-string\">'Login'<\/span>).pack(anchor=tk.W, padx=<span class=\"hljs-number\">10<\/span>, pady=<span class=\"hljs-number\">10<\/span>)\r\n\r\nroot.mainloop()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"326\" height=\"236\" class=\"wp-image-7427\" src=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-login-dialog.png\" alt=\"tkinter pack login dialog\" srcset=\"https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-login-dialog.png 326w, https:\/\/www.pythontutorial.net\/wp-content\/uploads\/2025\/04\/tkinter-pack-login-dialog-300x217.png 300w\" sizes=\"auto, (max-width: 326px) 100vw, 326px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>How it works.<\/p>\r\n\r\n\r\n\r\n<p>First, initialize a <a href=\"https:\/\/www.pythontutorial.net\/python-basics\/python-dictionary\/\">dictionary<\/a> to store the widgets:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">fields = {}<\/code><\/span><\/pre>\r\n\r\n\r\n<p>Second, create <code>Label<\/code> and <code>Entry<\/code> widgets:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">fields&#91;<span class=\"hljs-string\">'username_label'<\/span>] = ttk.Label(text=<span class=\"hljs-string\">'Username:'<\/span>)\r\nfields&#91;<span class=\"hljs-string\">'username'<\/span>] = ttk.Entry()\r\n\r\nfields&#91;<span class=\"hljs-string\">'password_label'<\/span>] = ttk.Label(text=<span class=\"hljs-string\">'Password:'<\/span>)\r\nfields&#91;<span class=\"hljs-string\">'password'<\/span>] = ttk.Entry(show=<span class=\"hljs-string\">\"*\"<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>Third, iterate through the widgets and pack them into the main window:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">for field in fields.values():\r\n    field.pack(anchor=tk.W, padx=10, pady=5, fill=tk.X)<\/code><\/span><\/pre>\r\n\r\n\r\n<p>Finally, add the login button:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">ttk.Button(text=<span class=\"hljs-string\">'Login'<\/span>).pack(anchor=tk.W, padx=<span class=\"hljs-number\">10<\/span>, pady=<span class=\"hljs-number\">5<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Use the Tkinter pack geometry manager to arrange widgets in one direction, either horizontally or vertically.<\/li>\r\n\r\n\r\n\r\n<li>Use the <code>side<\/code>, <code>expand<\/code>, and <code>fill<\/code>, <code>padx<\/code>, <code>pady<\/code>, <code>ipadx<\/code>, and <code>ipady<\/code> options of the pack geometry manager to control the layout of the widgets.<\/li>\r\n<\/ul>\r\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"1286\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-pack\/\"\n\t\t\t\tdata-post-title=\"Tkinter Pack\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"1286\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/tkinter\/tkinter-pack\/\"\n\t\t\t\tdata-post-title=\"Tkinter Pack\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\t\t\t<input type=\"button\" name=\"wth-submit\" class=\"wth-btn wth-btn-submit\" id=\"wth-submit\" \/>\n\t\t\t<input type=\"button\" class=\"wth-btn wth-btn-cancel\" value=\"Cancel\" \/>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn about the Tkinter pack geometry manager and how to use it to arrange widgets on a window.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1232,"menu_order":9,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1286","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/1286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/comments?post=1286"}],"version-history":[{"count":4,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/1286\/revisions"}],"predecessor-version":[{"id":7432,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/1286\/revisions\/7432"}],"up":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/1232"}],"wp:attachment":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/media?parent=1286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}