Merge pull request 'add if question and add autoconnect, autoconnect_var to class Filehandle in box_set no finish!' (#11) from wire-py-reformat-14-08-2024 into main

Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/11
This commit is contained in:
Désiré Werner Menrath 2024-09-04 09:20:05 +02:00
commit 7b1e543428
4 changed files with 36 additions and 9 deletions

View File

@ -4,11 +4,11 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="little fixes a &quot; &quot; to ' '">
<change afterPath="$PROJECT_DIR$/wg_py.xml" afterDir="false" />
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="add class FileHandle,&#10;add Label to show autoconnect Tunnel&#10;disable checkbox when Listbox is empty or no select Tunnel">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wg_func.py" beforeDir="false" afterPath="$PROJECT_DIR$/wg_func.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wg_py.xml" beforeDir="false" afterPath="$PROJECT_DIR$/wg_py.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -260,7 +260,15 @@
<option name="project" value="LOCAL" />
<updated>1725119445803</updated>
</task>
<option name="localTasksCounter" value="22" />
<task id="LOCAL-00022" summary="add class FileHandle,&#10;add Label to show autoconnect Tunnel&#10;disable checkbox when Listbox is empty or no select Tunnel">
<option name="closed" value="true" />
<created>1725391658456</created>
<option name="number" value="00022" />
<option name="presentableId" value="LOCAL-00022" />
<option name="project" value="LOCAL" />
<updated>1725391658456</updated>
</task>
<option name="localTasksCounter" value="23" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -308,6 +316,7 @@
<MESSAGE value="add export Tunnel as zip" />
<MESSAGE value="columnconfigure on all widgets set" />
<MESSAGE value="little fixes a &quot; &quot; to ' '" />
<option name="LAST_COMMIT_MESSAGE" value="little fixes a &quot; &quot; to ' '" />
<MESSAGE value="add class FileHandle,&#10;add Label to show autoconnect Tunnel&#10;disable checkbox when Listbox is empty or no select Tunnel" />
<option name="LAST_COMMIT_MESSAGE" value="add class FileHandle,&#10;add Label to show autoconnect Tunnel&#10;disable checkbox when Listbox is empty or no select Tunnel" />
</component>
</project>

View File

@ -180,6 +180,8 @@ class FrameWidgets(ttk.Frame):
text='Autoconnect on:',
variable=self.selected_option,
command=lambda: FileHandle.box_set(self))
self.wg_autostart.grid(column=1, row=4, sticky='nw')
on_or_off = open('wg_py.xml', 'r')
res = on_or_off.read()
if 'true' in res:
@ -192,8 +194,6 @@ class FrameWidgets(ttk.Frame):
self.auto_con = 'no Autoconnect'
on_or_off.close()
self.wg_autostart.grid(column=1, row=4, sticky='nw')
self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con)
self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, bd=2, fg='blue', padx=5)

View File

@ -233,6 +233,8 @@ class FileHandle:
def __init__(self):
self.wg_autostart = None
self.autoconnect = None
self.auto_con = None
self.autoconnect_var = None
self.tl = None
@ -257,7 +259,6 @@ class FileHandle:
os.system('nmcli con mod ' + str(tl) + ' connection.autoconnect no')
replacement = replacement + changes + "\n"
set_on.close()
self.autoconnect_var.set('')
if self.selected_option.get() == 1:
set_on = open('wg_py.xml', 'r')
replacement = ""
@ -271,10 +272,27 @@ class FileHandle:
set_off = open('wg_py.xml', 'w')
set_off.write(replacement)
set_off.close()
self.autoconnect_var.set(self.auto_con)
except IndexError:
self.selected_option.set(1)
on_or_off = open('wg_py.xml', 'r')
res = on_or_off.read()
if 'true' in res:
self.selected_option.set(1)
self.auto_con = res
self.auto_con = self.auto_con[5:]
print(self.auto_con)
else:
self.wg_autostart.configure(state='disabled')
self.auto_con = 'no Autoconnect'
on_or_off.close()
self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con)
self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, bd=2, fg='blue', padx=5)
self.autoconnect.config(font=('Ubuntu', 11))
self.autoconnect.grid(column=1, row=4, sticky='we')
class ExportTunnels:
@staticmethod

View File

@ -1 +1 @@
true iphone-wg
false iphone-wg