<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Corentin-zrt</title>
    <description>The latest articles on DEV Community by Corentin-zrt (@corentinzrt).</description>
    <link>https://dev.to/corentinzrt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F826231%2Fc9180c08-4dff-4102-a2e5-ef9cb1972ba1.jpeg</url>
      <title>DEV Community: Corentin-zrt</title>
      <link>https://dev.to/corentinzrt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/corentinzrt"/>
    <language>en</language>
    <item>
      <title>Build A Tkinter App (Part 2 / Widgets-2) - Python</title>
      <dc:creator>Corentin-zrt</dc:creator>
      <pubDate>Wed, 16 Mar 2022 13:29:14 +0000</pubDate>
      <link>https://dev.to/corentinzrt/build-a-tkinter-app-part-2-widgets-2-python-2hnk</link>
      <guid>https://dev.to/corentinzrt/build-a-tkinter-app-part-2-widgets-2-python-2hnk</guid>
      <description>&lt;p&gt;Today, we continue our course about create a tkinter application with Python. We are going to learn these 3 widgets : Input; Text; Canvas.&lt;/p&gt;

&lt;p&gt;So, if you don't have already see the others part of the course, let's watch this.&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;u&gt;Input:&lt;/u&gt;
&lt;/h1&gt;

&lt;p&gt;An input widget is a single line entry. We can create with like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;input_widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;input_widget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And like the Label and Button widgets, you can add the arguments about text : fg, bg, font, width, height. The width isn't in pixel in character.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;u&gt;Text:&lt;/u&gt;
&lt;/h1&gt;

&lt;p&gt;Now, a Text widget is an input but more wider then the Input because you can, like a notepad, write on multiple lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Same arguments for text, ect...&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;u&gt;Canvas:&lt;/u&gt;
&lt;/h1&gt;

&lt;p&gt;A Canvas is a surface where you can draw or place images.&lt;br&gt;
For an image :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;canv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Canvas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"white"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# width, height in pixels
&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;PhotoImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"image.png"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# Here we load an image
&lt;/span&gt;&lt;span class="n"&gt;canv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create_image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# 250 -&amp;gt; position x, 150 -&amp;gt; position Y
&lt;/span&gt;&lt;span class="n"&gt;canv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You must know that the 0;0 in a canvas isn't at the middle of it but in the left top corner.&lt;/p&gt;

&lt;p&gt;For a circle :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;canv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Canvas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"white"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;canv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create_circle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# (x0, y0, x1, y1)
&lt;/span&gt;&lt;span class="n"&gt;canv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T714BpiX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yhq7hh9fjuxcbenllcvv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T714BpiX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yhq7hh9fjuxcbenllcvv.png" alt="Image description" width="503" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more informations about figures that tkinter can support. Check this out : &lt;a href="http://tkinter.fdex.eu/doc/caw.html"&gt;http://tkinter.fdex.eu/doc/caw.html&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Now, you know the main widgets of Tkinter. In the next post, we'll see the bind method and the command argument in Button widget. And this course will be finish.&lt;br&gt;
So, have a nice day. And see you soon. Bye ! 👋👨‍💻&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Build A Tkinter App (Part 2 / Widgets-1) - Python</title>
      <dc:creator>Corentin-zrt</dc:creator>
      <pubDate>Thu, 10 Mar 2022 19:31:12 +0000</pubDate>
      <link>https://dev.to/corentinzrt/build-a-tkinter-app-part-2-widgets-1-python-d4g</link>
      <guid>https://dev.to/corentinzrt/build-a-tkinter-app-part-2-widgets-1-python-d4g</guid>
      <description>&lt;p&gt;Hey there ! Here is the second of &lt;a href="https://dev.to/corentinzrt/build-a-tkinter-app-part-1-python-8e3"&gt;this course&lt;/a&gt; on &lt;a href="https://docs.python.org/fr/3/library/tkinter.html"&gt;Tkinter&lt;/a&gt;. Today we are going to learn the different widgets that the module offers to us and how to display them on the screen.&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;u&gt;The syntax :&lt;/u&gt;
&lt;/h1&gt;

