Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
b68908eaef | |||
c4565ed169 | |||
485cfff457 | |||
1a0fc74a80 | |||
971c86c97f | |||
66dd27cc64 | |||
cf71eae7d3 | |||
1f80d5342c | |||
e719a1f23f | |||
a0da356cec | |||
ac87e0a4a7 | |||
6a3a982057 | |||
aab90eec70 | |||
511d5f72df | |||
ed93e99026 | |||
10c3b07053 | |||
e9814f2b60 | |||
c470783ff2 | |||
2fac03a927 | |||
03a7e48018 | |||
090842ab28 | |||
8a32065676 | |||
bc0d46d633 | |||
80c63eaf78 | |||
9eb99f0859 | |||
feb6217637 | |||
4bfc8c318e | |||
5f6aaa6cf1 | |||
63ed0abc98 | |||
3102c685fd | |||
ec10f912ea | |||
96164eb132 | |||
a19f889950 | |||
de2929896d | |||
f9d4256679 | |||
a0b895438c | |||
4c89488950 | |||
c0ae2d2b75 | |||
e4774abf19 | |||
7b1e543428 | |||
6f83fc7162 | |||
b70400b456 | |||
e25bc154ea | |||
7aa3cd75fe | |||
0b9eec8d1d | |||
b9083d4698 |
@ -4,15 +4,20 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="- Optimize Class and Tooltip">
|
||||
<change afterPath="$PROJECT_DIR$/run_as" afterDir="false" />
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="- 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">
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/128/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/128/info.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/256/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/256/info.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/32/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/32/info.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/48/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/48/info.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/64/error.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lx-icons/64/info.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Changelog" beforeDir="false" afterPath="$PROJECT_DIR$/Changelog" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/install" beforeDir="false" afterPath="$PROJECT_DIR$/install" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/settings" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/start_wg.py" beforeDir="false" afterPath="$PROJECT_DIR$/start_wg.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/theme" beforeDir="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$/cls_mth_fc.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wg_main.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_main.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -30,7 +35,7 @@
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="main" />
|
||||
<entry key="$PROJECT_DIR$" value="1.11.0824" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
@ -51,27 +56,28 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"Python.INSTALL.executor": "Run",
|
||||
"Python.install.executor": "Run",
|
||||
"Python.main.executor": "Run",
|
||||
"Python.messagebox.executor": "Run",
|
||||
"Python.start_wg.executor": "Run",
|
||||
"Python.testtheme.executor": "Run",
|
||||
"Python.wg_func.executor": "Run",
|
||||
"Python.wg_main.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"Shell Script.install.executor": "Run",
|
||||
"Shell Script.run_as.executor": "Run",
|
||||
"git-widget-placeholder": "main",
|
||||
"last_opened_file_path": "/home/punix/Pyapps/wire-py",
|
||||
"settings.editor.selected.configurable": "reference.settingsdialog.IDE.editor.colors"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"Python.INSTALL.executor": "Run",
|
||||
"Python.install.executor": "Run",
|
||||
"Python.main.executor": "Run",
|
||||
"Python.messagebox.executor": "Run",
|
||||
"Python.start_wg.executor": "Run",
|
||||
"Python.testtheme.executor": "Run",
|
||||
"Python.wg_func.executor": "Run",
|
||||
"Python.wg_main.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"Shell Script.install.executor": "Run",
|
||||
"Shell Script.run_as.executor": "Run",
|
||||
"git-widget-placeholder": "1.11.0824",
|
||||
"last_opened_file_path": "/home/punix/Pyapps/wire-py/lx-icons",
|
||||
"settings.editor.selected.configurable": "reference.settingsdialog.IDE.editor.colors"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/lx-icons" />
|
||||
<recent name="$PROJECT_DIR$" />
|
||||
</key>
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
@ -135,7 +141,7 @@
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-python-sdk-0e3be3396995-c546a90a8094-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-242.23339.19" />
|
||||
<option value="bundled-python-sdk-8336bb23522e-31b6be0877a2-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-241.19072.16" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
@ -148,30 +154,6 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1723279982210</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00017" summary="remove a ',' in DNS Name">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724576599289</created>
|
||||
<option name="number" value="00017" />
|
||||
<option name="presentableId" value="LOCAL-00017" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724576599289</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00018" summary="fix when Filname > 17 first copy file after rename">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724593165879</created>
|
||||
<option name="number" value="00018" />
|
||||
<option name="presentableId" value="LOCAL-00018" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724593165879</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00019" summary="add export Tunnel as zip">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724610514657</created>
|
||||
<option name="number" value="00019" />
|
||||
<option name="presentableId" value="LOCAL-00019" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724610514658</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00020" summary="columnconfigure on all widgets set">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724778892233</created>
|
||||
@ -540,18 +522,37 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1729938941027</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="66" />
|
||||
<task id="LOCAL-00066" summary="- 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">
|
||||
<option name="closed" value="true" />
|
||||
<created>1731097309468</created>
|
||||
<option name="number" value="00066" />
|
||||
<option name="presentableId" value="LOCAL-00066" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1731097309468</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00067" summary="- 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">
|
||||
<option name="closed" value="true" />
|
||||
<created>1731097969343</created>
|
||||
<option name="number" value="00067" />
|
||||
<option name="presentableId" value="LOCAL-00067" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1731097969344</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00068" summary="- 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">
|
||||
<option name="closed" value="true" />
|
||||
<created>1731098372497</created>
|
||||
<option name="number" value="00068" />
|
||||
<option name="presentableId" value="LOCAL-00068" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1731098372497</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="69" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
<option featureType="com.intellij.fileTypeFactory" implementationName="*.policy" />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="OPEN_GENERIC_TABS">
|
||||
<map>
|
||||
<entry key="f9756e7d-0c5c-4b84-84e4-660314c46ea4" value="TOOL_WINDOW" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
@ -562,7 +563,7 @@
|
||||
<entry key="branch">
|
||||
<value>
|
||||
<list>
|
||||
<option value="origin/wire-py-reformat-14-08-2024" />
|
||||
<option value="1.11.0824" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
@ -571,17 +572,11 @@
|
||||
</State>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="f9756e7d-0c5c-4b84-84e4-660314c46ea4">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||
<MESSAGE value="fix a filedialog for hidden Files work install rollback to bash for start wirepy and wirepy rollback to bash" />
|
||||
<MESSAGE value="install rollback bash to py wirepy and wirepy rollback to py" />
|
||||
<MESSAGE value="fix install and .desktop File Tar works now for user home and filebrowser.askfilebrowser start now in user home" />
|
||||
<MESSAGE value="replace tar with zip and Check if Zip file is empty" />
|
||||
@ -606,7 +601,8 @@
|
||||
<MESSAGE value=" - Add Options, Help, Update Label and Update Menubutton - Theme now separate Light and Dark" />
|
||||
<MESSAGE value="- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip" />
|
||||
<MESSAGE value="- Optimize Class and Tooltip" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="- Optimize Class and Tooltip" />
|
||||
<MESSAGE value="- 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" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="- 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" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
58
Changelog
@ -3,36 +3,80 @@ My standard System: Linux Mint 22 Cinnamon
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- os import in wg_func replaced by other methods
|
||||
- os import in cls_mth_fc.py replaced by other methods
|
||||
- If Wire-Py already runs, prevent further start
|
||||
- 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
|
||||
10-11-2024
|
||||
|
||||
- Translate file de_De complete
|
||||
- new FrameWidget for rename Entry and rename Button
|
||||
|
||||
|
||||
### Added
|
||||
09-11-2024
|
||||
|
||||
- Move Tips Method in separate class for Tooltips in another Apps
|
||||
- Move Version Variable in main script
|
||||
- Edit Class GiteaUpdate for requests in api_down and download
|
||||
- Description on Class GiteaUpdate
|
||||
|
||||
|
||||
### Added
|
||||
08-11-2024
|
||||
|
||||
- Preparation for language translation part 1
|
||||
- separate folder for general icons
|
||||
- install edit for new dir lx-icons
|
||||
|
||||
|
||||
### 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
|
||||
|
||||
- Add Autoconnect settings to settings.conf
|
||||
- Add Autoconnect settings to settings.conf
|
||||
|
||||
|
||||
### Added
|
||||
26-10-2024
|
||||
|
||||
- Add run_as Bash script and open_gitea.py python script
|
||||
- Add Tooltip disable/enable
|
||||
- Rename settings to settings.conf for theme, updates and tooltip enable in one file
|
||||
- Add run_as Bash script and open_gitea.py python script
|
||||
- Add Tooltip disable/enable
|
||||
- Rename settings to settings.conf for theme, updates and tooltip enable in one file
|
||||
|
||||
|
||||
### Added
|
||||
25-10-2024
|
||||
|
||||
- Optimize Class and Tooltip
|
||||
- Optimize Class and Tooltip
|
||||
|
||||
|
||||
### Added
|
||||
21-10-2024
|
||||
|
||||
- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip
|
||||
- Optimize Class. Move to wg_main Import Start/StopBTN and Tooltip
|
||||
|
||||
|
||||
### Added
|
||||
|
@ -1,35 +1,44 @@
|
||||
""" Wireguard Classes and Method for Wire-Py """
|
||||
""" Classes Method and functions for lx apps """
|
||||
|
||||
import gettext
|
||||
import locale
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
import tkinter as tk
|
||||
import zipfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
from tkinter import ttk
|
||||
import requests
|
||||
|
||||
APP = 'cls_mth_fc'
|
||||
LOCALE_DIR = "/usr/share/locale/"
|
||||
locale.bindtextdomain(APP, LOCALE_DIR)
|
||||
gettext.bindtextdomain(APP, LOCALE_DIR)
|
||||
gettext.textdomain(APP)
|
||||
_ = gettext.gettext
|
||||
|
||||
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year '''
|
||||
version = 'v. 1.10.2124'
|
||||
|
||||
path_to_file2 = Path('/etc/wire_py/settings.conf')
|
||||
wg_set = Path('/etc/wire_py/settings.conf')
|
||||
_u = Path.read_text(Path('/tmp/_u'))
|
||||
|
||||
UPDATE_API_URL = 'https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases'
|
||||
|
||||
class GiteaUpdate:
|
||||
"""
|
||||
Calling api_down requests the URL and the version of the running script.
|
||||
Example: version = 'v. 1.1.1.1' GiteaUpdate.api_down(http://example.de, version)
|
||||
|
||||
class WirePyUpdate:
|
||||
Calling download requests the download URL of the running script,
|
||||
the taskbar image for the “Download OK” window, the taskbar image for the
|
||||
“Download error” window and the variable res
|
||||
"""
|
||||
@staticmethod
|
||||
def api_down():
|
||||
def api_down(update_api_url, version):
|
||||
try:
|
||||
response = requests.get(UPDATE_API_URL)
|
||||
response = requests.get(update_api_url)
|
||||
response_dict = response.json()
|
||||
response_dict = response_dict[0]
|
||||
with open(path_to_file2, 'r') as set_file:
|
||||
with open(wg_set, 'r') as set_file:
|
||||
set_file = set_file.read()
|
||||
if 'on\n' in set_file:
|
||||
if version[3:] != response_dict['tag_name']:
|
||||
@ -42,51 +51,47 @@ class WirePyUpdate:
|
||||
return 'No Internet Connection!'
|
||||
|
||||
@staticmethod
|
||||
def download():
|
||||
def download(urld, down_ok_image, down_not_ok_image, res):
|
||||
try:
|
||||
url = f'https://git.ilunix.de/punix/Wire-Py/archive/{res}.zip'
|
||||
to_down = 'wget -qP ' + str(_u) + ' ' + url
|
||||
to_down = 'wget -qP ' + str(_u) + ' ' + urld
|
||||
result = subprocess.call(to_down, shell=True)
|
||||
if result == 0:
|
||||
shutil.chown(str(_u) + f'/{res}.zip', 1000, 1000)
|
||||
"""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_vpn.png'
|
||||
wt = 'Download Successful'
|
||||
msg_t = 'Your zip file is in home directory'
|
||||
iw = r'/usr/share/icons/lx-icons/64/info.png'
|
||||
ii = down_ok_image
|
||||
wt = _('Download Successful')
|
||||
msg_t = _('Your zip file is in home directory')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Download error'
|
||||
msg_t = 'Download failed! Please try again'
|
||||
iw = r'/usr/share/icons/lx-icons/64/error.png'
|
||||
ii = down_not_ok_image
|
||||
wt = _('Download error')
|
||||
msg_t = _('Download failed! Please try again')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
except subprocess.CalledProcessError:
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Download error'
|
||||
msg_t = 'Download failed! No internet connection!'
|
||||
iw = r'/usr/share/icons/lx-icons/64/error.png'
|
||||
ii = down_not_ok_image
|
||||
wt = _('Download error')
|
||||
msg_t = _('Download failed! No internet connection!')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
|
||||
res = WirePyUpdate.api_down()
|
||||
|
||||
|
||||
|
||||
def msg_window(img_w, img_i, w_title, w_txt, txt2=None, com=None):
|
||||
"""
|
||||
Function for different message windows for the user. with 4 arguments to be passed.
|
||||
To create messages with your own images, icons, and titles. As an alternative to Python Messagebox.
|
||||
Paths to images must be specified: r'/usr/share/icons/wp-icons/64/info.png'
|
||||
Paths to images must be specified: r'/usr/share/icons/lx-icons/64/info.png'
|
||||
img_w = Image for Tk Window
|
||||
img_i = Image for Icon
|
||||
w_title = Windows Title
|
||||
w_txt = Text for Tk Window
|
||||
txt2 = Text for Button two
|
||||
com = function for Button command
|
||||
"""
|
||||
|
||||
msg = tk.Toplevel()
|
||||
msg.resizable(width=False, height=False)
|
||||
msg.title(w_title)
|
||||
@ -98,7 +103,7 @@ def msg_window(img_w, img_i, w_title, w_txt, txt2=None, com=None):
|
||||
|
||||
label.grid(column=1, row=0)
|
||||
|
||||
if txt2 != None and com != None:
|
||||
if txt2 is not None and com is not None:
|
||||
label.config(font=('Ubuntu', 11), padx=15, justify='left')
|
||||
msg.i_window.grid(column=0, row=0, sticky='nw')
|
||||
button2 = ttk.Button(msg, text=f'{txt2}', command=com, padding=4)
|
||||
@ -120,7 +125,6 @@ def msg_window(img_w, img_i, w_title, w_txt, txt2=None, com=None):
|
||||
|
||||
|
||||
class Tunnel:
|
||||
|
||||
"""
|
||||
Class of Methods for Wire-Py
|
||||
"""
|
||||
@ -129,7 +133,6 @@ class Tunnel:
|
||||
The config file is packed into a dictionary,
|
||||
to display the values Address , DNS and Peer in the labels
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def con_to_dict(cls, file):
|
||||
|
||||
@ -171,11 +174,9 @@ class Tunnel:
|
||||
pre_key = final_dict['PreSharedKey']
|
||||
return address, dns, endpoint, pre_key
|
||||
|
||||
|
||||
"""
|
||||
Shows the Active Tunnel
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def active():
|
||||
|
||||
@ -190,7 +191,6 @@ class Tunnel:
|
||||
"""
|
||||
Shows all existing Wireguard tunnels
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def list():
|
||||
wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
|
||||
@ -199,13 +199,11 @@ class Tunnel:
|
||||
tl = wg_s[::3]
|
||||
return tl
|
||||
|
||||
|
||||
"""
|
||||
This will export the tunnels.
|
||||
A zipfile with current date and time is created
|
||||
in the user's home directory with correct right
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def export():
|
||||
_u1 = str(_u[6:])
|
||||
@ -228,43 +226,47 @@ class Tunnel:
|
||||
if len(zf.namelist()) != 0:
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_vpn.png'
|
||||
wt = 'Export Successful'
|
||||
msg_t = 'Your zip file is in home directory'
|
||||
wt = _('Export Successful')
|
||||
msg_t = _('Your zip file is in home directory')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
||||
iw = r'/usr/share/icons/lx-icons/64/error.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Export error'
|
||||
msg_t = 'Export failed! Please try again'
|
||||
wt = _('Export error')
|
||||
msg_t = _('Export failed! Please try again')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Select tunnel'
|
||||
msg_t = 'Please first import tunnel.'
|
||||
wt = _('Select tunnel')
|
||||
msg_t = _('Please first import tunnel')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
class Tipi:
|
||||
"""
|
||||
Class for Tooltip setting write in File
|
||||
Calling request path to file
|
||||
"""
|
||||
@staticmethod
|
||||
def if_tip():
|
||||
with open(path_to_file2, 'r') as set_file2:
|
||||
def if_tip(path):
|
||||
with open(path, 'r') as set_file2:
|
||||
lines2 = set_file2.readlines()
|
||||
if 'False\n' in lines2:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
tips = Tunnel.if_tip()
|
||||
|
||||
|
||||
|
||||
wg_tips = Tipi.if_tip(wg_set)
|
20
install
@ -7,10 +7,11 @@ BLUE='\033[30;1;34m'
|
||||
install_file_with(){
|
||||
clear
|
||||
sudo apt install python3-tk && \
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo cp -u wg_main.py start_wg.py cls_mth_fc.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings.conf /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||
sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \
|
||||
sudo cp -u Wire-Py.desktop /usr/share/applications/ && \
|
||||
@ -21,10 +22,11 @@ install_file_with(){
|
||||
install_arch_d(){
|
||||
clear
|
||||
sudo pacman -S --noconfirm tk python3 python-requests && \
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo cp -u wg_main.py start_wg.py cls_mth_fc.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -u settings.conf /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||
sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \
|
||||
sudo cp -u Wire-Py.desktop /usr/share/applications/ && \
|
||||
@ -89,10 +91,11 @@ elif grep -i 'fedora' /etc/os-release > /dev/null 2>&1
|
||||
if ! which python3-tkinter &> /dev/null
|
||||
then sudo dnf install python3-tkinter -y
|
||||
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo cp -u wg_main.py start_wg.py cls_mth_fc.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
||||
sudo cp -u settings.conf /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||
sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \
|
||||
@ -105,10 +108,11 @@ elif grep -i 'suse' /etc/os-release > /dev/null 2>&1
|
||||
then
|
||||
if ! which python311-tk &> /dev/null
|
||||
then sudo zypper install python311-tk
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo cp -u wg_main.py start_wg.py cls_mth_fc.py wirepy.py run_as open_gitea.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
||||
sudo cp -u settings.conf /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo cp -uR wp-icons lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo chown -R root:root /etc/wire_py && sudo chmod 755 /etc/wire_py && \
|
||||
sudo ln -sf /usr/bin/wirepy.py /usr/local/bin/wirepy && \
|
||||
sudo cp -u org.wirepy.policy /usr/share/polkit-1/actions/ && \
|
||||
|
BIN
languages/de/cls_mth_fc.mo
Normal file
BIN
languages/de/wirepy.mo
Normal file
BIN
lx-icons/128/error.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
lx-icons/128/info.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
lx-icons/256/error.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
lx-icons/256/info.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
lx-icons/32/error.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
lx-icons/32/info.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
lx-icons/48/error.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
lx-icons/48/info.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
lx-icons/64/error.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
lx-icons/64/info.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
412
wg_main.py
@ -1,17 +1,31 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import gettext
|
||||
import locale
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tkinter as tk
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
from tkinter import *
|
||||
from tkinter import filedialog, ttk
|
||||
|
||||
from wg_func import (Tunnel, msg_window, WirePyUpdate, res, _u, version, path_to_file2, tips)
|
||||
from tkinter import filedialog, ttk, TclError
|
||||
from cls_mth_fc import (Tunnel, msg_window, GiteaUpdate, _u, wg_tips, wg_set)
|
||||
|
||||
tcl_path = Path('/usr/share/TK-Themes')
|
||||
|
||||
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year '''
|
||||
version = 'v. 1.11.1024'
|
||||
|
||||
res = GiteaUpdate.api_down('https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases', version)
|
||||
|
||||
''' Translate '''
|
||||
APP = 'wirepy'
|
||||
LOCALE_DIR = "/usr/share/locale/"
|
||||
locale.bindtextdomain(APP, LOCALE_DIR)
|
||||
gettext.bindtextdomain(APP, LOCALE_DIR)
|
||||
gettext.textdomain(APP)
|
||||
_ = gettext.gettext
|
||||
|
||||
|
||||
class MainWindow(tk.Tk):
|
||||
|
||||
@ -19,19 +33,20 @@ 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.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') '''
|
||||
with open(path_to_file2, 'r') as read_file:
|
||||
with open(wg_set, 'r') as read_file:
|
||||
lines = read_file.readlines()
|
||||
if 'light\n' in lines:
|
||||
self.tk.call('set_theme', 'light')
|
||||
@ -44,38 +59,60 @@ 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/lx-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():
|
||||
if set_update.get() == 1:
|
||||
with open(path_to_file2, 'r') as set_file2:
|
||||
with open(wg_set, 'r') as set_file2:
|
||||
lines2 = set_file2.readlines()
|
||||
lines2[1] = 'off\n'
|
||||
with open(path_to_file2, 'w') as set_file2:
|
||||
with open(wg_set, 'w') as set_file2:
|
||||
set_file2.writelines(lines2)
|
||||
|
||||
if set_update.get() == 0:
|
||||
with open(path_to_file2, 'r') as set_file2:
|
||||
with open(wg_set, 'r') as set_file2:
|
||||
lines2 = set_file2.readlines()
|
||||
lines2[1] = 'on\n'
|
||||
with open(path_to_file2, 'w') as set_file2:
|
||||
with open(wg_set, '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():
|
||||
with open(path_to_file2, 'r') as set_file2:
|
||||
with open(wg_set, 'r') as set_file2:
|
||||
lines2 = set_file2.readlines()
|
||||
lines2[5] = 'False\n'
|
||||
with open(path_to_file2, 'w') as set_file2:
|
||||
with open(wg_set, 'w') as set_file2:
|
||||
set_file2.writelines(lines2)
|
||||
|
||||
else:
|
||||
with open(path_to_file2, 'r') as set_file2:
|
||||
with open(wg_set, 'r') as set_file2:
|
||||
lines2 = set_file2.readlines()
|
||||
lines2[5] = 'True\n'
|
||||
with open(path_to_file2, 'w') as set_file2:
|
||||
with open(wg_set, 'w') as set_file2:
|
||||
set_file2.writelines(lines2)
|
||||
|
||||
''' Set dark or light '''
|
||||
@ -84,21 +121,23 @@ class MainWindow(tk.Tk):
|
||||
if self.tk.call("ttk::style", "theme", "use") == "water-dark":
|
||||
''' Set light theme '''
|
||||
self.tk.call('set_theme', 'light')
|
||||
with open(path_to_file2, 'r') as theme_set2:
|
||||
with open(wg_set, 'r') as theme_set2:
|
||||
lines3 = theme_set2.readlines()
|
||||
lines3[3] = 'light\n'
|
||||
with open(path_to_file2, 'w') as theme_set2:
|
||||
with open(wg_set, '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":
|
||||
''' Set dark theme '''
|
||||
self.tk.call('set_theme', 'dark')
|
||||
with open(path_to_file2, 'r') as theme_set2:
|
||||
with open(wg_set, 'r') as theme_set2:
|
||||
lines4 = theme_set2.readlines()
|
||||
lines4[3] = 'dark\n'
|
||||
with open(path_to_file2, 'w') as theme_set2:
|
||||
with open(wg_set, 'w') as theme_set2:
|
||||
theme_set2.writelines(lines4)
|
||||
self.color_label()
|
||||
|
||||
def info():
|
||||
def link_btn():
|
||||
@ -109,12 +148,12 @@ class MainWindow(tk.Tk):
|
||||
"""img_w, img_i, w_title, w_txt , txt2, com hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/48/wg_vpn.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Info'
|
||||
msg_t = ('Wire-Py a simple Wireguard Gui for Linux systems.\n\n'
|
||||
wt = _('Info')
|
||||
msg_t = (_('Wire-Py a simple Wireguard Gui for Linux systems.\n\n'
|
||||
'Wire-Py is open source software written in Python.\n\n'
|
||||
'Email: polunga40@unity-mail.de also likes for donation.\n\n'
|
||||
'Use without warranty!\n')
|
||||
txt2 = 'Go to Wire-Py git'
|
||||
'Use without warranty!\n'))
|
||||
txt2 = _('Go to Wire-Py git')
|
||||
com = link_btn
|
||||
|
||||
msg_window(iw, ii, wt, msg_t, txt2, com)
|
||||
@ -122,14 +161,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 """
|
||||
@ -140,12 +177,12 @@ class MainWindow(tk.Tk):
|
||||
''' Remove Tool-Tip '''
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.options_btn = ttk.Menubutton(self.menu_frame, text='Options')
|
||||
self.options_btn.grid(column=1, row=0)
|
||||
self.options_btn = ttk.Menubutton(self.menu_frame, text=_('Options'))
|
||||
self.options_btn.grid(column=1, columnspan=1, row=0)
|
||||
|
||||
def sets_enter(event):
|
||||
""" The mouse moves into the entry widget """
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Click for Settings')
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, _('Click for Settings'))
|
||||
|
||||
def sets_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -161,23 +198,21 @@ class MainWindow(tk.Tk):
|
||||
set_tip = tk.BooleanVar()
|
||||
self.settings = tk.Menu(self, relief='flat')
|
||||
self.options_btn.configure(menu=self.settings, style='Toolbutton')
|
||||
self.settings.add_checkbutton(label='Disable Updates', command=update, variable=set_update)
|
||||
self.settings.add_checkbutton(label='Disable Tooltips', command=tooltip, variable=set_tip)
|
||||
self.settings.add_command(label='Light', command=theme_change_light)
|
||||
self.settings.add_command(label='Dark', command=theme_change_dark)
|
||||
self.settings.add_checkbutton(label=_('Disable Updates'), command=update, variable=set_update)
|
||||
self.settings.add_checkbutton(label=_('Disable Tooltips'), command=tooltip, variable=set_tip)
|
||||
self.settings.add_command(label=_('Light'), command=theme_change_light)
|
||||
self.settings.add_command(label=_('Dark'), command=theme_change_dark)
|
||||
|
||||
''' 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.about_btn = ttk.Button(self.menu_frame, text=_('About'), style='Toolbutton', command=info)
|
||||
self.about_btn.grid(column=2, columnspan=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)
|
||||
|
||||
self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
|
||||
'''View Checkbox for enable or disable Tooltip '''
|
||||
if tips:
|
||||
if wg_tips:
|
||||
set_tip.set(value=False)
|
||||
else:
|
||||
set_tip.set(value=True)
|
||||
@ -185,11 +220,11 @@ class MainWindow(tk.Tk):
|
||||
'''View Checkbox for enable or disable Updates '''
|
||||
if res == 'False':
|
||||
set_update.set(value=1)
|
||||
self.updates_lb.configure(text='Update search off')
|
||||
self.updates_lb.configure(text=_('Update search off'))
|
||||
|
||||
def disable_enter(event):
|
||||
""" The mouse moves into the entry widget """
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Updates you have disabled')
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, _('Updates you have disabled'))
|
||||
|
||||
def disable_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -199,14 +234,13 @@ class MainWindow(tk.Tk):
|
||||
self.updates_lb.bind('<Enter>', disable_enter)
|
||||
self.updates_lb.bind('<Leave>', disable_leave)
|
||||
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':
|
||||
self.updates_lb.configure(text='No Updates')
|
||||
self.updates_lb.configure(text=_('No Updates'))
|
||||
|
||||
def congratulations_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')
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, _('Congratulations! Wire-Py is up to date'))
|
||||
|
||||
def congratulations_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -217,16 +251,15 @@ class MainWindow(tk.Tk):
|
||||
self.updates_lb.bind('<Leave>', congratulations_leave)
|
||||
else:
|
||||
set_update.set(value=0)
|
||||
text = f'Update {res} available!'
|
||||
text = f'Update {res} ' + _('available!')
|
||||
|
||||
''' Update BTN Menu'''
|
||||
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, columnspan=3, row=0, padx=0)
|
||||
|
||||
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 """
|
||||
@ -239,35 +272,14 @@ class MainWindow(tk.Tk):
|
||||
self.download = tk.Menu(self, relief='flat')
|
||||
|
||||
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')
|
||||
self.download.add_command(label=_('Download'),
|
||||
command=lambda: GiteaUpdate.download(f'https://git.ilunix.de/punix'
|
||||
f'/Wire-Py/archive/'
|
||||
f'{res}.zip', r'/usr/'
|
||||
r'share/icons/wp-icons'
|
||||
r'/48/wg_vpn.png',
|
||||
r'/usr/share/icons/wp-icons'
|
||||
r'/48/wg_msg.png', res))
|
||||
|
||||
''' Show active Tunnel '''
|
||||
self.a = Tunnel.active()
|
||||
@ -276,42 +288,44 @@ 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)
|
||||
|
||||
''' Bottom Frame 5 '''
|
||||
self.lb_frame4 = ttk.Frame(self)
|
||||
self.lb_frame4.configure(relief='flat')
|
||||
self.lb_frame4.grid(column=2, row=5, columnspan=3, sticky='e', padx=15)
|
||||
|
||||
''' Show active Label '''
|
||||
self.select_tunnel = None
|
||||
self.lb = ttk.Label(self, text='Active: ')
|
||||
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)
|
||||
self.color_label()
|
||||
|
||||
''' Interface Label '''
|
||||
self.interface = ttk.Label(self.lb_frame, text='Interface')
|
||||
self.interface = ttk.Label(self.lb_frame, text=_('Interface'))
|
||||
self.interface.grid(column=0, row=3, sticky='we', padx=120)
|
||||
self.interface.config(font=('Ubuntu', 9))
|
||||
|
||||
''' Peer Label '''
|
||||
self.peer = ttk.Label(self.lb_frame2, text='Peer')
|
||||
self.peer = ttk.Label(self.lb_frame2, text=_('Peer'))
|
||||
self.peer.config(font=('Ubuntu', 9))
|
||||
self.peer.grid(column=0, row=4, sticky='we', padx=130)
|
||||
|
||||
@ -333,7 +347,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()
|
||||
@ -343,8 +356,7 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
def list_empty_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')
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, _('You must first import\na Wireguard tunnel'))
|
||||
|
||||
def list_empty_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -353,7 +365,7 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
def list_not_empty_enter(event):
|
||||
""" The mouse moves into the entry widget """
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Select a Tunnel')
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, _('Select a Tunnel'))
|
||||
|
||||
def list_not_empty_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -388,15 +400,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 """
|
||||
@ -416,14 +425,14 @@ class FrameWidgets(ttk.Frame):
|
||||
pre_key = key[3]
|
||||
check_call(['nmcli', 'connection', 'delete', select_tl])
|
||||
self.l_box.delete(self.select_tunnel[0])
|
||||
with open(path_to_file2, 'r') as set_file6:
|
||||
with open(wg_set, 'r') as set_file6:
|
||||
lines6 = set_file6.readlines()
|
||||
if select_tl == lines6[7].strip() and 'off' not in lines6[7].strip():
|
||||
lines6[7] = 'off'
|
||||
with open(path_to_file2, 'w') as set_file7:
|
||||
with open(wg_set, 'w') as set_file7:
|
||||
set_file7.writelines(lines6)
|
||||
self.selected_option.set(0)
|
||||
self.autoconnect_var.set('no Autoconnect')
|
||||
self.autoconnect_var.set(_('no Autoconnect'))
|
||||
|
||||
Path.unlink(Path('/etc/wire_py') / str(select_tl + '.conf'))
|
||||
with open('/etc/wire_py/.keys', 'r') as readfile:
|
||||
@ -440,8 +449,7 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
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 """
|
||||
@ -463,7 +471,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.btn_stst.bind('<Leave>', empty_list_start_leave)
|
||||
self.lb_rename.bind('<Enter>', rename_no_active_enter)
|
||||
self.lb_rename.bind('<Leave>', rename_no_active_leave)
|
||||
self.lb_rename.insert(0, 'Max. 12 characters!')
|
||||
self.lb_rename.insert(0, _('Max. 12 characters!'))
|
||||
|
||||
if self.a != '' and self.a == select_tl:
|
||||
self.StrVar.set(value='')
|
||||
@ -481,19 +489,19 @@ class FrameWidgets(ttk.Frame):
|
||||
if self.l_box.size() != 0:
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Select tunnel'
|
||||
msg_t = 'Please select a tunnel from the list.'
|
||||
wt = _('Select tunnel')
|
||||
msg_t = _('Please select a tunnel from the list')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Select tunnel'
|
||||
msg_t = 'Please first import tunnel.'
|
||||
wt = _('Select tunnel')
|
||||
msg_t = _('Please first import tunnel')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
''' Button Trash '''
|
||||
@ -503,8 +511,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 """
|
||||
@ -514,7 +521,7 @@ class FrameWidgets(ttk.Frame):
|
||||
def del_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!')
|
||||
_('Click to delete a Wireguard Tunnel\nSelect from the list!'))
|
||||
|
||||
def del_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -529,14 +536,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 """
|
||||
@ -546,7 +551,7 @@ class FrameWidgets(ttk.Frame):
|
||||
def exp_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')
|
||||
_(' Click to export all\nWireguard Tunnel to Zipfile'))
|
||||
|
||||
def exp_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -561,9 +566,9 @@ 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.insert(0, 'Max. 12 characters!')
|
||||
self.lb_rename = ttk.Entry(self.lb_frame4, 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')
|
||||
|
||||
def rename_no_active_leave(_):
|
||||
@ -574,12 +579,12 @@ class FrameWidgets(ttk.Frame):
|
||||
def rename_no_active_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')
|
||||
_('To rename a tunnel, at least one must be in the list'))
|
||||
|
||||
def rename_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')
|
||||
_('To rename a tunnel, you need to\nselect a tunnel from the list'))
|
||||
|
||||
def rename_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -599,28 +604,28 @@ class FrameWidgets(ttk.Frame):
|
||||
if len(self.lb_rename.get()) > 12:
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Renaming not possible'
|
||||
msg_t = 'The new name may contain only 12 characters.'
|
||||
wt = _('Renaming not possible')
|
||||
msg_t = _('The new name may contain only 12 characters')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
elif len(self.lb_rename.get()) == 0:
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Renaming not possible'
|
||||
msg_t = 'At least one character must be entered.'
|
||||
wt = _('Renaming not possible')
|
||||
msg_t = _('At least one character must be entered')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
elif any(ch in special_characters for ch in self.lb_rename.get()):
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Renaming not possible'
|
||||
msg_t = 'No valid sign. These must not be used.\nBlank, Slash, Backslash and { }\n'
|
||||
wt = _('Renaming not possible')
|
||||
msg_t = _('No valid sign. These must not be used.\nBlank, Slash, Backslash and { }\n')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
@ -642,11 +647,11 @@ class FrameWidgets(ttk.Frame):
|
||||
if self.a != '' and self.a == select_tl:
|
||||
self.a = Tunnel.active()
|
||||
self.StrVar.set(value=self.a)
|
||||
with open(path_to_file2, 'r') as set_file5:
|
||||
with open(wg_set, 'r') as set_file5:
|
||||
lines5 = set_file5.readlines()
|
||||
if select_tl == lines5[7].strip() and 'off' not in lines5[7].strip():
|
||||
lines5[7] = new_a_connect
|
||||
with open(path_to_file2, 'w') as theme_set5:
|
||||
with open(wg_set, 'w') as theme_set5:
|
||||
theme_set5.writelines(lines5)
|
||||
self.autoconnect_var.set(value=new_a_connect)
|
||||
|
||||
@ -655,34 +660,34 @@ class FrameWidgets(ttk.Frame):
|
||||
except IndexError:
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Renaming not possible'
|
||||
msg_t = 'Please select a tunnel from the list.'
|
||||
wt = _('Renaming not possible')
|
||||
msg_t = _('Please select a tunnel from the list')
|
||||
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_frame4, 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 """
|
||||
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')
|
||||
_('You must have at least one\n'
|
||||
'tunnel in the list,to use the autostart'))
|
||||
|
||||
def chk_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -693,7 +698,7 @@ class FrameWidgets(ttk.Frame):
|
||||
def chk_a_enter(event):
|
||||
""" The mouse moves into the entry widget """
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||
'To use the autostart, enable this Checkbox')
|
||||
_('To use the autostart, enable this Checkbox'))
|
||||
|
||||
def chk_a_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -710,7 +715,7 @@ class FrameWidgets(ttk.Frame):
|
||||
def chk_a_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')
|
||||
_('To use the autostart, a tunnel must be selected from the list'))
|
||||
|
||||
def chk_a_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -722,6 +727,7 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
self.on_off()
|
||||
|
||||
def import_sl(self):
|
||||
"""
|
||||
Import Methode for Wireguard config Files.
|
||||
Before importing, it is checked whether PrivateKey and PublicKey are in the file.
|
||||
@ -732,12 +738,9 @@ class FrameWidgets(ttk.Frame):
|
||||
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):
|
||||
|
||||
try:
|
||||
filepath = filedialog.askopenfilename(initialdir=str(_u), title='Select Wireguard config File',
|
||||
filetypes=[('WG config files', '*.conf')], )
|
||||
filepath = filedialog.askopenfilename(initialdir=str(_u), title=_('Select Wireguard config File'),
|
||||
filetypes=[(_('WG config files'), '*.conf')], )
|
||||
|
||||
with open(filepath, 'r') as file:
|
||||
read = file.read()
|
||||
@ -754,10 +757,10 @@ class FrameWidgets(ttk.Frame):
|
||||
p_key = readfile.readlines()
|
||||
if pre_key in p_key or pre_key + '\n' in p_key:
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
||||
iw = r'/usr/share/icons/lx-icons/64/error.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Import Error'
|
||||
msg_t = 'Tunnel already available!\nPlease use another file for import'
|
||||
wt = _('Import Error')
|
||||
msg_t = _('Tunnel already available!\nPlease use another file for import')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
@ -796,8 +799,8 @@ class FrameWidgets(ttk.Frame):
|
||||
def chk_a_enter(event):
|
||||
""" The mouse moves into the entry widget """
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||
'To use the autostart, enable this '
|
||||
'Checkbox')
|
||||
_('To use the autostart, enable this '
|
||||
'Checkbox'))
|
||||
|
||||
def chk_a_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -807,7 +810,7 @@ class FrameWidgets(ttk.Frame):
|
||||
def list_info_enter(event):
|
||||
""" The mouse moves into the entry widget """
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||
'List of available tunnels')
|
||||
_('List of available tunnels'))
|
||||
|
||||
def list_info_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -817,8 +820,8 @@ class FrameWidgets(ttk.Frame):
|
||||
def del_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!')
|
||||
_('Click to delete a Wireguard '
|
||||
'Tunnel\nSelect from the list!'))
|
||||
|
||||
def del_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -828,8 +831,8 @@ class FrameWidgets(ttk.Frame):
|
||||
def exp_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')
|
||||
_(' Click to export '
|
||||
'all\nWireguard Tunnel to Zipfile'))
|
||||
|
||||
def exp_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -839,8 +842,8 @@ class FrameWidgets(ttk.Frame):
|
||||
def rename_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\n'
|
||||
'select a tunnel from the list')
|
||||
_('To rename a tunnel, you need to\n'
|
||||
'select a tunnel from the list'))
|
||||
|
||||
def rename_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -874,10 +877,10 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
if 'PrivateKey = ' and 'Endpoint = ' not in read:
|
||||
"""img_w, img_i, w_title, w_txt hand over"""
|
||||
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
||||
iw = r'/usr/share/icons/lx-icons/64/error.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Import Error'
|
||||
msg_t = 'Oh... no valid Wireguard File!\nPlease select a valid Wireguard File'
|
||||
wt = _('Import Error')
|
||||
msg_t = _('Oh... no valid Wireguard File!\nPlease select a valid Wireguard File')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
except EOFError:
|
||||
@ -890,23 +893,21 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
print('Tunnel exist!')
|
||||
|
||||
'''
|
||||
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.
|
||||
'''
|
||||
|
||||
def box_set(self):
|
||||
|
||||
"""
|
||||
try:
|
||||
select_tunnel = self.l_box.curselection()
|
||||
select_tl = self.l_box.get(select_tunnel[0])
|
||||
|
||||
if self.selected_option.get() == 0:
|
||||
with open(path_to_file2, 'r') as set_file3:
|
||||
with open(wg_set, 'r') as set_file3:
|
||||
lines3 = set_file3.readlines()
|
||||
lines3[7] = 'off'
|
||||
with open(path_to_file2, 'w') as set_file3:
|
||||
with open(wg_set, 'w') as set_file3:
|
||||
set_file3.writelines(lines3)
|
||||
|
||||
tl = Tunnel.list()
|
||||
@ -915,10 +916,10 @@ class FrameWidgets(ttk.Frame):
|
||||
self.wg_autostart.configure(state='disabled')
|
||||
|
||||
if self.selected_option.get() >= 1:
|
||||
with open(path_to_file2, 'r') as set_file3:
|
||||
with open(wg_set, 'r') as set_file3:
|
||||
lines3 = set_file3.readlines()
|
||||
lines3[7] = select_tl
|
||||
with open(path_to_file2, 'w') as set_file3:
|
||||
with open(wg_set, 'w') as set_file3:
|
||||
set_file3.writelines(lines3)
|
||||
|
||||
except IndexError:
|
||||
@ -926,14 +927,13 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
self.on_off()
|
||||
|
||||
'''
|
||||
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
|
||||
'''
|
||||
|
||||
def on_off(self):
|
||||
with open(path_to_file2, 'r') as set_file4:
|
||||
"""
|
||||
with open(wg_set, 'r') as set_file4:
|
||||
lines4 = set_file4.readlines()
|
||||
|
||||
if lines4[7] != 'off':
|
||||
@ -944,28 +944,28 @@ class FrameWidgets(ttk.Frame):
|
||||
else:
|
||||
|
||||
self.wg_autostart.configure(state='disabled')
|
||||
self.auto_con = 'no Autoconnect'
|
||||
self.auto_con = _('no Autoconnect')
|
||||
self.autoconnect_var.set('')
|
||||
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)
|
||||
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
|
||||
"""
|
||||
|
||||
def init_and_report(self, data=None):
|
||||
""" Address Label """
|
||||
self.add = tk.StringVar()
|
||||
self.add.set('Address: ' + data[0])
|
||||
self.add.set(_('Address: ') + data[0])
|
||||
self.DNS = tk.StringVar()
|
||||
self.DNS.set(' DNS: ' + data[1])
|
||||
self.enp = tk.StringVar()
|
||||
self.enp.set('Endpoint: ' + data[2])
|
||||
self.enp.set(_('Endpoint: ') + data[2])
|
||||
|
||||
def label_empty(self):
|
||||
self.add.set('')
|
||||
@ -989,13 +989,13 @@ 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)
|
||||
|
||||
def stop_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')
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, _('Click to stop selected Wireguard Tunnel'))
|
||||
|
||||
def stop_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -1006,13 +1006,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 """
|
||||
@ -1021,8 +1021,7 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
def start_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')
|
||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, _('Click to start selected Wireguard Tunnel'))
|
||||
|
||||
def start_leave(_):
|
||||
""" The mouse moves from the entry widget """
|
||||
@ -1038,7 +1037,9 @@ class FrameWidgets(ttk.Frame):
|
||||
self.btn_stst.bind('<Leave>', start_leave)
|
||||
|
||||
def color_label(self):
|
||||
with open(path_to_file2, 'r') as read_file:
|
||||
""" View activ Tunnel in color green or yellow """
|
||||
|
||||
with open(wg_set, 'r') as read_file:
|
||||
lines = read_file.readlines()
|
||||
if 'light\n' in lines:
|
||||
self.lb_tunnel = ttk.Label(self, textvariable=self.StrVar, foreground='green')
|
||||
@ -1050,6 +1051,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 == '':
|
||||
@ -1096,29 +1098,29 @@ class FrameWidgets(ttk.Frame):
|
||||
if self.l_box.size() != 0:
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Select tunnel'
|
||||
msg_t = 'Please select a tunnel from the list.'
|
||||
wt = _('Select tunnel')
|
||||
msg_t = _('Please select a tunnel from the list')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
|
||||
"""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/lx-icons/64/info.png'
|
||||
ii = r'/usr/share/icons/wp-icons/48/wg_msg.png'
|
||||
wt = 'Select tunnel'
|
||||
msg_t = 'Please first import tunnel.'
|
||||
wt = _('Select tunnel')
|
||||
msg_t = _('Please first import tunnel')
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
|
||||
class MyToolTip(tk.Toplevel):
|
||||
TIP_X_OFFSET = 20
|
||||
TIP_Y_OFFSET = 20
|
||||
if not tips:
|
||||
if not wg_tips:
|
||||
AUTO_CLEAR_TIME = 0
|
||||
else:
|
||||
AUTO_CLEAR_TIME = 900 # Millisecond. (1/90 sec.)
|
||||
AUTO_CLEAR_TIME = 2000 # Millisecond. (1/200 sec.)
|
||||
|
||||
def __init__(self, x_pos, y_pos, message=None, auto_clear=True):
|
||||
self.x_pos = x_pos
|
||||
|