Skip to content

Python - mehrsprachiges GUI

Python3
  • Ok, hier mal kurz was zum Thema, wie man ein GUI, z.B. mein Restic UI ;), mehrsprachig gestalten kann. Dazu bin ich über eine tolle Anleitung gestolpert.

    Es gibt in Python das Modul gettext, damit kann man seine Anwendung mehrsprachig gestalten. Das ist gar nicht so einfach, wie ich mir das am Anfang vorgestellt habe. Heute hier an dieser Stelle nur ein paar Notizen, ich werde evt. später darauf nochmal eingehen.

    Die Ordnerstruktur

    78385975-defa-4b70-8292-2d5b375f4036-grafik.png

    base.pot

    # SOME DESCRIPTIVE TITLE.
    # Copyright (C) YEAR ORGANIZATION
    # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: PACKAGE VERSION\n"
    "POT-Creation-Date: 2022-04-26 17:11+0200\n"
    "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language-Team: LANGUAGE <LL@li.org>\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=UTF-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: pygettext.py 1.5\n"
    
    
    #: /home/frank/restic_ui/src/restic_ui.py:130
    msgid "This is a translatable string."
    msgstr ""
    
    #: /home/frank/restic_ui/src/restic_ui.py:4118
    msgid "Restic version"
    msgstr ""
    

    base.po (DE)

    # SOME DESCRIPTIVE TITLE.
    # Copyright (C) YEAR ORGANIZATION
    # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
    #
    msgid ""
    msgstr ""
    "Project-Id-Version: PACKAGE VERSION\n"
    "POT-Creation-Date: 2022-04-26 16:52+0200\n"
    "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    "Language-Team: LANGUAGE <LL@li.org>\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=UTF-8\n"
    "Content-Transfer-Encoding: 8bit\n"
    "Generated-By: pygettext.py 1.5\n"
    
    
    #: /home/frank/restic_ui/src/restic_ui.py:127
    msgid "This is a translatable string."
    msgstr "TESTING"
    
    #: /home/frank/restic_ui/src/restic_ui.py:4109
    msgid "Restic version"
    msgstr "Anzeige der Restic version"
    

    Und zwei Befehle, die man dazu noch benötigt.

    msgfmt -o base.mo base
    pygettext3.8 -d base -o /home/frank/restic_ui/locales/base.pot /home/frank/restic_ui/src/restic_ui.py 
    

    Jetzt muss ich mir noch Gedanken darüber machen, ob ich das brauche und so umsetze.

  • Python3 - Pipenv für die virtuelle Entwicklungsumgebung

    Python3
    2
    1
    0 Stimmen
    2 Beiträge
    382 Aufrufe
    FrankMF
    Ich ko... immer, wenn ich mein VSCodium neu installieren muss. Das größte Problem dabei ist immer, das ich fast immer vergesse den Python Interpreter zu setzen. "CTRL+SHIFT+P" and choose the correct python interpreter. [image: 1656256156412-46f85075-4dbc-414c-94c2-abc5bb6009b6-grafik.png] Danach startet das Python Programm auch wieder aus der richtigen Entwicklungsumgebung
  • Restic UI - QThread

    Restic UI
    1
    0 Stimmen
    1 Beiträge
    130 Aufrufe
    Niemand hat geantwortet
  • Python3 - Umzug nach Fedora 34

    Python3
    1
    0 Stimmen
    1 Beiträge
    183 Aufrufe
    Niemand hat geantwortet
  • Python3 - QSettings

    Python3
    1
    0 Stimmen
    1 Beiträge
    168 Aufrufe
    Niemand hat geantwortet
  • Python3 - virtuelle Entwicklungsumgebung

    Angeheftet Python3
    3
    0 Stimmen
    3 Beiträge
    361 Aufrufe
    FrankMF
    Nach Systemwechsel erneut Probleme. Hier noch mal aufgelistet. Aufpassen, das kein venv Ordner vorhanden ist! Neu anlegen! python3 -m venv venv Dann meckert mein Linux Mint Cinnamon The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package using the following command. apt install python3.8-venv You may need to use sudo with that command. After installing the python3-venv package, recreate your virtual environment. Failing command: ['/home/frank/Restic_UI_Produktiv/restic-ui-public/venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip'] Ok, das ist einfach apt install python3.8-venv python3 -m venv venv Danach aktivieren source venv/bin/activate Installation von PyQt5 (venv) frank@frank-MS-7C37:~/Restic_UI_Produktiv/restic-ui-public$ pip3 install PyQt5 Collecting PyQt5 Downloading PyQt5-5.15.4-cp36.cp37.cp38.cp39-abi3-manylinux2014_x86_64.whl (8.3 MB) |████████████████████████████████| 8.3 MB 1.7 MB/s Collecting PyQt5-Qt5>=5.15 Downloading PyQt5_Qt5-5.15.2-py3-none-manylinux2014_x86_64.whl (59.9 MB) |████████████████████████████████| 59.9 MB 18.3 MB/s Collecting PyQt5-sip<13,>=12.8 Downloading PyQt5_sip-12.9.0-cp38-cp38-manylinux1_x86_64.whl (332 kB) |████████████████████████████████| 332 kB 46.1 MB/s Installing collected packages: PyQt5-Qt5, PyQt5-sip, PyQt5 Successfully installed PyQt5-5.15.4 PyQt5-Qt5-5.15.2 PyQt5-sip-12.9.0 Danach meckert er über ein fehlendes Modul requests (venv) frank@frank-MS-7C37:~/Restic_UI_Produktiv/restic-ui-public$ python3 restic_ui.py Traceback (most recent call last): File "restic_ui.py", line 41, in <module> from functions import ( File "/home/frank/Restic_UI_Produktiv/restic-ui-public/functions.py", line 19, in <module> import requests as req ModuleNotFoundError: No module named 'requests' Installation requests (venv) frank@frank-MS-7C37:~/Restic_UI_Produktiv/restic-ui-public$ pip3 install requests Collecting requests Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB) |████████████████████████████████| 61 kB 802 kB/s Collecting chardet<5,>=3.0.2 Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB) |████████████████████████████████| 178 kB 2.7 MB/s Collecting certifi>=2017.4.17 Downloading certifi-2021.5.30-py2.py3-none-any.whl (145 kB) |████████████████████████████████| 145 kB 14.0 MB/s Collecting idna<3,>=2.5 Downloading idna-2.10-py2.py3-none-any.whl (58 kB) |████████████████████████████████| 58 kB 9.4 MB/s Collecting urllib3<1.27,>=1.21.1 Downloading urllib3-1.26.6-py2.py3-none-any.whl (138 kB) |████████████████████████████████| 138 kB 11.5 MB/s Installing collected packages: chardet, certifi, idna, urllib3, requests Successfully installed certifi-2021.5.30 chardet-4.0.0 idna-2.10 requests-2.25.1 urllib3-1.26.6 Und schwupps, geht mein Tool wieder [image: 1625848253488-4968ce42-7c66-4c8a-a2ad-424b9a529d87-grafik.png]
  • Python3 - subprocess.Popen

    Python3
    1
    0 Stimmen
    1 Beiträge
    308 Aufrufe
    Niemand hat geantwortet
  • Wireguard UI - mein erstes Python3 Projekt

    Python3
    2
    3
    0 Stimmen
    2 Beiträge
    251 Aufrufe
    FrankMF
    Dinge entwickeln sich. Es sieht alles schon wieder was anders aus Hauptfenster [image: 1600889374694-270b5c68-3d64-44ca-9a01-e3f24ba4a26c-grafik.png] Setup Fenster zum Erstellen der wg0.conf [image: 1600889412743-27c3cb28-50f5-4e00-b03d-de47c07372a0-grafik.png] Und alles funktioniert so weit
  • Wichtige Links

    Angeheftet Python3
    1
    0 Stimmen
    1 Beiträge
    194 Aufrufe
    Niemand hat geantwortet