Merge pull request '- Add Options, Help, Update Label and Update Menubutton' (#19) from 1.10.2024 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/19
This commit is contained in:
commit
96164eb132
@ -4,7 +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=" - Theme modify to water-theme - 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=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark">
|
||||||
<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_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" />
|
||||||
@ -137,14 +137,6 @@
|
|||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1723279982210</updated>
|
<updated>1723279982210</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00012" summary="fixed error when active tunnel is deleted, now also the Address Label is emptied">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1724400463791</created>
|
|
||||||
<option name="number" value="00012" />
|
|
||||||
<option name="presentableId" value="LOCAL-00012" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1724400463791</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00013" summary="In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together">
|
<task id="LOCAL-00013" summary="In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
<created>1724401340512</created>
|
<created>1724401340512</created>
|
||||||
@ -529,7 +521,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1729283719951</updated>
|
<updated>1729283719951</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="61" />
|
<task id="LOCAL-00061" summary=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1729353898829</created>
|
||||||
|
<option name="number" value="00061" />
|
||||||
|
<option name="presentableId" value="LOCAL-00061" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1729353898830</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="62" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="UnknownFeatures">
|
<component name="UnknownFeatures">
|
||||||
@ -570,7 +570,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="fix rename in Messagebox warning to error" />
|
|
||||||
<MESSAGE value="set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open" />
|
<MESSAGE value="set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open" />
|
||||||
<MESSAGE value="fix set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open" />
|
<MESSAGE value="fix set rights in install and a .conf a import Tunnel Filedialog Part 1 /home when open" />
|
||||||
<MESSAGE value="fix a filedialog for hidden Files work install rollback to bash for start wirepy and wirepy rollback to bash" />
|
<MESSAGE value="fix a filedialog for hidden Files work install rollback to bash for start wirepy and wirepy rollback to bash" />
|
||||||
@ -595,17 +594,7 @@
|
|||||||
<MESSAGE value="Fix msg_window and remove x , y argument Install further adapted and with colored text if user is not in group sudo or wheel. Added to install Opensuse for installation" />
|
<MESSAGE value="Fix msg_window and remove x , y argument Install further adapted and with colored text if user is not in group sudo or wheel. Added to install Opensuse for installation" />
|
||||||
<MESSAGE value=" - Menu add - New Modern Dark and Light(default) Theme" />
|
<MESSAGE value=" - Menu add - New Modern Dark and Light(default) Theme" />
|
||||||
<MESSAGE value=" - Theme modify to water-theme - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu" />
|
<MESSAGE value=" - Theme modify to water-theme - 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 - add ttk.Menubutton vor modern Menu and automatic theme and textvariable for color on font in menu" />
|
<MESSAGE value=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark" />
|
||||||
</component>
|
<option name="LAST_COMMIT_MESSAGE" value=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark" />
|
||||||
<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>
|
</component>
|
||||||
</project>
|
</project>
|
@ -16,6 +16,7 @@ My standard System: Linux Mint 22 Cinnamon
|
|||||||
|
|
||||||
- Add Options, Help, Update Label and Update Menubutton
|
- Add Options, Help, Update Label and Update Menubutton
|
||||||
- Theme now separate Light and Dark
|
- Theme now separate Light and Dark
|
||||||
|
- Add Own Tooltip (Class and def's) Part One
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
16-10-2024
|
16-10-2024
|
||||||
|
32
wg_func.py
32
wg_func.py
@ -11,6 +11,7 @@ from subprocess import check_call
|
|||||||
from tkinter import filedialog, ttk
|
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.1924'
|
version = 'v. 1.10.1924'
|
||||||
|
|
||||||
@ -74,6 +75,7 @@ class WirePyUpdate:
|
|||||||
|
|
||||||
res = WirePyUpdate.api_down()
|
res = WirePyUpdate.api_down()
|
||||||
|
|
||||||
|
|
||||||
def msg_window(img_w, img_i, w_title, w_txt):
|
def msg_window(img_w, img_i, w_title, w_txt):
|
||||||
"""
|
"""
|
||||||
Function for different message windows for the user. with 4 arguments to be passed.
|
Function for different message windows for the user. with 4 arguments to be passed.
|
||||||
@ -133,7 +135,6 @@ class GreenLabel:
|
|||||||
def rowconfigure(self, param, weight):
|
def rowconfigure(self, param, weight):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class StartStopBTN:
|
class StartStopBTN:
|
||||||
"""
|
"""
|
||||||
Show Start and Stop Button in Label
|
Show Start and Stop Button in Label
|
||||||
@ -154,7 +155,6 @@ class StartStopBTN:
|
|||||||
self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, command=self.wg_switch, padding=0)
|
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)
|
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
|
||||||
|
|
||||||
|
|
||||||
class ConToDict:
|
class ConToDict:
|
||||||
"""
|
"""
|
||||||
The config file is packed into a dictionary,
|
The config file is packed into a dictionary,
|
||||||
@ -525,3 +525,31 @@ class ExportTunnels:
|
|||||||
|
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MyToolTip(tk.Toplevel):
|
||||||
|
TIP_X_OFFSET = 8
|
||||||
|
TIP_Y_OFFSET = 8
|
||||||
|
AUTO_CLEAR_TIME = 10 # Millisecond. (1/100 sec.)
|
||||||
|
|
||||||
|
def __init__(self, x_pos, y_pos, message=None, auto_clear=False):
|
||||||
|
self.x_pos = x_pos
|
||||||
|
self.y_pos = y_pos
|
||||||
|
self.message = message
|
||||||
|
self.auto_clear = auto_clear
|
||||||
|
|
||||||
|
tk.Toplevel.__init__(self)
|
||||||
|
self.overrideredirect(True)
|
||||||
|
|
||||||
|
self.message_label = ttk.Label(self, compound='left', text=self.message, padding=4)
|
||||||
|
self.message_label.pack()
|
||||||
|
|
||||||
|
self.geometry("+%d+%d" % (self.x_pos + self.TIP_X_OFFSET,
|
||||||
|
self.y_pos + self.TIP_X_OFFSET))
|
||||||
|
|
||||||
|
if self.auto_clear:
|
||||||
|
self.after(self.AUTO_CLEAR_TIME, self.clear_tip)
|
||||||
|
|
||||||
|
def clear_tip(self):
|
||||||
|
"""Remove Tool-Tip"""
|
||||||
|
self.destroy()
|
||||||
|
306
wg_main.py
306
wg_main.py
@ -1,21 +1,24 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
from select import select
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
from tkinter import *
|
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, ShowAddress, FileHandle,
|
||||||
FileHandle, ExportTunnels, OnOff, msg_window, WirePyUpdate, res, version, path_to_file2,
|
ExportTunnels, OnOff, msg_window, WirePyUpdate, res, version, path_to_file2,
|
||||||
path_to_file3)
|
path_to_file3, MyToolTip)
|
||||||
|
|
||||||
tcl_path = Path('/usr/share/TK-Themes')
|
tcl_path = Path('/usr/share/TK-Themes')
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(tk.Tk):
|
class MainWindow(tk.Tk):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self.my_tool_tip = None
|
||||||
self.switch_on = None
|
self.switch_on = None
|
||||||
self.switch_off = None
|
self.switch_off = None
|
||||||
self.x_width = 600
|
self.x_width = 600
|
||||||
@ -57,6 +60,7 @@ class MainWindow(tk.Tk):
|
|||||||
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')
|
||||||
|
|
||||||
def theme_change_dark():
|
def theme_change_dark():
|
||||||
if not self.tk.call("ttk::style", "theme", "use") == "water-dark":
|
if not self.tk.call("ttk::style", "theme", "use") == "water-dark":
|
||||||
# Set dark theme
|
# Set dark theme
|
||||||
@ -64,15 +68,14 @@ class MainWindow(tk.Tk):
|
|||||||
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():
|
def instruction():
|
||||||
"""img_w, img_i, w_title, w_txt hand over"""
|
"""img_w, img_i, w_title, w_txt hand over"""
|
||||||
iw = r'/usr/share/icons/wp-icons/64/info.png'
|
iw = r'/usr/share/icons/wp-icons/48/wg_vpn.png'
|
||||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||||
wt = 'Select tunnel'
|
wt = 'Instruction'
|
||||||
msg_t = 'Here comes the instructions for Wire-Py .'
|
msg_t = 'Here comes the instructions for Wire-Py'
|
||||||
msg_window(iw, ii, wt, msg_t)
|
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')
|
||||||
@ -84,9 +87,33 @@ class MainWindow(tk.Tk):
|
|||||||
self.version_lb = ttk.Label(self.menu_frame, text=version)
|
self.version_lb = ttk.Label(self.menu_frame, text=version)
|
||||||
self.version_lb.config(font=('Ubuntu', 11), foreground='#00c4ff')
|
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, padx=10)
|
||||||
|
|
||||||
|
def version_mouse_enter(event):
|
||||||
|
""" The mouse moves into the Version widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, f'Version: {version[2:]}')
|
||||||
|
|
||||||
|
def version_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
self.options_btn = ttk.Menubutton(self.menu_frame, text='Options')
|
self.options_btn = ttk.Menubutton(self.menu_frame, text='Options')
|
||||||
self.options_btn.grid(column=1, row=0)
|
self.options_btn.grid(column=1, row=0)
|
||||||
|
|
||||||
|
def sets_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Click for Settings')
|
||||||
|
|
||||||
|
def sets_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
self.version_lb.bind('<Enter>', version_mouse_enter)
|
||||||
|
self.version_lb.bind('<Leave>', version_mouse_leave)
|
||||||
|
self.options_btn.bind('<Enter>', sets_mouse_enter)
|
||||||
|
self.options_btn.bind('<Leave>', sets_mouse_leave)
|
||||||
|
|
||||||
set_option = tk.IntVar()
|
set_option = tk.IntVar()
|
||||||
|
|
||||||
self.settings = tk.Menu(self)
|
self.settings = tk.Menu(self)
|
||||||
@ -98,9 +125,21 @@ class MainWindow(tk.Tk):
|
|||||||
''' Help BTN Menu / Label '''
|
''' Help BTN Menu / Label '''
|
||||||
self.help_btn = ttk.Menubutton(self.menu_frame, text='Help')
|
self.help_btn = ttk.Menubutton(self.menu_frame, text='Help')
|
||||||
self.help_btn.grid(column=2, row=0)
|
self.help_btn.grid(column=2, row=0)
|
||||||
|
|
||||||
|
def help_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Click for Help')
|
||||||
|
|
||||||
|
def help_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
self.help_btn.bind('<Enter>', help_mouse_enter)
|
||||||
|
self.help_btn.bind('<Leave>', help_mouse_leave)
|
||||||
self.readme = tk.Menu(self)
|
self.readme = tk.Menu(self)
|
||||||
self.help_btn.configure(menu=self.readme, style='Toolbutton')
|
self.help_btn.configure(menu=self.readme, style='Toolbutton')
|
||||||
self.readme.add_command(label='Readme', command=readme)
|
self.readme.add_command(label='Instruction', command=instruction)
|
||||||
|
|
||||||
''' Update Label '''
|
''' Update Label '''
|
||||||
self.updates_lb = ttk.Label(self.menu_frame)
|
self.updates_lb = ttk.Label(self.menu_frame)
|
||||||
@ -109,18 +148,57 @@ class MainWindow(tk.Tk):
|
|||||||
if res == 'False':
|
if res == 'False':
|
||||||
set_option.set(value=1)
|
set_option.set(value=1)
|
||||||
self.updates_lb.configure(text='Update search off')
|
self.updates_lb.configure(text='Update search off')
|
||||||
|
|
||||||
|
def disable_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Updates you have disabled')
|
||||||
|
|
||||||
|
def disable_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
self.updates_lb.bind('<Enter>', disable_mouse_enter)
|
||||||
|
self.updates_lb.bind('<Leave>', disable_mouse_leave)
|
||||||
elif res == 'No Internet Connection!':
|
elif res == 'No Internet Connection!':
|
||||||
self.updates_lb.configure(text='No Server Connection!', foreground='red')
|
self.updates_lb.configure(text='No Server Connection!', foreground='red')
|
||||||
elif res == 'No Updates':
|
elif res == 'No Updates':
|
||||||
self.updates_lb.configure(text='No Updates')
|
self.updates_lb.configure(text='No Updates')
|
||||||
|
|
||||||
|
def congratulations_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
'Congratulations! Wire-Py is up to date')
|
||||||
|
|
||||||
|
def congratulations_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
self.updates_lb.bind('<Enter>', congratulations_mouse_enter)
|
||||||
|
self.updates_lb.bind('<Leave>', congratulations_mouse_leave)
|
||||||
else:
|
else:
|
||||||
set_option.set(value=0)
|
set_option.set(value=0)
|
||||||
text = f'Update {res} available!'
|
text = f'Update {res} available!'
|
||||||
|
|
||||||
''' Update BTN Menu'''
|
''' Update BTN Menu'''
|
||||||
|
|
||||||
self.update_btn = ttk.Menubutton(self.menu_frame, text=text, )
|
self.update_btn = ttk.Menubutton(self.menu_frame, text=text)
|
||||||
self.update_btn.grid(column=4, row=0, padx=0)
|
self.update_btn.grid(column=4, row=0, padx=0)
|
||||||
|
|
||||||
|
def download_mouse_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')
|
||||||
|
|
||||||
|
def download_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
self.update_btn.bind('<Enter>', download_mouse_enter)
|
||||||
|
self.update_btn.bind('<Leave>', download_mouse_leave)
|
||||||
|
|
||||||
self.download = tk.Menu(self)
|
self.download = tk.Menu(self)
|
||||||
|
|
||||||
self.update_btn.configure(menu=self.download, style='Toolbutton')
|
self.update_btn.configure(menu=self.download, style='Toolbutton')
|
||||||
@ -129,9 +207,73 @@ class MainWindow(tk.Tk):
|
|||||||
FrameWidgets(self).grid()
|
FrameWidgets(self).grid()
|
||||||
|
|
||||||
|
|
||||||
|
class StartStopBTN:
|
||||||
|
"""
|
||||||
|
Show Start and Stop Button in Label
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.lb_frame_btn_lbox = None
|
||||||
|
self.wg_switch = None
|
||||||
|
self.btn_stst = 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')
|
||||||
|
|
||||||
|
def button_stop(self):
|
||||||
|
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)
|
||||||
|
|
||||||
|
def stop_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
'Click to stop selected Wireguard Tunnel')
|
||||||
|
|
||||||
|
def stop_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
self.btn_stst.bind('<Enter>', stop_mouse_enter)
|
||||||
|
self.btn_stst.bind('<Leave>', stop_mouse_leave)
|
||||||
|
|
||||||
|
def button_start(self):
|
||||||
|
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_mouse_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')
|
||||||
|
|
||||||
|
def empty_list_start_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
def start_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
'Click to start selected Wireguard Tunnel')
|
||||||
|
|
||||||
|
def start_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
tl = ListTunnels.tl_list()
|
||||||
|
if len(tl) == 0:
|
||||||
|
self.btn_stst.bind('<Enter>', empty_list_start_mouse_enter)
|
||||||
|
self.btn_stst.bind('<Leave>', empty_list_start_mouse_leave)
|
||||||
|
else:
|
||||||
|
self.btn_stst.bind('<Enter>', start_mouse_enter)
|
||||||
|
self.btn_stst.bind('<Leave>', start_mouse_leave)
|
||||||
|
|
||||||
|
|
||||||
class FrameWidgets(ttk.Frame):
|
class FrameWidgets(ttk.Frame):
|
||||||
def __init__(self, container, **kwargs):
|
def __init__(self, container, **kwargs):
|
||||||
super().__init__(container, **kwargs)
|
super().__init__(container, **kwargs)
|
||||||
|
|
||||||
|
self.btn_stst = None
|
||||||
self.auto_con = None
|
self.auto_con = None
|
||||||
self.enp = None
|
self.enp = None
|
||||||
self.DNS = None
|
self.DNS = None
|
||||||
@ -195,18 +337,34 @@ class FrameWidgets(ttk.Frame):
|
|||||||
|
|
||||||
''' Listbox with Scrollbar '''
|
''' Listbox with Scrollbar '''
|
||||||
|
|
||||||
|
|
||||||
|
def box_info_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
'You must first import\na Wireguard tunnel')
|
||||||
|
|
||||||
|
def box_info_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
|
||||||
def enable_check_box(event):
|
def enable_check_box(event):
|
||||||
tl = ListTunnels.tl_list()
|
|
||||||
if len(tl) != 0:
|
if len(tl) != 0:
|
||||||
self.wg_autostart.configure(state='normal')
|
self.wg_autostart.configure(state='normal')
|
||||||
self.lb_rename.config(state='normal')
|
self.lb_rename.config(state='normal')
|
||||||
self.lb_rename.delete(0, tk.END)
|
self.lb_rename.delete(0, tk.END)
|
||||||
self.btn_rename.config(state='normal')
|
self.btn_rename.config(state='normal')
|
||||||
|
|
||||||
|
|
||||||
self.l_box = tk.Listbox(self.lb_frame_btn_lbox, selectmode='single')
|
self.l_box = tk.Listbox(self.lb_frame_btn_lbox, selectmode='single')
|
||||||
self.l_box.config(relief='ridge')
|
self.l_box.config(relief='ridge', font=('Ubuntu', 12, 'bold'))
|
||||||
self.l_box.config(font=('Ubuntu', 12, 'bold'))
|
|
||||||
self.l_box.grid(column=1, rowspan=4, row=0, sticky='ns')
|
self.l_box.grid(column=1, rowspan=4, row=0, sticky='ns')
|
||||||
|
tl = ListTunnels.tl_list()
|
||||||
|
if len(tl) == 0:
|
||||||
|
self.l_box.bind('<Enter>', box_info_mouse_enter)
|
||||||
|
self.l_box.bind('<Leave>', box_info_mouse_leave)
|
||||||
self.l_box.event_add('<<ClickEvent>>', '<Button-1>')
|
self.l_box.event_add('<<ClickEvent>>', '<Button-1>')
|
||||||
self.l_box.bind('<<ClickEvent>>', enable_check_box)
|
self.l_box.bind('<<ClickEvent>>', enable_check_box)
|
||||||
self.scrollbar = ttk.Scrollbar(self.lb_frame_btn_lbox, orient='vertical', command=self.l_box.yview)
|
self.scrollbar = ttk.Scrollbar(self.lb_frame_btn_lbox, orient='vertical', command=self.l_box.yview)
|
||||||
@ -246,6 +404,19 @@ class FrameWidgets(ttk.Frame):
|
|||||||
padding=0)
|
padding=0)
|
||||||
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
|
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
|
||||||
|
|
||||||
|
def import_mouse_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')
|
||||||
|
|
||||||
|
def import_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
self.btn_i.bind('<Enter>', import_mouse_enter)
|
||||||
|
self.btn_i.bind('<Leave>', import_mouse_leave)
|
||||||
|
|
||||||
def delete():
|
def delete():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -275,7 +446,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
file_one.replace(file_two)
|
file_one.replace(file_two)
|
||||||
|
|
||||||
''' for disable checkbox when Listbox empty '''
|
''' for disable checkbox when Listbox empty '''
|
||||||
tl = ListTunnels.tl_list()
|
|
||||||
if len(tl) == 0:
|
if len(tl) == 0:
|
||||||
self.wg_autostart.configure(state='disabled')
|
self.wg_autostart.configure(state='disabled')
|
||||||
if self.a != '' and self.a == select_tl:
|
if self.a != '' and self.a == select_tl:
|
||||||
@ -289,7 +460,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.enp.set('')
|
self.enp.set('')
|
||||||
return select_tl
|
return select_tl
|
||||||
except IndexError:
|
except IndexError:
|
||||||
tl = ListTunnels.tl_list()
|
|
||||||
if len(tl) != 0:
|
if len(tl) != 0:
|
||||||
|
|
||||||
"""img_w, img_i, w_title, w_txt hand over"""
|
"""img_w, img_i, w_title, w_txt hand over"""
|
||||||
@ -313,17 +484,94 @@ class FrameWidgets(ttk.Frame):
|
|||||||
style='CButton.TButton')
|
style='CButton.TButton')
|
||||||
self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
|
self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
|
||||||
|
|
||||||
|
def empty_list_del_mouse_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')
|
||||||
|
|
||||||
|
def empty_list_del_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
def delete_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
'Click to delete a Wireguard Tunnel\nSelect from the list!')
|
||||||
|
|
||||||
|
def delete_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
if len(tl) == 0:
|
||||||
|
self.btn_tr.bind('<Enter>', empty_list_del_mouse_enter)
|
||||||
|
self.btn_tr.bind('<Leave>', empty_list_del_mouse_leave)
|
||||||
|
else:
|
||||||
|
self.btn_tr.bind('<Enter>', delete_mouse_enter)
|
||||||
|
self.btn_tr.bind('<Leave>', delete_mouse_leave)
|
||||||
|
|
||||||
''' Button Export '''
|
''' Button Export '''
|
||||||
self.btn_exp = ttk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, command=ExportTunnels.wg_export,
|
self.btn_exp = ttk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, command=ExportTunnels.wg_export,
|
||||||
padding=0)
|
padding=0)
|
||||||
self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
|
self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
|
||||||
|
def empty_list_mouse_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')
|
||||||
|
|
||||||
|
def empty_list_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
def export_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
' Click to export all\nWireguard Tunnel to Zipfile')
|
||||||
|
|
||||||
|
def export_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
if len(tl) == 0:
|
||||||
|
self.btn_exp.bind('<Enter>', empty_list_mouse_enter)
|
||||||
|
self.btn_exp.bind('<Leave>', empty_list_mouse_leave)
|
||||||
|
else:
|
||||||
|
self.btn_exp.bind('<Enter>', export_mouse_enter)
|
||||||
|
self.btn_exp.bind('<Leave>', export_mouse_leave)
|
||||||
|
|
||||||
''' Label Entry '''
|
''' Label Entry '''
|
||||||
self.lb_rename = ttk.Entry(self, width=20)
|
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.grid(column=2, row=4, padx=30, pady=15, sticky='nw')
|
||||||
self.lb_rename.insert(0, 'Max. 12 characters!')
|
self.lb_rename.insert(0, 'Max. 12 characters!')
|
||||||
self.lb_rename.config(state='disable')
|
self.lb_rename.config(state='disable')
|
||||||
|
def rename_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
'To rename a tunnel, you need to\nselect a tunnel from the list')
|
||||||
|
|
||||||
|
def rename_no_active_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
def rename_no_active_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
'To rename a tunnel, at least one must be in the list')
|
||||||
|
|
||||||
|
def rename_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
if len(tl) != 0:
|
||||||
|
self.lb_rename.bind('<Enter>', rename_mouse_enter)
|
||||||
|
self.lb_rename.bind('<Leave>', rename_mouse_leave)
|
||||||
|
else:
|
||||||
|
self.lb_rename.bind('<Enter>', rename_no_active_mouse_enter)
|
||||||
|
self.lb_rename.bind('<Leave>', rename_no_active_mouse_leave)
|
||||||
def tl_rename():
|
def tl_rename():
|
||||||
special_characters = ['\\', '/', '{', '}', ' ']
|
special_characters = ['\\', '/', '{', '}', ' ']
|
||||||
|
|
||||||
@ -395,6 +643,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
style='RnButton.TButton')
|
style='RnButton.TButton')
|
||||||
self.btn_rename.grid(column=2, row=4, padx=20, pady=15, sticky='ne')
|
self.btn_rename.grid(column=2, row=4, padx=20, pady=15, sticky='ne')
|
||||||
|
|
||||||
|
|
||||||
''' Check Buttons '''
|
''' Check Buttons '''
|
||||||
self.selected_option = tk.IntVar()
|
self.selected_option = tk.IntVar()
|
||||||
self.autoconnect_var = tk.StringVar()
|
self.autoconnect_var = tk.StringVar()
|
||||||
@ -408,6 +657,33 @@ class FrameWidgets(ttk.Frame):
|
|||||||
variable=self.selected_option,
|
variable=self.selected_option,
|
||||||
command=lambda: FileHandle.box_set(self))
|
command=lambda: FileHandle.box_set(self))
|
||||||
self.wg_autostart.grid(column=0, row=4, pady=15, padx=15, sticky='nw')
|
self.wg_autostart.grid(column=0, row=4, pady=15, padx=15, sticky='nw')
|
||||||
|
def chk_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
'You must have at least one\n'
|
||||||
|
'tunnel in the list,to use the autostart')
|
||||||
|
|
||||||
|
def chk_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
if len(tl) == 0:
|
||||||
|
self.wg_autostart.bind('<Enter>', chk_mouse_enter)
|
||||||
|
self.wg_autostart.bind('<Leave>', chk_mouse_leave)
|
||||||
|
else:
|
||||||
|
def chk_a_mouse_enter(event):
|
||||||
|
""" The mouse moves into the entry widget """
|
||||||
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
|
'To use the autostart, a tunnel must be selected from the list')
|
||||||
|
|
||||||
|
def chk_a_mouse_leave(event):
|
||||||
|
""" The mouse moves from the entry widget """
|
||||||
|
''' Remove Tool-Tip '''
|
||||||
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
self.wg_autostart.bind('<Enter>', chk_a_mouse_enter)
|
||||||
|
self.wg_autostart.bind('<Leave>', chk_a_mouse_leave)
|
||||||
|
|
||||||
OnOff.on_off(self)
|
OnOff.on_off(self)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user