<?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: Edvard Rejthar</title>
    <description>The latest articles on DEV Community by Edvard Rejthar (@e2rd).</description>
    <link>https://dev.to/e2rd</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%2F2407785%2Ff13affcc-4116-452d-a440-a495f06e0955.JPG</url>
      <title>DEV Community: Edvard Rejthar</title>
      <link>https://dev.to/e2rd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/e2rd"/>
    <language>en</language>
    <item>
      <title>Incredibly easy way to do a program</title>
      <dc:creator>Edvard Rejthar</dc:creator>
      <pubDate>Mon, 19 May 2025 15:15:36 +0000</pubDate>
      <link>https://dev.to/e2rd/incredibly-easy-way-to-do-a-program-4nad</link>
      <guid>https://dev.to/e2rd/incredibly-easy-way-to-do-a-program-4nad</guid>
      <description>&lt;p&gt;The hardest part of programming is interacting with the user. It’s often unnecessary and time-consuming. You can either use &lt;code&gt;input()&lt;/code&gt;, or you have to learn an entire framework. But which one should you choose? A GUI toolkit? What if your app also needs to run in the terminal?&lt;/p&gt;

&lt;p&gt;This package, Mininterface, saves you a lot of time. Just a single import turns any script into a real program — with a command-line interface, support for config files, and dialogs that work both as a desktop app and a terminal app, depending on where it’s run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/CZ-NIC/mininterface/" rel="noopener noreferrer"&gt;https://github.com/CZ-NIC/mininterface/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>I've created a library that adds GUI and TUI to your project</title>
      <dc:creator>Edvard Rejthar</dc:creator>
      <pubDate>Wed, 29 Jan 2025 17:00:24 +0000</pubDate>
      <link>https://dev.to/e2rd/ive-created-a-library-that-adds-gui-and-tui-to-your-project-3bbn</link>
      <guid>https://dev.to/e2rd/ive-created-a-library-that-adds-gui-and-tui-to-your-project-3bbn</guid>
      <description>&lt;p&gt;Single line of code – and you get GUI, TUI, CLI and config file parsing. It is frequently said Python comes with batteries included. But you may not yet heard about this battery cell. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/CZ-NIC/mininterface" rel="noopener noreferrer"&gt;https://github.com/CZ-NIC/mininterface&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;I have a lot of ideas. I’ve always been frustrated that even though something is simple to implement, I spend a lot of time designing the UI. When I want to use a utility on a remote computer, I need an interactive TUI. When using it locally, I want a GUI (since GUI is the only option for non-skilled users). But for advanced users, I needed a CLI so they could automate scripts.&lt;/p&gt;

&lt;p&gt;Years and years passed, and I kept researching whether something like this already existed. In May, I did a big study and compared 30 current libraries. No match. Finally, I've created the perfect program, which I’ve been using for all my projects for the past six months. It can save a lot of work for others as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hello world
&lt;/h2&gt;

&lt;p&gt;The thing is, you use a dataclass(es) to hold the program configuration. This is the only condition you have. Mininterface takes care of the rest. Forget about argparse.&lt;/p&gt;

&lt;p&gt;Take a look to this dataclass. You wrap it to the &lt;code&gt;run(Env)&lt;/code&gt; and that's all.&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="n"&gt;dataclasses&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;mininterface&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt;

&lt;span class="nd"&gt;@dataclass&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;my_str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;my_int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;form&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;my_int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 10
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you invoke the &lt;code&gt;m.form()&lt;/code&gt; method, a dialog is raised. In a graphical environment, it looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwqpy1anxxcj3hg4212b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwqpy1anxxcj3hg4212b.png" alt="GUI" width="255" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When there is no display available, we stick to the textual interface. Still fully interactive (you can even use the mouse).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F15y4wks0s6mens3ayvbm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F15y4wks0s6mens3ayvbm.png" alt="TUI" width="488" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every attribute is available through command line too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv7wfp97saboz2ttqjd8j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv7wfp97saboz2ttqjd8j.png" alt="CLI" width="646" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally, if a file named &lt;code&gt;program.yaml&lt;/code&gt; exists, all the values pick their default from there. Simple, isn't it?&lt;/p&gt;

&lt;h2&gt;
  
  
  Much more
&lt;/h2&gt;

&lt;p&gt;Since my initial impulse to write this library was frustration, you may find a lot of details that will eliminate your frustration as well.&lt;br&gt;
Nested configuration, choice handling (smooth!), validation, other useful dialog templates, image displaying (yes, even in the terminal)... In the past weeks, we've added a great calendar for date/time selection. Not just some corporate-style calendar that looks nice but is frustrating to use. This one is designed for real users. The arrow keys behave intelligently, and everything can be controlled entirely via the keyboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzxe4ywzagmuk21i2z51.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzxe4ywzagmuk21i2z51.png" alt="Calendar widget" width="518" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Take a look to the &lt;a href="https://cz-nic.github.io/mininterface/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;. I know from experience that if a code snippet doesn't work immediately, if a code snippet is but a stub, I tend to discard the whole project. That’s why I make sure that all code examples are self-contained and always include a screenshot, so it’s clear what each part of the program does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Thoughts
&lt;/h2&gt;

&lt;p&gt;The best part? You don’t have to keep reinventing the interface on your own.&lt;br&gt;
Annoyed by how images are displayed? Improve it once, and it will enhance not just your programs but also every project that uses mininterface. We can join forces.&lt;/p&gt;

&lt;p&gt;Even though I strive to keep the interface stable and highly intuitive, I’m open to changes and new features. What do you think, what's missing? What should look better? What's the biggest pain? What would persuade you to give it a chance?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/CZ-NIC/mininterface" rel="noopener noreferrer"&gt;https://github.com/CZ-NIC/mininterface&lt;/a&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>python</category>
      <category>ui</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
