Feeds

EuroPython: EuroPython Society 2024 fellows

Planet Python - 8 hours 40 min ago

Hi everyone! A warm welcome to the newly elected EuroPython Society Fellows in the year 2024.

    • Laís Carvalho
    • Cyril Bitterich

EuroPython Society Fellows

EuroPython Society Fellows have contributed significantly towards our mission, the EuroPython conference and the Society as an organisation. They are eligible for a lifetime free attendance of the EuroPython conference and will be listed on our EuroPython Society Fellow Grant page in recognition of their work.‌

Laís has been volunteering with the EPS since 2020 and is currently serving as a board member for 2023–2024. Theofanis wrote in nominating her for the EuroPython Society fellowship.

Lais is the "superhero" of this year&aposs EuroPython Organization. She&aposs constantly trying to improve our processes, our way of operating, to push for diversity and inclusion, and to make things happen. Apart from that, she&aposs always passionate about the EuroPython Society Mission, actioning on community outreach, expanding EPS communication channels and helping, in action, EPS to support the local python communities. I have no doubt that with her key contribution, 2024 will be one of the most impactful years for the mission of EPS.

Cyril started volunteering for EuroPython since 2022, He started helping with Ops and Programme teams initially and his firefighting skills proved invaluable as he supported other teams and the general organisation, making him a de facto member of the 2024 core organisers team. Theofanis Petkos put it best in his email, nominating Cyril for the EuroPython Society fellowship

Cyril is one of the most dedicated volunteers I&aposve ever met. You&aposll argue with him, he&aposll care, you&aposll ask for his help. He will have input, he will review everything on time. Constantly trying to help, to include more people and always passionate about documenting all of our processes. Cyril is one of the people I&aposm very proud I have worked with and I&aposm sure with his contribution EPS will make a lot of steps forward.

The EuroPython Society Board would like to congratulate and thank all the above new Fellows for their tireless work towards our mission! If you want to send in your nomination, check out our Fellowship page and get in touch!

Many thanks,
EuroPython Society
https://www.europython-society.org/

Categories: FLOSS Project Planets

Aurelien Jarno: UEFI Unified Kernel Image for Debian Installer on riscv64

Planet Debian - 9 hours 41 min ago

On the riscv64 port, the default boot method is UEFI, with U-Boot typically used as the firmware. This approach aligns more closely with other architectures, which avoid developping riscv64 specific code. For advanced users, booting using U-Boot and extlinux is possible, thanks to the kernel being built with CONFIG_EFI_STUB=y.

The same applies to the Debian Installer, which is provided as ISO images in various sizes and formats like on other architectures. These images can be put on a USB drive or an SD-card and booted directly from U-Boot in UEFI mode. Some users prefer to use the netboot "image", which in practice consists of a Linux kernel, an initrd, plus a set of Device Tree Blob (DTB) files.

However, booting this in UEFI mode is not straightforward, unless you use a TFTP server, which is also not trivial. Less known to users, there is also a corresponding mini.iso image, which contains all the above plus a bootloader. This offers a simpler alternative for installation, but depending on your (vendor) U-Boot version this still requires to go through a media.

Systemd version 257-rc2 comes with a great new feature, the ability to include multiple DTB files in a single UKI (Unified Kernel Image) file, with systemd-stub automatically loading the appropriate one for the current hardware. A UKI file combines a UEFI boot stub program, a Linux kernel image, an optional initrd, and further resources in a single UEFI PE file. This finally solves the DTB problem in the UEFI world for distributions, as a single image can work on multiple boards.

Building upon this, debian-installer on riscv64 now also creates a UEFI UKI mini.efi image, which contains systemd-stub, a Linux kernel, an initrd, plus a set of Device Tree Blob (DTB) files. Using this image also ensures that the system is booted in UEFI mode. Booting it with debian-installer is as simple as:

load mmc 0:1 mini.efo $kernel_addr_r # (can also be done using tftpboot, wget, etc.) bootefi $kernel_addr_r

Additional parameters can be passed to the image using the U-Boot bootargs environment variable. For instance, to boot in rescue mode:

setenv bootargs "rescue/enable=true"
Categories: FLOSS Project Planets

October/November in KDE Itinerary

Planet KDE - 11 hours 22 min ago

In the two month since the previous summary KDE Itinerary got a new trip map view, per-trip statistics and better Android integration, and we have been preparing for Transious’ move to MOTIS v2, to just name a few things.

New Features Trip map

The move to a per-trip timeline view described in the previous issue enables a bunch of new per-trip features.

The first of those is a map view for all activities and locations related to a trip.

Trip map view in Itinerary.

Locations and intermediate stops are interactive and show additional information when clicked.

Trip statistics

Itinerary now also shows a summary of the traveled distance, the estimated CO₂ emission and the total cost for each trip. The cost is based on information extracted from travel documents or manual editing of individual entries, and is automatically converted into your home currency if currency conversions are enabled in the settings.

Trip statistics in Itinerary. Pre-defined locations for journey searches

All locations involved in the current trip are now added to the location search history for train or bus journey searches. They appear similarly to entries from past searches (but unlike those cannot be deleted).

This avoids having to enter locations again that you’ll likely need in public transport search during a trip.

New timeline layout

There’s ongoing work for an updated timeline layout, in particular for public transport journeys, making the effects of delays and disruptions easier to see. It’s not yet finished and integrated at the time of writing (but might very well be by the time of publishing this post), so this will be covered next time. In the meantime you’ll probably get to see pictures of it in one of the next “This Week in KDE Apps” posts on Planet KDE.

Infrastructure Work MOTIS v2

Transitous, the community-run free and open public transport routing services used by Itinerary, is preparing to move to the next major version of the routing engine MOTIS.

This meant implementing support for the new MOTIS API in KPublicTransport. The new API provides more control over access and egress modes and transfer times and returns more detailed information for foot paths (more details here).

Transfer foot path shown on a map.

MOTIS v2 brings considerable performance improvements for OSM-based routing which should make it viable for Transitous to deploy door-to-door routing rather than just the current stop-to-stop routing. That is also the prerequisite for enabling support for shared vehicle routing eventually.

Android platform integration

There have also been a number of improvements on Android platform integration, most of which not just benefit Itinerary but all KDE Android apps.

  • Fixed the translation lookup order when non-US English is used as one of multiple languages in the system settings.
  • Fixed deploying and loading of Qt’s own translation catalogs.
  • Implemented support for the 24h time format platform settings in locales that usually use a 12h format (CR 600295, available in Qt 6.8.1).
  • Enabled support for app-specific language selection in Android 13 or higher.
  • Foundational work on changing the application language at runtime in Qt and KDE Frameworks. For complete support this is still missing reevaluating locale API related expressions in QML (CR 599626).

There’s some more details in a dedicated post about this.

Matrix session verification

While trip synchronization over Matrix unfortunately didn’t get done after all in time for 24.12, there’s nevertheless progress here.

