add method init_and_report and label_empty to Class ShowAddress

This commit is contained in:
Désiré Werner Menrath 2024-08-23 12:57:07 +02:00
parent 101a2167b6
commit c87ba4493d
3 changed files with 33 additions and 26 deletions

View File

@ -4,9 +4,10 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="fixed error when active tunnel is deleted,&#10;now also the Address Label is emptied">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment="In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together">
<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" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -186,7 +187,15 @@
<option name="project" value="LOCAL" />
<updated>1724400463791</updated>
</task>
<option name="localTasksCounter" value="13" />
<task id="LOCAL-00013" summary="In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together">
<option name="closed" value="true" />
<created>1724401340512</created>
<option name="number" value="00013" />
<option name="presentableId" value="LOCAL-00013" />
<option name="project" value="LOCAL" />
<updated>1724401340512</updated>
</task>
<option name="localTasksCounter" value="14" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -225,6 +234,7 @@
<MESSAGE value="Set Style to Clam&#10;Improved layout of widgets" />
<MESSAGE value="Remove open file function, add Show Address Labels with tk.StrVar when remove a not active Tunnel Labels of Active Tunnel removed!" />
<MESSAGE value="fixed error when active tunnel is deleted,&#10;now also the Address Label is emptied" />
<option name="LAST_COMMIT_MESSAGE" value="fixed error when active tunnel is deleted,&#10;now also the Address Label is emptied" />
<MESSAGE value="In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together" />
<option name="LAST_COMMIT_MESSAGE" value="In FrameWidged Class else Block StrVar, this resorts reference and variable assignment together" />
</component>
</project>

27
main.py
View File

@ -103,12 +103,7 @@ class FrameWidgets(ttk.Frame):
file = open(wg_read, 'r')
data = ConToDict.covert_to_dict(file)
# Address Label
self.add = tk.StringVar()
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])
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
file.close()
else:
@ -117,9 +112,7 @@ class FrameWidgets(ttk.Frame):
self.add = tk.StringVar()
self.DNS = tk.StringVar()
self.enp = tk.StringVar()
self.add.set('')
self.DNS.set('')
self.enp.set('')
ShowAddress.label_empty(self)
ShowAddress.show_data(self)
# Button Import
self.btn_i = tk.Button(self, image=self.imp_pic, bd=0, command=lambda: ImportTunnel.wg_import_select(self))
@ -136,11 +129,8 @@ class FrameWidgets(ttk.Frame):
StartStopBTN.button_start(self)
self.l_box.update()
# Address Label
self.add.set('')
self.DNS.set('')
self.enp.set('')
ShowAddress.label_empty(self)
ShowAddress.show_data(self)
# Button Trash
self.btn_tr = tk.Button(self, image=self.tr_pic, bd=0, command=delete)
self.btn_tr.grid(column=0, row=3, padx=15, pady=15)
@ -164,12 +154,7 @@ class FrameWidgets(ttk.Frame):
file = open(wg_read, 'r')
data = ConToDict.covert_to_dict(file)
# Address Label
self.add = tk.StringVar()
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])
ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
file.close()
# Button Start/Stop
@ -188,9 +173,7 @@ class FrameWidgets(ttk.Frame):
self.StrVar.set('')
GreenLabel.green_show_label(self)
# Address Label
self.add.set('')
self.DNS.set('')
self.enp.set('')
ShowAddress.label_empty(self)
ShowAddress.show_data(self)

View File

@ -118,6 +118,20 @@ class ShowAddress(tk.Tk):
self.DNS = None
self.add = None
def init_and_report(self, data=None):
# Address Label
self.add = tk.StringVar()
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])
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')