Merge pull request '- Create file for settings (Autoupdate)' (#17) from 1.10.1224 into main
Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/17
This commit is contained in:
commit
de2929896d
@ -4,13 +4,15 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="Changelog create When exporting, the folder is now copied to /tmp and the non .conf files are deleted before the zip file is created. In main.py os import removed. Since os have been replaced by pathlib and shutil. Start with version number 1.4.7 Message window size corrected so text is displayed better">
|
||||
<change afterPath="$PROJECT_DIR$/wire-py1.10.0424.tar.gz" afterDir="false" />
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="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">
|
||||
<change afterPath="$PROJECT_DIR$/settings" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/theme" 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$/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$/wire-py1.10.0424.tar.gz" beforeDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -124,7 +126,7 @@
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-python-sdk-8336bb23522e-31b6be0877a2-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-241.19072.16" />
|
||||
<option value="bundled-python-sdk-0e3be3396995-c546a90a8094-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-242.23339.19" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
@ -137,14 +139,6 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1723279982210</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00008" summary="add file dict_to_address for address a active Tunnel. Label green pack in Class. add Class to convert fileoutput as String to Dictionary">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724233806458</created>
|
||||
<option name="number" value="00008" />
|
||||
<option name="presentableId" value="LOCAL-00008" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1724233806458</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00009" summary="add Class StartStopBTN to wg_func.py">
|
||||
<option name="closed" value="true" />
|
||||
<created>1724237471056</created>
|
||||
@ -529,7 +523,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1727525609728</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="57" />
|
||||
<task id="LOCAL-00057" summary="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">
|
||||
<option name="closed" value="true" />
|
||||
<created>1728059870005</created>
|
||||
<option name="number" value="00057" />
|
||||
<option name="presentableId" value="LOCAL-00057" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1728059870005</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="58" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="UnknownFeatures">
|
||||
@ -570,7 +572,6 @@
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||
<MESSAGE value="new format little fixes icons sort add policy add .desktop File install Part 2" />
|
||||
<MESSAGE value="install fix for set dir right" />
|
||||
<MESSAGE value="fix checkbox disable and policy rename main.py to wg_main.py" />
|
||||
<MESSAGE value="fix rename in Messagebox warning to error" />
|
||||
@ -595,6 +596,7 @@
|
||||
<MESSAGE value="fix msg_boxes when tunnel list = 0 a Start, Delete and Export" />
|
||||
<MESSAGE value="fix installer add .keys file" />
|
||||
<MESSAGE value="Changelog create When exporting, the folder is now copied to /tmp and the non .conf files are deleted before the zip file is created. In main.py os import removed. Since os have been replaced by pathlib and shutil. Start with version number 1.4.7 Message window size corrected so text is displayed better" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Changelog create When exporting, the folder is now copied to /tmp and the non .conf files are deleted before the zip file is created. In main.py os import removed. Since os have been replaced by pathlib and shutil. Start with version number 1.4.7 Message window size corrected so text is displayed better" />
|
||||
<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" />
|
||||
<option name="LAST_COMMIT_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" />
|
||||
</component>
|
||||
</project>
|
13
Changelog
13
Changelog
@ -2,17 +2,24 @@ Changelog for Wire-Py
|
||||
My standard System: Linux Mint 22 Cinnamon
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- os import in wg_func replaced by other methods
|
||||
- Autoupdate in Options
|
||||
- Guide to menu '?' with pictures
|
||||
- Create file for settings (Autoupdate)
|
||||
- In Gitea Readme enter text, images
|
||||
- Dark Theme for Wire-Py
|
||||
- Own filedialog for import
|
||||
- If Wire-Py already runs, prevent further start
|
||||
- for loops with lists replaced by List Comprehensions
|
||||
- Keeping Classes Together
|
||||
|
||||
### Added
|
||||
12-10-2024
|
||||
|
||||
- Create file for settings (Autoupdate)
|
||||
- Create file for theme
|
||||
- Autoupdate in Options
|
||||
- Dark Theme for Wire-Py
|
||||
|
||||
|
||||
### Added
|
||||
04-10-2024
|
||||
|
||||
|
18
install
18
install
@ -6,9 +6,10 @@ BLUE='\033[30;1;34m'
|
||||
|
||||
install_file_with(){
|
||||
clear
|
||||
sudo apt install python3-tk && \
|
||||
sudo apt install python3-tk , tcl-ttkthemes && \
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -uR wp-icons /usr/share/icons/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -n settings theme /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && \
|
||||
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/ && \
|
||||
@ -19,9 +20,10 @@ install_file_with(){
|
||||
|
||||
install_arch_d(){
|
||||
clear
|
||||
sudo pacman -S --noconfirm tk python3 && \
|
||||
sudo pacman -S --noconfirm tk python3 python-requests && \
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -uR wp-icons /usr/share/icons/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -n settings theme /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && \
|
||||
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/ && \
|
||||
@ -88,7 +90,9 @@ elif grep -i 'fedora' /etc/os-release > /dev/null 2>&1
|
||||
then sudo dnf install python3-tkinter -y
|
||||
|
||||
sudo cp -u wg_main.py start_wg.py wg_func.py wirepy.py /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -uR wp-icons /usr/share/icons/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
||||
sudo cp -n settings theme /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && \
|
||||
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/ && \
|
||||
@ -102,7 +106,9 @@ elif grep -i 'suse' /etc/os-release > /dev/null 2>&1
|
||||
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 /usr/bin/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && sudo cp -uR wp-icons /usr/share/icons/ && \
|
||||
sudo mkdir -p /etc/wire_py && sudo touch /etc/wire_py/.keys && \
|
||||
sudo cp -n settings theme /etc/wire_py/ && \
|
||||
sudo cp -uR wp-icons /usr/share/icons/ && \
|
||||
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/ && \
|
||||
|
142
wg_func.py
142
wg_func.py
@ -8,13 +8,110 @@ import zipfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
from tkinter import filedialog
|
||||
from tkinter import filedialog, ttk
|
||||
import requests
|
||||
|
||||
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year '''
|
||||
version = 'v. 1.10.1224'
|
||||
|
||||
font_color = '#4011a7'
|
||||
dk_theme = '#2e2e2e'
|
||||
path_to_file = Path('/etc/wire_py/wg_py')
|
||||
path_to_file2 = Path('/etc/wire_py/settings')
|
||||
path_to_file3 = Path('/etc/wire_py/theme')
|
||||
_u = Path.read_text(Path('/tmp/_u'))
|
||||
|
||||
UPDATE_API_URL = 'https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases'
|
||||
|
||||
class WirePyUpdate:
|
||||
@staticmethod
|
||||
def api_down():
|
||||
try:
|
||||
response = requests.get(UPDATE_API_URL)
|
||||
response_dict = response.json()
|
||||
response_dict = response_dict[0]
|
||||
with open(path_to_file2, 'r') as set_file:
|
||||
set_file = set_file.read()
|
||||
if 'Update on' in set_file:
|
||||
if version[3:] != response_dict['tag_name']:
|
||||
return response_dict['tag_name']
|
||||
else:
|
||||
return 'No Updates'
|
||||
else:
|
||||
return 'False'
|
||||
except requests.exceptions.ConnectionError:
|
||||
return 'No Internet Connection!'
|
||||
|
||||
|
||||
@staticmethod
|
||||
def download():
|
||||
try:
|
||||
url = f'https://git.ilunix.de/punix/Wire-Py/archive/{res}.zip'
|
||||
to_down = 'wget -qP ' + str(_u) + ' ' + url
|
||||
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'
|
||||
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'
|
||||
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!'
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
|
||||
res = WirePyUpdate.api_down()
|
||||
|
||||
|
||||
class Themes:
|
||||
@staticmethod
|
||||
def dark():
|
||||
global back_gd
|
||||
with open(path_to_file3, 'w') as theme_set2:
|
||||
theme_set2.write('black')
|
||||
back_gd = '#424242'
|
||||
return back_gd
|
||||
|
||||
@staticmethod
|
||||
def light():
|
||||
global back_gd
|
||||
with open(path_to_file3, 'w') as theme_set2:
|
||||
theme_set2.write('light')
|
||||
back_gd = '#f5f6f7'
|
||||
return back_gd
|
||||
|
||||
def light_dark():
|
||||
|
||||
with open(path_to_file3) as theme_set:
|
||||
if 'black' in theme_set:
|
||||
theme = 'black'
|
||||
else:
|
||||
theme = 'arc'
|
||||
return theme
|
||||
|
||||
bg = light_dark()
|
||||
if bg == 'black':
|
||||
back_gd = '#424242'
|
||||
fore_gd = 'white'
|
||||
font_color_active = 'yellow'
|
||||
font_color = '#5e87da'
|
||||
else:
|
||||
back_gd = '#f5f6f7'
|
||||
fore_gd = 'black'
|
||||
font_color_active = 'green'
|
||||
font_color = '#4011a7'
|
||||
|
||||
def msg_window(img_w, img_i, w_title, w_txt):
|
||||
"""
|
||||
@ -26,18 +123,19 @@ def msg_window(img_w, img_i, w_title, w_txt):
|
||||
w_title = Windows Title
|
||||
w_txt = Text for Tk Window
|
||||
"""
|
||||
|
||||
msg = tk.Toplevel()
|
||||
msg.resizable(width=False, height=False)
|
||||
msg.title(w_title)
|
||||
msg.configure(pady=15)
|
||||
msg.configure(pady=15, padx=15, background=back_gd)
|
||||
msg.img = tk.PhotoImage(file=img_w)
|
||||
msg.i_window = tk.Label(msg, image=msg.img)
|
||||
msg.i_window = tk.Label(msg, image=msg.img, background=back_gd)
|
||||
msg.i_window.grid(column=0, row=0)
|
||||
label = tk.Label(msg, text=w_txt)
|
||||
label.config(font=('Ubuntu', 11), padx=15)
|
||||
label.config(font=('Ubuntu', 11), padx=15, background=back_gd, foreground=fore_gd)
|
||||
label.grid(column=1, row=0)
|
||||
button = tk.Button(msg, text='OK', command=msg.destroy)
|
||||
button.config(padx=15)
|
||||
button = ttk.Button(msg, text='OK', command=msg.destroy, padding=4)
|
||||
button.config()
|
||||
button.grid(column=0, columnspan=2, row=1)
|
||||
img_i = tk.PhotoImage(file=img_i)
|
||||
msg.iconphoto(True, img_i)
|
||||
@ -52,13 +150,11 @@ class GreenLabel:
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.StrVar = None
|
||||
self.lb_tunnel = None
|
||||
|
||||
def green_show_label(self):
|
||||
|
||||
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
|
||||
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, foreground=font_color_active, background=back_gd)
|
||||
self.lb_tunnel.config(font=('Ubuntu', 11, 'bold'))
|
||||
self.lb_tunnel.grid(column=2, padx=10, row=0)
|
||||
self.columnconfigure(2, weight=1)
|
||||
@ -77,7 +173,6 @@ class StartStopBTN:
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.lb_frame_btn_lbox = None
|
||||
self.wg_switch = None
|
||||
self.btn_stst = None
|
||||
@ -85,13 +180,13 @@ class StartStopBTN:
|
||||
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 = tk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
|
||||
self.btn_stst = tk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, bd=0, command=self.wg_switch,
|
||||
background=back_gd, highlightthickness=0, activebackground=back_gd)
|
||||
self.btn_stst.grid(column=0, row=0, padx=15, pady=8)
|
||||
|
||||
def button_start(self):
|
||||
|
||||
self.btn_stst = tk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
|
||||
self.btn_stst = tk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, bd=0, command=self.wg_switch,
|
||||
background=back_gd, highlightthickness=0, activebackground=back_gd)
|
||||
self.btn_stst.grid(column=0, row=0, padx=15, pady=8)
|
||||
|
||||
|
||||
@ -167,7 +262,6 @@ class ShowAddress:
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.lb_frame2 = None
|
||||
self.lb_frame = None
|
||||
self.endpoint = None
|
||||
@ -178,7 +272,6 @@ class ShowAddress:
|
||||
self.add = None
|
||||
|
||||
def init_and_report(self, data=None):
|
||||
|
||||
""" Address Label """
|
||||
self.add = tk.StringVar()
|
||||
self.add.set('Address: ' + data[0])
|
||||
@ -188,25 +281,23 @@ class ShowAddress:
|
||||
self.enp.set('Endpoint: ' + data[2])
|
||||
|
||||
def label_empty(self):
|
||||
|
||||
self.add.set('')
|
||||
self.DNS.set('')
|
||||
self.enp.set('')
|
||||
|
||||
def show_data(self):
|
||||
|
||||
""" Address Label """
|
||||
self.address = tk.Label(self.lb_frame, textvariable=self.add, fg='blue')
|
||||
self.address = tk.Label(self.lb_frame, textvariable=self.add, background=back_gd, foreground=font_color)
|
||||
self.address.grid(column=0, row=4, sticky='w', padx=10, pady=6)
|
||||
self.address.config(font=('Ubuntu', 9))
|
||||
|
||||
''' DNS Label '''
|
||||
self.dns = tk.Label(self.lb_frame, textvariable=self.DNS, fg='blue')
|
||||
self.dns = tk.Label(self.lb_frame, textvariable=self.DNS, background=back_gd, foreground=font_color)
|
||||
self.dns.grid(column=0, row=6, sticky='w', padx=10, pady=6)
|
||||
self.dns.config(font=('Ubuntu', 9))
|
||||
|
||||
''' Endpoint Label '''
|
||||
self.endpoint = tk.Label(self.lb_frame2, textvariable=self.enp, fg='blue')
|
||||
self.endpoint = tk.Label(self.lb_frame2, textvariable=self.enp, background=back_gd, foreground=font_color)
|
||||
self.endpoint.grid(column=0, row=7, sticky='w', padx=10, pady=10)
|
||||
self.endpoint.config(font=('Ubuntu', 9))
|
||||
|
||||
@ -407,7 +498,8 @@ class OnOff:
|
||||
self.autoconnect_var.set('')
|
||||
self.autoconnect_var = tk.StringVar()
|
||||
self.autoconnect_var.set(self.auto_con)
|
||||
self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, fg='blue', padx=5)
|
||||
self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var,padx=5,
|
||||
background=back_gd, foreground=font_color)
|
||||
self.autoconnect.config(font=('Ubuntu', 11))
|
||||
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=20)
|
||||
|
||||
@ -465,4 +557,4 @@ class ExportTunnels:
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
except TypeError:
|
||||
pass
|
||||
pass
|
101
wg_main.py
101
wg_main.py
@ -5,15 +5,22 @@ from subprocess import check_call
|
||||
from tkinter import *
|
||||
from pathlib import Path
|
||||
from tkinter import ttk
|
||||
|
||||
from wg_func import (TunnelActiv, ListTunnels, ImportTunnel, ConToDict, GreenLabel, StartStopBTN, ShowAddress,
|
||||
FileHandle, ExportTunnels, OnOff, msg_window)
|
||||
|
||||
font_color = '#4011a7'
|
||||
dk_theme = '#2e2e2e'
|
||||
''' 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year '''
|
||||
version = 'v. 1.10.0424'
|
||||
FileHandle, ExportTunnels, OnOff, msg_window, WirePyUpdate, res, version, Themes, bg, font_color,
|
||||
path_to_file2, back_gd, fore_gd)
|
||||
|
||||
label_bg = '#d9d9d9'
|
||||
if bg == 'black':
|
||||
back_gd = '#424242'
|
||||
fore_gd = 'white'
|
||||
lbox_color = '#5c5c5c'
|
||||
font_color_update = 'yellow'
|
||||
else:
|
||||
back_gd = '#f5f6f7'
|
||||
fore_gd = 'black'
|
||||
lbox_color = 'white'
|
||||
lbox_font_color = 'grey'
|
||||
font_color_update = 'green'
|
||||
|
||||
class MainWindow(tk.Tk):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -27,33 +34,67 @@ class MainWindow(tk.Tk):
|
||||
self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 2)
|
||||
self.resizable(width=False, height=False)
|
||||
self.title('Wire-Py')
|
||||
self.configure()
|
||||
self.configure(background=back_gd)
|
||||
self.geometry('%dx%d+%d+%d' % (self.x_width, self.y_height, self.monitor_center_x, self.monitor_center_y))
|
||||
self.columnconfigure(0, weight=1)
|
||||
self.rowconfigure(0, weight=1)
|
||||
self.style = ttk.Style(self)
|
||||
self.style.theme_use('clam')
|
||||
self.style.theme_use(bg)
|
||||
|
||||
''' Load the image file from disk. '''
|
||||
self.wg_icon = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn.png')
|
||||
# Set it as the window icon.
|
||||
self.iconphoto(True, self.wg_icon)
|
||||
|
||||
# App Menu
|
||||
self.app_menu = tk.Menu(self, borderwidth=0)
|
||||
#Set on or off in file
|
||||
def on_off():
|
||||
if set_option.get() == 1:
|
||||
with open(path_to_file2, 'w') as set_file2:
|
||||
set_file2.write('Update off')
|
||||
|
||||
if set_option.get() == 0:
|
||||
with open(path_to_file2, 'w') as set_file2:
|
||||
set_file2.write('Update on')
|
||||
|
||||
# App Menu
|
||||
self.app_menu = tk.Menu(self, borderwidth=0, tearoff=tk.NO, disabledforeground=font_color,
|
||||
background=back_gd, foreground=fore_gd)
|
||||
self.configure(menu=self.app_menu)
|
||||
self.app_menu.add_cascade(label=version)
|
||||
self.app_menu.add_cascade(label='Options')
|
||||
set_option = tk.IntVar()
|
||||
|
||||
self.settings = tk.Menu(self.app_menu, tearoff=tk.NO, background=back_gd)
|
||||
self.settings.add_checkbutton(label='Disable updates', command=on_off,
|
||||
variable=set_option, foreground=fore_gd)
|
||||
self.settings.add_command(label='Dark', command=Themes.dark, background=back_gd, foreground=fore_gd)
|
||||
self.settings.add_command(label='Light', command=Themes.light, background=back_gd, foreground=fore_gd)
|
||||
self.to_load = tk.Menu(self.app_menu, tearoff=tk.NO, background=back_gd)
|
||||
self.to_load.add_command(label='Download Update', command=WirePyUpdate.download,
|
||||
foreground=fore_gd, background=back_gd)
|
||||
self.app_menu.add_cascade(label=version, state='disabled')
|
||||
self.app_menu.add_cascade(label='Options', menu=self.settings, background=back_gd, foreground=fore_gd)
|
||||
self.app_menu.add_cascade(label='?')
|
||||
|
||||
if res == 'False':
|
||||
set_option.set(value=1)
|
||||
self.app_menu.add_cascade(label='Update search off', activebackground=back_gd,
|
||||
activeforeground=fore_gd, background=back_gd)
|
||||
elif res == 'No Internet Connection!':
|
||||
self.app_menu.add_cascade(label='No Internet Connection!', foreground='red', activebackground=back_gd,
|
||||
activeforeground='red')
|
||||
elif res == 'No Updates':
|
||||
self.app_menu.add_cascade(label='No Updates', activeforeground=fore_gd, activebackground=back_gd)
|
||||
|
||||
else:
|
||||
set_option.set(value=0)
|
||||
self.app_menu.add_cascade(label=f'Update {res} available!', menu=self.to_load, foreground=font_color_update,
|
||||
activebackground=back_gd, activeforeground=font_color_update)
|
||||
|
||||
FrameWidgets(self).grid()
|
||||
|
||||
|
||||
class FrameWidgets(ttk.Frame):
|
||||
def __init__(self, container, **kwargs):
|
||||
super().__init__(container, **kwargs)
|
||||
|
||||
self.auto_con = None
|
||||
self.enp = None
|
||||
self.DNS = None
|
||||
@ -95,7 +136,7 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
''' Show active Label '''
|
||||
self.select_tunnel = None
|
||||
self.lb = tk.Label(self, text='Active: ')
|
||||
self.lb = tk.Label(self, text='Active: ', background=back_gd, foreground=fore_gd)
|
||||
self.lb.config(font=('Ubuntu', 11, 'bold'))
|
||||
self.lb.grid(column=2, row=0, padx=15, sticky='w')
|
||||
self.columnconfigure(2, weight=1)
|
||||
@ -106,12 +147,12 @@ class FrameWidgets(ttk.Frame):
|
||||
GreenLabel.green_show_label(self)
|
||||
|
||||
''' Interface Label '''
|
||||
self.interface = tk.Label(self.lb_frame, text='Interface', fg=font_color)
|
||||
self.interface = tk.Label(self.lb_frame, text='Interface', background=back_gd, foreground=font_color)
|
||||
self.interface.grid(column=0, row=2, sticky='we', padx=120)
|
||||
self.interface.config(font=('Ubuntu', 9))
|
||||
|
||||
''' Peer Label '''
|
||||
self.peer = tk.Label(self.lb_frame2, text='Peer', fg=font_color)
|
||||
self.peer = tk.Label(self.lb_frame2, text='Peer', background=back_gd, foreground=font_color)
|
||||
self.peer.config(font=('Ubuntu', 9))
|
||||
self.peer.grid(column=0, row=3, sticky='we', padx=130)
|
||||
|
||||
@ -124,8 +165,9 @@ class FrameWidgets(ttk.Frame):
|
||||
self.lb_rename.delete(0, tk.END)
|
||||
self.btn_rename.config(state='normal')
|
||||
|
||||
self.l_box = tk.Listbox(self.lb_frame_btn_lbox, fg='#606060', selectmode='single')
|
||||
self.l_box.config(highlightthickness=0, relief='ridge')
|
||||
self.l_box = tk.Listbox(self.lb_frame_btn_lbox, background=lbox_color, foreground=fore_gd,
|
||||
selectmode='single')
|
||||
self.l_box.config(relief='ridge')
|
||||
self.l_box.config(font=('Ubuntu', 12, 'bold'))
|
||||
self.l_box.grid(column=1, rowspan=4, row=0, sticky='ns')
|
||||
self.l_box.event_add('<<ClickEvent>>', '<Button-1>')
|
||||
@ -164,7 +206,8 @@ class FrameWidgets(ttk.Frame):
|
||||
''' Button Import '''
|
||||
self.btn_i = tk.Button(self.lb_frame_btn_lbox,
|
||||
image=self.imp_pic, bd=0,
|
||||
command=lambda: ImportTunnel.wg_import_select(self))
|
||||
command=lambda: ImportTunnel.wg_import_select(self), activebackground=back_gd,
|
||||
background=back_gd, borderwidth=0, highlightthickness=0)
|
||||
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
|
||||
|
||||
def delete():
|
||||
@ -230,11 +273,13 @@ class FrameWidgets(ttk.Frame):
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
''' Button Trash '''
|
||||
self.btn_tr = tk.Button(self.lb_frame_btn_lbox, image=self.tr_pic, bd=0, command=delete)
|
||||
self.btn_tr = tk.Button(self.lb_frame_btn_lbox, image=self.tr_pic, bd=0, command=delete,
|
||||
activebackground=back_gd, background=back_gd, borderwidth=0, highlightthickness=0)
|
||||
self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
|
||||
|
||||
''' Button Export '''
|
||||
self.btn_exp = tk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, bd=0, command=ExportTunnels.wg_export)
|
||||
self.btn_exp = tk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, bd=0, command=ExportTunnels.wg_export,
|
||||
activebackground=back_gd, background=back_gd, borderwidth=0, highlightthickness=0)
|
||||
self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
|
||||
|
||||
''' Label Entry '''
|
||||
@ -310,7 +355,7 @@ class FrameWidgets(ttk.Frame):
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
''' Button Rename '''
|
||||
self.btn_rename = ttk.Button(self, text='Rename', state='disable', command=tl_rename)
|
||||
self.btn_rename = ttk.Button(self, text='Rename', state='disable', command=tl_rename, padding=4)
|
||||
self.btn_rename.grid(column=2, row=4, padx=20, pady=10, sticky='e')
|
||||
|
||||
''' Check Buttons '''
|
||||
@ -319,18 +364,17 @@ class FrameWidgets(ttk.Frame):
|
||||
self.autoconnect_var.set(self.auto_con)
|
||||
self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, fg='blue', padx=5)
|
||||
self.autoconnect.config(font=('Ubuntu', 11))
|
||||
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=10)
|
||||
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=20)
|
||||
self.wg_autostart = tk.Checkbutton(self,
|
||||
text='Autoconnect on:',
|
||||
variable=self.selected_option,
|
||||
command=lambda: FileHandle.box_set(self))
|
||||
command=lambda: FileHandle.box_set(self), activebackground=back_gd,
|
||||
background=back_gd, foreground=fore_gd, selectcolor=back_gd,
|
||||
highlightthickness=0)
|
||||
self.wg_autostart.grid(column=0, row=4, pady=19, padx=15, sticky='nw')
|
||||
|
||||
OnOff.on_off(self)
|
||||
|
||||
#self.wg_update = tk.Checkbutton(self, tex='Search automatically for\nWire-Py updates')
|
||||
#self.wg_update.grid(column=1, rowspan=3, row=5)
|
||||
|
||||
def wg_switch(self):
|
||||
self.a = TunnelActiv.active()
|
||||
try:
|
||||
@ -408,3 +452,4 @@ if __name__ == '__main__':
|
||||
window.tk.call('set', '::tk::dialog::file::showHiddenBtn', '0')
|
||||
window.tk.call('set', '::tk::dialog::file::showHiddenVar', '0')
|
||||
window.mainloop()
|
||||
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user