Skip to content

Commit

Permalink
Add focus and winsounds to messageboxes. Add missing messageboxes. (#58)
Browse files Browse the repository at this point in the history
* Add focus and winsounds to messageboxes. Add missing messageboxes.
* Add missing focus to CTKMessageboxes
* Use try in import winsound, to prevent errors on other platforms
  • Loading branch information
Kielx authored Jul 26, 2023
1 parent ef68d34 commit cc22a99
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 72 deletions.
9 changes: 7 additions & 2 deletions frames/AnydeskFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from CTkMessagebox import CTkMessagebox
from PIL import Image
from utils.event_utils import myEvent
from utils.sound_utils import play_message_beep

import customtkinter

Expand Down Expand Up @@ -243,7 +244,8 @@ def fetch_logs_button_callback(self):
for x in threads:
x.start()
else:
CTkMessagebox(title=_("Select option"), message=_("Please select at least one option."))
play_message_beep()
CTkMessagebox(title=_("Select option"), message=_("Please select at least one option."), option_focus=1)

def print_logs_to_textbox(self, log_filename_with_path: str):
"""A function that calls get_anydesk_logs function and prints output to textbox
Expand Down Expand Up @@ -326,7 +328,9 @@ def on_finished_searching(self):
self.checkbox_fetch_programdata_logs,
self.checkbox_search_for_logs_in_location
], state="normal")

global_state.refresh_reports_list = True
play_message_beep()

@staticmethod
def turn_off_switches(switches_list: list[tkinter.BooleanVar]):
Expand Down Expand Up @@ -362,4 +366,5 @@ def open_report_folder():
try:
os.startfile(report_folder_path)
except FileNotFoundError:
print(_("Report folder not found!"))
play_message_beep()
CTkMessagebox(title=_("Report folder not found!"), message=_("Report folder not found!"), option_focus=1)
24 changes: 20 additions & 4 deletions frames/BrowseReportsFrame.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import csv
import os
from CTkMessagebox import CTkMessagebox
import customtkinter
from CTkMessagebox import CTkMessagebox
from PIL import Image

from utils.file_operations import split_computer_datetime_dirname, get_reports_folder_list
from utils.widget_utils import add_widgets
from utils.locale_utils import _
from utils.sound_utils import play_message_beep


class BrowseReportsFrame(customtkinter.CTkScrollableFrame):
Expand All @@ -27,6 +28,7 @@ class Report_Frame(customtkinter.CTkFrame):
It also shows the number of files and IP addresses found in the report.
Button located in frame opens the report folder.
"""
master: BrowseReportsFrame

def __init__(self, master, **kwargs):
super().__init__(master)
Expand Down Expand Up @@ -75,6 +77,9 @@ def __init__(self, master, **kwargs):

class Report_Button(customtkinter.CTkButton):
"""A class representing a button that opens the report folder."""
master: Report_Frame



def __init__(self, master, **kwargs):
super().__init__(master)
Expand All @@ -88,11 +93,17 @@ def __init__(self, master, **kwargs):
self.grid(row=1, column=0, columnspan=1, sticky="ew", padx=10, pady=10)

def open_report(self):
os.startfile(self.report_path)
try:
os.startfile(self.report_path)
except Exception as e:
play_message_beep()
CTkMessagebox(title=_('Error'), message=_('Could not open report folder.'), icon="warning", option_focus=1)
refresh(self.master.master)


class Delete_Report_Button(customtkinter.CTkButton):
"""A class representing a button that deletes the report folder."""
master: Report_Frame

def __init__(self, master, **kwargs):
super().__init__(master)
Expand All @@ -110,7 +121,8 @@ def confirm_delete(self):
# get yes/no answers
msg = CTkMessagebox(title=_('Delete Report' + "?"),
message=_('Do you really want to delete the selected report?'),
icon="warning", option_1=_('Cancel'), option_2=_('Delete'), cancel_button="cross")
icon="warning", option_1=_('Cancel'), option_2=_('Delete'), cancel_button="cross",
option_focus=2)
msg.button_2.configure(text_color="#eee", fg_color=("#ef4444", "#b91c1c"),
hover_color=("#dc2626", "#991b1b"))
response = msg.get()
Expand All @@ -122,7 +134,11 @@ def confirm_delete(self):

def delete_report(self):
import shutil
shutil.rmtree(self.report_path)
try:
shutil.rmtree(self.report_path)
except Exception as e:
play_message_beep()
CTkMessagebox(title=_('Error'), message=_('Could not delete report folder.'), icon="warning", option_focus=1)
# refresh browse reports frame
refresh(self.master.master)

Expand Down
76 changes: 44 additions & 32 deletions locale/Main.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
msgid ""
msgstr ""
"Project-Id-Version: AnyGrabber\n"
"POT-Creation-Date: 2023-07-18 14:09+0200\n"
"POT-Creation-Date: 2023-07-19 22:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Krzysztof Pañtak, [email protected]\n"
"Language-Team: Krzysztof Pañtak, [email protected]\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=cp1250\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 3.2.2\n"
"X-Generator: Poedit 3.3.2\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-KeywordsList: _(\";{_(\";{_(\"*\")}\n"
"X-Poedit-SearchPath-0: frames/HomeFrame.py\n"
Expand All @@ -23,131 +23,143 @@ msgstr ""
"X-Poedit-SearchPath-3: frames\n"
"X-Poedit-SearchPath-4: utils\n"