Most notable is support for Matrix session verification, which is a prerequisite for end-to-end encrypted (E2EE) communication.

Emoji-based Matrix session verification.

After a fix in libQuotient the trip syncing code can now also handle attached documents, using Matrix’ built-in E2EE file sharing.

Lobbying & Politics

Last week I attended a networking event hosted by DELFI together with a couple of others representing various FOSS and Open Data projects and communities. DELFI is the entity producing Germany’s national aggregate public transport datasets. Those are used by Transitous and thus indirectly by Itinerary, and getting in direct contact with the people working on this is obviously useful.

  • Most of what I heart was sensible and aligns with what we’d like to see as well, e.g. around quality gates for the datasets. One major exception was Deutsche Bahn’s refusal to allow DELFI to publish their realtime data. Coincidentally a new law mandating exactly that just had its first reading in the second chamber of the German parliament that day, so fortunately the pressure to publish this just keeps increasing.
  • Lacking a better “official” channel some of the DELFI teams actually use the community-provided Github issue repositories as feedback channels for data issues. That works, any channel to get fixes upstream is good.
  • The current realtime feed is supposed to cover about 70% of the static data and contain up to 22k concurrent trips according to DELFI, which is very far from what we actually see in Transitous currently. Where exactly that difference comes from isn’t fully understood yet though, but knowing the expectation and having people to talk to should help with resolving that.

This is the first time DELFI ran such an event also open to externals. Good to see some things slowly turning into the right direction after years of pushing by the community. There’s still much more to wish for of course, such as a deeper collaboration/integration between the stop registry and OSM.

Fixes & Improvements Travel document extractor
  • New or improved extractors for Agoda, Booking.com, Eurostar/Thalys, Flixbus, lu.ma, NH Hotels, NS, planway.com, Renfe, SBB, Thai state railway, Trenitalia and VietJet Air.
  • Support for automatic price extraction from Apple Wallet files that use the currencyCode field.

All of this has been made possible thanks to your travel document donations!

Public transport data
  • Unfortunately Navitia ended their service, so the corresponding backend has been removed. For most affected areas there are fortunately alternatives meanwhile, such as Transitous.
  • Added support for the NS onboard API.
  • Translated backend information are reloaded correctly now when the system language changes.
  • Implausible turns in railway paths found in German GTFS shapes or Hafas responses are now filtered out.
  • The journey query API now has support for indicating a required bike transport, for specifying direct transportation preferences and for returning rental vehicle booking deep links.
  • More Wikidata logo properties are considered for line logos now.
Itinerary app
  • Favorite locations used in a trip are now also part of a trip export.
  • Transfers can now be added in more cases.
  • Statistics also include transfers and live data where available, which should yield more accurate results.
  • Incremental import of multi-traveler reservations has been fixed.
  • The weather forecast on the entire day of departure and day of arrival is now included in the trip timeline.
  • Checking for updates and downloading map data are now per-trip rather than global actions.
  • Added a safety question before clearing the stop search history.
  • Enabled importing GIF images on Android.
  • Fixed importing DB return tickets via the online import.
  • Fixed barcode scanning when using Itinerary as a Flatpak.
  • Fixed display of canceled journeys.
  • Fixed initial Matrix account setup working without needing a restart of the app.
  • A fix for QtLocation map updates sometimes getting stuck until an application restart is still stuck in review (affects not just Itinerary).
How you can help

Feedback and travel document samples are very much welcome, as are all other forms of contributions. Feel free to join us in the KDE Itinerary Matrix channel.

Categories: FLOSS Project Planets

This Week in Plasma: Disable-able KWin Rules

Planet KDE - Fri, 2024-11-29 23:00

This week there was a flurry of UI polishing work and a nice new feature to go along with the usual background level of bug-fixing. Some of the changes are quite consequential, being minor pain points for years. So hopefully this should be a crowd-pleasing week! If that's the case, consider directing your pleased-ness at KDE's year-end fundraiser! As of the time of writing, we're at 98% of our goal, and it would be amazing to get to 100% by the end of November!

Notable New Features

It's now possible to temporarily disable KWin window rules rather than fully deleting them. (Ismael Asensio, 6.3.0. Link)

Notable UI Improvements

Discover no longer shows you a bunch of irrelevant information about Flatpak runtime packages. (Nate Graham, 6.2.4. Link)

The User Switcher widget now has a more sensible default height, fitting its content better. (Blazer Silving, 6.2.4. Link)

When you've disabled window thumbnails in the Task Manager widget, it now shows normal tooltips for open windows, rather than nothing at all. (Nate Graham, 6.3.0. Link)

Wireless headphones that expose battery information properly (as opposed to headsets, which include a microphone) now get a better icon in the Power and Battery widget and low battery notifications (Kai Uwe Broulik, 6.3.0. Link 1 and link 2)

KWin's Slide Back effect now has a duration that better matches the duration of other effects and animations, and responds more predictably and consistently to non-default global animation speed settings. (Blazer Silving, 6.3.0. Link)

On Ubuntu-based distros, the icon that appears in the System Tray alerting you to a major update available is now symbolic when using the Breeze icon theme, matching other such icons. (Nate Graham, Frameworks 6.9. Link)

Resizing windows for Qt-Quick-based apps should now look significantly better and smoother. (David Edmundson, Qt 6.9.0. Link)

Qt is now capable of displaying color emojis interspersed with black-and-white text when using the default font settings in Plasma. (Eskil Abrahamsen Blomfeldt, Qt 6.9.0. Link)

Notable Bug Fixes

Fixed a case where Plasma could crash when you dismiss a notification about network changes. (Nicolas Fella, 6.2.4. Link)

Fixed a case where KWin could crash after running out of file descriptors when using certain non-Intel GPU drivers. (Xaver Hugl, 6.2.5. Link)

System Settings no longer crashes when you plug in a mouse while viewing the Mouse page. (Nicolas Fella, 6.2.5. Link)

Fixed a strange issue that would cause notifications to be mis-positioned after the first time you dragged any widgets that were on the desktop. This turned out to have been caused by the Plasma config file having old crusty System Tray widgets in it left over from prior Plasma customizations, which were competing for control over the positions of notifications. Now they're cleaned up properly, which also reduces memory usage, removes a ton of cruft in the config file, and may resolve other mysterious and random-seeming issues with notifications being positioned incorrectly. (Marco Martin, 6.2.5. Link 1 and link 2)

Fixed a bug that could make panels in "Fit Content" mode sometimes be too small when Plasma loads. (Niccolò Venerandi, 6.3.0. Link)

Fixed one of the last remaining known bugs relating to desktop icons shifting around: this time due to always-visible panels loading after the desktop and sometimes pushing the icons away. Now that doesn't happen anymore! (Akseli Lahtinen, 6.3.0. Link)

Fixed a regression caused by a change elsewhere in the stack that interacted poorly with some questionable code on our side that caused the highlight effect on the tab bar in the expanded view for the active network in the Networks widget to be invisible. (Harald Sitter, 6.3.0. Link)

