Sunday, May 12, 2024

What's Brewing: A Sneak Peek into My Latest Project

Hey there, fellow tech enthusiasts! It's been a while since my last blog post, but that doesn't mean I've been idle. Quite the contrary – I've been hard at work on some exciting new projects, and I can't wait to share them with you.

One of the projects I've been pouring my heart and soul into is the Codeplug Wizard. For those unfamiliar, it's a software solution aimed at simplifying codeplug creation and editing for Anytone 878 and Quansheng radios. It's been quite the journey developing this tool, and I'm thrilled with the progress we've made so far.

While I'm not quite ready to unveil all the details just yet, I wanted to give you a sneak peek into what's to come. Behold, a screenshot from the Codeplug Wizard program:

As you can see, we're aiming for a clean and intuitive interface that makes radio configuration a breeze. But that's just the tip of the iceberg – there are plenty of exciting features packed into this software that I can't wait to share with you.

So, why the delay in posting about it? Well, as any developer knows, good things take time. I want to ensure that Codeplug Wizard is polished and ready for prime time before I officially unveil it to the world. But rest assured, it won't be long now – I'm hoping to share more about this project very soon.

In the meantime, stay tuned for updates and announcements and perhaps i will also post about some othet things going on. If you're curious about what else I've been up to, feel free to reach out – I always love hearing from fellow tech enthusiasts.

Until next time, happy coding!

Thursday, April 25, 2024

Exploring Different Methods to Display Images in Python - Part 1

When working with images in Python, there are various libraries and frameworks available, each with its own strengths and capabilities. In this series, we'll explore different methods to display images.
This first post is about using popular libraries such as Matplotlib, OpenCV, Pygame, Pillow (PIL), and Tkinter.

Ilustration for this blogpost created using NightCafe Studio.

