- Add Options, Help, Update Label and Update Menubutton

- Theme now separate Light and Dark
This commit is contained in:
Désiré Werner Menrath 2024-10-19 18:04:36 +02:00
parent c645d23514
commit bcdabadd0e
4 changed files with 85 additions and 91 deletions

View File

@ -5,39 +5,7 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment=" - Theme modify to water-theme&#10; - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu"> <list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment=" - Theme modify to water-theme&#10; - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu">
<change afterPath="$PROJECT_DIR$/TK-Themes/water.tcl" 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$/TK-Themes/azure.tcl" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark.tcl" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark.tcl" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/box-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/box-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/check-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/check-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/check-tri-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/check-tri-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/circle-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/circle-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/combo-button-focus.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/combo-button-focus.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/hor-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/hor-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/on-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/on-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/radio-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/radio-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/radio-tri-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/radio-tri-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/rect-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/rect-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/tab-basic.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/tab-basic.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/tick-hor-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/tick-hor-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/tick-vert-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/tick-vert-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/tree-pressed.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/tree-pressed.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/dark/vert-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/dark/vert-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light.tcl" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light.tcl" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/box-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/box-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/check-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/check-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/check-tri-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/check-tri-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/circle-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/circle-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/combo-button-focus.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/combo-button-focus.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/hor-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/hor-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/on-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/on-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/radio-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/radio-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/radio-tri-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/radio-tri-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/rect-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/rect-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/tick-hor-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/tick-hor-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/tick-vert-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/tick-vert-accent.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/TK-Themes/theme/light/vert-accent.png" beforeDir="false" afterPath="$PROJECT_DIR$/TK-Themes/theme/light/vert-accent.png" 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" />
<change beforePath="$PROJECT_DIR$/wg_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_main.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/wg_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_main.py" afterDir="false" />
</list> </list>
@ -169,14 +137,6 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1723279982210</updated> <updated>1723279982210</updated>
</task> </task>
<task id="LOCAL-00011" summary="Remove open file function, add Show Address Labels with tk.StrVar when remove a not active Tunnel Labels of Active Tunnel removed!">
<option name="closed" value="true" />
<created>1724371229008</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1724371229008</updated>
</task>
<task id="LOCAL-00012" summary="fixed error when active tunnel is deleted,&#10;now also the Address Label is emptied"> <task id="LOCAL-00012" summary="fixed error when active tunnel is deleted,&#10;now also the Address Label is emptied">
<option name="closed" value="true" /> <option name="closed" value="true" />
<created>1724400463791</created> <created>1724400463791</created>
@ -561,7 +521,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1729283656387</updated> <updated>1729283656387</updated>
</task> </task>
<option name="localTasksCounter" value="60" /> <task id="LOCAL-00060" summary=" - Theme modify to water-theme&#10; - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu">
<option name="closed" value="true" />
<created>1729283719951</created>
<option name="number" value="00060" />
<option name="presentableId" value="LOCAL-00060" />
<option name="project" value="LOCAL" />
<updated>1729283719951</updated>
</task>
<option name="localTasksCounter" value="61" />
<servers /> <servers />
</component> </component>
<component name="UnknownFeatures"> <component name="UnknownFeatures">
@ -629,4 +597,15 @@
<MESSAGE value=" - Theme modify to water-theme&#10; - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu" /> <MESSAGE value=" - Theme modify to water-theme&#10; - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu" />
<option name="LAST_COMMIT_MESSAGE" value=" - Theme modify to water-theme&#10; - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu" /> <option name="LAST_COMMIT_MESSAGE" value=" - Theme modify to water-theme&#10; - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu" />
</component> </component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/wg_main.py</url>
<line>185</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project> </project>

View File

@ -11,6 +11,12 @@ My standard System: Linux Mint 22 Cinnamon
- for loops with lists replaced by List Comprehensions - for loops with lists replaced by List Comprehensions
- Keeping Classes Together - Keeping Classes Together
### Added
19-10-2024
- Add Options, Help, Update Label and Update Menubutton
- Theme now separate Light and Dark
### Added ### Added
16-10-2024 16-10-2024

View File