Fixed a regression introduced with Frameworks 6.7 that caused many pieces of selected text in Plasma and QtQuick-based apps to become inappropriately de-selected after right-clicking on them. (Akseli Lahtinen, Frameworks 6.9. Link)

Other bug information of note:

Notable in Performance & Technical

Made KWin more robust against apps that send faulty HDR metadata so that it is less likely to crash when encountering this condition. (Xaver Hugl, 6.2.5. Link)

Made Plasma more robust against faulty widgets; now it is more likely to communicate a comprehensible error message rather than crashing. (Nicolas Fella, 6.2.5. Link)

Made Plasma more robust against malformed .desktop files; now it similarly robust against more types of broken files. (Alexander Lohnau, 6.2.4. Link)

How You Can Help

KDE has become important in the world, and your time and contributions have helped us get there. As we grow, we need your support to keep KDE sustainable.

You can help KDE by becoming an active community member and getting involved somehow. Each contributor makes a huge difference in KDE — you are not a number or a cog in a machine!

You don’t have to be a programmer, either. Many other opportunities exist:

You can also help us by donating to our yearly fundraiser! Any monetary contribution — however small — will help us cover operational costs, salaries, travel expenses for contributors, and in general just keep KDE bringing Free Software to the world.

To get a new Plasma feature or a bugfix mentioned here, feel free to push a commit to the relevant merge request on invent.kde.org.

Categories: FLOSS Project Planets

Russell Coker: Links November 2024

Planet Debian - Fri, 2024-11-29 21:52

Interesting news about NVidia using RISC-V CPUs in all their GPUs [1]. Hopefully they will develop some fast RISC-V cores.

Interesting blog post about using an 8K TV as a monitor, I’m very tempted to do this [2].

Interesting post about how the Windows kernel development work can’t compete with Linux kernel development [3].

Paul T wrote an insightful article about the ideal of reducing complexity of computer systems and the question of from who’s perspective complexity will be reduced [4].

Interesting lecture at the seL4 symposium about the PANCAKE language for verified systems programming [5]. The idea that “if you are verifying your code types don’t help much” is interesting.

Interesting lecture from the seL4 summit about real world security, starts with the big picture and ends with seL4 specifics [6].

Interesting lecture from the seL4 summit about Cog’s work building a commercial virtualised phome [7]. He talks about not building a “brick of a smartphone that’s obsolete 6 months after release”, is he referring to the Librem5?

Informative document about how Qualcom prevents OSs from accessing EL2 on Snapdragon devices with a link to a work-around for devices shipped with Windows (not Android), this means that only Windows can use the hypervisor features of those CPUs [8].

Linus tech tips did a walk through of an Intel fab, I learned a few things about CPU manufacture [9].

Interesting information on the amount of engineering that can go into a single component. There’s lots of parts that are grossly overpriced (Dell and HP have plenty of examples in their catalogues) but generally aerospace doesn’t have much overpricing [10].

Interesting lecture about TEE on RISC-V with the seL4 kernel [11].

Ian Jackson wrote an informative blog post about the repeating issue of software licenses that aren’t free enough with Rust being the current iteration of this issue [12].

The quackery of Master Bates to allegedly remove the need for glasses is still going around [13].

Related posts:

  1. Links October 2024 Dacid Brin wrote an interesting article about AI ecosystems and...
  2. Links August 2024 Bruce Schneier and Kim Córdova wrote an insightful article about...
  3. Links September 2024 CNA Insider has an insightful documentary series about Chinese illegal...
Categories: FLOSS Project Planets

FSF Blogs: FSD meeting recap 2024-11-29

GNU Planet! - Fri, 2024-11-29 15:43
Check out the important work our volunteers accomplished at today's Free Software Directory (FSD) IRC meeting.
Categories: FLOSS Project Planets

FSD meeting recap 2024-11-29

FSF Blogs - Fri, 2024-11-29 15:43
Check out the important work our volunteers accomplished at today's Free Software Directory (FSD) IRC meeting.
Categories: FLOSS Project Planets

Dirk Eddelbuettel: RcppAPT 0.0.10: Maintenance

Planet Debian - Fri, 2024-11-29 15:19

A new version of the RcppAPT package arrived on CRAN earlier today. RcppAPT connects R to the C++ library behind the awesome apt, apt-get, apt-cache, … commands (and their cache) which powering Debian, Ubuntu and other derivative distributions.

RcppAPT allows you to query the (Debian or Ubuntu) package dependency graph at will, with build-dependencies (if you have deb-src entries), reverse dependencies, and all other goodies. See the vignette and examples for illustrations.

This release moves the C++ compilation standard from C++11 to C++17. I had removed the setting for C++11 last year as compilation ‘by compiler default’ worked well enough. But the version at CRAN still carried, which started to lead to build failures on Debian unstable so it was time for an update. And rather than implicitly relying on C++17 as selected by the last two R releases, we made it explicit. Otherwise a few of the regular package and repository updates have been made, but no new code or features were added The NEWS entries follow.

Changes in version 0.0.10 (2024-11-29)
  • Package maintenance updating continuous integration script versions as well as coverage link from README, and switching to Authors@R

  • C++ compilation standards updated to C++17 to comply with libapt-pkg

Courtesy of my CRANberries, there is also a diffstat report for this release. A bit more information about the package is available here as well as at the GitHub repo. If you like this or other open-source work I do, you can now sponsor me at GitHub.

This post by Dirk Eddelbuettel originated on his Thinking inside the box blog. Please report excessive re-aggregation in third-party for-profit settings.

Categories: FLOSS Project Planets

Anwesha Das: Keynote at PyLadiesCon!

Planet Python - Fri, 2024-11-29 12:35

Since the very inception of my journey in Python and PyLadies, I have always thought of having a PyLadies Conference, a celebration of PyLadies. There were conversations here and there, but nothing was fruitful then. In 2023, Mariatta, Cheuk, Maria Jose, and many more PyLadies volunteers around the globe made this dream come true, and we had our first ever PyLadiesCon.
I submitted a talk for the first-ever PyLadiesCon (how come I didn&apost?), and it was rejected. In 2024, I missed the CFP deadline. I was sad. Will I never be able to participate in PyLadiesCon?

On October 10th, 2024, I had my talk at PyCon NL. I woke up early to practice. I saw an email from PyLadiesCon, titled "Invitation to be a Keynote Speaker at PyLadiesCon". The panic call went to Kushal Das. "Check if there is any attack in the Python server? I got a spamming email about PyLadiesCon and the address is correct. "No, nothing.", replied Kushal after checking. Wait then "WHAT???". PyLadiesCon wants me to give the keynote. THE KEYNOTE in PyLadiesCon.

Thank you Audrey for conceptualizing and creating PyLadies, our home.

And here I am now. I will give the keynote on 7 December 2024 at PyLadiesCon on how PyLadies gave me purpose. See you all there.

