27 Commits

Author SHA1 Message Date
03a7e48018 Merge pull request '1.11.0824' (#23) from 1.11.0824 into main
Reviewed-on: #23
2024-11-08 21:24:31 +01:00
090842ab28 wg_func.py aktualisiert 2024-11-08 21:23:59 +01:00
8a32065676 - methods from class MainWindow move to class FrameWidgets for active color_label when theme change
- optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets
- add new Frame for Widgets on Bottom
- optimize from tkinter * to from tkinter import filedialog, ttk, TclError
2024-11-08 21:21:43 +01:00
bc0d46d633 - methods from class MainWindow move to class FrameWidgets for active color_label when theme change
- optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets
- add new Frame for Widgets on Bottom
- optimize from tkinter * to from tkinter import filedialog, ttk, TclError
2024-11-08 20:49:59 +01:00
80c63eaf78 rows adjusted 2024-11-07 19:49:35 +01:00
9eb99f0859 Changelog aktualisiert
Changelog  updated
2024-11-07 19:30:08 +01:00
feb6217637 wg_func.py aktualisiert
Version number adjusted
2024-11-07 19:27:57 +01:00
4bfc8c318e Version number adjusted 2024-11-07 19:24:16 +01:00
5f6aaa6cf1 Merge pull request '1.11.0724' (#22) from 1.11.0724 into main
Reviewed-on: #22
2024-11-07 19:16:22 +01:00
63ed0abc98 testtheme.py gelöscht 2024-10-26 12:31:53 +02:00
3102c685fd Merge pull request '1.10.2124' (#21) from 1.10.2124 into main
Reviewed-on: #21
2024-10-22 12:41:47 +02:00
ec10f912ea Merge pull request '- Fix a ConToDict Class when Endpoint not in Wireguard config file' (#20) from 1.10.2024 into main
Reviewed-on: #20
2024-10-20 12:20:41 +02:00
96164eb132 Merge pull request '- Add Options, Help, Update Label and Update Menubutton' (#19) from 1.10.2024 into main
Reviewed-on: #19
2024-10-20 02:15:23 +02:00
a19f889950 Merge pull request '1.10.1924' (#18) from 1.10.1924 into main
Reviewed-on: #18
2024-10-19 18:06:55 +02:00
de2929896d Merge pull request '- Create file for settings (Autoupdate)' (#17) from 1.10.1224 into main
Reviewed-on: #17
2024-10-12 13:39:04 +02:00
f9d4256679 Merge pull request 'Fix msg_window and remove x , y argument' (#16) from 1.10.0424 into main
Reviewed-on: #16
2024-10-04 21:01:26 +02:00
a0b895438c Merge pull request '28-09-2024' (#15) from 28-09-2024 into main
Reviewed-on: #15
2024-09-28 14:17:38 +02:00
4c89488950 Merge pull request 'wire-py-reformat-14-09-2024' (#14) from wire-py-reformat-14-09-2024 into main
Reviewed-on: #14
2024-09-14 23:31:00 +02:00
c0ae2d2b75 Merge pull request 'wire-py-reformat-14-08-2024' (#13) from wire-py-reformat-14-08-2024 into main
Reviewed-on: #13
2024-09-05 22:22:00 +02:00
e4774abf19 Merge pull request 'fixes on empty Listbox now is disable and now works autoconnect label with read and write, delete works now with read and write' (#12) from wire-py-reformat-14-08-2024 into main
Reviewed-on: #12
2024-09-04 20:55:51 +02:00
7b1e543428 Merge pull request 'add if question and add autoconnect, autoconnect_var to class Filehandle in box_set no finish!' (#11) from wire-py-reformat-14-08-2024 into main
Reviewed-on: #11
2024-09-04 09:20:05 +02:00
6f83fc7162 Merge pull request 'wire-py-reformat-14-08-2024' (#10) from wire-py-reformat-14-08-2024 into main
Reviewed-on: #10
2024-09-04 06:26:30 +02:00
b70400b456 Merge pull request 'wire-py-reformat-14-08-2024' (#9) from wire-py-reformat-14-08-2024 into main
Reviewed-on: #9
2024-08-25 20:32:05 +02:00
e25bc154ea Merge pull request 'wire-py-reformat-14-08-2024' (#8) from wire-py-reformat-14-08-2024 into main
Reviewed-on: #8
2024-08-23 18:00:19 +02:00
7aa3cd75fe Merge pull request 'Set Style to Clam' (#7) from wire-py-reformat-14-08-2024 into main
Reviewed-on: #7
2024-08-21 22:52:27 +02:00
0b9eec8d1d Merge pull request 'add Class StartStopBTN to wg_func.py' (#6) from wire-py-reformat-14-08-2024 into main
Reviewed-on: #6
2024-08-21 12:52:51 +02:00
b9083d4698 Merge pull request 'add file dict_to_address for' (#5) from wire-py-reformat-14-08-2024 into main
Reviewed-on: #5
2024-08-21 12:00:18 +02:00
3 changed files with 106 additions and 111 deletions

View File

@ -8,6 +8,25 @@ My standard System: Linux Mint 22 Cinnamon
- for loops with lists replaced by List Comprehensions
- Update search after start of Wire-Py
### Added
07-11-2024
- remove classes and add methods to class FrameWidgets (removed self errors)
### Added
08-11-2024
- methods from class MainWindow move to class FrameWidgets for active color_label when theme change
- optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets
- add new Frame for Widgets on Bottom
- optimize from tkinter * to from tkinter import filedialog, ttk, TclError
### Added
07-11-2024
- remove classes and add methods to class FrameWidgets (removed self errors)
### Added
27-10-2024

View File

@ -14,7 +14,7 @@ import requests
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year '''
version = 'v. 1.10.2124'
version = 'v. 1.11.0824'
path_to_file2 = Path('/etc/wire_py/settings.conf')
_u = Path.read_text(Path('/tmp/_u'))
@ -265,6 +265,3 @@ class Tunnel:
return True
tips = Tunnel.if_tip()

View File

@ -5,8 +5,7 @@ import subprocess
import tkinter as tk
from pathlib import Path
from subprocess import check_call
from tkinter import *
from tkinter import filedialog, ttk
from tkinter import filedialog, ttk, TclError
from wg_func import (Tunnel, msg_window, WirePyUpdate, res, _u, version, path_to_file2, tips)
@ -19,15 +18,16 @@ class MainWindow(tk.Tk):
super().__init__(*args, **kwargs)
self.my_tool_tip = None
self.switch_on = None
self.switch_off = None
self.x_width = 600
self.y_height = 400
self.y_height = 383
self.monitor_center_x = self.winfo_screenwidth() / 2 - (self.x_width / 2)
self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 2)
self.resizable(width=False, height=False)
self.resizable(width=True, height=True)
self.title('Wire-Py')
self.geometry('%dx%d+%d+%d' % (self.x_width, self.y_height, self.monitor_center_x, self.monitor_center_y))
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
self.style = ttk.Style(self)
self.tk.call('source', str(tcl_path) + '/water.tcl')
''' self.tk.call('source', 'TK-Themes/water.tcl') '''
@ -44,6 +44,28 @@ class MainWindow(tk.Tk):
''' Set it as the window icon '''
self.iconphoto(True, self.wg_icon)
FrameWidgets(self).grid()
class FrameWidgets(ttk.Frame):
def __init__(self, container, **kwargs):
super().__init__(container, **kwargs)
self.lb_tunnel = None
self.btn_stst = None
self.endpoint = None
self.dns = None
self.address = None
self.auto_con = None
self.wg_vpn_start = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-start.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-stop.png')
self.imp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_import.png')
self.tr_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_trash.png')
self.exp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_export.png')
self.warning_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/64/error.png')
self.wg_vpn_start = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-start.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-stop.png')
''' Set on or off in file '''
def update():
@ -61,7 +83,7 @@ class MainWindow(tk.Tk):
with open(path_to_file2, 'w') as set_file2:
set_file2.writelines(lines2)
''' Set on or off in file '''
''' Set True or False in file '''
def tooltip():
if set_tip.get():
@ -89,6 +111,7 @@ class MainWindow(tk.Tk):
lines3[3] = 'light\n'
with open(path_to_file2, 'w') as theme_set2:
theme_set2.writelines(lines3)
self.color_label()
def theme_change_dark():
if not self.tk.call("ttk::style", "theme", "use") == "water-dark":
@ -99,6 +122,7 @@ class MainWindow(tk.Tk):
lines4[3] = 'dark\n'
with open(path_to_file2, 'w') as theme_set2:
theme_set2.writelines(lines4)
self.color_label()
def info():
def link_btn():
@ -122,14 +146,12 @@ class MainWindow(tk.Tk):
''' Frame for Menu '''
self.menu_frame = ttk.Frame(self)
self.menu_frame.configure(relief='flat')
self.menu_frame.grid(column=0, row=0, sticky='w')
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
self.menu_frame.grid(column=0, row=0, columnspan=4, sticky='w')
''' App Menu '''
self.version_lb = ttk.Label(self.menu_frame, text=version)
self.version_lb.config(font=('Ubuntu', 11), foreground='#00c4ff')
self.version_lb.grid(column=0, row=0, padx=10)
self.version_lb.grid(column=0, row=0, rowspan=4, padx=10)
def version_enter(event):
""" The mouse moves into the Version widget """
@ -169,13 +191,11 @@ class MainWindow(tk.Tk):
''' About BTN Menu / Label '''
self.about_btn = ttk.Button(self.menu_frame, text='About', style='Toolbutton', command=info)
self.about_btn.grid(column=2, row=0)
self.readme = tk.Menu(self)
''' Update and Tooltip Label '''
self.updates_lb = ttk.Label(self.menu_frame)
self.updates_lb.grid(column=3, row=0, padx=10)
'''View Checkbox for enable or disable Tooltip '''
if tips:
set_tip.set(value=False)
@ -225,8 +245,7 @@ class MainWindow(tk.Tk):
def download_enter(event):
""" The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
'Click to download new version')
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Click to download new version')
def download_leave(_):
""" The mouse moves from the entry widget """
@ -240,35 +259,6 @@ class MainWindow(tk.Tk):
self.update_btn.configure(menu=self.download, style='Toolbutton')
self.download.add_command(label='Download', command=WirePyUpdate.download)
FrameWidgets(self).grid()
class FrameWidgets(ttk.Frame):
def __init__(self, container, **kwargs):
super().__init__(container, **kwargs)
self.endpoint = None
self.dns = None
self.address = None
self.btn_stst = None
self.auto_con = None
self.enp = None
self.DNS = None
self.add = None
self.data = None
self.peer = None
self.lb_tunnel = None
self.wg_read = None
self.wg_vpn_start = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-start.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-stop.png')
self.imp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_import.png')
self.tr_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_trash.png')
self.exp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_export.png')
self.warning_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/64/error.png')
self.wg_vpn_start = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-start.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-stop.png')
''' Show active Tunnel '''
self.a = Tunnel.active()
@ -276,30 +266,27 @@ class FrameWidgets(ttk.Frame):
self.lb_frame_btn_lbox = ttk.Frame(self)
self.lb_frame_btn_lbox.configure(relief='flat')
self.lb_frame_btn_lbox.grid(column=0, rowspan=3, row=1)
self.columnconfigure(0, weight=1)
self.rowconfigure(1, weight=1)
''' Label Frame 2 '''
self.lb_frame = ttk.Frame(self)
self.lb_frame.configure(relief='solid')
self.lb_frame.grid(column=2, row=2, sticky='snew', padx=20, pady=5)
self.columnconfigure(2, weight=1)
self.rowconfigure(2, weight=1)
''' Label Frame 3 '''
self.lb_frame2 = ttk.Frame(self)
self.lb_frame2.configure(relief='solid')
self.lb_frame2.grid(column=2, row=3, sticky='snew', padx=20, pady=5)
self.columnconfigure(2, weight=1)
self.rowconfigure(3, weight=1)
''' Bottom Frame 4 '''
self.lb_frame3 = ttk.Frame(self)
self.lb_frame3.configure(relief='flat')
self.lb_frame3.grid(column=0, row=5, columnspan=4, sticky='snew', padx=2, pady=2)
''' Show active Label '''
self.select_tunnel = None
self.lb = ttk.Label(self, text='Active: ')
self.lb.config(font=('Ubuntu', 11, 'bold'))
self.lb.grid(column=2, row=1, padx=15, pady=4, sticky='w')
self.columnconfigure(2, weight=1)
self.rowconfigure(0, weight=1)
''' Label to Show active Tunnel '''
self.StrVar = tk.StringVar(value=self.a)
@ -333,7 +320,6 @@ class FrameWidgets(ttk.Frame):
self.scrollbar = ttk.Scrollbar(self.lb_frame_btn_lbox, orient='vertical', command=self.l_box.yview)
self.scrollbar.grid(column=1, rowspan=4, row=0, sticky='nse')
self.l_box.configure(yscrollcommand=self.scrollbar.set)
self.rowconfigure(0, weight=1)
''' Tunnel List '''
self.tl = Tunnel.list()
@ -388,15 +374,12 @@ class FrameWidgets(ttk.Frame):
self.show_data()
''' Button Import '''
self.btn_i = ttk.Button(self.lb_frame_btn_lbox,
image=self.imp_pic, command=self.import_sl,
padding=0)
self.btn_i = ttk.Button(self.lb_frame_btn_lbox, image=self.imp_pic, command=self.import_sl, padding=0)
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
def imp_enter(event):
""" The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
'Click to import a Wireguard Tunnel')
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Click to import a Wireguard Tunnel')
def imp_leave(_):
""" The mouse moves from the entry widget """
@ -503,8 +486,7 @@ class FrameWidgets(ttk.Frame):
def empty_list_enter(event):
""" The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
'No tunnels to delete in the list')
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'No tunnels to delete in the list')
def empty_list_leave(_):
""" The mouse moves from the entry widget """
@ -529,14 +511,12 @@ class FrameWidgets(ttk.Frame):
self.btn_tr.bind('<Leave>', del_leave)
''' Button Export '''
self.btn_exp = ttk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, command=Tunnel.export,
padding=0)
self.btn_exp = ttk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, command=Tunnel.export, padding=0)
self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
def empty_list_enter(event):
""" The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
'No Tunnels in List for Export')
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'No Tunnels in List for Export')
def empty_list_leave(_):
""" The mouse moves from the entry widget """
@ -561,8 +541,8 @@ class FrameWidgets(ttk.Frame):
self.btn_exp.bind('<Leave>', exp_leave)
''' Label Entry '''
self.lb_rename = ttk.Entry(self, width=20)
self.lb_rename.grid(column=2, row=4, padx=30, pady=15, sticky='nw')
self.lb_rename = ttk.Entry(self.lb_frame3, width=20)
self.lb_rename.grid(column=2, row=0, padx=8, pady=10, sticky='ne')
self.lb_rename.insert(0, 'Max. 12 characters!')
self.lb_rename.config(state='disable')
@ -662,21 +642,21 @@ class FrameWidgets(ttk.Frame):
msg_window(iw, ii, wt, msg_t)
''' Button Rename '''
self.btn_rename = ttk.Button(self, text='Rename', state='disable', command=tl_rename, padding=4,
self.btn_rename = ttk.Button(self.lb_frame3, text='Rename', state='disable', command=tl_rename, padding=4,
style='RnButton.TButton')
self.btn_rename.grid(column=2, row=4, padx=20, pady=15, sticky='ne')
self.btn_rename.grid(column=3, row=0, padx=5, pady=10, sticky='ne')
''' Check Buttons '''
self.selected_option = tk.IntVar()
self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con)
''' Frame for Labels, Entry and Button'''
self.autoconnect = ttk.Label(self, textvariable=self.autoconnect_var)
self.autoconnect = ttk.Label(self.lb_frame3, textvariable=self.autoconnect_var, width=15)
self.autoconnect.config(font=('Ubuntu', 11))
self.autoconnect.grid(column=0, row=4, sticky='ne', padx=10, pady=15)
self.wg_autostart = ttk.Checkbutton(self, text='Autoconnect on:', variable=self.selected_option,
self.autoconnect.grid(column=1, row=0, sticky='e', pady=19)
self.wg_autostart = ttk.Checkbutton(self.lb_frame3, text='Autoconnect on:', variable=self.selected_option,
command=self.box_set)
self.wg_autostart.grid(column=0, row=4, pady=15, padx=15, sticky='nw')
self.wg_autostart.grid(column=0, row=0, pady=15, padx=15, sticky='nw')
def chk_enter(event):
""" The mouse moves into the entry widget """
@ -722,19 +702,17 @@ class FrameWidgets(ttk.Frame):
self.on_off()
"""
Import Methode for Wireguard config Files.
Before importing, it is checked whether PrivateKey and PublicKey are in the file.
If True then it is checked whether the PreSharedKey is already in the key file
to avoid an import error so that no double wgconf are imported.
Thus, tunnels can be renamed without the problems arise. If False then the key is written into the file.
Furthermore, it is checked whether the name is longer than 12 characters.
If True then the name is automatically shortened to 12 characters and then imported.
If in each case false comes out, a corresponding window comes to inform the user that something is wrong.
"""
def import_sl(self):
"""
Import Methode for Wireguard config Files.
Before importing, it is checked whether PrivateKey and PublicKey are in the file.
If True then it is checked whether the PreSharedKey is already in the key file
to avoid an import error so that no double wgconf are imported.
Thus, tunnels can be renamed without the problems arise. If False then the key is written into the file.
Furthermore, it is checked whether the name is longer than 12 characters.
If True then the name is automatically shortened to 12 characters and then imported.
If in each case false comes out, a corresponding window comes to inform the user that something is wrong.
"""
try:
filepath = filedialog.askopenfilename(initialdir=str(_u), title='Select Wireguard config File',
filetypes=[('WG config files', '*.conf')], )
@ -890,14 +868,12 @@ class FrameWidgets(ttk.Frame):
print('Tunnel exist!')
'''
This Method will display the autostart label which
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.
'''
def box_set(self):
"""
This Method will display the autostart label which
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.
"""
try:
select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(select_tunnel[0])
@ -926,13 +902,12 @@ class FrameWidgets(ttk.Frame):
self.on_off()
'''
Here it is checked whether the path to the file is there if not it is created.
Set (on), the selected tunnel is displayed in the label.
At (off) the label is first emptied then filled with No Autoconnect
'''
def on_off(self):
"""
Here it is checked whether the path to the file is there if not it is created.
Set (on), the selected tunnel is displayed in the label.
At (off) the label is first emptied then filled with No Autoconnect
"""
with open(path_to_file2, 'r') as set_file4:
lines4 = set_file4.readlines()
@ -949,16 +924,16 @@ class FrameWidgets(ttk.Frame):
self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con)
self.autoconnect = ttk.Label(self, textvariable=self.autoconnect_var, foreground='#0071ff')
self.autoconnect = ttk.Label(self.lb_frame3, textvariable=self.autoconnect_var, foreground='#0071ff', width=15)
self.autoconnect.config(font=('Ubuntu', 11))
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=19)
"""
Displays the value address, DNS and peer in the labels
or empty it again
"""
self.autoconnect.grid(column=1, row=0, sticky='e', pady=19)
def init_and_report(self, data=None):
"""
Displays the value address, DNS and peer in the labels
or empty it again
"""
""" Address Label """
self.add = tk.StringVar()
self.add.set('Address: ' + data[0])
@ -989,6 +964,7 @@ class FrameWidgets(ttk.Frame):
self.endpoint.config(font=('Ubuntu', 9))
def stop(self):
""" Stop Button """
self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, command=self.wg_switch, padding=0)
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
@ -1006,13 +982,13 @@ class FrameWidgets(ttk.Frame):
self.btn_stst.bind('<Leave>', stop_leave)
def start(self):
""" Start Button """
self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, command=self.wg_switch, padding=0)
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
def empty_list_start_enter(event):
""" The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
'No tunnels to start in the list')
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'No tunnels to start in the list')
def empty_list_start_leave(_):
""" The mouse moves from the entry widget """
@ -1038,6 +1014,8 @@ class FrameWidgets(ttk.Frame):
self.btn_stst.bind('<Leave>', start_leave)
def color_label(self):
""" View activ Tunnel in color green or yellow """
with open(path_to_file2, 'r') as read_file:
lines = read_file.readlines()
if 'light\n' in lines:
@ -1050,6 +1028,7 @@ class FrameWidgets(ttk.Frame):
self.lb_tunnel.grid(column=2, padx=10, row=1)
def wg_switch(self):
self.a = Tunnel.active()
try:
if self.a == '':