{"id":13780,"date":"2020-09-03T11:52:20","date_gmt":"2020-09-03T11:52:20","guid":{"rendered":"https:\/\/holypython.com\/?p=13780"},"modified":"2023-08-23T16:30:39","modified_gmt":"2023-08-23T16:30:39","slug":"creating-gui-programs-w-python-fast-easy-pysimplegui","status":"publish","type":"post","link":"https:\/\/holypython.com\/creating-gui-programs-w-python-fast-easy-pysimplegui\/","title":{"rendered":"Creating GUI Programs w\/ Python: Fast &#038; Easy (PySimpleGUI PART I)"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"13780\" class=\"elementor elementor-13780\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-acc69dc elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"acc69dc\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-b2556c8\" data-id=\"b2556c8\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-73ff535 elementor-widget elementor-widget-text-editor\" data-id=\"73ff535\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>If you&#8217;re looking to take your coding journey to next level, or if you&#8217;re specifically looking for a leap into GUI, jackpot! I will share with you the nicest, coolest, most practical GUI solution for Python.<\/p><p><b>I really think GUI adds a new dimension to the code and the coding as a learning journey.\u00a0<\/b><b>This can help you step up your programming in a way that it offers so many new benefits directly and indirectly!<\/b>:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-704dd08 elementor-widget elementor-widget-text-editor\" data-id=\"704dd08\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Holy Python is reader-supported. When you buy through links on our site, we may earn an affiliate commission.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-34cc8fa elementor-widget elementor-widget-text-editor\" data-id=\"34cc8fa\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ul><li>Your code doesn&#8217;t look like some weird output that&#8217;d only be used in Matrix triology.<\/li><li>You can have your program used via:<ul><li>radio buttons<\/li><li>checklists<\/li><li>menus<\/li><li>dropdown lists<\/li><li>value wheels<\/li><li>value bars etc.<\/li><\/ul><\/li><li>You can actually call your code a program<\/li><li>You can tap into a new source of imagination since things start getting visual<\/li><li>You can decide on the level of GUI (you don&#8217;t have to get super visual, it&#8217;s up to you and your program)<\/li><li>More opportunities to have your code used by a wide range of people from different backgrounds.<\/li><li>Pretty graphs<\/li><li>Games<\/li><li>Monetization of your code \/ program \/ software (You can actually create a product or service that can be marketed and sold)<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-5c01cbd\" data-id=\"5c01cbd\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-577ec89 elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"577ec89\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"far fa-clock\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tEstimated Time\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\t15 mins\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1b9b662 elementor-widget elementor-widget-raven-divider\" data-id=\"1b9b662\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-49a4d80 elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"49a4d80\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"far fa-thumbs-up\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tSkill Level\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\tIntermediate\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-997cb59 elementor-widget elementor-widget-raven-divider\" data-id=\"997cb59\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-921a548 elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"921a548\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"far fa-bookmark\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tImportant Parameters\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\t.Button, .Window<br>.Text, .T, .theme\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6e5a3cc elementor-widget elementor-widget-raven-divider\" data-id=\"6e5a3cc\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-086a05e elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"086a05e\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"fas fa-book\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tLibraries\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\tPySimpleGui\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cbb08f5 elementor-widget elementor-widget-raven-divider\" data-id=\"cbb08f5\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-e12be3b elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e12be3b\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-68872fd\" data-id=\"68872fd\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f0509cf elementor-widget elementor-widget-text-editor\" data-id=\"f0509cf\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>GUI is a huge step forward in anyone&#8217;s coding journey.<\/p><p>I think if we consider a cost\/benefit ratio for GUI methods where cost is the learning effort and time and benefit is the potential outcome opportunities, I must say ratio is very very high.<\/p><p>GUI adds a whole new dimension to coding that enables you to create buttons, menus, lists, checklists, messages, boxes, layout design etc. This obviously makes your code actually usable by a marginally larger demographics but I&#8217;d like to argue that benefits are even bigger than just other people being able to use your code.<\/p><p><b>When you start creating GUI applications, you might start to realize that you&#8217;re tapping into a new creativity resource with that visual experience. Albert Einstein says: Imagination is everything. GUI sort of boosts imagination and lets you get hand-onsy with code.<\/b><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-ccf2fb5 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"ccf2fb5\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-0cf9daa\" data-id=\"0cf9daa\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-61299d4 elementor-widget elementor-widget-text-editor\" data-id=\"61299d4\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Now historically, GUI also had limitations and there were also limited amount of libraries. This could make GUI learning curve pretty steep for Pythonistas.<\/p><p>This doesn&#8217;t have to be the case. In this article We&#8217;re going to share with you the most straight-forward, practical GUI technology that you can start implementing right away without losing your precious hair.<\/p><p>Let&#8217;s get started.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-370af17 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"370af17\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f126082\" data-id=\"f126082\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-87857dd elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"87857dd\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Simple GUI Example (<i>Getting Started<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-45fec2c elementor-widget elementor-widget-text-editor\" data-id=\"45fec2c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Let&#8217;s create a layout and a button in it. We&#8217;ll do this in 4 baby steps:<\/p><ul><li>We&#8217;re gonna import the necessary library<\/li><li>We&#8217;ll create a layout in list format with brackets: [ ]<\/li><li>We&#8217;ll use <code>sg.Button()<\/code> method and put it inside the layout.<\/li><li>Then we&#8217;ll create a <b>window <\/b>using <code>sg.Window() <\/code>which takes<ol><li>a title string<\/li><li>layout object<\/li><\/ol><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e905d04 elementor-widget elementor-widget-text-editor\" data-id=\"e905d04\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>1- Import the PySimpleGUI library:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f593e3c elementor-widget elementor-widget-text-editor\" data-id=\"f593e3c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>If you don&#8217;t have PySimpleGUI library you can simple install it by executing the following command in Anaconda Command Prompt (or Command Prompt):<\/p><p><code>pip install pysimplegui<\/code><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-064ff61 elementor-widget elementor-widget-html\" data-id=\"064ff61\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import PySimpleGUI as sg\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0223209 elementor-widget elementor-widget-text-editor\" data-id=\"0223209\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>2- Create a layout with a button in it.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-fa0d24b elementor-widget elementor-widget-html\" data-id=\"fa0d24b\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>layout = [[sg.Button('Hello World')]]<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-edb1b04 elementor-widget elementor-widget-text-editor\" data-id=\"edb1b04\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>3- Create the window with a title and the layout we created earlier:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d30bb7b elementor-widget elementor-widget-html\" data-id=\"d30bb7b\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>window = sg.Window('Push my Buttons', layout)\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-305787c elementor-widget elementor-widget-text-editor\" data-id=\"305787c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>4- Reading the window to make it show up:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-645023c elementor-widget elementor-widget-html\" data-id=\"645023c\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>event, values = window.read()<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4fa9dd5 elementor-widget elementor-widget-image\" data-id=\"4fa9dd5\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"121\" height=\"71\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui0.png\" class=\"attachment-full size-full wp-image-13811\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">First GUI Application<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-02c408e elementor-widget elementor-widget-text-editor\" data-id=\"02c408e\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>You&#8217;ll get a window like this. Now, we&#8217;ve already created the first GUI application. Let&#8217;s build up the tutorial for a few more interesting points.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-10ac864 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"10ac864\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-6066a62\" data-id=\"6066a62\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6c619a0 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"6c619a0\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">GUI Size Settings (<i>Layout Size, Button Size, Font Size etc.<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-891245e elementor-widget elementor-widget-text-editor\" data-id=\"891245e\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>You can simply add tuples of size parameters to both the <code>sg.Button<\/code> and <code>sg.Window<\/code>.<br \/>It works so: <code>size(width, height)<\/code><\/p><p>Here is the full code so far with a couple of size parameters added:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ceeaa8e elementor-widget elementor-widget-html\" data-id=\"ceeaa8e\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import PySimpleGUI as sg\r\nlayout  = [[sg.Button('Hello World', size=(20,4))]]\r\nwindow = sg.Window('Push my Buttons', layout, size=(200,150))\r\nevent, values = window.read()\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-069ecee elementor-widget elementor-widget-image\" data-id=\"069ecee\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"199\" height=\"179\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui1.png\" class=\"attachment-full size-full wp-image-13807\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">First GUI Application<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-441e282 elementor-widget elementor-widget-text-editor\" data-id=\"441e282\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Boom! Our GUI window is instantly starting to look better. But there are more cool tricks to check out.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1af2800 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1af2800\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-988f407\" data-id=\"988f407\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0ec08a2 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"0ec08a2\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">GUI Alignment Tricks (<i>Row Alignment, Column Alignment<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7aafe7f elementor-widget elementor-widget-text-editor\" data-id=\"7aafe7f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>You can simply add <code>sg.T<\/code> or <code>sg.Text<\/code> methods to add a text or add blank strings to move the buttons Left and Right:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-36d4dfa elementor-widget elementor-widget-html\" data-id=\"36d4dfa\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>layout = [[sg.Text(\"Primary Button: \"), sg.Button('Hello World',size=(20,4))]]\r\nwindow = sg.Window('Bunch of Buttons', layout, size=(270,100))\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4bc3e4b elementor-widget elementor-widget-image\" data-id=\"4bc3e4b\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"285\" height=\"147\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui2b.png\" class=\"attachment-full size-full wp-image-13820\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI Button Horizontal Alignment<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-58c8346 elementor-widget elementor-widget-text-editor\" data-id=\"58c8346\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>It looks like this.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-84edf2b elementor-widget elementor-widget-text-editor\" data-id=\"84edf2b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>So, here is the trick, inside the same bracket we&#8217;re altering the same row. Create new brackets and you&#8217;ll be creating new rows which can be used to alter column alignment. Let&#8217;s use <b>sg.T<\/b> this time and a string with blanks to create space above the button:<\/p><p>Note: Also pay attention to the windows size we&#8217;re changing that to create a more suitable window for the layout.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c734bb3 elementor-widget elementor-widget-html\" data-id=\"c734bb3\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>layout = [[sg.T(\"\")], [sg.Button('Hello World',size=(20,4))]]\r\nwindow = sg.Window('Push my Buttons', layout, size=(210,150))\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e3fa853 elementor-widget elementor-widget-image\" data-id=\"e3fa853\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"223\" height=\"193\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui2c.png\" class=\"attachment-full size-full wp-image-13821\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI Button Vertical Alignment<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cc05c4b elementor-widget elementor-widget-text-editor\" data-id=\"cc05c4b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Now it looks like this. Including the text inside a new bracket created a new row above the button.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-8f4a7b8 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"8f4a7b8\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-48fae5f\" data-id=\"48fae5f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-1882464 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"1882464\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Themes (<i>Prettify GUI real quick<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bf74a30 elementor-widget elementor-widget-text-editor\" data-id=\"bf74a30\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>PySimpleGUI has great color themes that you can apply to your program to make things a little more colorful (or sometimes less)<\/p><p>These theme colors are really well prepared and makes styling so much easier.<\/p><p>We will use <code>sg.theme()<\/code> method to implement various colors to the GUI window.<\/p><p>I find\u00a0<strong>reddit<\/strong> color scheme really sleek. Let&#8217;s take a look at that:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d2968b1 elementor-widget elementor-widget-html\" data-id=\"d2968b1\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import PySimpleGUI as sg\r\nsg.theme('Reddit')\r\nlayout = [[sg.Text(\"Primary Button: \"), sg.Button('Hello World',size=(20,4))]]\r\nwindow = sg.Window('Push my Buttons', layout, size=(270,100))\r\nevent, values = window.read()\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c4837e7 elementor-widget elementor-widget-image\" data-id=\"c4837e7\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"283\" height=\"143\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui3.png\" class=\"attachment-full size-full wp-image-13825\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI Reddit Theme<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a018812 elementor-widget elementor-widget-text-editor\" data-id=\"a018812\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><span style=\"color: var( --e-global-color-text ); font-family: var( --e-global-typography-text-font-family );\">Here is a look at LightYellow, DarkBlue15, Tan, DarkTeal2, Topango, LightBrown5.<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-0e4363b elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"0e4363b\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-33 elementor-inner-column elementor-element elementor-element-5270918\" data-id=\"5270918\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-717c7b9 elementor-widget elementor-widget-image\" data-id=\"717c7b9\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"285\" height=\"143\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui3b.png\" class=\"attachment-full size-full wp-image-13828\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI LightYellow Theme<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-33 elementor-inner-column elementor-element elementor-element-b448b4f\" data-id=\"b448b4f\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-4afa3b4 elementor-widget elementor-widget-image\" data-id=\"4afa3b4\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"283\" height=\"143\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui3c.png\" class=\"attachment-full size-full wp-image-13829\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI DarkBlue15 Theme<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-33 elementor-inner-column elementor-element elementor-element-2a39722\" data-id=\"2a39722\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2c1ea5c elementor-widget elementor-widget-image\" data-id=\"2c1ea5c\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"285\" height=\"145\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui3d.png\" class=\"attachment-full size-full wp-image-13830\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI Tan Theme<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-780f412 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"780f412\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-33 elementor-inner-column elementor-element elementor-element-5f2d3d2\" data-id=\"5f2d3d2\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d5f6b3e elementor-widget elementor-widget-image\" data-id=\"d5f6b3e\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"285\" height=\"145\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui3e.png\" class=\"attachment-full size-full wp-image-13832\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI DarkTeal2 Theme<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-33 elementor-inner-column elementor-element elementor-element-55d045b\" data-id=\"55d045b\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-64a07bc elementor-widget elementor-widget-image\" data-id=\"64a07bc\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"283\" height=\"145\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui3f.png\" class=\"attachment-full size-full wp-image-13833\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI Topango Theme<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-33 elementor-inner-column elementor-element elementor-element-fe971f9\" data-id=\"fe971f9\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-ea59a2e elementor-widget elementor-widget-image\" data-id=\"ea59a2e\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"283\" height=\"143\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui3g.png\" class=\"attachment-full size-full wp-image-13834\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI LightBrown5 Theme<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<div class=\"elementor-element elementor-element-b49dd3c elementor-widget elementor-widget-text-editor\" data-id=\"b49dd3c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><b>Here are some more ideas to check out:<\/b><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-00f53eb elementor-widget elementor-widget-text-editor\" data-id=\"00f53eb\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"text-align: center;\">Black<br \/>TealMono<br \/>TanBlue<br \/>LightGreen1<br \/>LightGreen2<br \/>LightGreen3<br \/>LightGreen4<br \/>DarkBlue15<br \/>Tan<br \/>SystemDefault<br \/>LightBlue5<br \/>LightBrown<\/p><p style=\"text-align: center;\">DarkPurple<br \/>DarkGreen<br \/>LightPurple<br \/>LightGrey<br \/>Green<br \/>Dark<br \/>BrownBlue<br \/>BrightColors<br \/>BlueMono<br \/>BluePurple<br \/>DarkRed<br \/>DarkBlack<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-8abad0a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"8abad0a\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9fdc83a\" data-id=\"9fdc83a\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-2cc8fa9 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"2cc8fa9\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">How to tie buttons to functions? (<i>Action time<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d1585d6 elementor-widget elementor-widget-text-editor\" data-id=\"d1585d6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Now, if you&#8217;re creating buttons you&#8217;ll likely want them to execute something. That&#8217;s the whole point right. We can simply create user defined functions or map Python&#8217;s builtin functions to the buttons we create with the PySimpleGUI library.<\/p><p>So, mapping buttons to functions is not that complicated. You just need some basic loop knowledge in Python.<br \/>Please feel free to these materials if you need to polish your <a href=\"https:\/\/holypython.com\/intermediate-python-lessons\/lesson-8-python-for-loop\/\">For Loop<\/a> and <a href=\"https:\/\/holypython.com\/intermediate-python-lessons\/lesson-9-while-loop\/\">While Loop<\/a> knowledge.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-70a536b elementor-widget elementor-widget-html\" data-id=\"70a536b\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>while True:\r\n    event, values = window.read()\r\n    if event == sg.WIN_CLOSED:\r\n        break\r\n    elif event == 'Hello World!':\r\n        print(\"Hello World!\")\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9ad8eb3 elementor-widget elementor-widget-text-editor\" data-id=\"9ad8eb3\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>So what&#8217;s going on in this code snippet?<\/p><ul><li>Firstly, everything is structured inside an infinite while loop. This way GUI interface is continuously monitored and executions are carried out when needed.<\/li><li>GUI windows is being monitored with <code>.read()<\/code> method. This means every time a button is pressed or a selection is made those values can be interpreted by the program.<\/li><li>if statement ensures that program is closed when close button is pressed. This is achieved by break statement. If you need a primer on that we have a great lesson focusing on <a href=\"https:\/\/holypython.com\/intermediate-python-lessons\/lesson-10-break-continue\/\">break statement<\/a> and its cousin <a href=\"https:\/\/holypython.com\/advanced-python-lessons\/lesson-3-try-except\/\">try\/except<\/a> statement can be useful as well.<\/li><li>elif statements manage each action that needs to be done <b>when event equals buttons name. <\/b>This is stated as:<br \/><code>elif event == \"Hello World!\":<\/code><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-be4a41e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"be4a41e\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-062e755\" data-id=\"062e755\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-ca7f5ab elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"ca7f5ab\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Closing Thoughts (<i>Conclusion<\/i>)<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f2ad69a elementor-widget elementor-widget-text-editor\" data-id=\"f2ad69a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>That&#8217;s about it. Now, regarding a GUI application you know how to create these:<\/p><ul><li>layout,<\/li><li>window,<\/li><li>buttons,<\/li><li>text(s),<\/li><\/ul><div>In addition you know how to:<\/div><ul><li>resize GUI window, button and text<\/li><li>align GUI objects vertically and horizontally<\/li><li>spice up the color scheme with PySimpleGUI themes<\/li><li>read from the GUI application<\/li><li>and map buttons to functions or various code.<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6b2bf64 elementor-widget elementor-widget-text-editor\" data-id=\"6b2bf64\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>You can apply this knowledge to create multiple buttons and text as well as other interesting object that&#8217;s usually included in software such as:<\/p><ul><li>sliders<\/li><li>radio buttons<\/li><li>checklist buttons<\/li><li><span style=\"color: var( --e-global-color-text );\">dropdown menus<\/span><\/li><li><span style=\"color: var( --e-global-color-text );\">forms etc.<\/span><\/li><\/ul><div>Here is a simple application with multiple buttons that prints a unique message on the console when each button is pressed.<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cd513c5 elementor-widget elementor-widget-image\" data-id=\"cd513c5\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"435\" height=\"295\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui4.png\" class=\"attachment-full size-full wp-image-13852\" alt=\"\" srcset=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui4.png 435w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/gui4-300x203.png 300w\" sizes=\"(max-width: 435px) 100vw, 435px\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">PySimpleGUI Topango Theme<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6a2d5eb elementor-widget elementor-widget-text-editor\" data-id=\"6a2d5eb\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>And here is the full code:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-13e84f8 elementor-widget elementor-widget-html\" data-id=\"13e84f8\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import PySimpleGUI as sg\r\nsg.theme('LightYellow')\r\n\r\nlayout  = [[sg.T(\"\")],[sg.Button('Hello World!',size=(20,4))],[sg.Text(\"  \")],\r\n[sg.Button('Winter Olympics 2022 (Beijing)'), sg.Button('Summer Olympics 2021 (Tokyo)')],[sg.Text(\" \")],\r\n[sg.Button('Fifa World Cup 2022 (Qatar)'), sg.T(\" \"*2),sg.Button('Tour de France')]]\r\n\r\nwindow = sg.Window('Bunch of Buttons', layout, size=(420,250))\r\nevent, values = window.read()\r\n\r\n##########Button Functions##########\r\nwhile True:             # Event Loop\r\n    event, values = window.read()\r\n    if event == sg.WIN_CLOSED:\r\n        break\r\n    elif event == 'Hello World!':\r\n        print(\"Hello World!\")      # call the \"Callback\" function\r\n    elif event == 'Winter Olympics 2022 (Beijing)':\r\n        print(\"Winter Olympics 2022 (Beijing)\")\r\n    elif event == 'Summer Olympics 2021 (Tokyo)':\r\n        print(\"Summer Olympics 2021 (Tokyo)\")\r\n    elif event == 'Tour de France':\r\n        print(\"Tour de France\")\r\n    elif event == 'Fifa World Cup 2022 (Qatar)':\r\n        print(\"Fifa World Cup 2022 (Qatar)\")\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1d66f24 elementor-widget elementor-widget-text-editor\" data-id=\"1d66f24\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>You can find this code in <a href=\"https:\/\/github.com\/holypython\/holypython\/blob\/master\/tutorials\/gui\/Simple GUI - Multiple Buttons\" target=\"_blank\" rel=\"noopener\" data-wplink-url-error=\"true\">HolyPython Github repository<\/a>.\u00a0<span style=\"color: var( --e-global-color-text );\">You can also find the official repository page of PySimpleGUI library\u00a0<\/span><a style=\"background-color: #ffffff;\" href=\"https:\/\/pypi.org\/project\/PySimpleGUI\/\" target=\"_blank\" rel=\"noopener\">here<\/a><span style=\"color: var( --e-global-color-text );\">.<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-faf27c3 elementor-widget elementor-widget-text-editor\" data-id=\"faf27c3\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>I&#8217;m so happy to create this tutorial because it can really help people from all backgrounds step up their programming skills and outcomes as a result of it. It also takes 5-10 minutes to learn and maybe a couple hours to master. Then you have a whole new skill-set to make use of your basic programming skills.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0f925b7 elementor-widget elementor-widget-text-editor\" data-id=\"0f925b7\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>This was a simple GUI tutorial for <b>Python <\/b>using\u00a0<span style=\"color: var( --e-global-color-text ); font-weight: bold;\">PySimpleGUI <\/span><span style=\"color: var( --e-global-color-text );\">library<\/span><span style=\"color: var( --e-global-color-text );\">.<\/span><\/p><p>You can also check out this <a href=\"https:\/\/holypython.com\/how-to-schedule-tasks-with-py-files-python-manual-automated\/\">tutorial about Task Scheduling with Python&#8217;s .py files<\/a> which goes hand in hand with GUI applications sometimes.<\/p><p>Please share this post if you found it useful. Thank you!<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re looking to take your coding journey to next level, or if you&#8217;re specifically looking for a leap into GUI, jackpot! I will share with you the nicest, coolest, most practical GUI solution for Python. I really think GUI adds a new dimension to the code and the coding as a learning journey.\u00a0This can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13849,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[60,52],"tags":[],"class_list":["post-13780","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gui","category-tutorials"],"acf":[],"_links":{"self":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts\/13780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/comments?post=13780"}],"version-history":[{"count":3,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts\/13780\/revisions"}],"predecessor-version":[{"id":31675,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts\/13780\/revisions\/31675"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/media\/13849"}],"wp:attachment":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/media?parent=13780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/categories?post=13780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/tags?post=13780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}