Dreams do come true.

Categories: FLOSS Project Planets

The Drop Times: The Beginning and Growth of Splash Awards with Bert Boerland

Planet Drupal - Fri, 2024-11-29 09:03
The Splash Awards 2024 marks a decade of celebrating innovation and excellence in Drupal, putting the spotlight on agencies and users who push boundaries in the field. Bert Boerland, Chairman of the Drupal Netherlands Foundation, reflects on the journey from a bold idea in 2014 to a prestigious event that now inspires entries from around the globe. From overcoming challenges in jury selection to dreaming of a pan-European “Euro Splash Awards,” Bert shares insights and memorable moments from the awards’ evolution. Interview by Esmeralda Braad-Tijhoff.
Categories: FLOSS Project Planets

Real Python: The Real Python Podcast – Episode #230: marimo: Reactive Notebooks and Deployable Web Apps in Python

Planet Python - Fri, 2024-11-29 07:00

What are common issues with using notebooks for Python development? How do you know the current state, share reproducible results, or create interactive applications? This week on the show, we speak with Akshay Agrawal about the open-source reactive marimo notebook for Python.

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Web Review, Week 2024-48

Planet KDE - Fri, 2024-11-29 06:49

Let’s go for my web review for the week 2024-48.

Are Overemployed ‘Ghost Engineers’ Making Six Figures to Do Nothing?

Tags: tech, algorithm, productivity, business

Can you see this kind of models getting abused quickly? Clearly it says something about the tech industry wanting to reduce costs.

https://www.404media.co/are-overemployed-ghost-engineers-making-six-figures-to-do-nothing/


the tech utopia fantasy is over

Tags: tech, politics

Technology isn’t neutral. It’s impossible to ignore the ideologies of the moguls funding or leading big tech companies. We can’t afford to trust their promises.

https://blog.avas.space/tech-utopia-fantasy/


X’s Objection to the Onion Buying InfoWars Is a Reminder You Do Not Own Your Social Media Accounts

Tags: tech, social-media, twitter, law

Everything is in the title… if you thought you owned anything on those platforms, think twice.

https://www.404media.co/xs-objection-to-the-onion-buying-infowars-is-a-reminder-you-do-not-own-your-social-media-accounts/


OpenAI blamed NYT for tech problem erasing evidence of copyright abuse

Tags: tech, ai, machine-learning, gpt, law, copyright

More shady practices to try to save themselves. Let’s hope it won’t work.

https://arstechnica.com/tech-policy/2024/11/tech-problems-plague-openai-court-battles-judge-rejects-a-key-fair-use-defense/


‘Thirsty’ ChatGPT uses four times more water than previously thought

Tags: tech, ai, machine-learning, gpt, ecology, water

The water problem is obviously hard to ignore. This piece does a good job illustrating how large the impact is.

https://www.thetimes.com/uk/technology-uk/article/thirsty-chatgpt-uses-four-times-more-water-than-previously-thought-bc0pqswdr


Self-Hosting Isn’t a Solution; It’s A Patch

Tags: tech, self-hosting, privacy, gdpr, law, politics, decentralized

Definitely this. Sure we should seek for decentralization, but this is not going to happen or be effective without regulation. Ensuring privacy is a legislative and political problem as much as a technical one.

https://matduggan.com/self-hosting-isnt-a-solution-its-a-patch/


How decentralized is Bluesky really?

Tags: tech, social-media, fediverse, decentralized, bluesky

A long and comprehensive analysis of Bluesky. Also brings interesting critiques about both Bluesky and the Fediverse. Clearly Bluesky as of today is not effectively decentralized and shouldn’t be considered as such.

https://dustycloud.org/blog/how-decentralized-is-bluesky/


Reply on Bluesky and Decentralization

Tags: tech, social-media, bluesky, fediverse, decentralized

The debate about how BlueSky and decentralisation or federation continues. It’s nice to see how civilized the people involved are. This is how we can make progress.

https://whtwnd.com/bnewbold.net/3lbvbtqrg5t2t


So you want to write a KMail plugin?

Tags: tech, kde, documentation

Since the documentation is severely lacking in this area, this ends up being a nice how to. I wish we’d have more like this in the official documentation.

https://datagirl.xyz/posts/kontact_plugin_writing.html


The two factions of C++

Tags: tech, c++, safety, community

It’s clear that a split is forming in the C++ community on how to evolve the language. Could it lead to a full fledged divorce?

https://herecomesthemoon.net/2024/11/two-factions-of-cpp/#fnref:4


if constexpr requires requires { requires }

Tags: tech, c++, metaprogramming, type-systems

Are you confused with the use of requires in C++20? This post might help.

https://www.think-cell.com/en/career/devblog/if-constexpr-requires-requires-requires


Unsafe for work

Tags: tech, rust, safety

Good explanation of what Rust’s unsafe really does.

https://oida.dev/unsafe-for-work/


Mark–Scavenge: Waiting for Trash to Take Itself Out – Inside.java

Tags: tech, java, memory, garbage-collector

Looks like there is a new venue to improve garbage collectors performance. This should be interesting down the line.

https://inside.java/2024/11/22/mark-scavenge-gc/


SLAX: an alternative syntax for XSLT which is tailored for readability and familiarity

Tags: tech, xslt

Tempted to do some XSLT? Did you notice it’s almost 2025? So yeah, just don’t. At least there’s a proper alternative if you still need to process that XML input.

https://github.com/Juniper/libslax/wiki


Petnames: A humane approach to secure, decentralized naming

Tags: tech, security, dns

Interesting approach to have secure and decentralized naming while keeping it human readable.

https://files.spritely.institute/papers/petnames.html


Naming things

Tags: tech, programming, design, craftsmanship

This is a good point. Idiosyncrasies are not necessarily a bad thing for naming things. Natural languages are fickle friends, you might need to rely to specific metaphors in order to disambiguate.

https://wiki.dpk.land/Naming_things


Codin’ Dirty

Tags: tech, programming, complexity, design, tests

Another rebuttal of Clean Code. Most of it makes sense if not overdone. There’s the usual confusion around the “unit tests” term though, so take that section with a pinch of salt.

https://htmx.org/essays/codin-dirty/


Bye for now!

Categories: FLOSS Project Planets

Raju Devidas: Finding all sub domains of a main domain

Planet Debian - Fri, 2024-11-29 05:31

Problem: Need to know all the sub domains of a main domain, e.g. example.com has a sub domain dev.example.com , I also want to know other sub domains.

Solution:

Install the package called sublist3r, written by Ahmed Aboul-Ela

$ sudo apt install sublist3r

run the command