**Note:** The scripts for each method are available on [GitHub](https://github.com/JanJeronimus/Python_Show_Image), and they have been tested on a Windows 10 machine.

1. Matplotlib

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. While its primary use is for plotting graphs and charts, it also provides functionalities for displaying images.

2. OpenCV

OpenCV (Open Source Computer Vision Library) is a powerful open-source computer vision and machine learning software library. It's widely used for real-time image processing and computer vision tasks.

3. Pygame

Pygame is a cross-platform set of Python modules designed for writing video games. It provides functionalities for multimedia applications, including displaying images and handling user input.

4. Pillow (PIL)

Pillow, also known as PIL (Python Imaging Library), is a library for opening, manipulating, and saving many different image file formats. It's widely used for basic image processing tasks.

5. Tkinter

Tkinter is the standard GUI (Graphical User Interface) toolkit for Python. It provides a simple way to create GUI applications, including the display of images. My script displays an image using the Tkinter library with the help of Pillow (PIL).

Conclusion :

My conclusion after having explored this five different methods for displaying images in Python: Matplotlib, OpenCV, Pygame, Pillow (PIL), and Tkinter. Each method has its advantages and considerations. Matplotlib provides a straightforward approach, while OpenCV may require additional setup time but offers powerful image processing capabilities. Pygame, while versatile, may exhibit slower image display performance. Pillow offers simplicity for basic image handling tasks, and Tkinter provides a GUI-based solution. Depending on the specific requirements of a project, developers can choose the most suitable method to efficiently display images while considering factors such as ease of use, performance, and required functionalities.

Stay tuned for more insights and explorations in the upcoming parts of this series!

Additionally, Also explore my Image Viewer Repository: Another Python Tkinter Project. This collection of image viewer applications is developed using the Tkinter library for GUI and the PIL module for image handling. Each version of the image viewer offers unique functionalities and enhancements, catering to different user preferences and needs. You can find more about it here.


Sunday, April 21, 2024

Exploring my Image Viewer Repository: A Python Tkinter Project (Part 2)

Are you interested in exploring the world of Python GUI programming and image manipulation? If so, you're in the right place! In this blog post, we'll dive further into creating a simple yet powerful picture viewer application using Python's Tkinter library. 

A short time ago a first post about this topic was presented on my blog. and i already have planned a next post about this topic with further improvements. 

Introduction to Tkinter and Image Manipulation

Tkinter is a popular Python library for creating graphical user interfaces (GUIs). It provides a simple and intuitive way to build interactive applications with widgets like buttons, labels, and frames.

Combined with the PIL (Python Imaging Library) or its successor, Pillow, Tkinter becomes a versatile tool for handling and displaying images within your applications. With these libraries, you can load, resize, and manipulate images with ease.

Coding and Tkinter libary (create using NightCafe Studio AI)

Building the Picture Viewer App

The goal is to create a picture viewer application that allows users to view different images and toggle the visibility of the picture frame. Here's an overview of the key components of our application:

Tkinter Window Initialization: We start by creating a Tkinter window as the main container for our application.

Picture Frame Creation: Within the main window, we create a frame to display the images. This frame will dynamically update to show the selected image.

Menu Bar Setup: We design a menu bar with options to control the picture frame. Users can show or hide the frame, toggle its visibility, and exit the application.

Image Loading and Display: Using PIL (or Pillow), we load images from file paths and display them within the picture frame. Images are resized to fit the frame's dimensions.

Frame Control Functions: We implement functions to handle frame visibility. Users can show, hide, or toggle the frame's visibility based on their preferences.

Exploring the Code

The Python code is structured into a class named PictureViewerApp, encapsulating the entire application logic. Here's a brief breakdown of the class methods:

  • __init__: Initializes the Tkinter window, creates the picture frame, loads an initial image, and sets up the menu bar.
  • create_menu: Creates the menu bar with options for controlling the picture frame and selecting images.
  • load_image: Loads an image file from the provided path and displays it within the picture frame.
  • display_image: Displays the currently loaded image within the picture frame after resizing it to fit.
  • show_frame and hide_frame: Functions to explicitly show or hide the picture frame.
  • toggle_frame: Toggles the visibility of the picture frame based on its current state.

In the provided code, the lambda function is used within the menu creation to bind commands to menu items dynamically. Let's break down its use and why it's needed in this context.   

The most recent version of the code will be posted as  `image_viewer05_lambda.py` in my GitHub Repository about this topic however i also did put the code below:   

import tkinter as tk

from PIL import ImageTk, Image

class PictureViewerApp:

    """

    A simple picture viewer application using Tkinter.

    This application allows users to view different pictures and toggle the visibility of the picture frame.

    Attributes:

        master (tk.Tk): The main Tkinter window.

        plugin_frame (tk.Frame): The frame to display the pictures.

        current_image (Image): The currently displayed image.

        menu_bar (tk.Menu): The main menu bar.

        frame_menu (tk.Menu): Submenu for frame options.

        picture_menu (tk.Menu): Submenu for picture options.

    """

    def __init__(self, master):

        """

        Initialize the PictureViewerApp.

        Args:

            master (tk.Tk): The main Tkinter window.

        """

        self.master = master

        master.title("Picture Viewer Example")

        # Create a frame inside the main window

        self.plugin_frame = tk.Frame(master, padx=20, pady=20)

        self.plugin_frame.pack()

        # Load initial image

        self.current_image = Image.open("img/picture1.jpg")

        self.display_image()

        # Create menu

        self.create_menu()

    def create_menu(self):

        """

        Create the main menu bar and its submenus.

        """

        self.menu_bar = tk.Menu(self.master)

        self.master.config(menu=self.menu_bar)

        # Frame submenu

        self.frame_menu = tk.Menu(self.menu_bar, tearoff=0)

        self.frame_menu.add_command(label="Show", command=self.show_frame)

        self.frame_menu.add_command(label="Hide", command=self.hide_frame)

        self.frame_menu.add_separator()

        self.frame_menu.add_command(label="Toggle", command=self.toggle_frame)

        self.frame_menu.add_separator()

        self.frame_menu.add_command(label="Exit", command=exit)

        # Pictures submenu

        self.picture_menu = tk.Menu(self.menu_bar, tearoff=0)

        self.picture_menu.add_command(label="Picture 1", command=lambda: self.load_image("img/picture1.jpg"))

        self.picture_menu.add_command(label="Picture 2", command=lambda: self.load_image("img/picture2.jpg"))

        self.picture_menu.add_command(label="Picture 3", command=lambda: self.load_image("img/picture3.jpg"))

        self.picture_menu.add_command(label="Picture 4", command=lambda: self.load_image("img/picture4.jpg"))

        self.picture_menu.add_command(label="Picture 5", command=lambda: self.load_image("img/picture5.jpg"))

        self.menu_bar.add_cascade(label="Frame", menu=self.frame_menu)

        self.menu_bar.add_cascade(label="Pictures", menu=self.picture_menu)

    def load_image(self, filename):

        """

        Load an image file and display it in the frame.

        Args:

            filename (str): The path to the image file.

        """

        self.current_image = Image.open(filename)

        self.display_image()

    def display_image(self):

        """

        Display the current image in the frame.

        """

        # Clear the frame

        for widget in self.plugin_frame.winfo_children():

            widget.destroy()

        # Resize the image to fit the frame

        resized_image = self.current_image.resize((400, 300), Image.BILINEAR)

        photo = ImageTk.PhotoImage(resized_image)

        # Display the image in a label

        image_label = tk.Label(self.plugin_frame, image=photo)

        image_label.image = photo  # Keep a reference to avoid garbage collection

        image_label.pack()

    def show_frame(self):

        """

        Show the picture frame.

        """

        self.plugin_frame.pack()

    def hide_frame(self):

        """

        Hide the picture frame.

        """

        self.plugin_frame.pack_forget()

    def toggle_frame(self):

        """

        Toggle the visibility of the picture frame.

        """

        if self.plugin_frame.winfo_ismapped():

            self.hide_frame()

        else:

            self.show_frame()


# Create the main window and run the application

root = tk.Tk()

app = PictureViewerApp(root)

root.mainloop()


What is a Lambda Function?

A lambda function in Python is a small anonymous function defined using the lambda keyword. It allows you to create a function without a name. Lambda functions can have any number of arguments but only one expression, which is evaluated and returned. They are often used as a shortcut for simple, one-line functions.

Why is Lambda Needed?

In the context of the provided code, lambda functions are used to create anonymous functions that call the load_image method with different arguments based on the selected menu item. Let's take a closer look at how this is achieved:

self.picture_menu.add_command(label="Picture 1", command=lambda: self.load_image("img/picture1.jpg"))

Here, lambda: self.load_image("img/picture1.jpg") is a lambda function. When the "Picture 1" menu item is selected, this lambda function is executed, which in turn calls the load_image method with the argument "img/picture1.jpg". Similarly, lambda functions are used for other menu items, each calling the load_image method with a different file path.

Why Lambda is Useful:

Dynamic Binding: Lambda functions allow us to bind commands to menu items dynamically. Instead of defining a separate function for each menu item, we can use lambda to create anonymous functions inline.

Conciseness: Lambda functions are concise and can be written in a single line, making the code more readable and reducing the need for additional named functions.

Flexibility: Lambda functions are flexible and can be used in situations where a named function would be cumbersome or unnecessary, such as when defining callbacks for GUI events.

Conclusion

By combining the power of Tkinter for GUI development and PIL/Pillow for image manipulation, we've created a functional picture viewer application in Python. This project serves as a great starting point for exploring more advanced GUI applications and image processing tasks.

The lambda functions are useful in this context because they provide a concise and flexible way to dynamically bind commands to menu items, allowing for cleaner and more readable code. They help streamline the process of defining callbacks for GUI elements like menu items.

In a an upcoming part i will further improve this program. Whether you're building a simple viewer for personal use or integrating image viewing capabilities into a larger application, Tkinter and PIL/Pillow provide the tools you need to succeed.

Happy coding and exploring the world of Python GUI programming!

Friday, April 19, 2024

ChatGPTtrainer

I asked ChatGPT (GPT-3.5 model chat.openai.com on 17apr2024): "What is the length of text i can type in here?"
The response was: "You can type up to 4096 characters in a single message. If you need to convey more information, you can break it up into multiple messages."

So i created with help of ChatGTP a tool to split information in digestible parts of around 4000 characters in separate files and published it on GitHub https://github.com/JanJeronimus/ChatGPTtrainer

Saturday, April 6, 2024

ChatGPT can create a story using Emoji

ChatGPT can create a story using Emoji (and other languages)
I recently asked ChatGTP to tell a story without words only with Emoji

Here's the story:

  1. 1️⃣👨‍👩‍👧‍👦🏠
  2. 🌞🕖🍳☕
  3. 🚌🏢👨‍💼💼💻
  4. 🕓🚌🏠
  5. 📺🛋️🍿
  6. 🌙🛌
  7. 📅🌞🛤️🏖️
  8. 👨‍👩‍👧‍👦🎡🎢🍦
  9. 🌞🌊🏄‍♂️🏊‍♂️🏖️
  10. 🥪🥤🏖️
It also asked the story in other languages. Some of these languages i don't know, so i hope the translation is correct and no offensive words are used.

Dutch/Nederlands:

🤖✨ Dit is een verhaal gemaakt door ChatGPT en geschreven in emoji, en vervolgens vertaald naar verschillende talen door ChatGPT.
  1. Het gezin woont in huis nummer 1️⃣.
  2. Ze staan om 7 uur op en ontbijten met eieren en koffie 🌞🕖🍳☕.
  3. Vader neemt de bus naar zijn werk in een kantoorgebouw, waar hij de hele dag aan zijn bureau werkt met zijn computer 🚌🏢👨‍💼💼💻.
  4. Om 4 uur neemt hij de bus terug naar huis 🕓🚌🏠.
  5. 's Avonds ontspannen ze samen voor de tv op de bank met popcorn 📺🛋️🍿.
  6. Ze gaan slapen 🌙🛌.
  7. De volgende dag vertrekken ze naar het strand 📅🌞🛤️🏖️.
  8. Op het strand genieten ze van attracties, ijsjes, surfen en zwemmen 👨‍👩‍👧‍👦🎡🎢🍦.
  9. Ze lunchen met sandwiches en drankjes op het strand 🌞🌊🏄‍♂️🏊‍♂️🏖️.
  10. Deze keer nemen ze de trein terug naar huis 🥪🥤🏖️.

Spanish/Español:

🤖✨ Esta es una historia creada por ChatGPT y escrita en emoji, y luego traducida a varios idiomas por ChatGPT.
  1. La familia vive en la casa número 1️⃣.
  2. Se levantan a las 7 de la mañana y desayunan huevos y café 🌞🕖🍳☕.
  3. El padre toma el autobús hacia su trabajo en un edificio de oficinas, donde pasa el día trabajando en su escritorio con su computadora 🚌🏢👨‍💼💼💻.
  4. A las 4 de la tarde, toma el autobús de regreso a casa 🕓🚌🏠.
  5. Por la noche, se relajan juntos viendo la televisión en el sofá con palomitas de maíz 📺🛋️🍿.
  6. Se van a dormir 🌙🛌.
  7. Al día siguiente, se dirigen a la playa 📅🌞🛤️🏖️.
  8. En la playa, disfrutan de atracciones, helados, surf y natación 👨‍👩‍👧‍👦🎡🎢🍦.
  9. Almuerzan con sándwiches y bebidas en la playa 🌞🌊🏄‍♂️🏊‍♂️🏖️.
  10. Esta vez, toman el tren de regreso a casa 🥪🥤🏖️.

German/Deutsch:

🤖✨ Dies ist eine Geschichte, die von ChatGPT erstellt und in Emoji geschrieben wurde und anschließend von ChatGPT in mehrere Sprachen übersetzt wurde.
  1. Die Familie lebt im Haus Nummer 1️⃣.
  2. Sie stehen um 7 Uhr auf und frühstücken Eier und Kaffee 🌞🕖🍳☕.
  3. Der Vater nimmt den Bus zur Arbeit in einem Bürogebäude, wo er den ganzen Tag an seinem Schreibtisch mit seinem Computer arbeitet 🚌🏢👨‍💼💼💻.
  4. Um 4 Uhr nimmt er den Bus zurück nach Hause 🕓🚌🏠.
  5. Abends entspannen sie sich zusammen und schauen fern auf dem Sofa mit Popcorn 📺🛋️🍿.
  6. Sie gehen schlafen 🌙🛌.
  7. Am nächsten Tag fahren sie zum Strand 📅🌞🛤️🏖️.
  8. Am Strand genießen sie Attraktionen, Eis, Surfen und Schwimmen 👨‍👩‍👧‍👦🎡🎢🍦.
  9. Sie machen ein Picknick mit Sandwiches und Getränken am Strand 🌞🌊🏄‍♂️🏊‍♂️🏖️.
  10. Dieses Mal nehmen sie den Zug zurück nach Hause 🥪🥤🏖️.

English:

🤖✨ This is a story created by ChatGPT and written in emoji, and then translated into multiple languages by ChatGPT.
  1. The family lives in house number 1️⃣.
  2. They wake up at 7 o'clock and have eggs and coffee for breakfast 🌞🕖🍳☕.
  3. The father takes the bus to work in an office building, where he spends the whole day at his desk with his computer 🚌🏢👨‍💼💼💻.
  4. At 4 o'clock, he takes the bus back home 🕓🚌🏠.
  5. In the evening, they relax together and watch TV on the couch with popcorn 📺🛋️🍿.
  6. They go to sleep 🌙🛌.
  7. The next day, they head to the beach 📅🌞🛤️🏖️.
  8. At the beach, they enjoy attractions, ice cream, surfing, and swimming 👨‍👩‍👧‍👦🎡🎢🍦.
  9. They have a picnic with sandwiches and drinks on the beach 🌞🌊🏄‍♂️🏊‍♂️🏖️.
  10. This time, they take the train back home 🥪🥤🏖️.

French/Français:

🤖✨ Il s'agit d'une histoire créée par ChatGPT et écrite en emoji, puis traduite dans plusieurs langues par ChatGPT.
  1. La famille vit dans la maison numéro 1️⃣.
  2. Ils se réveillent à 7 heures et prennent des œufs et du café pour le petit-déjeuner 🌞🕖🍳☕.
  3. Le père prend le bus pour aller travailler dans un immeuble de bureaux, où il passe toute la journée à son bureau avec son ordinateur 🚌🏢👨‍💼💼💻.
  4. À 4 heures, il prend le bus pour rentrer chez lui 🕓🚌🏠.
  5. Le soir, ils se détendent ensemble et regardent la télévision sur le canapé avec du popcorn 📺🛋️🍿.
  6. Ils vont se coucher 🌙🛌.
  7. Le lendemain, ils se rendent à la plage 📅🌞🛤️🏖️.
  8. À la plage, ils profitent des attractions, de la crème glacée, du surf et de la natation 👨‍👩‍👧‍👦🎡🎢🍦.
  9. Ils pique-niquent avec des sandwiches et des boissons sur la plage 🌞🌊🏄‍♂️🏊‍♂️🏖️.
  10. Cette fois, ils prennent le train pour rentrer chez eux 🥪🥤🏖️.

Turkish/Türkçe:

 🤖✨ ChatGPT tarafından oluşturulan ve emoji'lerle yazılan bir hikaye ve daha sonra birkaç dilde ChatGPT tarafından çevrilmiş bir metindir.
  1. Aile ev numarasında yaşıyor 1️⃣.
  2. Sabah saat 7'de uyanırlar ve kahvaltıda yumurta ve kahve içerler 🌞🕖🍳☕.
  3. Baba işe gitmek için bir iş binasına otobüsle gider, burada bütün gün masası ve bilgisayarıyla çalışır 🚌🏢👨‍💼💼💻.
  4. Saat 4'te eve döner 🕓🚌🏠.
  5. Akşam, birlikte koltukta televizyon izleyerek ve patlamış mısır yiyerek dinlenirler 📺🛋️🍿.
  6. Uykuya dalarlar 🌙🛌.
  7. Ertesi gün, plaja giderler 📅🌞🛤️🏖️.
  8. Plajda, atraksiyonlardan, dondurmadan, sörf yapmaktan ve yüzmekten keyif alırlar 👨‍👩‍👧‍👦🎡🎢🍦.
  9. Plajda sandviçler ve içeceklerle piknik yaparlar 🌞🌊🏄‍♂️🏊‍♂️🏖️.
  10. Bu sefer, eve dönmek için treni kullanırlar 🥪🥤🏖️.

Polish/Polski:

🤖✨ To historia stworzona przez ChatGPT i napisana w emoji, a następnie przetłumaczona na kilka języków przez ChatGPT.
  1. Rodzina mieszka w domu numer 1️⃣.
  2. Budzą się o godzinie 7 i jedzą jajka i kawę na śniadanie 🌞🕖🍳☕.
  3. Ojciec jedzie autobusem do pracy w biurowcu, gdzie spędza cały dzień przy biurku ze swoim komputerem 🚌🏢👨‍💼💼💻.
  4. O 16:00 wraca autobusem do domu 🕓🚌🏠.
  5. Wieczorem odpoczywają razem, oglądając telewizję na kanapie z popcornem 📺🛋️🍿.
  6. Idą spać 🌙🛌.
  7. Następnego dnia udają się na plażę 📅🌞🛤️🏖️.
  8. Na plaży korzystają z atrakcji, lodów, surfowania i pływania 👨‍👩‍👧‍👦🎡🎢🍦.
  9. Na plaży jedzą kanapki i piją napoje 🌞🌊🏄‍♂️🏊‍♂️🏖️.
  10. Tym razem wracają do domu pociągiem 🥪🥤🏖️.

Chinese/中文:

🤖✨ 这是由ChatGPT创建的并用表情符号编写的故事,然后由ChatGPT翻译成几种语言。
  1. 家里住在1️⃣号房子里。
  2. 他们在早上7点起床,吃鸡蛋和咖啡🌞🕖🍳☕。
  3. 父亲乘坐公共汽车去办公楼上班,在那里他整天都在办公桌前用电脑工作🚌🏢👨‍💼💼💻。
  4. 下午4点,他乘坐公共汽车回家🕓🚌🏠。
  5. 晚上,他们一起放松,坐在沙发上看电视,吃爆米花📺🛋️🍿。
  6. 他们去睡觉了🌙🛌。
  7. 第二天,他们前往海滩📅🌞🛤️🏖️。
  8. 在海滩上,他们享受景点,冰淇淋,冲浪和游泳👨‍👩‍👧‍👦🎡🎢🍦。
  9. 他们在海滩上用三明治和饮料野餐🌞🌊🏄‍♂️🏊‍♂️🏖️。
  10. 这次,他们乘火车回家🥪🥤🏖️。

Korean/한국어:

 🤖✨ 이것은 ChatGPT에 의해 만들어진 이모지로 작성된 이야기이며, 그 후 ChatGPT에 의해 여러 언어로 번역되었습니다.
  1. 가족은 1️⃣호 집에 삽니다.
  2. 그들은 아침 7시에 일어나 계란과 커피를 먹습니다 🌞🕖🍳☕.
  3. 아버지는 오피스 빌딩에서 일하기 위해 버스를 타고 오르내리고, 거기서 하루 종일 책상과 컴퓨터와 함께 일합니다 🚌🏢👨‍💼💼💻.
  4. 오후 4시에는 다시 집으로 돌아갑니다 🕓🚌🏠.
  5. 저녁에는 함께 쇼파에서 텔레비전을 보며 팝콘을 먹으면서 휴식을 취합니다 📺🛋️🍿.
  6. 그들은 잠을 잡니다 🌙🛌.
  7. 다음 날은 해변으로 향합니다 📅🌞🛤️🏖️.
  8. 해변에서는 놀이기구, 아이스크림, 서핑, 수영을 즐깁니다 👨‍👩‍👧‍👦🎡🎢🍦.
  9. 해변에서 샌드위치와 음료수로 피크닉을 합니다 🌞🌊🏄‍♂️🏊‍♂️🏖️.
  10. 이번에는 기차로 집으로 돌아갑니다 🥪🥤🏖️.  

Klingon/tlhIngan Hol.:

🤖✨ qaStaHvIS ChatGPT DawIvpu' emoji jIH 'ej wej Dujvetlh ChatGPT ghom loQ.

ChatGPT

I'm sorry, but I'm unable to provide a translation into Klingon as it's a fictional language created for the Star Trek universe. However, if you have specific phrases or sentences you'd like to see translated into Klingon, I can try to assist you with that using available resources. Let me know if there's anything else I can help you with!

User

Translate the 10 line story you wrote in Klingon

ChatGPT

I'm sorry for any confusion, but Klingon is a constructed language created for the Star Trek series, and there are no widely accepted translations for everyday phrases or texts like the one you provided. However, I can attempt to provide a rough translation of the story into Klingon based on the grammar and vocabulary of the language:
  1. tInwI' neH num 1️⃣.
  2. cha'maH vagh jajvam je 🌞🕖🍳☕.
  3. vav Hutlhbogh ghotI' vIghro' qetbogh 'oy' yIlo' 'ej Hutbogh vIlegh 💼💻.
  4. wa'maH jav qetbogh veS 🕓🚌🏠.
  5. 'oH 'ejwI' lunga' jIH 📺🛋️🍿.
  6. ngaj vISov 🌙🛌.
  7. wa'DIch qeng 'etlh 📅🌞🛤️🏖️.
  8. vav veng, chabmaH'e' jIH 👨‍👩‍👧‍👦🎡🎢🍦.
  9. qen nach yuvtlh tlho' qatlh 🌞🌊🏄‍♂️🏊‍♂️🏖️.
  10. qaS DaneH'a' 🥪🥤🏖️.
Please note that Klingon translations can vary based on interpretation and context, and this translation may not be entirely accurate.

Emoji

Exploring Emojis in Python: A Fun Demo

Emojis have become an integral part of online communication, adding color and emotion to our text-based conversations. Did you know that you can also use emojis as variables in your Python code? In this post, we'll explore how to do just that with a simple Python script.

Using Emojis as Variables

I recently stumbled upon a fascinating aspect of Python: you can use emojis as variable names and also print out the variable name along with its value. This opens up a world of possibilities for adding a touch of fun to your code. 

Let's take a look at a Python script I created to demonstrate this concept. The script contains various emoji variables along with their Unicode representations. It also includes a function called show_line() that prints each emoji variable, its Unicode representation, and its description.

Here's a snippet of the script: .

# Emoticons
emoji_smile = '\U0001F600'               # 😀
emoji_scissors = '\u2702'                # ✂
emoji_check = '\u2714'                   # ✔
# More emoji variables ...


def show_line(var_name) -> None:
    if not isinstance(var_name, str):
        print("Error: var_name must be a string.")
        return
    global_vars = globals()
    if var_name in global_vars:
        var_value = global_vars[var_name]
        var_suffix = var_name.replace("emoji_", "")
        print(f"{var_name.ljust(40)} = '", end="")
        var_unicode_hex = ''.join([f"\\U{hex(ord(char))[2:].upper().zfill(8)}" for char in var_value])
        print(var_unicode_hex, end="'\t# ")
        print(f"{var_value}, '{var_suffix}'")
    else:
        print(f"Error: {var_name} not found in global variables.")

# Demo usage of the script
print("\n# Emoticons:")
show_line('emoji_smile')
show_line('emoji_scissors')
# More calls to show_line() ...

How to Use the Script

To run the script and see the emojis in action, simply execute the main() function of the full script in my GitHub. You'll see each emoji variable printed along with its Unicode representation and description.

Additional Information

This script is intended for simple use cases when only a few emojis are used. For more advanced emoji usage, you might want to consider using the python-emoji library.

Feel free to explore my GitHub repository for the complete script and contribute if you'd like to  improve the script further.



Friday, April 5, 2024

Exploring my Image Viewer Repository: A Python Tkinter Project (Part 1)

Introduction:

Welcome to my Image Viewer Repository! This GitHub repository hosts a collection of image viewer applications developed in Python using the Tkinter library for GUI and the PIL module for image handling. Each version of the image viewer offers unique functionalities and enhancements, catering to different user preferences and needs.

Repository Overview:

  • image_viewer_basic.py: This version of the image viewer provides a basic interface with buttons to load predefined images.
  • image_viewer_dropdown.py: An enhanced version featuring a dropdown menu to select images, offering a more intuitive user experience.
  • image_viewer_with_menu.py: This version introduces a menu-based interface for selecting images, adding another layer of usability to the application.
  • image_viewer_img_objects.py: An advanced iteration of the image viewer where images are treated as objects, allowing for more flexibility and scalability in managing and displaying images.

Usage:

To run any of the provided Python scripts, follow these simple steps:

  1. Clone or download the repository to your local machine.
  2. Open a terminal or command prompt.
  3. Navigate to the directory containing the desired Python script.
  4. Run the following command: python script_name.py, replacing script_name.py with the name of the script you wish to execute.

License:

This project is licensed under the MIT License, granting users the freedom to utilize, modify, and distribute the code as they see fit. For more details, refer to the LICENSE file in the repository.

Explore the Repository:

Ready to dive into the world of image viewers? Visit my Image Viewer Repository on GitHub to access the code and explore the different versions of the image viewer: Image Viewer Repository

Conclusion:

Thank you for exploring my Image Viewer Repository! Whether you're a Python enthusiast, a Tkinter aficionado, or simply looking for an intuitive way to view images, this repository has something for everyone. Feel free to experiment with the different versions and make the image viewer your own. Happy coding!

Friday, March 29, 2024

AI ChatGTP and music

One idea for this year is to make more use of AI in my projects. On my last blogpost about Python pandas i added an AI generated picture. The picture below is a result of quick experiments with 'NightCafe AI Art Creator' to make an illustration about 'AI generated music', the topic of this blogpost. My first attempts only gave a paper with music notes or some orchestra. so it was a bit of a challenge to get something nice.

AI generated music picture
AI generated music (NightCafe AI Art Creator)

My post about Python pandas also triggered me to take a look at other blogposts i have done to look if more pictures added something. For example a blogpost about Mysteries in ChatGPT had almost no illustrations and could need something extra. To go over older blogposts and add make changes did not give a good feeling. I like to limit changes in posts, however i also like to experiment with AI.

To try something complete different i did let another AI  (Sono) generate a song about Mysteries in ChatGPT :


The video (on my YouTube channel.) is complete generated with Suno . I hope you will play it to hear the result.
Python pandas
Python pandas
(NightCafe AI Art Creator)

I did not play a lot with Suno, and you only get a limited amount of 'virtual credits'to experiment. The interface (on my phone) did give me some problems and by accident i created multiple songs with the same input that where not much different from each other. 
I also created songs as mp3 audio files about 'Python pandas' . Unfortunately it is not easy possible to post audiofiles on this google blog. Therefore i created a video using the 'NightCafe AI Art Creator' picture as background and did put two (almost similar) the songs about 'Python pandas" in it. (I did this using a free version of ApowerEdit so it has a watermark.) By investing more time the video part could be improved a lot with multiple pictures and movement. I also tried Google subtitling to automatic generate a subtitle (containing the lyrics) however the result with (this) music seems poor.



I hope you enjoy hearing the audio on these two recently published videos.