&lt;p&gt;So first, every widgets are made with the same syntax. You have to tell wich one you use by its name and give it few arguments. The main one is the app where your widget will be display. Example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_This is an example of a widget in tkinter :_
Widget(app)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are many different arguments for all widgets. Today we are going to learn 5 of these widgets :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Label&lt;/li&gt;
&lt;li&gt;Button&lt;/li&gt;
&lt;li&gt;Input&lt;/li&gt;
&lt;li&gt;Text&lt;/li&gt;
&lt;li&gt;Canvas&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  &lt;u&gt;How to display a Widget ?&lt;/u&gt;
&lt;/h1&gt;

&lt;p&gt;To display a widget on the screen we can use two different ways.&lt;br&gt;
We can use the &lt;code&gt;pack&lt;/code&gt; command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;my_widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Widget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myApp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;my_widget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# Display on screen
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or we can use the &lt;code&gt;grid&lt;/code&gt; method :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;my_widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Widget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myApp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;my_widget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# Display on screen
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference between these two methods is that the &lt;code&gt;grid&lt;/code&gt; acts like a grid WOW. You have to put a certain column and row like that :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;my_widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Widget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;myApp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;my_widget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# Display on screen at first column cell and first row cell
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pack method, put the widget in the center of the screen and below the others.&lt;br&gt;
Here are just a little of what these methods can do. So if you want more informations, go here : &lt;a href="http://tkinter.fdex.eu/doc/gp.html"&gt;http://tkinter.fdex.eu/doc/gp.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you know how to display something on the screen !&lt;/p&gt;
&lt;h1&gt;
  
  
  - &lt;u&gt;Label :&lt;/u&gt;
&lt;/h1&gt;

&lt;p&gt;The Label is just a widget that display a text. And to create one you have just to paste this code in your script : &lt;br&gt;
&lt;em&gt;PS : during the whole course, i'll use the script we used before...&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;tkinter&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Tk&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Our Application"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;geometry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"600x400"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# The Label Widget :
&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Label&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"My awesome Label !"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# We display it
&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mainloop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yes, it's not hard as you see... Surely there are many arguments that a Label can take. We have :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;bg : for the background ('name of the color')&lt;/li&gt;
&lt;li&gt;fg : the color of the text&lt;/li&gt;
&lt;li&gt;font : A tuple with the font and the size. Ex : ('Arial', 25)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;tkinter&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Tk&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Our Application"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;geometry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"600x400"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# The Label Widget :
&lt;/span&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Label&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"My awesome Label !"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'red'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Arial'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# We display it
&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mainloop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iqfSpY6i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jh0e2xe7r40ygn5dhmut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iqfSpY6i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jh0e2xe7r40ygn5dhmut.png" alt="Image description" width="606" height="435"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  - &lt;u&gt;Button :&lt;/u&gt;
&lt;/h1&gt;

&lt;p&gt;Now you have understand the logic of the widgets, you could know how to create a button right ? &lt;br&gt;
You just have to paste that under the label :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;btn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"My Button !"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'blue'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Arial'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# We display it
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FYl-RUZA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z0gaz7j1296lcugrlv4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FYl-RUZA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z0gaz7j1296lcugrlv4a.png" alt="Image description" width="606" height="437"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;As you see, the arguments seem to be the same. But there is one of these that will be interesting : the &lt;code&gt;command&lt;/code&gt;. But yeah, it's not for now because it enters in input section. So you'll see it in two posts because this one is already long. So I split it in two parts.&lt;/p&gt;

&lt;p&gt;In the next one, we'll see the others widgets. Don't worry !&lt;/p&gt;