$ sublist3r -d example.com -o subdomains-example.com.txt ____ _ _ _ _ _____ / ___| _ _| |__ | (_)___| |_|___ / _ __ \___ \| | | | &apos_ \| | / __| __| |_ \| &apos__| ___) | |_| | |_) | | \__ \ |_ ___) | | |____/ \__,_|_.__/|_|_|___/\__|____/|_| # Coded By Ahmed Aboul-Ela - @aboul3la [-] Enumerating subdomains now for example.com [-] Searching now in Baidu.. [-] Searching now in Yahoo.. [-] Searching now in Google.. [-] Searching now in Bing.. [-] Searching now in Ask.. [-] Searching now in Netcraft.. [-] Searching now in DNSdumpster.. [-] Searching now in Virustotal.. [-] Searching now in ThreatCrowd.. [-] Searching now in SSL Certificates.. [-] Searching now in PassiveDNS.. Process DNSdumpster-8: Traceback (most recent call last): File "/usr/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/usr/lib/python3/dist-packages/sublist3r.py", line 269, in run domain_list = self.enumerate() ^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/sublist3r.py", line 649, in enumerate token = self.get_csrftoken(resp) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/sublist3r.py", line 644, in get_csrftoken token = csrf_regex.findall(resp)[0] ~~~~~~~~~~~~~~~~~~~~~~~~^^^ IndexError: list index out of range [!] Error: Google probably now is blocking our requests [~] Finished now the Google Enumeration ... [!] Error: Virustotal probably now is blocking our requests [-] Saving results to file: subdomains-example.com.txt [-] Total Unique Subdomains Found: 7 AS207960 Test Intermediate - example.com www.example.com dev.example.com m.example.com products.example.com support.example.com m.testexample.com

We can see the subdomains listed at the end of the command output.

enjoy, have fun, drink water!

Categories: FLOSS Project Planets

mark.ie: Introducing the New ChatGPT-Powered Drupal Answers Portal

Planet Drupal - Fri, 2024-11-29 05:07

Your Go-To Source for Drupal Answers, direct from trusted sources only.

Categories: FLOSS Project Planets

Bits from Debian: Debian welcomes its new Outreachy interns

Planet Debian - Fri, 2024-11-29 04:15

Debian continues participating in Outreachy, and we're excited to announce that Debian has selected two interns for the Outreachy December 2024 - March 2025 round.

Patrick Noblet Appiah will work on Automatic Indi-3rd-party driver update, mentored by Thorsten Alteholz.

Divine Attah-Ohiemi will work on Making the Debian main website more attractive by switching to HuGo as site generator, mentored by Carsten Schoenert, Subin Siby and Thomas Lange.

Congratulations and welcome Patrick Noblet Appiah and Divine Attah-Ohiemi!

From the official website: Outreachy provides three-month internships for people from groups traditionally underrepresented in tech. Interns work remotely with mentors from Free and Open Source Software (FOSS) communities on projects ranging from programming, user experience, documentation, illustration and graphical design, to data science.

The Outreachy programme is possible in Debian thanks to the efforts of Debian developers and contributors who dedicate their free time to mentor students and outreach tasks, and the Software Freedom Conservancy's administrative support, as well as the continued support of Debian's donors, who provide funding for the internships.

Join us and help extend Debian! You can follow the work of the Outreachy interns reading their blogs (they are syndicated in Planet Debian), and chat with us in the #debian-outreach IRC channel and mailing list.

Categories: FLOSS Project Planets

Bits from Debian: Debian welcomes its new Outreachy interns

Planet Debian - Fri, 2024-11-29 04:00

Debian continues participating in Outreachy, and we're excited to announce that Debian has selected two interns for the Outreachy December 2024 - March 2025 round.

Patrick Noblet Appiah will work on Automatic Indi-3rd-party driver update, mentored by Thorsten Alteholz.

Divine Attah-Ohiemi will work on Making the Debian main website more attractive by switching to HuGo as site generator, mentored by Carsten Schoenert, Subin Siby and Thomas Lange.

Congratulations and welcome Patrick Noblet Appiah and Divine Attah-Ohiemi!

From the official website: Outreachy provides three-month internships for people from groups traditionally underrepresented in tech. Interns work remotely with mentors from Free and Open Source Software (FOSS) communities on projects ranging from programming, user experience, documentation, illustration and graphical design, to data science.

The Outreachy programme is possible in Debian thanks to the efforts of Debian developers and contributors who dedicate their free time to mentor students and outreach tasks, and the Software Freedom Conservancy's administrative support, as well as the continued support of Debian's donors, who provide funding for the internships.

Join us and help extend Debian! You can follow the work of the Outreachy interns reading their blogs (they are syndicated in Planet Debian), and chat with us in the #debian-outreach IRC channel and mailing list.

Categories: FLOSS Project Planets

Kushal Das: Amnesty seminar on activism

Planet Python - Fri, 2024-11-29 02:35

2 Weeks ago I was down with fever, but as I became better after a few days I managed to attend Amnesty International's Stockholm chapter's event on activism. I had to travel to a different part of Stockholm, which was fun.

The day started with welcome talk and then a new "Palestine Activist Group" presented their work (in both English and Swedish). Then the main opening talk (in Swedish) from a very senior Swedish journalist about history and important dates related to Palestine. I managed to understand 50-60% of the words. Still a lot of learn.

During the break I had longer chats about privacy, data and our lives. It was good to find folks who knows/uses Python/Fedora/Debian/Ubuntu and other Open Source tools in their daily lives, sometimes even without knowing.

After the morning break, I attended a workshop about being an activist. It was filled with discussions, and of course a lot of new words in Swedish for me. But, the delivery of the workshop was good, people talked about what they think about being an individual activist and things to consider etc.

Next day I had a workshop for a selected group, about boycotting large services and how to providing least amount data to preserve our privacy. The group consisted people from various parts of Swedish society, people working in other government agencies and large multinational companies.

We talked about metadata and phones provide both metadata and real data to the various services via apps. Explaining people to imagine that every time they get out of home, there are many humans walking with them to every destination, keeping notes of every place visit, and every chats they are having with another person or about groups, and then later selling that information to other businesses. It is one thing to talk about these, but it is complete opposite to show. So, I showed them live how much our phones/computers talk. I had my old Pixel4a configured with GrapheneOS, and one of the participant connected their regular Pixel phone to the same VPN. And people seemed to be offended by seeing the amount of data flowing, even when the phone is not use. The below is a screenshot I took today morning from the same demo setup.

We also talked about various chatting platforms, I already built another system to teach kids about how various social chatting platforms work. It was a perfect tool for this demo. We discussed about various other technologies in our daily lives and how they affect privacy.

Categories: FLOSS Project Planets

Russ Allbery: Review: The Duke Who Didn't

Planet Debian - Fri, 2024-11-29 01:32

Review: The Duke Who Didn't, by Courtney Milan

Series: Wedgeford Trials #1 Publisher: Femtopress Copyright: September 2020 ASIN: B08G4QC3JC Format: Kindle Pages: 334

The Duke Who Didn't is a Victorian romance novel, the first of a loosely-connected trilogy in the romance sense of switching protagonists between books. It's self-published, but by Courtney Milan, so the quality of the editing and publishing is about as high as you will see for a self-published novel.

