replace download with open lxtoolsinstaller add translate german for logviewer fix message dialog

This commit is contained in:
2025-06-29 18:08:35 +02:00
parent 7351100e55
commit 52f782b4e8
7 changed files with 200 additions and 18 deletions

View File

@ -5,6 +5,7 @@ import tkinter as tk
from tkinter import TclError, filedialog, ttk
from pathlib import Path
import webbrowser
import subprocess
from functools import partial
from shared_libs.gitea import GiteaUpdate
from shared_libs.message import MessageDialog
@ -47,6 +48,9 @@ class LogViewer(tk.Tk):
self.createWidgets(_)
self.load_file(_, modul_name=modul_name)
self.log_icon = tk.PhotoImage(file=modul_name.AppConfig.IMAGE_PATHS["icon_log"])
self.update_icon = tk.PhotoImage(
file=modul_name.AppConfig.IMAGE_PATHS["update"]
)
self.iconphoto(True, self.log_icon)
self.grid_rowconfigure(0, weight=1)
self.grid_rowconfigure(1, weight=1)
@ -164,6 +168,12 @@ class LogViewer(tk.Tk):
else:
self.updates_lb.grid_remove()
def updater(self):
"""Start the lxtools_installer"""
result = subprocess.run(["/usr/local/bin/lxtools_installer"], check=False)
if result.returncode != 0:
MessageDialog("error", result.stderr)
# Update the labels based on the result
def update_ui_for_update(self, res, modul_name, _):
"""Update UI elements based on an update check result"""
@ -200,25 +210,20 @@ class LogViewer(tk.Tk):
else:
self.set_update.set(value=0)
update_text = f"Update {res} {_('available!')}"
# Clear the label text since we'll show the button instead
self.update_label.set("")
# Create the update button
self.update_btn = ttk.Menubutton(self.menu_frame, text=update_text)
self.update_btn = ttk.Button(
self.menu_frame,
image=self.update_icon,
style="Toolbutton",
command=self.updater,
)
self.update_btn.grid(column=5, row=0, padx=0)
Tooltip(
self.update_btn, _("Click to download new version"), self.tooltip_state
)
self.download = tk.Menu(self, relief="flat")
self.update_btn.configure(menu=self.download, style="Toolbutton")
self.download.add_command(
label=_("Download"),
command=lambda: GiteaUpdate.download(
f"{modul_name.AppConfig.DOWNLOAD_URL}/{res}.zip", res
),
self.update_btn, _("Click to install new version"), self.tooltip_state
)
@staticmethod
@ -362,11 +367,11 @@ class LogViewer(tk.Tk):
self.text_area.bind("<Button-3>", self.show_context_menu)
self._entry.bind("<Button-3>", self.show_context_menu)
search_button = ttk.Button(next_frame, text="Search", command=self._onFind)
search_button = ttk.Button(next_frame, text=_("Search"), command=self._onFind)
search_button.grid(row=0, column=0, padx=5, pady=5, sticky=tk.EW)
delete_button = ttk.Button(
next_frame, text="Delete_Log", command=self.delete_file
next_frame, text=_("Delete_Log"), command=self.delete_file
)
delete_button.grid(row=0, column=2, padx=5, pady=5, sticky=tk.EW)