@ -12,7 +12,7 @@ from tkinter import filedialog, ttk
import requests import requests
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year ''' ''' 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_file = Path('/etc/wire_py/wg_py')
path_to_file2 = Path('/etc/wire_py/settings') path_to_file2 = Path('/etc/wire_py/settings')
@ -115,7 +115,13 @@ class GreenLabel:
self.lb_tunnel = None self.lb_tunnel = None
def green_show_label(self): 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.config(font=('Ubuntu', 11, 'bold'))
self.lb_tunnel.grid(column=2, padx=10, row=1) self.lb_tunnel.grid(column=2, padx=10, row=1)
self.columnconfigure(2, weight=1) self.columnconfigure(2, weight=1)
@ -458,7 +464,7 @@ class OnOff:
self.autoconnect_var = tk.StringVar() self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con) 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.config(font=('Ubuntu', 11))
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=19) self.autoconnect.grid(column=0, row=4, sticky='ne', pady=19)
@ -484,6 +490,8 @@ class ExportTunnels:
source = Path('/tmp/wire_py') source = Path('/tmp/wire_py')
Path.unlink(Path(source) / 'wg_py', missing_ok=True) Path.unlink(Path(source) / 'wg_py', missing_ok=True)
Path.unlink(Path(source) / '.keys', 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.make_archive(wg_tar, 'zip', source)
shutil.chown(wg_tar + '.zip', 1000, 1000) shutil.chown(wg_tar + '.zip', 1000, 1000)
shutil.rmtree(source) shutil.rmtree(source)

View File

@ -6,8 +6,8 @@ from tkinter import *
from pathlib import Path from pathlib import Path
from tkinter import ttk from tkinter import ttk
from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLabel, StartStopBTN, ShowAddress, from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLabel, StartStopBTN, ShowAddress,
FileHandle, ExportTunnels, OnOff, msg_window, WirePyUpdate, res, version, FileHandle, ExportTunnels, OnOff, msg_window, WirePyUpdate, res, version, path_to_file2,
path_to_file2, path_to_file3) path_to_file3)
tcl_path = Path('/usr/share/TK-Themes') tcl_path = Path('/usr/share/TK-Themes')
@ -19,26 +19,24 @@ class MainWindow(tk.Tk):
self.switch_on = None self.switch_on = None
self.switch_off = None self.switch_off = None
self.x_width = 600 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_x = self.winfo_screenwidth() / 2 - (self.x_width / 2)
self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 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.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.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.style = ttk.Style(self)
#self.tk.call('source', str(tcl_path) + '/azure.tcl') self.tk.call('source', str(tcl_path) + '/water.tcl')
self.tk.call('source', 'TK-Themes/water.tcl') #self.tk.call('source', 'TK-Themes/water.tcl')
with open(path_to_file3, 'r') as read_file: with open(path_to_file3, 'r') as read_file:
if 'light' in read_file: if 'light' in read_file:
self.tk.call('set_theme', 'light') self.tk.call('set_theme', 'light')
else: else:
self.tk.call('set_theme', 'dark') self.tk.call('set_theme', 'dark')
''' Load the image file from disk. ''' ''' Load the image file from disk. '''
self.wg_icon = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn.png') self.wg_icon = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn.png')
# Set it as the window icon. # Set it as the window icon.
self.iconphoto(True, self.wg_icon) self.iconphoto(True, self.wg_icon)
@ -53,21 +51,28 @@ class MainWindow(tk.Tk):
set_file2.write('Update on') set_file2.write('Update on')
# Set dark or light # Set dark or light
def theme_change(): def theme_change_light():
if self.tk.call("ttk::style", "theme", "use") == "water-dark": if self.tk.call("ttk::style", "theme", "use") == "water-dark":
# Set light theme # Set light theme
self.tk.call('set_theme', 'light') self.tk.call('set_theme', 'light')
with open(path_to_file3, 'w') as theme_set2: with open(path_to_file3, 'w') as theme_set2:
theme_set2.write('light') theme_set2.write('light')
else: def theme_change_dark():
if not self.tk.call("ttk::style", "theme", "use") == "water-dark":
# Set dark theme # Set dark theme
self.tk.call('set_theme', 'dark') self.tk.call('set_theme', 'dark')
with open(path_to_file3, 'w') as theme_set2: with open(path_to_file3, 'w') as theme_set2:
theme_set2.write('dark') 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 ''' ''' Frame for Menu '''
self.menu_frame = ttk.Frame(self) self.menu_frame = ttk.Frame(self)
self.menu_frame.configure(relief='flat') self.menu_frame.configure(relief='flat')
@ -87,43 +92,39 @@ class MainWindow(tk.Tk):
self.settings = tk.Menu(self) self.settings = tk.Menu(self)
self.options_btn.configure(menu=self.settings, style='Toolbutton') 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_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) ''' Update Label '''
#self.to_load.add_command(label='Download Update', command=WirePyUpdate.download) self.updates_lb = ttk.Label(self.menu_frame)
#self.app_menu.add_cascade(label=version, foreground='#0071ff', activebackground=activ_background, self.updates_lb.grid(column=3, row=0, padx=10)
# activeforeground=activ_foreground)
#self.app_menu.add_cascade(label='Options', menu=self.settings)
#self.app_menu.add_cascade(label='?')
#if res == 'False': if res == 'False':
# set_option.set(value=1) set_option.set(value=1)
# self.app_menu.add_cascade(label='Update search off', state='disabled') self.updates_lb.configure(text='Update search off')
#elif res == 'No Internet Connection!': elif res == 'No Internet Connection!':
# self.app_menu.add_cascade(label='No Internet Connection!', foreground='red', activebackground=back_gd, self.updates_lb.configure(text='No Server Connection!', foreground='red')
# activeforeground='red') elif res == 'No Updates':
#elif res == 'No Updates': self.updates_lb.configure(text='No Updates')
# self.app_menu.add_cascade(label='No Updates', activeforeground=fore_gd, activebackground=back_gd) else:
# set_option.set(value=0)
#else: text = f'Update {res} available!'
# 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')
#with open(path_to_file3, 'r') as read_file: ''' Update BTN Menu'''
# if 'light' in read_file:
# self.app_menu.configure(background='#e0e2fd', foreground='black', activebackground='#e0e2fd')
# else: self.update_btn = ttk.Menubutton(self.menu_frame, text=text, )
# self.app_menu.configure(background='#424242', foreground='white', activebackground='#424242') 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() FrameWidgets(self).grid()