Chloe Fong has a goal: to make her father's sauce the success that it should be. His previous version of the recipe was stolen by White and Whistler and is now wildly popular as Pure English Sauce. His current version is much better. In a few days, tourists will come from all over England to the annual festival of the Wedgeford Trials, and this will be Chloe's opportunity to give the sauce a proper debut and marketing push. There is only the small matter of making enough sauce and coming up with a good name. Chloe is very busy and absolutely does not have time for nonsense. Particularly nonsense in the form of Jeremy Yu.

Jeremy started coming to the Wedgeford Trials at the age of twelve. He was obviously from money and society, obviously enough that the villagers gave him the nickname Posh Jim after his participation in the central game of the trials. Exactly how wealthy and exactly which society, however, is something that he never quite explained, at first because he was having too much fun and then because he felt he'd waited too long. The village of Wedgeford was thriving under the benevolent neglect of its absent duke and uncollected taxes, and no one who loved it had any desire for that to change. Including Jeremy, the absent duke in question.

Jeremy had been in love with Chloe for years, but the last time he came to the Trials, Chloe told him to stop pursuing her unless he could be serious. That was three years and three Trials ago, and Chloe was certain Jeremy had made his choice by his absence. But Jeremy never forgot her, and despite his utter failure to become a more serious person, he is determined to convince her that he is serious about her. And also determined to finally reveal his identity without breaking everything he loves about the village. Somehow.

I have mentioned in other reviews that I mostly read sapphic instead of heterosexual romance because the gender roles in heterosexual romance are much more likely to irritate me. It occurred to me that I was probably being unfair to the heterosexual romance genre, I hadn't read nearly widely enough to draw any real conclusions, and I needed to find better examples. I've followed Courtney Milan occasionally on social media (for reasons unrelated to her novels) for long enough to know that she was unlikely to go for gender essentialism, and I'd been meaning to try one of her books for a while. Hence this novel.

It is indeed not gender-essentialist. Neither Chloe nor Jeremy fit into obvious gender boxes. Chloe is the motivating force in the novel and many of their interactions were utterly charming. But, despite that, the gender roles still annoyed me in ways that are entirely not the fault of this book. I'm not sure I can even put a finger on something specific. It's a low-grade, pervasive feeling that men do one type of thing and women do a different type of thing, and even if these characters don't stick to that closely, it saturates the vibes. (Admittedly, a Victorian romance was probably not the best choice when I knew this was my biggest problem with genre heterosexual romance. It was just what I had on hand.)

The conceit of the Wedgeford Trials series is that the small village of Wedgeford in England, through historical accident, ended up with an unusually large number of residents with Chinese ancestry. This is what I would call a "believable outlier": there was not such a village so far as I know, but there could well have been. At the least, there were way more people with non-English ancestry, including east Asian ancestry, in Victorian England than modern readers might think. There is quite a lot in this novel about family history, cultural traditions, immigration, and colonialism that I'm wholly unqualified to comment on but that was fascinating to read about and seemed (as one would expect from Milan) adroitly written.

As for the rest of the story, The Duke Who Didn't is absolutely full of banter. If your idea of a good time with a romance novel is teasing, word play, mock irritation, and endless verbal fencing as a way to avoid directly confronting difficult topics, you will be in heaven. Jeremy is one of those people who is way too much in his own head and has turned his problems into a giant ball of anxiety, but who is good at being the class clown, and therefore leans heavily on banter and making people laugh (or blush) as a way of avoiding whatever he's anxious about. I thought the characterization was quite good, but I admit I still got a bit tired of it. 350 pages is a lot of banter, particularly when the characters have some serious communication problems they need to resolve, and to fully enjoy this book you have to have a lot of patience for Jeremy's near-pathological inability to be forthright with Chloe.

Chloe's most charming characteristic is that she makes lists, particularly to-do lists. Her ideal days proceed as an orderly process of crossing things off of lists, and her way to approach any problem is to make a list. This is a great hook, and extremely relatable, but if you're going to talk this much about her lists, I want to see the lists! Chloe is all about details; show me the details! This book does not contain anywhere close to enough of Chloe's lists. I'm not sure there was a single list in this book that the reader both got to see the details of and that made it to more than three items. I think Chloe would agree that it's pointless to talk about the concept of lists; one needs to commit oneself to making an actual list.

This book I would unquestioningly classify as romantic comedy (which given my utter lack of familiarity with romance subgenres probably means that it isn't). Jeremy's standard interaction style with anyone is self-deprecating humor, and Chloe is the sort of character who is extremely serious in ways that strike other people as funny. Towards the end of the book, there is a hilarious self-aware subversion of a major romance novel trope that even I caught, despite my general lack of familiarity with the genre. The eventual resolution of Jeremy's problem of hidden identity caught me by surprise in that way where I should have seen it all along, and was both beautifully handled and quite entertaining.

All the pieces are here for a great time, and I think a lot of people would love this book. Somehow, it still wasn't quite my thing; I thoroughly enjoyed parts of it, but I don't find myself eager to read another. I'm kind of annoyed at myself that it didn't pull me in, since if I'd liked this I know where to find lots more like it. But ah well.

If you like banter-heavy heterosexual romance that is very self-aware about its genre without devolving into metafiction, this is at least worth a try.

Followed in the romance series way by The Marquis Who Mustn't, but this is a complete story with a satisfying ending.

Rating: 7 out of 10

Categories: FLOSS Project Planets

Python GUIs: Building a Translation Application Using Tkinter — Translate Your Text With Python and Tkinter

Planet Python - Fri, 2024-11-29 01:00

Whether learning a new natural language or just browsing foreign websites, you sometimes come across text that you want to read but is written in a language you don't fully understand. To translate one natural language into your native language you can use a translator tool, like Google Translate.

In this tutorial, we'll build a desktop translator application to translate natural language using the Google Translate APIs. The UI will be built using the Tkinter GUI library from the Python standard library.

Table of Contents Demo: A Translator App with Tkinter

We'll work through the process of building the app step by step. Once we finish the tutorial, the app will look and work like the following:

You can select the source and destination languages. Then, you can paste or type some text in the left-hand area and hit the Translate button to get the translated text in the right-hand area.

Installing the Required Packages

Our Translator uses the googletrans library to perform the actual translation via Google. Tkinter is already available in the standard library, so we just need to install googletrans-py and a library called httpcore to deal with connection errors.

The first task will be to set up a Python virtual environment. Open the terminal, and run the following commands:

bat > mkdir translator > cd translator > python -m venv venv > .\venv\Scripts\activate > python -m pip install googletrans-py httpcore sh $ mkdir translator $ cd translator/ $ python -m venv venv $ source venv/bin/activate (venv) $ python -m pip install googletrans-py httpcore

Working through these instructions, first we create a root directory for the Translator app. Next we create and activate a Python virtual environment for the project. Finally, we install googletrans and httpcore packages.

Now, create a file named translator.py in the root of your project. Additionally, create a folder called images/ where you'll store the icons for the application. The folder structure should look like this:

python translator/ &boxv &boxvr&boxh&boxh images/ &boxv &boxvr&boxh&boxh arrow.png &boxv &boxur&boxh&boxh logo.png &boxv &boxur&boxh&boxh translator.py

The images for this project can be downloaded here.

The images/ folder contains the two icons that you'll use for the application. The translator.py is the app's source file.

Building the Window

Open the translator.py file with your favorite Python code editor. We'll start by creating our main window:

python import tkinter as tk class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) if __name__ == "__main__": app = TranslatorApp() app.mainloop()

