little fixes

This commit is contained in:
Désiré Werner Menrath 2024-09-26 21:18:48 +02:00
parent 6689d8110f
commit e1623ab184
3 changed files with 34 additions and 30 deletions

View File

@ -4,8 +4,10 @@
<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="ad max 12-character message, no character message and special_characters message for entry label"> <list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="info icon shadow fix end msg Export fix to">
<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_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_main.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -132,14 +134,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1723279982210</updated> <updated>1723279982210</updated>
</task> </task>
<task id="LOCAL-00003" summary="wg_import_select in wg_func.py extended">
<option name="closed" value="true" />
<created>1723847456806</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1723847456806</updated>
</task>
<task id="LOCAL-00004" summary="add class Frame and class Massage, delete funktion go 100%, add resize window"> <task id="LOCAL-00004" summary="add class Frame and class Massage, delete funktion go 100%, add resize window">
<option name="closed" value="true" /> <option name="closed" value="true" />
<created>1724013210356</created> <created>1724013210356</created>
@ -524,7 +518,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1727288788988</updated> <updated>1727288788988</updated>
</task> </task>
<option name="localTasksCounter" value="52" /> <task id="LOCAL-00052" summary="info icon shadow fix end msg Export fix to">
<option name="closed" value="true" />
<created>1727347126769</created>
<option name="number" value="00052" />
<option name="presentableId" value="LOCAL-00052" />
<option name="project" value="LOCAL" />
<updated>1727347126769</updated>
</task>
<option name="localTasksCounter" value="53" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures"> <component name="UnknownFeatures">
@ -565,7 +567,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" />
<MESSAGE value="little fixes replace os.system with check_call&#10;first steps in install Script add wg_start.service file" /> <MESSAGE value="little fixes replace os.system with check_call&#10;first steps in install Script add wg_start.service file" />
<MESSAGE value="little fixes a labels when stop and start, installer first functions works" /> <MESSAGE value="little fixes a labels when stop and start, installer first functions works" />
<MESSAGE value="little fixes, add msg_window() &#10;function for Messagebox to show a tk.Toplevel()&#10;replace var = open() with: &#10;with open() as var:&#10;and remove by classes (tk.tk) and super()" /> <MESSAGE value="little fixes, add msg_window() &#10;function for Messagebox to show a tk.Toplevel()&#10;replace var = open() with: &#10;with open() as var:&#10;and remove by classes (tk.tk) and super()" />
@ -590,31 +591,22 @@
<MESSAGE value="fix scrollbar view with set self.y_height = 330 to self.y_height = 340" /> <MESSAGE value="fix scrollbar view with set self.y_height = 330 to self.y_height = 340" />
<MESSAGE value="in msg_window two further parameters to be added to the pass, so height and wide can also be specified.&#10;In rename, messages come now if new names do not fit&#10;Fix Index Error on msg_window()" /> <MESSAGE value="in msg_window two further parameters to be added to the pass, so height and wide can also be specified.&#10;In rename, messages come now if new names do not fit&#10;Fix Index Error on msg_window()" />
<MESSAGE value="ad max 12-character message, no character message and special_characters message for entry label" /> <MESSAGE value="ad max 12-character message, no character message and special_characters message for entry label" />
<option name="LAST_COMMIT_MESSAGE" value="ad max 12-character message, no character message and special_characters message for entry label" /> <MESSAGE value="info icon shadow fix end msg Export fix to" />
<option name="LAST_COMMIT_MESSAGE" value="info icon shadow fix end msg Export fix to" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<breakpoints> <breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/wg_func.py</url> <url>file://$PROJECT_DIR$/wg_func.py</url>
<line>137</line> <line>184</line>
<option name="timeStamp" value="1" /> <option name="timeStamp" value="1" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/wg_func.py</url> <url>file://$PROJECT_DIR$/wg_func.py</url>
<line>196</line> <line>294</line>
<option name="timeStamp" value="2" /> <option name="timeStamp" value="2" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/wg_func.py</url>
<line>74</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/wg_func.py</url>
<line>348</line>
<option name="timeStamp" value="4" />
</line-breakpoint>
</breakpoints> </breakpoints>
</breakpoint-manager> </breakpoint-manager>
</component> </component>

View File

@ -10,6 +10,7 @@ from pathlib import Path
from subprocess import check_call from subprocess import check_call
font_color = '#4011a7' font_color = '#4011a7'
dk_theme = '#2e2e2e'
path_to_file = Path('/etc/wire_py/wg_py') path_to_file = Path('/etc/wire_py/wg_py')
_u = Path.read_text(Path('/tmp/_u')) _u = Path.read_text(Path('/tmp/_u'))
@ -34,19 +35,20 @@ def msg_window(img_w, img_i, w_title, w_txt, x, y):
msg.monitor_center_x = msg.winfo_screenwidth() / 2 - (msg.x_width / 2) 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.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.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=15)
msg.configure(pady=20)
msg.img = tk.PhotoImage(file=img_w) msg.img = tk.PhotoImage(file=img_w)
msg.i_window = tk.Label(msg, image=msg.img) msg.i_window = tk.Label(msg, image=msg.img)
msg.i_window.grid(column=0, row=0) msg.i_window.grid(column=0, row=0)
label = tk.Label(msg, text=w_txt) label = tk.Label(msg, text=w_txt)
label.config(font=('Ubuntu', 11), padx=15, pady=15) label.config(font=('Ubuntu', 11), padx=15)
label.grid(column=1, row=0) label.grid(column=1, row=0)
button = tk.Button(msg, text='OK', command=msg.destroy) button = tk.Button(msg, text='OK', command=msg.destroy)
button.config(padx=15, pady=5) button.config(padx=15)
button.grid(column=0, columnspan=2, row=1) button.grid(column=0, columnspan=2, row=1)
img_i = tk.PhotoImage(file=img_i) img_i = tk.PhotoImage(file=img_i)
msg.iconphoto(True, img_i) msg.iconphoto(True, img_i)
msg.columnconfigure(0, weight=1)
msg.rowconfigure(0, weight=1)
msg.winfo_toplevel() msg.winfo_toplevel()
@ -54,6 +56,7 @@ class GreenLabel:
""" """
Show the active tunnel in green in the label Show the active tunnel in green in the label
""" """
def __init__(self): def __init__(self):
self.StrVar = None self.StrVar = None
self.lb_tunnel = None self.lb_tunnel = None
@ -76,6 +79,7 @@ class StartStopBTN:
""" """
Show Start and Stop Button in Label Show Start and Stop Button in Label
""" """
def __init__(self): def __init__(self):
self.lb_frame_btn_lbox = None self.lb_frame_btn_lbox = None
self.wg_switch = None self.wg_switch = None
@ -97,6 +101,7 @@ class ConToDict:
The config file is packed into a dictionary, The config file is packed into a dictionary,
to display the values Address , DNS and Peer in the labels to display the values Address , DNS and Peer in the labels
""" """
@classmethod @classmethod
def covert_to_dict(cls, file): def covert_to_dict(cls, file):
dictlist = [] dictlist = []
@ -139,6 +144,7 @@ class TunnelActiv:
""" """
Shows the Active Tunnel Shows the Active Tunnel
""" """
@staticmethod @staticmethod
def active(): # Shows the active tunnel def active(): # Shows the active tunnel
active = os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"').read().split() active = os.popen('nmcli con show --active | grep -iPo "(.*)(wireguard)"').read().split()
@ -155,6 +161,7 @@ class ShowAddress:
Displays the value address, DNS and peer in the labels Displays the value address, DNS and peer in the labels
or empty it again or empty it again
""" """
def __init__(self): def __init__(self):
self.lb_frame2 = None self.lb_frame2 = None
self.lb_frame = None self.lb_frame = None
@ -198,6 +205,7 @@ class ListTunnels:
""" """
Shows all existing Wireguard tunnels Shows all existing Wireguard tunnels
""" """
@staticmethod @staticmethod
def tl_list(): def tl_list():
wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split() wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
@ -319,6 +327,7 @@ class FileHandle:
Tunnel is automatically started regardless of the active tunnel. Tunnel is automatically started regardless of the active tunnel.
The selected tunnel is written into a file to read it after the start of the system. The selected tunnel is written into a file to read it after the start of the system.
""" """
def __init__(self): def __init__(self):
self.wg_autostart = None self.wg_autostart = None
@ -352,6 +361,7 @@ class OnOff:
Set (on), the selected tunnel is displayed in the label. Set (on), the selected tunnel is displayed in the label.
At (off) the label is first emptied then filled with No Autoconnect At (off) the label is first emptied then filled with No Autoconnect
""" """
def __init__(self): def __init__(self):
self.wg_autostart = None self.wg_autostart = None
self.selected_option = None self.selected_option = None
@ -384,6 +394,7 @@ class ExportTunnels:
A zipfile with current date and time is created A zipfile with current date and time is created
in the user's home directory with correct right in the user's home directory with correct right
""" """
@staticmethod @staticmethod
def wg_export(): def wg_export():
_u1 = str(_u[6:]) _u1 = str(_u[6:])

View File

@ -10,6 +10,7 @@ from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLab
FileHandle, ExportTunnels, OnOff, msg_window) FileHandle, ExportTunnels, OnOff, msg_window)
font_color = '#4011a7' font_color = '#4011a7'
dk_theme = '#2e2e2e'
class MainWindow(tk.Tk): class MainWindow(tk.Tk):
@ -242,7 +243,7 @@ class FrameWidgets(ttk.Frame):
iw = r'/usr/share/icons/wp-icons/64/info.png' iw = r'/usr/share/icons/wp-icons/64/info.png'
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png' ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
wt = 'Renaming not possible' wt = 'Renaming not possible'
msg_t = 'No valid sign. These must not be used.\nBlank, Slash, Backslash and { }' msg_t = 'No valid sign. These must not be used.\nBlank, Slash, Backslash and { }\n'
x = 370 # width x = 370 # width
y = 130 # height y = 130 # height
msg_window(iw, ii, wt, msg_t, x, y) msg_window(iw, ii, wt, msg_t, x, y)