#: frames/AnydeskFrame.py:73
#: frames/AnydeskFrame.py:74
msgid "Choose where to search for logs:"
msgstr ""

#: frames/AnydeskFrame.py:102
#: frames/AnydeskFrame.py:103
msgid "Custom location"
msgstr ""

#: frames/AnydeskFrame.py:117 frames/AnydeskFrame.py:316
#: frames/AnydeskFrame.py:118 frames/AnydeskFrame.py:316
msgid "Fetch logs"
msgstr ""

#: frames/AnydeskFrame.py:131
#: frames/AnydeskFrame.py:132
msgid "Open report"
msgstr ""

#: frames/AnydeskFrame.py:145
#: frames/AnydeskFrame.py:146
msgid "Searching for files in"
msgstr ""

#: frames/AnydeskFrame.py:146
#: frames/AnydeskFrame.py:147
msgid "it may take a while"
msgstr ""

#: frames/AnydeskFrame.py:173 frames/AnydeskFrame.py:175
#: frames/AnydeskFrame.py:174 frames/AnydeskFrame.py:176
msgid "No files were found in"
msgstr ""

#: frames/AnydeskFrame.py:232
msgid "Stop fetching"
msgstr ""

#: frames/AnydeskFrame.py:247
#: frames/AnydeskFrame.py:248
msgid "Select option"
msgstr ""

#: frames/AnydeskFrame.py:247
#: frames/AnydeskFrame.py:248
msgid "Please select at least one option."
msgstr ""

#: frames/AnydeskFrame.py:260
#: frames/AnydeskFrame.py:261
msgid "Fetching logs from"
msgstr ""

#: frames/AnydeskFrame.py:262
#: frames/AnydeskFrame.py:263
msgid "No IP logs found inside file!"
msgstr ""

#: frames/AnydeskFrame.py:268
#: frames/AnydeskFrame.py:269
msgid "Logs not found in"
msgstr ""

#: frames/AnydeskFrame.py:296
#: frames/AnydeskFrame.py:322
msgid "Search stopped"
msgstr ""

#: frames/AnydeskFrame.py:321
#: frames/AnydeskFrame.py:324
msgid "Searching for files finished"
msgstr ""

#: frames/AnydeskFrame.py:365
#: frames/AnydeskFrame.py:371
msgid "Report folder not found!"
msgstr ""

#: frames/BrowseReportsFrame.py:62
#: frames/BrowseReportsFrame.py:64
msgid "Files: "
msgstr ""

#: frames/BrowseReportsFrame.py:63
#: frames/BrowseReportsFrame.py:65
msgid "IP Addresses: "
msgstr ""

#: frames/BrowseReportsFrame.py:85
#: frames/BrowseReportsFrame.py:87
msgid "Open Report folder"
msgstr ""

#: frames/BrowseReportsFrame.py:103
#: frames/BrowseReportsFrame.py:97 frames/BrowseReportsFrame.py:137
msgid "Error"
msgstr ""

#: frames/BrowseReportsFrame.py:97
msgid "Could not open report folder."
msgstr ""

#: frames/BrowseReportsFrame.py:110
msgid "Delete Report"
msgstr ""

#: frames/BrowseReportsFrame.py:111
#: frames/BrowseReportsFrame.py:118
msgid "Delete Report?"
msgstr ""

#: frames/BrowseReportsFrame.py:112
#: frames/BrowseReportsFrame.py:119
msgid "Do you really want to delete the selected report?"
msgstr ""

#: frames/BrowseReportsFrame.py:113
#: frames/BrowseReportsFrame.py:120
msgid "Cancel"
msgstr ""

#: frames/BrowseReportsFrame.py:113 frames/BrowseReportsFrame.py:118
#: frames/BrowseReportsFrame.py:120 frames/BrowseReportsFrame.py:126
msgid "Delete"
msgstr ""

#: frames/BrowseReportsFrame.py:149
#: frames/BrowseReportsFrame.py:137
msgid "Could not delete report folder."
msgstr ""

#: frames/BrowseReportsFrame.py:161
msgid "Reports List"
msgstr ""

#: frames/HomeFrame.py:27
msgid "welcome screen\n"
msgstr ""

#: main.py:41
#: main.py:43
msgid "Restart required"
msgstr ""

#: main.py:41
#: main.py:43
msgid "Please restart the application to apply changes."
msgstr ""

#: main.py:94
#: main.py:97
msgid "Home"
msgstr ""

#: main.py:109
#: main.py:112
msgid "Browse Reports"
msgstr ""

#: main.py:117
#: main.py:120
msgid "Theme"
msgstr ""

#: main.py:129
#: main.py:132
msgid "Language"
msgstr ""

Expand Down
Binary file modified locale/pl-PL/LC_MESSAGES/Main.mo
Binary file not shown.
Loading

0 comments on commit cc22a99

Please sign in to comment.