This code imports Tkinter and then defines the application's main class, which we have called TranslatorApp. This class will hold the application's main window and allow us to run the main loop.

Importing tkinter under the alias tk is a common convention in Tkinter code.

Inside the class we define the __init__() method, which handles initialization of the class. In this method we first call the initializer __init__() of the parent class, tk.Tk, to initialize the app's window. Then, we set the window's title using the title() method. To make the window unresizable, we use the resizable() method with width and height set to False.

At the bottom of the code, we have the if __name__ == "__main__" idiom to check whether the file is being run directly as an executable program. Inside the condition block we first create an instance of TranslatorApp and then run the application's main loop or event loop.

If you run this code, you'll get an empty Tkinter window on your desktop:

python python translator.py

The empty Tkinter window

Creating the GUI

Now that the main window is set up, let's start adding widgets to build the GUI. To do this, we'll create a method called setup_ui(), as shown below:

python import tkinter as tk class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): frame = tk.Frame(self) frame.pack(padx=10, pady=10) if __name__ == "__main__": app = TranslatorApp() app.mainloop()

The setup_ui() method will define the application's GUI. In this method, we first create a frame widget using the tk.Frame class whose master argument is set to self (the application's main window). Next, we position the frame inside the main window using the pack() geometry manager, using padx and pady arguments to set some padding around the frame.

Finally, we add the call to self.setup_ui() to the __init__() method.

We'll continue to develop the UI by adding code to the setup_ui() method.

Net we'll add the app's logo. In the setup_ui() method add the following code below the frame definition:

python import tkinter as tk class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): frame = tk.Frame(self) frame.pack(padx=10, pady=10) self.logo = tk.PhotoImage(file="images/logo.png").subsample(5, 5) tk.Label(frame, image=self.logo).grid(row=0, column=0, sticky="w") if __name__ == "__main__": app = TranslatorApp() app.mainloop()

This code loads the logo using the tk.PhotoImage class. To resize it, we use the subsample() method. Then, we add the logo to the frame using a tk.Label widget. The label takes the frame and the logo as arguments. Finally, to position the logo, we use the grid() geometry manager with appropriate values for the row, column, and sticky arguments.

The sticky argument determines which side of a cell the widget should align -- North (top), South (bottom), East (right) or West (left). Here we're aligning it on the Wiest or left of the cell with "w":

Tkinter window with the Google Translate logo in it

Let's start adding some inputs to the UIs. First, we'll create the language selection drop-down boxes:

python import tkinter as tk import tkinter.ttk as ttk from googletrans import LANGUAGES DEFAULT_SOURCE = "English" DEFAULT_DEST = "Dutch" class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): frame = tk.Frame(self) frame.pack(padx=10, pady=10) self.logo = tk.PhotoImage(file="images/logo.png").subsample(5, 5) tk.Label(frame, image=self.logo).grid(row=0, column=0, sticky="w") # Source language combobox languages = [lang.title() for lang in LANGUAGES.values()] self.from_language = ttk.Combobox(frame, values=languages) self.from_language.current(languages.index(DEFAULT_SOURCE)) self.from_language.grid(row=1, column=0, sticky="we") # Arrow icon self.arrows = tk.PhotoImage(file="images/arrow.png").subsample(15, 15) tk.Label(frame, image=self.arrows).grid(row=1, column=1) # Destination language combobox self.to_language = ttk.Combobox(frame, values=languages) self.to_language.current(languages.index(DEFAULT_DEST)) self.to_language.grid(row=1, column=2, sticky="we") if __name__ == "__main__": app = TranslatorApp() app.mainloop()

We can get a list of languages from the googletrans module. We also define the default languages for when the application starts up, using constants DEFAULT_SOURCE and DEFAULT_DEST.

To build the language list for the combo boxes we take the LANGUAGES dictionary imported from googletrans and convert it into a list of strings called languages. We use a list comprehension to make all the names start with an uppercase letter, using title().

Next we create two combo boxes, to hold the list of source and destination langauges. The combo boxes are created using the ttk.Combobox class. One to the left and another to the right. Between the combo boxes, we've also added an arrow icon loaded using the tk.PhotoImage class. Again, we've added the icon to the app's window using ttk.Label.

Both combo boxes take frame and values as arguments. The values argument populates the combo boxes with languages. To specify the default language, we use the current() method, looking up the position of our default languages in the languages list with index().

To position the combo boxes inside the frame, we use the grid() geometry manager with the appropriate arguments. Run the application, and you will see the following window:

Source and destination languages

If you click on the sources combo box on the left, then you get the following:

Source language combo box

Similarly, if you click on the destination combo box on the right, you get the following:

Destination combo box

With the source and destination combo boxes in place, let's add three more widgets: two scrollable text widgets and a button. The scrollable text on the left will hold the source text, while the scrollable text on the right will hold the translated text. The button will allow us to run the actual translation.

Get back to the code editor and update the setup_ui() method as follows. Note that we also need to import the ScrollText class:

python import tkinter as tk import tkinter.ttk as ttk from tkinter.scrolledtext import ScrolledText from googletrans import LANGUAGES DEFAULT_SOURCE = "English" DEFAULT_DEST = "Dutch" class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): frame = tk.Frame(self) frame.pack(padx=10, pady=10) self.logo = tk.PhotoImage(file="images/logo.png").subsample(5, 5) tk.Label(frame, image=self.logo).grid(row=0, column=0, sticky="w") # Source language combobox languages = [lang.title() for lang in LANGUAGES.values()] self.from_language = ttk.Combobox(frame, values=languages) self.from_language.current(languages.index(DEFAULT_SOURCE)) self.from_language.grid(row=1, column=0, sticky="we") # Arrow icon self.arrows = tk.PhotoImage(file="images/arrow.png").subsample(15, 15) tk.Label(frame, image=self.arrows).grid(row=1, column=1) # Destination language combobox self.to_language = ttk.Combobox(frame, values=languages) self.to_language.current(languages.index(DEFAULT_DEST)) self.to_language.grid(row=1, column=2, sticky="we") # Source text self.from_text = ScrolledText( frame, font=("Dotum", 16), width=50, height=20, ) self.from_text.grid(row=2, column=0) # Translated text self.to_text = ScrolledText( frame, font=("Dotum", 16), width=50, height=20, state="disabled", ) self.to_text.grid(row=2, column=2) # Translate button self.translate_button = ttk.Button( frame, text="Translate", command=self.translate, ) self.translate_button.grid(row=3, column=0, columnspan=3, pady=10) def translate(self): pass if __name__ == "__main__": app = TranslatorApp() app.mainloop()