&lt;p&gt;So it's time to say goobye ! 👋👨‍💻&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Build A Tkinter App (Part 1 / Basics) - Python</title>
      <dc:creator>Corentin-zrt</dc:creator>
      <pubDate>Tue, 08 Mar 2022 08:44:57 +0000</pubDate>
      <link>https://dev.to/corentinzrt/build-a-tkinter-app-part-1-python-8e3</link>
      <guid>https://dev.to/corentinzrt/build-a-tkinter-app-part-1-python-8e3</guid>
      <description>&lt;p&gt;Today we're going to use a usefull library in python to build awesome applications. We'll use : &lt;a href="https://docs.python.org/fr/3/library/tkinter.html"&gt;&lt;code&gt;Tkinter&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a2oq2pcC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://encrypted-tbn0.gstatic.com/images%3Fq%3Dtbn:ANd9GcSlPahCP6G8aYJFvBy8-KMzH9Zq6QlIFbBRKw%26usqp%3DCAU" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a2oq2pcC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://encrypted-tbn0.gstatic.com/images%3Fq%3Dtbn:ANd9GcSlPahCP6G8aYJFvBy8-KMzH9Zq6QlIFbBRKw%26usqp%3DCAU" alt="Image description" width="236" height="213"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this first part, we'll know how to create the base of our application. In a second part, we'll see the different widgets, this module propose to us and how to display them. And finally, in a third part, the inputs and actions.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;u&gt;The module : &lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;First Tkinter is a module that can create some GUI applications for all plateforms as Windows, Mac OS and Linux. If you have Python already installed on your computer, you have surely tkinter with it. If it's not you can run this command in the console :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install tkinter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;u&gt;The base of the app :&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;So, let's start with the script. Create a file with the &lt;code&gt;.py&lt;/code&gt; extension (PS : you can use &lt;code&gt;.pyw&lt;/code&gt; extension if you want to hide the console when the script is running).&lt;/p&gt;

&lt;p&gt;In this empty file, insert the import of Tkinter :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;tkinter&lt;/span&gt; &lt;span class="c1"&gt;# Basic import
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;tkinter&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="c1"&gt;# Import all propreties from tkinter module
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll use the second import because it's a better way to do.&lt;/p&gt;

&lt;p&gt;Now, we can create a variable that store the application :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Tk&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, we can asign some options to the app :&lt;/p&gt;

&lt;p&gt;1) A title : &lt;code&gt;app.title("Our Application")&lt;/code&gt;&lt;br&gt;
2) A size by default : &lt;code&gt;app.geometry("600x400")&lt;/code&gt; -&amp;gt; "widthxheight"&lt;/p&gt;

&lt;p&gt;And now, we can finally finish the programm by this line :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mainloop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Like that our app can run on the screen.&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;u&gt;Full script :&lt;/u&gt;
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;tkinter&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Tk&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Our Application"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;geometry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"600x400"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mainloop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;u&gt;Output :&lt;/u&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lylis4gY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjk4jpf45mwn0sqp2py1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lylis4gY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjk4jpf45mwn0sqp2py1.png" alt="Image description" width="604" height="433"&gt;&lt;/a&gt; &lt;br&gt;
Yeah, an exmpty screen... But it's a good start.&lt;/p&gt;




&lt;p&gt;As you see, create a desktop application with tkinter is very simple. In the next post, we'll see the different widgets we can add to our app and how to display them on the screen.&lt;/p&gt;

&lt;p&gt;If you have some questions on this first part, please write it in the comment section below.&lt;/p&gt;

&lt;p&gt;I hope this help you. And see you soon. Bye bye 👋👨‍💻&lt;/p&gt;

</description>
      <category>learn</category>
      <category>python</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Create IMG file by a url link - Python</title>
      <dc:creator>Corentin-zrt</dc:creator>
      <pubDate>Sun, 06 Mar 2022 20:05:28 +0000</pubDate>
      <link>https://dev.to/corentinzrt/create-img-file-by-a-link-python-458k</link>
      <guid>https://dev.to/corentinzrt/create-img-file-by-a-link-python-458k</guid>
      <description>&lt;p&gt;Hey ! In this post, I'll show you how to create an IMG file, like a png or jpg file, with a url link in Python. Even if it seems difficult, it isn't !&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;The import :&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;Yeah for sure, we must to import a package that will scrap informations from the img link you want. And this package is : &lt;strong&gt;&lt;em&gt;&lt;a href="https://docs.python-requests.org/en/latest/"&gt;requests&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dan1WXRq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o05iarsndpdyoote0su8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dan1WXRq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o05iarsndpdyoote0su8.png" alt="Image description" width="676" height="346"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;u&gt;So, let's go :&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;1) First open a new terminal and run the command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install requests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it's not already installed.&lt;/p&gt;

