diff --git a/.idea/workspace.xml b/.idea/workspace.xml index bd46a9f..e671b91 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,39 +5,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -169,14 +137,6 @@ @@ -629,4 +597,15 @@ + + + + + file://$PROJECT_DIR$/wg_main.py + 185 + + + + \ No newline at end of file diff --git a/Changelog b/Changelog index c41d52b..884b39a 100644 --- a/Changelog +++ b/Changelog @@ -11,6 +11,12 @@ My standard System: Linux Mint 22 Cinnamon - for loops with lists replaced by List Comprehensions - Keeping Classes Together + ### Added +19-10-2024 + + - Add Options, Help, Update Label and Update Menubutton + - Theme now separate Light and Dark + ### Added 16-10-2024 diff --git a/wg_func.py b/wg_func.py index 8aef9a8..d373362 100755 --- a/wg_func.py +++ b/wg_func.py @@ -12,7 +12,7 @@ from tkinter import filedialog, ttk import requests ''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year ''' -version = 'v. 1.10.1824' +version = 'v. 1.10.1924' path_to_file = Path('/etc/wire_py/wg_py') path_to_file2 = Path('/etc/wire_py/settings') @@ -115,7 +115,13 @@ class GreenLabel: self.lb_tunnel = None def green_show_label(self): - self.lb_tunnel = ttk.Label(self, textvariable=self.StrVar) + with open(path_to_file3, 'r') as read_file: + if 'light' in read_file: + self.lb_tunnel = ttk.Label(self, textvariable=self.StrVar, foreground='green') + + else: + self.lb_tunnel = ttk.Label(self, textvariable=self.StrVar, foreground='yellow') + self.lb_tunnel.config(font=('Ubuntu', 11, 'bold')) self.lb_tunnel.grid(column=2, padx=10, row=1) self.columnconfigure(2, weight=1) @@ -458,7 +464,7 @@ class OnOff: self.autoconnect_var = tk.StringVar() self.autoconnect_var.set(self.auto_con) - self.autoconnect = ttk.Label(self, textvariable=self.autoconnect_var, foreground='blue') + self.autoconnect = ttk.Label(self, textvariable=self.autoconnect_var, foreground='#0071ff') self.autoconnect.config(font=('Ubuntu', 11)) self.autoconnect.grid(column=0, row=4, sticky='ne', pady=19) @@ -484,6 +490,8 @@ class ExportTunnels: source = Path('/tmp/wire_py') Path.unlink(Path(source) / 'wg_py', missing_ok=True) Path.unlink(Path(source) / '.keys', missing_ok=True) + Path.unlink(Path(source) / 'settings', missing_ok=True) + Path.unlink(Path(source) / 'theme', missing_ok=True) shutil.make_archive(wg_tar, 'zip', source) shutil.chown(wg_tar + '.zip', 1000, 1000) shutil.rmtree(source) diff --git a/wg_main.py b/wg_main.py index 6141a56..25715c3 100755 --- a/wg_main.py +++ b/wg_main.py @@ -6,8 +6,8 @@ from tkinter import * from pathlib import Path from tkinter import ttk from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLabel, StartStopBTN, ShowAddress, - FileHandle, ExportTunnels, OnOff, msg_window, WirePyUpdate, res, version, - path_to_file2, path_to_file3) + FileHandle, ExportTunnels, OnOff, msg_window, WirePyUpdate, res, version, path_to_file2, + path_to_file3) tcl_path = Path('/usr/share/TK-Themes') @@ -19,26 +19,24 @@ class MainWindow(tk.Tk): self.switch_on = None self.switch_off = None self.x_width = 600 - self.y_height = 390 + self.y_height = 400 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=False, height=False) self.title('Wire-Py') - #self.configure(background=back_gd) 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) + '/azure.tcl') - self.tk.call('source', 'TK-Themes/water.tcl') + self.tk.call('source', str(tcl_path) + '/water.tcl') + #self.tk.call('source', 'TK-Themes/water.tcl') with open(path_to_file3, 'r') as read_file: if 'light' in read_file: self.tk.call('set_theme', 'light') - else: self.tk.call('set_theme', 'dark') + ''' Load the image file from disk. ''' self.wg_icon = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn.png') + # Set it as the window icon. self.iconphoto(True, self.wg_icon) @@ -53,21 +51,28 @@ class MainWindow(tk.Tk): set_file2.write('Update on') # Set dark or light - def theme_change(): - + def theme_change_light(): if self.tk.call("ttk::style", "theme", "use") == "water-dark": # Set light theme self.tk.call('set_theme', 'light') - - with open(path_to_file3, 'w') as theme_set2: theme_set2.write('light') - else: + def theme_change_dark(): + if not self.tk.call("ttk::style", "theme", "use") == "water-dark": # Set dark theme self.tk.call('set_theme', 'dark') with open(path_to_file3, 'w') as theme_set2: theme_set2.write('dark') + def readme(): + """img_w, img_i, w_title, w_txt hand over""" + iw = r'/usr/share/icons/wp-icons/64/info.png' + ii = r'/usr/share/icons/wp-icons/48/wg_msg.png' + wt = 'Select tunnel' + msg_t = 'Here comes the instructions for Wire-Py .' + msg_window(iw, ii, wt, msg_t) + + ''' Frame for Menu ''' self.menu_frame = ttk.Frame(self) self.menu_frame.configure(relief='flat') @@ -87,43 +92,39 @@ class MainWindow(tk.Tk): self.settings = tk.Menu(self) self.options_btn.configure(menu=self.settings, style='Toolbutton') self.settings.add_checkbutton(label='Disable updates', command=on_off, variable=set_option) - self.settings.add_command(label='Dark/Light', command=theme_change) + self.settings.add_command(label='Light', command=theme_change_light) + self.settings.add_command(label='Dark', command=theme_change_dark) + ''' Help BTN Menu / Label ''' + self.help_btn = ttk.Menubutton(self.menu_frame, text='Help') + self.help_btn.grid(column=2, row=0) + self.readme = tk.Menu(self) + self.help_btn.configure(menu=self.readme, style='Toolbutton') + self.readme.add_command(label='Readme', command=readme) - #self.to_load = tk.Menu(self.app_menu, tearoff=tk.NO) - #self.to_load.add_command(label='Download Update', command=WirePyUpdate.download) - #self.app_menu.add_cascade(label=version, foreground='#0071ff', activebackground=activ_background, - # activeforeground=activ_foreground) - #self.app_menu.add_cascade(label='Options', menu=self.settings) - #self.app_menu.add_cascade(label='?') + ''' Update Label ''' + self.updates_lb = ttk.Label(self.menu_frame) + self.updates_lb.grid(column=3, row=0, padx=10) - #if res == 'False': - # set_option.set(value=1) - # self.app_menu.add_cascade(label='Update search off', state='disabled') - #elif res == 'No Internet Connection!': - # self.app_menu.add_cascade(label='No Internet Connection!', foreground='red', activebackground=back_gd, - # activeforeground='red') - #elif res == 'No Updates': - # self.app_menu.add_cascade(label='No Updates', activeforeground=fore_gd, activebackground=back_gd) -# - #else: - # set_option.set(value=0) - # with open(path_to_file3, 'r') as read_file: - # if 'light' in read_file: - # self.tk.call('set_theme', 'light') - # self.app_menu.add_cascade(label=f'Update {res} available!', menu=self.to_load, foreground='green', - # activebackground=activ_background, activeforeground='green') - # else: - # self.app_menu.add_cascade(label=f'Update {res} available!', menu=self.to_load, - # foreground='yellow', activebackground=activ_background, - # activeforeground='yellow') + if res == 'False': + set_option.set(value=1) + self.updates_lb.configure(text='Update search off') + elif res == 'No Internet Connection!': + self.updates_lb.configure(text='No Server Connection!', foreground='red') + elif res == 'No Updates': + self.updates_lb.configure(text='No Updates') + else: + set_option.set(value=0) + text = f'Update {res} available!' - #with open(path_to_file3, 'r') as read_file: - # if 'light' in read_file: - # self.app_menu.configure(background='#e0e2fd', foreground='black', activebackground='#e0e2fd') + ''' Update BTN Menu''' - # else: - # self.app_menu.configure(background='#424242', foreground='white', activebackground='#424242') + self.update_btn = ttk.Menubutton(self.menu_frame, text=text, ) + self.update_btn.grid(column=4, row=0, padx=0) + self.download = tk.Menu(self) + + self.update_btn.configure(menu=self.download, style='Toolbutton') + self.download.add_command(label='Download', command=WirePyUpdate.download) FrameWidgets(self).grid()