Will McGugan Profile picture
CEO / Founder of https://t.co/90g34bZPn7 Hyperborean Python expert, author, humanist, husband, sometimes wildlife photographer. He/him @willmcgugan@mastodon.social
Aromat Profile picture 1 subscribed
May 28, 2022 6 tweets 2 min read
Solved the out-by-one error we had with layout logic.

You can specify a height as a percentage, OR as a fraction. A percentage is natural, but you can't specify a third exactly. The hack of 33.333333333333% makes me cringe.

Here are three widgets with a height: 1fr This is a deceptively tricky class of problems.

Consider a terminal with two widgets with 50% height. The terminal has 11 lines, giving each widget a height of 5.5

But you can't have half a line in the terminal, so the height is rounded down. And you have a spare line.
May 27, 2022 39 tweets 23 min read
As promised, a thread of amazing folks working in Open Source. Like most people in FOSS they probably don't get the recognition they deserve.

If you like #Python and programming, I suggest you following everyone in this tread.

Doubles as #FF

Please RT for visibility.

🧵 Follow João S. O. Bueno @gwidion

João is building terminedia and rows

github.com/jsbueno/termin…
github.com/turicas/rows
May 14, 2022 18 tweets 3 min read
A while back I was struggling to manage async creep in Textual ("async creep" is the tendency for all methods to become async).

A *single method* in asyncio allowed me to reverse that decision, and prevent asyncio creep. #Python

🧵 First, the reason why I disliked asyncing all the things.

The "await" keyword is boilerplate. Its existence is mostly for the language and doesn't help the developer.
Apr 19, 2022 29 tweets 10 min read
I recently asked for folk to fill in a survey regarding terminal usage. Over 1000 of you responded!

Here are the results.

First up, how "old are you"

Really surprised that the peak was around 40-ish. And there is a fairly decent contingent over 60! Next, "what best describes your job".

This will be heavily influenced by the list I provided. Lots of web developers.

Also shows it is impossible to narrow job titles in tech, of which there are *many*.
Apr 16, 2022 4 tweets 2 min read
Been encoding videos for the new Textualize.io site. This video is going in the hero section. It's a teaser of Textual. I suspect we'll update this video from time to time when new features come online. It looks kinda cool playing within a perspective adjusted terminal!
Apr 2, 2022 8 tweets 1 min read
I think #Python's defaultdict's are overused (I include myself in that). Consider this for accumulating lists of things.

shopping = defaultdict(list)

shopping["fruit"].append("apple") Convenient, right?

But a typo can lead to confusing results:

print(shopping["fruiit"])

Returns an empty list. But that's not what you intended, and Python can't tell you there was an error.
Mar 25, 2022 11 tweets 2 min read
I'm a bit obsessive about naming things in code. To the point where I hesitate to implement something because I don't have the perfect name for it. My objects are simple nouns, my methods are verb if they act on the object, verb+noun if they act on another object, properties are always nouns.
Mar 24, 2022 4 tweets 2 min read
The next version of Rich will be able to export console output to SVG!

The attached image was produced this way (i.e. it is not a screenshot of any terminal).

It's as easy as:

console.export_svg("out.svg")

@nwkautomaniac Rich-CLI will inherit this feature. I'm imagining a --export-svg switch that outputs an SVG of anything you print with the `rich` command.

github.com/Textualize/ric…
Mar 24, 2022 12 tweets 2 min read
A conversation with @njr0 on #Python typing got me thinking.

Many people (plenty of experienced devs amongst them) don't like typing.

Why is that?

🧵 One reason, which I somewhat agree with, is Python type annotations are a wee bit verbose. If Python was ever "executable pseudocode" then type annotations break that. 🤷‍♂️
Mar 6, 2022 24 tweets 4 min read
My name is Will McGugan. 👋 I am the creator of Rich and Textual, and the founder and CEO of Textualize. At the end of last year I took a year off to work on my Open-source projects and develop an idea that I believe will allow the terminal to eat some of the browser’s lunch. Turns out this idea was compelling enough to attract some sweet sweet VC cash and I am now hiring a third Python developer to join the company.
Mar 4, 2022 4 tweets 1 min read
Well Textualize has a blog now.

It's Wordpress. I considered a static blog generator and my own blog software, but some times it easier just to get the debit card out. Up and running in ten minutes.

blog.textualize.io One day it will be a Textual app, but today is not that day.
Mar 4, 2022 7 tweets 3 min read
Rich will auto-highlight strings you print in the terminal. You can configure it to highlight anything you like, but the defaults are generally useful.

Let's look at a few.

It will highlight anything that looks like a tag: Image It will highlight IP addresses, IPv4 and IPv6 Image
Jan 4, 2022 7 tweets 2 min read
Seen some tweets about #Python lambdas recently.

There are alternatives to lambdas which are still one-liners but are faster and (arguably) simpler.

Let's look at a few.

<🧵> Let's say you want a quick function to upper class a string.

Here's the obvious lambda solution:

lambda s: s.upper()

But you can also do the following:

str.upper

Both define a callable that upper cases a string, but the latter is faster.
Jan 3, 2022 7 tweets 1 min read
I've recently reach an age where I need reading glasses, after a couple of years being pissed that food manufacturers were shrinking the size of nutrition labels.

Getting old sucks sometimes, but still better than the alternative. The condition is called presbyopia and it happens to *everyone* around the age of 45, as your cornea hardens and becomes less flexible.
Dec 23, 2021 13 tweets 3 min read
Working on a popular #Python library has taught me that I shouldn't assume everyone is a Python expert.

The Rich Table class has an add_row methods which collects positional args, so you can do add_row("foo", "bar") I've had a number of bug reports that there is no way to add a row from a list. The answer is to do add_row(*my_list) which the OP didn't know / forgot.
Sep 1, 2021 8 tweets 2 min read
I have some personal news which will have a big impact on the future of Rich and Textual.

In three weeks time I will have wrapped up work with my current client as I'm going to work full time on open source.

<🧵> For at least 3 months, possibly up to a year, working on open source will be my full-time gig. Mainly Textual and Rich, but there is plenty of opportunity for other projects.

Why am I doing this?