&lt;p&gt;2) Now create a new file, with the name you want and the &lt;code&gt;.py&lt;/code&gt;&lt;br&gt;
 extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;The script :&lt;/u&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"https://mywebsite.com/image.png"&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"myIMG.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"wb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;img_file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;img_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So as you see, the script is 5 lines long. It's nothing !&lt;/p&gt;

&lt;p&gt;First we import the package we installed before and the os package to open files.&lt;br&gt;
Then, we open the file &lt;code&gt;myIMG.jpg&lt;/code&gt; in &lt;u&gt;write byte&lt;/u&gt; mode, and store it in img_file variable. &lt;em&gt;The name and the extension of the img file can be modify for sure.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Inside the 'with', we make a request that get the content of the page from the url &lt;code&gt;https://mywebsite.com/image.png&lt;/code&gt;. And after that, we simply write the content of this request in the file with the write method.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Summary :&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;As you see, to scrap an image and 'download' it by a python script isn't difficult. You just need of a package and a file where you write the content of the image you scraped.&lt;/p&gt;

&lt;p&gt;If you want to know more about the requests package, check this out : &lt;u&gt;&lt;a href="https://docs.python-requests.org/en/latest/"&gt;https://docs.python-requests.org/en/latest/&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;So nice to see you ! And see you in the next post. Bye bye 👋👨‍💻&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Python CMD Progress Bars</title>
      <dc:creator>Corentin-zrt</dc:creator>
      <pubDate>Sun, 06 Mar 2022 16:04:12 +0000</pubDate>
      <link>https://dev.to/corentinzrt/python-cmd-progress-bars-2ac4</link>
      <guid>https://dev.to/corentinzrt/python-cmd-progress-bars-2ac4</guid>
      <description>&lt;p&gt;Python is one of the most used programming language in the world. Today we're going to create a progress bar in the CMD console.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Package installation&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;First of all, you just need to import, by pip, the package &lt;u&gt;&lt;a href="https://rich.readthedocs.io/en/stable/"&gt;rich&lt;/a&gt;&lt;/u&gt;. In your CMD, write this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install rich
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then the package will be installed on your computer. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;The script&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;After that, you can create a script with the name you want, follow by the &lt;code&gt;.py&lt;/code&gt; extension. And paste this in it :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;time&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;rich.progress&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Progress&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;Progress&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="n"&gt;task1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"[red]Downloading..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;task2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"[green]Processing..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;task3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_task&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"[cyan]Cooking..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;finished&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;advance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;advance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;advance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.02&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nevermind, I'll explain what it does.&lt;/p&gt;

&lt;p&gt;The first line just imports the time module. The second line imports the module rich and especially the class &lt;strong&gt;Progress&lt;/strong&gt;. The 'with' keyword means that we asign the class &lt;strong&gt;Progress()&lt;/strong&gt; to the variable &lt;strong&gt;progress&lt;/strong&gt; in the block below. &lt;br&gt;
The first three variables are tasks as it's written and there are two arguments to pass :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;u&gt;The name&lt;/u&gt; : it's a string value to describe what the progress bar does. We see &lt;u&gt;[ ]&lt;/u&gt; with colors : it's just to have a colored text on the screen.&lt;/li&gt;
&lt;li&gt;
&lt;u&gt;total&lt;/u&gt; : it's the value that the progress bar goes to. In the exemple, it goes from 0 to 100.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now there is a while loop and this will run until all the progess bars asigned before will be finished. Below this while, we have three instructions that increase task bars by a certain value each time (with the advance parameter).&lt;/p&gt;

&lt;p&gt;And then we stop the script during 0.02 seconds.&lt;/p&gt;

&lt;p&gt;In the console, you should have something like this :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OQpGYtNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n44l3x5v59tlnuqzqpxh.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OQpGYtNd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n44l3x5v59tlnuqzqpxh.PNG" alt="Image description" width="554" height="49"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Conclusion&lt;/u&gt;
&lt;/h2&gt;

&lt;p&gt;Just like this, you have created a simple progress bar using the &lt;u&gt;rich&lt;/u&gt; package in python. Don't forget to look at the documentation of rich at this link : &lt;u&gt;&lt;a href="https://rich.readthedocs.io/en/stable/"&gt;https://rich.readthedocs.io/en/stable/&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;See you in the next topic. Bye Bye coder friends... 👨‍💻&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