In the code snippet, we use the ScrolledText class to create the two scrolled text areas. Both text areas take frame, font, width, and height as arguments. The second text area also takes state as an additional argument. Setting state to "disabled" allows us to create a read-only text area.

Then, we use the ttk.Button class to create a button with frame, text, and command as arguments. The command argument allows us to bind the button's click event to the self.translate() method, which we will define in a moment. For now, we've added a placeholder.

To position all these widgets on the app's window, we use the grid() geometry manager. Now, the app will look like the following:

Translator app's GUI

Our translation app's GUI is ready! Finally, we can start adding functionality to the application.

Implementing the Translation Functionality

We'll implement the language translation functionality in the translate() method. This gets the current values from the UI and then uses googletrans to perform the translation. We need a few more imports, and to create the translator instance at the top of the application:

python import tkinter as tk import tkinter.ttk as ttk from tkinter.messagebox import showerror from tkinter.scrolledtext import ScrolledText import httpcore from googletrans import LANGUAGES, Translator DEFAULT_SOURCE = "English" DEFAULT_DEST = "Dutch" translator = Translator()

Here we've imported the showerror helper for displaying error boxes in our application. We've imported httpcore which we'll use to handle HTTP errors when accessing the API. Finally, we've added an import for the Translator class from googletrans. This is what handles the actual translation.

To use it, we create an instance of the class as translator.

We'll continue by implementing the translate method. Below we're just showing the function itself:

python class TranslatorApp(tk.Tk): # ... def translate(self): source_language = self.from_language.get() destination_language = self.to_language.get() text = self.from_text.get(1.0, tk.END).strip() if not source_language or not destination_language: showerror( title="Error", message="Make sure to set the source and destination language", ) return if not text: showerror( title="Error", message="Make sure to enter some text to translate", ) return try: translation = self.translator.translate( text, src=source_language, dest=destination_language, ) except httpcore.ConnectError: showerror( title="Error", message="Make sure you have an internet connection", ) return except Exception as e: showerror( title="Error", message=f"An unexpected error occurred: {e}", ) return self.to_text.config(state="normal") self.to_text.delete(1.0, tk.END) self.to_text.insert(tk.END, translation.text) self.to_text.config(state="disabled")

The translate() method handles the entire translation process. It starts by retrieving the source and destination languages from the corresponding combo boxes. If either language is not defined, then we display a message to inform the user about the problem. To do this, we use a showerror dialog.

Next, we try to get the input text from the source scrolled area on the left. If the user doesn't provide any text, then we display an error with the appropriate message.

Once we have the source and destination language and some text to translate, we can perform the actual translation. To run this task, we use the translate() method of the self.translator object, which is an instance of googletrans.Translator.

If the call to translate() finds a connection error, then we tell the user to check their internet connection. To handle any other exceptions, we catch the generic Exception class and display an error message with the exception details.

If the translation is successful, then we enable the destination scrolled area, display the translated text, and disable the area again so it remains read-only.

The complete final code is shown below:

python import tkinter as tk import tkinter.ttk as ttk from tkinter.messagebox import showerror from tkinter.scrolledtext import ScrolledText import httpcore from googletrans import LANGUAGES, Translator DEFAULT_SOURCE = "English" DEFAULT_DEST = "Dutch" translator = Translator() class TranslatorApp(tk.Tk): def __init__(self): super().__init__() self.title("Language Translator") self.resizable(width=False, height=False) self.setup_ui() def setup_ui(self): languages = [lang.title() for lang in LANGUAGES.values()] frame = tk.Frame(self) frame.pack(padx=10, pady=10) self.logo = tk.PhotoImage(file="images/logo.png").subsample(5, 5) tk.Label(frame, image=self.logo).grid(row=0, column=0, sticky="w") # Source language combobox self.from_language = ttk.Combobox(frame, values=languages) self.from_language.current(languages.index(DEFAULT_SOURCE)) self.from_language.grid(row=1, column=0, sticky="we") # Arrow icon self.arrows = tk.PhotoImage(file="images/arrow.png").subsample(15, 15) tk.Label(frame, image=self.arrows).grid(row=1, column=1) # Destination language combobox self.to_language = ttk.Combobox(frame, values=languages) self.to_language.current(languages.index(DEFAULT_DEST)) self.to_language.grid(row=1, column=2, sticky="we") # Source text self.from_text = ScrolledText( frame, font=("Dotum", 16), width=50, height=20, ) self.from_text.grid(row=2, column=0) # Translated text self.to_text = ScrolledText( frame, font=("Dotum", 16), width=50, height=20, state="disabled", ) self.to_text.grid(row=2, column=2) # Translate button self.translate_button = ttk.Button( frame, text="Translate", command=self.translate, ) self.translate_button.grid(row=3, column=0, columnspan=3, pady=10) def translate(self): source_language = self.from_language.get() destination_language = self.to_language.get() if not source_language or not destination_language: showerror( title="Error", message="Make sure to set the source and destination language", ) return text = self.from_text.get(1.0, tk.END).strip() if not text: showerror( title="Error", message="Make sure to enter some text to translate", ) return try: translation = translator.translate( text, src=source_language, dest=destination_language, ) except httpcore.ConnectError: showerror( title="Error", message="Make sure you have an internet connection", ) return except Exception as e: showerror( title="Error", message=f"An unexpected error occurred: {e}", ) return self.to_text.config(state="normal") self.to_text.delete(1.0, tk.END) self.to_text.insert(tk.END, translation.text) self.to_text.config(state="disabled") if __name__ == "__main__": app = TranslatorApp() app.mainloop() Using the Translator App

The video below demonstrates how we can use our app to translate some text from one natural language to another:

Great! You have successfully built a language translator using Python, Tkinter, and the googletrans package.

Conclusion

In this tutorial we built a Translator application using the Tkinter GUI library from the Python standard library. We worked step by step through building the UI using a grid layout, and then implemented the language translation functionality with googletrans.

Try and take what you've learnt in this tutorial & applying it to your own projects!

Categories: FLOSS Project Planets

Spyder IDE: The inside scoop on Spyder 6's new remote development platform

Planet Python - Thu, 2024-11-28 19:00
Spyder 6 includes a brand new remote development platform, building the foundations for enabling Spyder to easily leverage the power and data of remote desktops, servers, clusters and the cloud from anywhere! Hendrik Louzada, the lead developer behind this new backend, shares the details on how it all works, how he implemented it and his experiences doing so, and what's next for remote development in Spyder 6.1!
Categories: FLOSS Project Planets

Pages