Create your own message boxes for export

This commit is contained in:
Désiré Werner Menrath 2024-09-20 16:06:15 +02:00
parent 41391b0ef1
commit a3f3604a1f
7 changed files with 70 additions and 8 deletions

View File

@ -4,7 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home"> <list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="replace tar with zip and Check if Zip file is empty">
<change afterPath="$PROJECT_DIR$/wp-icons/128/info.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/wp-icons/256/info.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/wp-icons/32/info.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/wp-icons/48/info.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/wp-icons/64/info.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" />
</list> </list>
@ -453,7 +458,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1726777434040</updated> <updated>1726777434040</updated>
</task> </task>
<option name="localTasksCounter" value="41" /> <task id="LOCAL-00041" summary="replace tar with zip and Check if Zip file is empty">
<option name="closed" value="true" />
<created>1726836930251</created>
<option name="number" value="00041" />
<option name="presentableId" value="LOCAL-00041" />
<option name="project" value="LOCAL" />
<updated>1726836930251</updated>
</task>
<option name="localTasksCounter" value="42" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures"> <component name="UnknownFeatures">
@ -494,7 +507,6 @@
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" /> <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="little fixes in Class Import" />
<MESSAGE value="fix label when laat Tunnel delete and fix Tuple error in delete and Start/Stop when listbox empty" /> <MESSAGE value="fix label when laat Tunnel delete and fix Tuple error in delete and Start/Stop when listbox empty" />
<MESSAGE value="remove a ',' in DNS Name" /> <MESSAGE value="remove a ',' in DNS Name" />
<MESSAGE value="fix when Filname &gt; 17 first copy file after rename" /> <MESSAGE value="fix when Filname &gt; 17 first copy file after rename" />
@ -519,6 +531,7 @@
<MESSAGE value="fix a filedialog for hidden Files work&#10;install rollback to bash for start wirepy and wirepy rollback to bash" /> <MESSAGE value="fix a filedialog for hidden Files work&#10;install rollback to bash for start wirepy and wirepy rollback to bash" />
<MESSAGE value="install rollback bash to py wirepy and wirepy rollback to py" /> <MESSAGE value="install rollback bash to py wirepy and wirepy rollback to py" />
<MESSAGE value="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home" /> <MESSAGE value="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home" />
<option name="LAST_COMMIT_MESSAGE" value="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home" /> <MESSAGE value="replace tar with zip and Check if Zip file is empty" />
<option name="LAST_COMMIT_MESSAGE" value="replace tar with zip and Check if Zip file is empty" />
</component> </component>
</project> </project>

View File

@ -3,7 +3,7 @@ import os
import shutil import shutil
import zipfile import zipfile
from datetime import datetime from datetime import datetime
from tkinter import filedialog, messagebox from tkinter import filedialog
import tkinter as tk import tkinter as tk
from pathlib import Path from pathlib import Path
from subprocess import check_call from subprocess import check_call
@ -38,6 +38,56 @@ def msg_window():
msg.winfo_toplevel() msg.winfo_toplevel()
def msg_exp_successful_window():
msg = tk.Toplevel()
msg.resizable(width=False, height=False)
msg.x_width = 340
msg.y_height = 140
msg.title('Import error!')
msg.monitor_center_x = msg.winfo_screenwidth() / 2 - (msg.x_width / 2)
msg.monitor_center_y = msg.winfo_screenheight() / 2 - (msg.y_height / 2)
msg.geometry('%dx%d+%d+%d' % (msg.x_width, msg.y_height, msg.monitor_center_x, msg.monitor_center_y))
msg.columnconfigure(0, weight=1)
msg.configure(pady=20)
msg.warning = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/64/info.png')
msg.i_warning = tk.Label(msg, image=msg.warning)
msg.i_warning.grid(column=0, row=0)
label = tk.Label(msg, text='Your zip file is in home directory')
label.config(font=('Ubuntu', 11), padx=15, pady=15)
label.grid(column=1, row=0)
button = tk.Button(msg, text='OK', command=msg.destroy)
button.config(padx=15, pady=5)
button.grid(column=0, columnspan=2, row=1)
wg_icon_2 = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn.png')
msg.iconphoto(True, wg_icon_2)
msg.winfo_toplevel()
def msg_exp_fail_window():
msg = tk.Toplevel()
msg.resizable(width=False, height=False)
msg.x_width = 340
msg.y_height = 140
msg.title('Export error!')
msg.monitor_center_x = msg.winfo_screenwidth() / 2 - (msg.x_width / 2)
msg.monitor_center_y = msg.winfo_screenheight() / 2 - (msg.y_height / 2)
msg.geometry('%dx%d+%d+%d' % (msg.x_width, msg.y_height, msg.monitor_center_x, msg.monitor_center_y))
msg.columnconfigure(0, weight=1)
msg.configure(pady=20)
msg.warning = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/64/error.png')
msg.i_warning = tk.Label(msg, image=msg.warning)
msg.i_warning.grid(column=0, row=0)
label = tk.Label(msg, text='Export failed! Please try again')
label.config(font=('Ubuntu', 11), padx=15, pady=15)
label.grid(column=1, row=0)
button = tk.Button(msg, text='OK', command=msg.destroy)
button.config(padx=15, pady=5)
button.grid(column=0, columnspan=2, row=1)
wg_icon_2 = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_msg.png')
msg.iconphoto(True, wg_icon_2)
msg.winfo_toplevel()
class GreenLabel: class GreenLabel:
def __init__(self): def __init__(self):
self.StrVar = None self.StrVar = None
@ -306,9 +356,8 @@ class ExportTunnels:
shutil.make_archive(wg_tar, 'zip', p_to_conf) shutil.make_archive(wg_tar, 'zip', p_to_conf)
with zipfile.ZipFile((wg_tar + '.zip'), 'r') as zf: with zipfile.ZipFile((wg_tar + '.zip'), 'r') as zf:
if len(zf.namelist()) != 0: if len(zf.namelist()) != 0:
messagebox.showinfo('Wire_py Export', 'Tarfile is in your Homedirectory') msg_exp_successful_window()
else: else:
messagebox.showerror('Wire_py Export', 'Tarfile is failed please resume Export') msg_exp_fail_window()
except TypeError: except TypeError:
pass pass

BIN
wp-icons/128/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
wp-icons/256/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
wp-icons/32/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
wp-icons/48/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
wp-icons/64/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB