Merge pull request 'add Class StartStopBTN to wg_func.py' (#6) from wire-py-reformat-14-08-2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/6
This commit is contained in:
commit
0b9eec8d1d
@ -4,8 +4,7 @@
|
|||||||
<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="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel">
|
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="add file dict_to_address for address a active Tunnel. Label green pack in Class. add Class to convert fileoutput as String to Dictionary">
|
||||||
<change afterPath="$PROJECT_DIR$/dict_to_address" 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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" 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" />
|
||||||
@ -147,7 +146,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1724102937260</updated>
|
<updated>1724102937260</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="8" />
|
<task id="LOCAL-00008" summary="add file dict_to_address for address a active Tunnel. Label green pack in Class. add Class to convert fileoutput as String to Dictionary">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1724233806458</created>
|
||||||
|
<option name="number" value="00008" />
|
||||||
|
<option name="presentableId" value="LOCAL-00008" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1724233806458</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="9" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
@ -181,6 +188,18 @@
|
|||||||
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic" />
|
<MESSAGE value="add class Frame and class Massage, delete funktion go 100%, add resize window, add warning pic" />
|
||||||
<MESSAGE value="add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)" />
|
<MESSAGE value="add class ListTunnels and class ImportTunnel, and add class ExportTunnels (ExportTunnels no finish)" />
|
||||||
<MESSAGE value="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel" />
|
<MESSAGE value="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="add Label Interface and Peer to new FrameWidget one and two. when import Tunnel then add to list works and remove of list when Tunnel delete.(with Label active on and off) add to class and methods open a avtive Tunnel when Wire-Py open, when import and start a Tunnel" />
|
<MESSAGE value="add file dict_to_address for address a active Tunnel. Label green pack in Class. add Class to convert fileoutput as String to Dictionary" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="add file dict_to_address for address a active Tunnel. Label green pack in Class. add Class to convert fileoutput as String to Dictionary" />
|
||||||
|
</component>
|
||||||
|
<component name="XDebuggerManager">
|
||||||
|
<breakpoint-manager>
|
||||||
|
<breakpoints>
|
||||||
|
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||||
|
<url>file://$PROJECT_DIR$/wg_func.py</url>
|
||||||
|
<line>116</line>
|
||||||
|
<option name="timeStamp" value="3" />
|
||||||
|
</line-breakpoint>
|
||||||
|
</breakpoints>
|
||||||
|
</breakpoint-manager>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,3 +1,3 @@
|
|||||||
192.168.178.158/24
|
10.64.1.5/32
|
||||||
192.168.178.1,
|
10.64.1.1
|
||||||
rj2cexasg9b9oydd.myfritz.net:54775
|
wg.iunix.dedyn.io:51820
|
||||||
|
24
main.py
24
main.py
@ -4,7 +4,7 @@ import tkinter as tk
|
|||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
|
|
||||||
from wg_func import (TunnelActiv, ListTunnels, ImportTunnel,
|
from wg_func import (TunnelActiv, ListTunnels, ImportTunnel,
|
||||||
ConToDict, GreenLabel, ExportTunnels)
|
ConToDict, GreenLabel, StartStopBTN, ExportTunnels)
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(tk.Tk):
|
class MainWindow(tk.Tk):
|
||||||
@ -37,8 +37,6 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.wg_read = None
|
self.wg_read = None
|
||||||
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
|
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
|
||||||
self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
|
self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
|
||||||
self.wgi_on = tk.PhotoImage(file=r'icons/wire-switch-on-48.png')
|
|
||||||
self.wgi_off = tk.PhotoImage(file=r'icons/wire-switch-off-48.png')
|
|
||||||
self.imp_pic = tk.PhotoImage(file=r'icons/wg-import.png')
|
self.imp_pic = tk.PhotoImage(file=r'icons/wg-import.png')
|
||||||
self.tr_pic = tk.PhotoImage(file=r'icons/wg-trash-48.png')
|
self.tr_pic = tk.PhotoImage(file=r'icons/wg-trash-48.png')
|
||||||
self.exp_pic = tk.PhotoImage(file=r'icons/wg-export-48.png')
|
self.exp_pic = tk.PhotoImage(file=r'icons/wg-export-48.png')
|
||||||
@ -97,15 +95,13 @@ class FrameWidgets(ttk.Frame):
|
|||||||
|
|
||||||
# Button Vpn
|
# Button Vpn
|
||||||
if self.a != '':
|
if self.a != '':
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
StartStopBTN.button_stop(self)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
|
||||||
wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
|
wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
|
||||||
file = open(wg_read, 'r')
|
file = open(wg_read, 'r')
|
||||||
ConToDict.covert_to_dict(file)
|
ConToDict.covert_to_dict(file)
|
||||||
file.close()
|
file.close()
|
||||||
else:
|
else:
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
|
StartStopBTN.button_start(self)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
|
||||||
# Button Import
|
# Button Import
|
||||||
self.btn_i = tk.Button(self, image=self.imp_pic, bd=0, command=lambda: ImportTunnel.wg_import_select(self))
|
self.btn_i = tk.Button(self, image=self.imp_pic, bd=0, command=lambda: ImportTunnel.wg_import_select(self))
|
||||||
self.btn_i.grid(column=0, row=2, padx=15, pady=15)
|
self.btn_i.grid(column=0, row=2, padx=15, pady=15)
|
||||||
@ -118,8 +114,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
os.remove(os.environ['HOME'] + '/tester/' + str(select_tl) + '.conf')
|
os.remove(os.environ['HOME'] + '/tester/' + str(select_tl) + '.conf')
|
||||||
if self.a != '':
|
if self.a != '':
|
||||||
self.StrVar.set(value='')
|
self.StrVar.set(value='')
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
|
StartStopBTN.button_start(self)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
|
||||||
self.l_box.update()
|
self.l_box.update()
|
||||||
|
|
||||||
# Button Trash
|
# Button Trash
|
||||||
@ -138,7 +133,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
def wg_switch(self):
|
def wg_switch(self):
|
||||||
self.a = TunnelActiv.active()
|
self.a = TunnelActiv.active()
|
||||||
if self.a == '':
|
if self.a == '':
|
||||||
|
StartStopBTN.button_start(self)
|
||||||
self.select_tunnel = self.l_box.curselection()
|
self.select_tunnel = self.l_box.curselection()
|
||||||
select_tl = self.l_box.get(self.select_tunnel[0])
|
select_tl = self.l_box.get(self.select_tunnel[0])
|
||||||
os.system('nmcli connection up ' + str(select_tl))
|
os.system('nmcli connection up ' + str(select_tl))
|
||||||
@ -147,20 +142,17 @@ class FrameWidgets(ttk.Frame):
|
|||||||
ConToDict.covert_to_dict(file)
|
ConToDict.covert_to_dict(file)
|
||||||
file.close()
|
file.close()
|
||||||
# Button Start/Stop
|
# Button Start/Stop
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
StartStopBTN.button_stop(self)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
|
||||||
self.a = TunnelActiv.active()
|
self.a = TunnelActiv.active()
|
||||||
self.StrVar = tk.StringVar()
|
self.StrVar = tk.StringVar()
|
||||||
self.StrVar.set(self.a)
|
self.StrVar.set(self.a)
|
||||||
GreenLabel.green_show_label(self)
|
GreenLabel.green_show_label(self)
|
||||||
elif self.a != '':
|
elif self.a != '':
|
||||||
# Button Start/Stop
|
# Button Start/Stop
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
StartStopBTN.button_stop(self)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
|
||||||
os.system('nmcli connection down ' + str(self.a))
|
os.system('nmcli connection down ' + str(self.a))
|
||||||
# Button Start/Stop
|
# Button Start/Stop
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
|
StartStopBTN.button_start(self)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
|
||||||
self.a = TunnelActiv.active()
|
self.a = TunnelActiv.active()
|
||||||
self.StrVar = tk.StringVar()
|
self.StrVar = tk.StringVar()
|
||||||
self.StrVar.set(value=' ')
|
self.StrVar.set(value=' ')
|
||||||
|
20
wg_func.py
20
wg_func.py
@ -41,6 +41,23 @@ class GreenLabel(tk.Tk):
|
|||||||
self.lb_tunnel.grid(column=3, row=1, sticky="w")
|
self.lb_tunnel.grid(column=3, row=1, sticky="w")
|
||||||
|
|
||||||
|
|
||||||
|
class StartStopBTN(tk.Tk):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.wg_switch = None
|
||||||
|
self.btn_stst = None
|
||||||
|
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
|
||||||
|
self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
|
||||||
|
|
||||||
|
def button_stop(self):
|
||||||
|
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
||||||
|
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
||||||
|
|
||||||
|
def button_start(self):
|
||||||
|
self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
|
||||||
|
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
||||||
|
|
||||||
|
|
||||||
class ConToDict:
|
class ConToDict:
|
||||||
@classmethod
|
@classmethod
|
||||||
def covert_to_dict(cls, file):
|
def covert_to_dict(cls, file):
|
||||||
@ -138,8 +155,7 @@ class ImportTunnel:
|
|||||||
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
|
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
|
||||||
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
|
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
|
||||||
self.lb_tunnel.grid(column=3, row=1, sticky="w")
|
self.lb_tunnel.grid(column=3, row=1, sticky="w")
|
||||||
self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
StartStopBTN.button_stop(self)
|
||||||
self.btn_stst.grid(column=0, row=1, padx=15, pady=15, sticky="s")
|
|
||||||
wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
|
wg_read = os.environ['HOME'] + '/tester/' + str(self.a) + '.conf'
|
||||||
file = open(wg_read, 'r')
|
file = open(wg_read, 'r')
|
||||||
ConToDict.covert_to_dict(file)
|
ConToDict.covert_to_dict(file)
|
||||||
|
Loading…
Reference in New Issue
Block a user