Commits

Joshua Bonsink committed 4066b0d

Imrpoved the embedded terminal

Comments (0)

Files changed (1)

         super(Ui_MainWindow, self).__init__()
                 
         self.last_mode_selected = None
-                
+        self.opened_terminal = 0
+        
         self.initUI()       
             
     def initUI(self):        
                  
         tab_common = QtGui.QWidget()
         tab_topology = QtGui.QWidget()
-        tab_terminal = QtGui.QWidget()
+        self.tab_terminal1 = QtGui.QWidget()
+        self.tab_terminal2 = QtGui.QWidget()
         tab_netanim = QtGui.QWidget()
         
         self.tab_ddos_flooding = QtGui.QWidget()
         
         self.tab_widget.addTab(tab_common, "Common settings")
         self.tab_widget.addTab(tab_topology, "Topology Editor")
-        self.tab_widget.addTab(tab_terminal, "Terminal")
         self.tab_widget.addTab(tab_netanim, "NetAnim")
+        self.tab_widget.addTab(self.tab_terminal1, "Terminal")        
         
         self.setCentralWidget(self.tab_widget)
 
         process.start(executable)        
         container.resize(700, 616)
         
-        # --- Terminal --- #
-        tab_terminal_layout = QtGui.QVBoxLayout(tab_terminal)
+        # --- Terminal 1 & 2--- #
+        tab_terminal_layout1 = QtGui.QVBoxLayout(self.tab_terminal1)
         self.container2 = QtGui.QX11EmbedContainer()               
-        tab_terminal_layout.addWidget(self.container2)
+        tab_terminal_layout1.addWidget(self.container2)
                 
         self.container2.show()
-        self.processTerminal = QtCore.QProcess(self.container2)
+        self.processTerminal1 = QtCore.QProcess(self.container2)
         executable = QtCore.QString("xterm -into " + str(self.container2.winId()))    
-        self.processTerminal.start(executable)  
+        self.processTerminal1.start(executable)  
+        
+        tab_terminal_layout2 = QtGui.QVBoxLayout(self.tab_terminal2)
+        self.container4 = QtGui.QX11EmbedContainer()               
+        tab_terminal_layout2.addWidget(self.container4)
+                
+        self.container4.show()
+        self.processTerminal2 = QtCore.QProcess(self.container4)       
         
         # --- NetAnim -- #
         tab_netanim_layout = QtGui.QVBoxLayout(tab_netanim)
         if self.implementation.itemText ( self.implementation.currentIndex() ) == 'Visual':
             cmd += ' --SimulatorImpl=Visual'
         
-        print cmd
-        #os.system("xterm -e 'bash -c \"" + str(cmd) + "; exec bash\"'")
-        executable = QtCore.QString('xterm -hold -into ' + str(self.container2.winId()) + ' -e "' + str(cmd) + '"')     
-        print executable   
-        self.processTerminal.start(executable)  
+        print cmd         
+        
+        self.opened_terminal += 1
+        self.opened_terminal %= 2
+                        
+        if self.opened_terminal == 0:          
+            self.processTerminal2.kill()
+            self.tab_widget.removeTab(3)
+            executable = QtCore.QString('xterm -hold -into ' + str(self.container2.winId()) + ' -e "' + str(cmd) + '"')     
+            self.processTerminal1.start(executable)  
+            self.tab_widget.insertTab(3, self.tab_terminal1, "Terminal") 
+        else:
+            self.processTerminal1.kill()
+            self.tab_widget.removeTab(3)
+            executable = QtCore.QString('xterm -hold -into ' + str(self.container4.winId()) + ' -e "' + str(cmd) + '"')     
+            self.processTerminal2.start(executable)
+            self.tab_widget.insertTab(3, self.tab_terminal2, "Terminal")            
         
     def startScenario(self, settings_type, attack):        
         open_f = choseCorrectFile(settings_type)
                 self.startSim('netns3', scenario, MANUAL_TOPO, self.manual_bt_duration.value(), 
                     self.manual_topo_file_location.text(), self.manual_net_settings_location.text())                    
             
-        elif mode == PURE_SIM:         
-            self.processTerminal.kill()
-            experiment = self.pure_exp.itemText( self.pure_exp.currentIndex() )
-            print experiment
+        elif mode == PURE_SIM:                     
+            experiment = self.pure_exp.itemText( self.pure_exp.currentIndex() )            
             if experiment == "Complex Network Experiment":
                 self.startSim('sim', scenario, COMPLEX, self.complex_duration.value(), 
                     self.complex_topo_file_location.text(), self.complex_net_settings_location.text(),