@@ -42,7 +42,9 @@ def __init__(self):
4242 self .click_value_3rd = ''
4343 self .click_value_VPN = ''
4444 self .root = TkinterDnD .Tk ()
45- self .root .title ("Network Sketcher ver 2.5.5" )
45+ style = ttk .Style (self .root )
46+ style .configure ('TNotebook.Tab' , font = ('TkDefaultFont' , 11 ))
47+ self .root .title ("Network Sketcher ver 2.6.0" )
4648 self .root .geometry ("510x200+100+100" )
4749
4850 def resource_path (relative_path ):
@@ -64,22 +66,24 @@ def resource_path(relative_path):
6466 # create Tabs
6567 tab_x1 = tk .Frame (nb )
6668 tab_x2 = tk .Frame (nb )
69+ tab_x3 = tk .Frame (nb )
6770
6871 nb .add (tab_x1 , text = ' Main Panel ' , padding = 5 )
72+ nb .add (tab_x3 , text = ' External Systems ' , padding = 5 )
6973 nb .add (tab_x2 , text = ' Help ' , padding = 5 )
7074 nb .pack (expand = 1 , fill = 'both' )
7175
7276 '''
7377 tab_x1 <<Main Panel>>
7478 '''
75- self .main1_1 = tk .LabelFrame (tab_x1 , text = " Please input a file for Network Sketcher " , font = ("" , 14 ), height = 1 , background = "#F2FDE3" )
79+ self .main1_1 = tk .LabelFrame (tab_x1 , text = " Select a file for use with Network Sketcher " , font = ("" , 14 ), height = 1 , background = "#F2FDE3" , labelanchor = "n " )
7680 self .main1_1 .grid (row = 0 , column = 1 , sticky = 'W' , padx = 5 , pady = 5 , ipadx = 5 , ipady = 5 )
7781
7882 self .main1_1_label_1 = tk .Label (self .main1_1 , text = "" , background = "#F2FDE3" )
7983 self .main1_1_label_1 .grid (row = 1 , column = 0 , sticky = 'W' , padx = 5 , pady = 5 , ipadx = 5 , ipady = 5 )
8084
8185 self .text = tk .StringVar ()
82- self .text .set (" drag and drop here (*.pptx;*.xlsx;*.yaml )" )
86+ self .text .set (" drag and drop here (*.pptx; *.xlsx)" )
8387 self .main1_1_label_4 = tk .Label (self .main1_1 , textvariable = self .text , font = ("" , 10 ), background = "#F2FDE3" )
8488 self .main1_1_label_4 .grid (row = 4 , column = 1 , columnspan = 3 , sticky = 'W' , padx = 5 , pady = 2 )
8589
@@ -98,11 +102,10 @@ def resource_path(relative_path):
98102 self .main1_1 .drop_target_register (DND_FILES )
99103 self .main1_1 .dnd_bind ("<<Drop>>" , self .drop_main1_1 ,self .entry_name_main1_1 )
100104
101- ### Help
102- #Help_1_label_1 = tk.Label(tab_x2, text="Version 2.1.0", background="#FFFFFF")
103- #Help_1_label_1.grid(row=0, column=0, sticky='W', padx=5, pady=2)
104-
105- Help_1 = tk .LabelFrame (tab_x2 , text = " Online User Guide " , font = ("" , 14 ), height = 1 , background = "#FFFFFF" )
105+ '''
106+ tab_x2 <<Help>>
107+ '''
108+ Help_1 = tk .LabelFrame (tab_x2 , text = " Online User Guide " , font = ("" , 14 ), height = 1 , background = "#FFFFFF" ,labelanchor = "n" )
106109 Help_1 .grid (row = 0 , column = 0 , sticky = 'W' , padx = 5 , pady = 5 , ipadx = 10 , ipady = 5 )
107110
108111 Help_1_button_2 = tk .Button (Help_1 , text = "English" , font = ("" , 14 ), command = lambda : self .click_action_main1_1 ('self.help_1_button_2' ))
@@ -117,6 +120,45 @@ def resource_path(relative_path):
117120 Help_1_1 = tk .Label (tab_x2 , font = ("" , 10 ), text = "Copyright 2023 Cisco Systems, Inc. and its affiliates \n SPDX-License-Identifier: Apache-2.0" , background = '#FFFFFF' )
118121 Help_1_1 .grid (column = 0 , row = 4 , pady = 2 )
119122
123+ '''
124+ tab_x3 <<External Systems>>
125+ '''
126+ self .external_systems1_1 = tk .LabelFrame (tab_x3 , text = " Select a file from an external system. \n CML(yaml), Visio(svg), draw.io(svg), NetBox(csv) " , font = ("" , 14 ), height = 1 , background = "#B8E7A7" ,labelanchor = "n" )
127+ self .external_systems1_1 .grid (row = 0 , column = 1 , sticky = 'W' , padx = 5 , pady = 5 , ipadx = 5 , ipady = 5 )
128+
129+ self .external_systems1_1_label_1 = tk .Label (self .external_systems1_1 , text = "" , background = "#B8E7A7" , font = ("" , 6 ))
130+ self .external_systems1_1_label_1 .grid (row = 1 , column = 0 , sticky = 'W' , padx = 5 , pady = 0 , ipadx = 5 , ipady = 0 )
131+
132+ self .text2 = tk .StringVar ()
133+ self .text2 .set (" drag and drop here (*.yaml; *.svg; *.csv)" )
134+ self .external_systems1_1_label_4 = tk .Label (self .external_systems1_1 , textvariable = self .text2 , font = ("" , 10 ), background = "#B8E7A7" )
135+ self .external_systems1_1_label_4 .grid (row = 4 , column = 1 , columnspan = 3 , sticky = 'W' , padx = 5 , pady = 2 )
136+
137+ self .external_systems1_1_label_6 = tk .Label (self .external_systems1_1 , text = "" , background = "#B8E7A7" )
138+ self .external_systems1_1_label_6 .grid (row = 5 , column = 1 , sticky = 'W' , padx = 5 , pady = 2 )
139+
140+ self .external_systems1_1_entry_1 = tk .Entry (self .external_systems1_1 )
141+ self .external_systems1_1_entry_1 .grid (row = 7 , column = 1 , sticky = "WE" , pady = 3 , ipadx = 90 )
142+ self .external_systems1_1_button_1 = tk .Button (self .external_systems1_1 , text = "Browse ..." , command = lambda : self .click_action_external_systems1_1 ('self.external_systems1_1_button_1' ))
143+ self .external_systems1_1_button_1 .grid (row = 7 , column = 2 , sticky = 'W' , padx = 5 , pady = 2 )
144+ self .external_systems1_1_button_2 = tk .Button (self .external_systems1_1 , text = "Submit" , command = lambda : self .click_action_external_systems1_1 ('self.external_systems1_1_button_2' ))
145+ self .external_systems1_1_button_2 .grid (row = 7 , column = 3 , sticky = 'W' , padx = 0 , pady = 2 )
146+
147+ self .inFileTxt_2_1 = tk .Entry (self .external_systems1_1 )
148+ self .outFileTxt_2_1 = tk .Entry (self .external_systems1_1 )
149+ self .outFileTxt_2_2 = tk .Entry (self .external_systems1_1 )
150+ self .outFileTxt_2_3 = tk .Entry (self .external_systems1_1 )
151+ self .outFileTxt_2_4 = tk .Entry (self .external_systems1_1 )
152+ self .outFileTxt_1a_1 = tk .Entry (self .external_systems1_1 )
153+ self .outFileTxt_1a_2 = tk .Entry (self .external_systems1_1 )
154+ self .inFileTxt_1a_1 = tk .Entry (self .external_systems1_1 )
155+ self .inFileTxt_1a_2 = tk .Entry (self .external_systems1_1 )
156+
157+ #drag and drop
158+ self .entry_name_external_systems1_1 = 'self.external_systems1_1_entry_1'
159+ self .external_systems1_1 .drop_target_register (DND_FILES )
160+ self .external_systems1_1 .dnd_bind ("<<Drop>>" , self .drop_external_systems1_1 ,self .entry_name_external_systems1_1 )
161+
120162 # main loop
121163 self .root .mainloop ()
122164
@@ -185,13 +227,6 @@ def click_action_main1_1(self,click_value):
185227 self .main1_1_label_4 .grid (row = 4 , column = 1 , columnspan = 7 , sticky = 'W' , padx = 5 , pady = 2 )
186228 ns_front_run .sub_excel_device_1 (self , file_type_array )
187229
188- elif file_type_array [0 ] == 'YAML_CML' :
189- #print(file_type_array)
190- self .main1_1_label_4 = tk .Label (self .main1_1 , textvariable = self .text , font = ("" , 10 ), background = "#F2FDE3" )
191- self .main1_1_label_4 .grid (row = 4 , column = 1 , columnspan = 7 , sticky = 'W' , padx = 5 , pady = 2 )
192-
193- network_sketcher_dev .ns_front_run .click_action (self ,'1-4b' )
194-
195230 else :
196231 self .text .set ('[ERROR] Please enter a file compatible with NS' )
197232 self .main1_1_label_4 = tk .Label (self .main1_1 , textvariable = self .text , font = ("" , 10 ), background = "#FBE5D6" )
@@ -203,6 +238,61 @@ def click_action_main1_1(self,click_value):
203238 if click_value == 'self.help_1_button_2' :
204239 webbrowser .open ('https://github.com/cisco-open/network-sketcher/wiki/User_Guide%5BEN%5D' )
205240
241+ def drop_external_systems1_1 (self , event ):
242+ if event :
243+ event .data = event .data .replace ('{' , '' ).replace ('}' , '' )
244+ if event .data .endswith ('.svg' ) or event .data .endswith ('.yaml' ) or event .data .endswith ('.csv' ):
245+ exec (self .entry_name_external_systems1_1 + '.delete(0, tkinter.END)' )
246+ exec (self .entry_name_external_systems1_1 + '.insert(tk.END, event.data)' )
247+ self .filename = os .path .basename (event .data )
248+ self .full_filepath = event .data
249+ self .text2 .set (self .filename )
250+ self .click_action_external_systems1_1 ('self.external_systems1_1_button_2' )
251+ else :
252+ self .text2 .set ('[ERROR] ' + 'Please input a file compatible with NS' )
253+ self .external_systems1_1_label_4 = tk .Label (self .external_systems1_1 , textvariable = self .text2 , font = ("" , 10 ), background = "#FBE5D6" )
254+ self .external_systems1_1_label_4 .grid (row = 4 , column = 1 , columnspan = 7 , sticky = 'W' , padx = 5 , pady = 2 )
255+
256+ def click_action_external_systems1_1 (self ,click_value ):
257+ if click_value == 'self.external_systems1_1_button_1' : # select browse
258+ fTyp = [("" , "*.yaml;*.svg;*.csv" )]
259+ iDir = os .path .abspath (os .path .dirname (sys .argv [0 ]))
260+ self .full_filepath = tk .filedialog .askopenfilename (filetypes = fTyp , initialdir = iDir )
261+ self .filename = os .path .basename (self .full_filepath )
262+ exec (self .entry_name_external_systems1_1 + '.delete(0, tkinter.END)' )
263+ exec (self .entry_name_external_systems1_1 + '.insert(tk.END, self.full_filepath)' )
264+ self .text2 .set (self .filename )
265+
266+ if click_value == 'self.external_systems1_1_button_2' : # run submit on External Systems
267+ file_type_array = ns_def .check_file_type (self .external_systems1_1_entry_1 .get ())
268+
269+ if file_type_array [0 ] == 'ERROR' :
270+ self .text2 .set ('[ERROR] ' + file_type_array [1 ])
271+ self .external_systems1_1_label_4 = tk .Label (self .external_systems1_1 , textvariable = self .text2 , font = ("" , 10 ), background = "#FBE5D6" )
272+ self .external_systems1_1_label_4 .grid (row = 4 , column = 1 , columnspan = 7 , sticky = 'W' , padx = 5 , pady = 2 )
273+
274+ elif file_type_array [0 ] == 'YAML_CML' :
275+ #print(file_type_array)
276+ self .external_systems1_1_label_4 = tk .Label (self .external_systems1_1 , textvariable = self .text2 , font = ("" , 10 ), background = "#F2FDE3" )
277+ self .external_systems1_1_label_4 .grid (row = 4 , column = 1 , columnspan = 7 , sticky = 'W' , padx = 5 , pady = 2 )
278+
279+ network_sketcher_dev .ns_front_run .click_action (self ,'1-4b' )
280+
281+ elif file_type_array [0 ] == 'SVG' :
282+ #print(file_type_array)
283+ self .external_systems1_1_label_4 = tk .Label (self .external_systems1_1 , textvariable = self .text2 , font = ("" , 10 ), background = "#F2FDE3" )
284+ self .external_systems1_1_label_4 .grid (row = 4 , column = 1 , columnspan = 7 , sticky = 'W' , padx = 5 , pady = 2 )
285+
286+ network_sketcher_dev .ns_front_run .click_action (self ,'1-4a' )
287+
288+
289+ elif file_type_array [0 ] == 'CSV' :
290+ #print(file_type_array)
291+ self .external_systems1_1_label_4 = tk .Label (self .external_systems1_1 , textvariable = self .text2 , font = ("" , 10 ), background = "#F2FDE3" )
292+ self .external_systems1_1_label_4 .grid (row = 4 , column = 1 , columnspan = 7 , sticky = 'W' , padx = 5 , pady = 2 )
293+
294+ network_sketcher_dev .ns_front_run .click_action (self ,'1-4c' )
295+
206296 '''
207297 Sketch Panel
208298 '''
0 commit comments