示例#1
0
	def __init__(self):
		#Carrega a interface a partir do arquivo glade
		
		self.gui = gtk.glade.XML('gui/monitor.glade')
		self.window = self.gui.get_widget('mainWindow')
		self.about = self.gui.get_widget('aboutdialog1')
		self.Communication = Comunic()
		self.statusbar = self.gui.get_widget('statusbar')
		#self.statusbar.set_has_resize_grip(True)	
		self.notebookMain = self.gui.get_widget('notebookMain')	
		self.liststore = gtk.ListStore(str, str, str) # Name, Unit, #Description
		
		self.sensorsTab = SensorsTab(self.gui, self.liststore)
		self.sensorTypes = self.sensorsTab.sensorTypes		
		self.proceduresTab = ProceduresTab(self.gui, self.Communication)
		#@attention: Verificar funcionamento após
		self.connectionTab = ConnectionTab(self.gui, self.Communication, self.statusbar)
		self.consoleTab = ConsoleTab(self.gui, self.Communication, self.statusbar, self.liststore, self.sensorTypes)
		
		#Obtendo interface do projeto Blocos
		gui_blocos_path = path.join(config.glade_dir, "blocos", "main.glade")
		self.gui_blocos = gtk.glade.XML(gui_blocos_path)
		self.blocosRegion = self.gui_blocos.get_widget("blocosMainRegion")
		self.blocosRegion.reparent(self.notebookMain)
		label = gtk.Label("Blocos")
		label.set_alignment(0.0, 0.0)
		self.notebookMain.set_tab_label(self.blocosRegion, label)
		self.blocos = Blocos(self.gui_blocos, self.window, self.Communication)
		
		self.buttonDownloadProcedure = self.gui.get_widget("buttonDownloadProcedure")
		self.buttonDownloadBlocos = self.gui_blocos.get_widget("buttonDownloadBlocos")
		self.buttonConnect = self.gui.get_widget("buttonConnect")
		self.buttonDisconnect = self.gui.get_widget("buttonDisconnect")
		self.menuItemCode = self.gui.get_widget("menu_code")
				
		#Conecta Sinais aos Callbacks:		
		dic = {"gtk_main_quit" : gtk.main_quit}
		self.gui.signal_autoconnect(dic)	
		self.gui.signal_autoconnect(self)
		self.gui_blocos.signal_autoconnect(self)
		
		#Exibe toda interface:
		self.window.show_all()
		
		#Inicia o loop principal de eventos (GTK MainLoop):
		gtk.main()
示例#2
0
class BoardMonitor(object):
	def __init__(self):
		#Carrega a interface a partir do arquivo glade
		
		self.gui = gtk.glade.XML('gui/monitor.glade')
		self.window = self.gui.get_widget('mainWindow')
		self.about = self.gui.get_widget('aboutdialog1')
		self.Communication = Comunic()
		self.statusbar = self.gui.get_widget('statusbar')
		#self.statusbar.set_has_resize_grip(True)	
		self.notebookMain = self.gui.get_widget('notebookMain')	
		self.liststore = gtk.ListStore(str, str, str) # Name, Unit, #Description
		
		self.sensorsTab = SensorsTab(self.gui, self.liststore)
		self.sensorTypes = self.sensorsTab.sensorTypes		
		self.proceduresTab = ProceduresTab(self.gui, self.Communication)
		#@attention: Verificar funcionamento após
		self.connectionTab = ConnectionTab(self.gui, self.Communication, self.statusbar)
		self.consoleTab = ConsoleTab(self.gui, self.Communication, self.statusbar, self.liststore, self.sensorTypes)
		
		#Obtendo interface do projeto Blocos
		gui_blocos_path = path.join(config.glade_dir, "blocos", "main.glade")
		self.gui_blocos = gtk.glade.XML(gui_blocos_path)
		self.blocosRegion = self.gui_blocos.get_widget("blocosMainRegion")
		self.blocosRegion.reparent(self.notebookMain)
		label = gtk.Label("Blocos")
		label.set_alignment(0.0, 0.0)
		self.notebookMain.set_tab_label(self.blocosRegion, label)
		self.blocos = Blocos(self.gui_blocos, self.window, self.Communication)
		
		self.buttonDownloadProcedure = self.gui.get_widget("buttonDownloadProcedure")
		self.buttonDownloadBlocos = self.gui_blocos.get_widget("buttonDownloadBlocos")
		self.buttonConnect = self.gui.get_widget("buttonConnect")
		self.buttonDisconnect = self.gui.get_widget("buttonDisconnect")
		self.menuItemCode = self.gui.get_widget("menu_code")
				
		#Conecta Sinais aos Callbacks:		
		dic = {"gtk_main_quit" : gtk.main_quit}
		self.gui.signal_autoconnect(dic)	
		self.gui.signal_autoconnect(self)
		self.gui_blocos.signal_autoconnect(self)
		
		#Exibe toda interface:
		self.window.show_all()
		
		#Inicia o loop principal de eventos (GTK MainLoop):
		gtk.main()

### Main Window Callbacks:
	def notebookPageSwitched(self, widget, page, pagenum):
		#Sensibilidade do item "Ver código gerado"
		if pagenum == 3:
			self.menuItemCode.set_sensitive(True)
		else:
			self.menuItemCode.set_sensitive(False)

	def updateButtonsSensivity(self, isConnected):
		if isConnected:
			self.buttonConnect.set_sensitive(False)
			self.buttonDisconnect.set_sensitive(True)
			self.buttonDownloadBlocos.set_sensitive(True)
			self.buttonDownloadProcedure.set_sensitive(True)
		else:
			self.buttonConnect.set_sensitive(True)
			self.buttonDisconnect.set_sensitive(False)
			self.buttonDownloadBlocos.set_sensitive(False)
			self.buttonDownloadProcedure.set_sensitive(False)
	
### Menus
	def menuNew(self, widget):
		self.blocos.new_proj()
	def menuOpen(self, widget):
		self.blocos.load_proj()
	def menuSave(self, widget):
		self.blocos.save_proj()
	def menuSaveAs(self, widget):
		self.blocos.saveas_proj()
	def menuQuit(self, widget):
		self.blocos.quit()
	def menuUndo(self, widget):
		self.blocos.undo()
	def menuCut(self, widget):
		self.blocos.cut()
	def menuCopy(self, widget):
		self.blocos.copy()
	def menuPaste(self, widget):
		self.blocos.paste()
	def menuClear(self, widget):
		self.blocos.clear()
	def menuCode(self, widget):
		self.blocos.show_code()
	def menuAbout(self, widget):
		self.about.run()
		self.about.hide()
	#def menuHelp(self, widget):
		#webbrowser.open('http://code.google.com/p/real-project')

### Board Console Callbacks:	
	def buttonBeep_clicked_cb(self, widget):
		self.consoleTab.buttonBeep_clicked_cb(widget)		
		
	def buttonLedOn_clicked_cb(self, widget):
		self.consoleTab.buttonLedOn_clicked_cb(widget)		
		
	def buttonLedOff_clicked_cb(self, widget):
		self.consoleTab.buttonLedOff_clicked_cb(widget)		
		
	def checkbuttonMotor_toggled_cb(self, widget):
		self.consoleTab.checkbuttonMotor_toggled_cb(widget)		
		
	def buttonMotorControlOn_clicked_cb(self, widget):
		self.consoleTab.buttonMotorControlOn_clicked_cb(widget)		
	
	def buttonMotorControlOff_clicked_cb(self, widget):		
		self.consoleTab.buttonMotorControlOff_clicked_cb(widget)
	
	def buttonMotorControlBreak_clicked_cb(self, widget):
		self.consoleTab.buttonMotorControlBreak_clicked_cb(widget)
		
	def buttonMotorControlCoast_clicked_cb(self, widget):
		self.consoleTab.buttonMotorControlCoast_clicked_cb(widget)
	
	def buttonPowerSet_clicked_cb(self, widget):
		self.consoleTab.buttonPowerSet_clicked_cb(widget)
	
	def buttonMotorControlThisway_clicked_cb(self, widget):
		self.consoleTab.buttonMotorControlThisway_clicked_cb(widget)
		
	def buttonMotorControlThatway_clicked_cb(self, widget):
		self.consoleTab.buttonMotorControlThatway_clicked_cb(widget)
		
	def buttonMotorControlReverse_clicked_cb(self, widget):
		self.consoleTab.buttonMotorControlReverse_clicked_cb(widget)
		
	
	# def entryMinPwmDuty_changed_cb(self,widget):
		# print "entryMinPwmDuty_changed_cb"
		# #self.consoleTab.entryMaxPwmDuty_changed_cb(widget)
			
	# def entryMaxPwmDuty_changed_cb(self,widget):
		# print "entryMaxPwmDuty_changed_cb"
		# #self.consoleTab.entryMaxPwmDuty_changed_cb(widget)
	
	def entryMinPwmDuty_changed_cb(self, widget):
		self.consoleTab.entryMinPwmDuty_changed_cb(widget)
		
	def entryMaxPwmDuty_changed_cb(self, widget):
		self.consoleTab.entryMaxPwmDuty_changed_cb(widget)
		
	def buttonSetPwmDuty_clicked_cb(self, widget):
		self.consoleTab.buttonSetPwmDuty_clicked_cb(widget)
	
	def buttonRefreshAll_clicked_cb(self, widget):
		self.consoleTab.buttonRefreshAll_clicked_cb(widget)
	
	def buttonSensorBurstOn_clicked_cb(self, widget):
		self.consoleTab.buttonSensorBurstOn_clicked_cb(widget)
		
	def radiobuttonBurstFast_toggled_cb(self, widget):
		self.consoleTab.radiobuttonBurstFast_toggled_cb(widget)
			
	def radiobuttonBurstSlow_toggled_cb(self, widget):
		self.consoleTab.radiobuttonBurstSlow_toggled_cb(widget)
	
	def buttonSensorBurstOff_clicked_cb(self, widget):
		self.consoleTab.buttonSensorBurstOff_clicked_cb(widget)	
	
		
### /Board Console
	
	
### Logo Procedures Callbacks:	
	def buttonNew_clicked_cb(self, widget):
		self.proceduresTab.buttonNew_clicked_cb(widget)
		
	def buttonOpen_clicked_cb(self, widget):
		self.proceduresTab.buttonOpen_clicked_cb(widget)
		
	def buttonSave_clicked_cb(self, widget):
		self.proceduresTab.buttonSave_clicked_cb(widget)
		
	def buttonSaveAs_clicked_cb(self, widget):
		self.proceduresTab.buttonSaveAs_clicked_cb(widget)
		
	def downloadProcedure(self, widget):
			self.proceduresTab.buttonDownload_clicked_cb(widget)

	#Blocos Callbacks	
	def downloadBlocos(self, widget):
		self.blocos.download()
		self.proceduresTab.load_code(self.blocos.get_generated_code())
		
			
### /Logo Procedures
	
	
### Configuration Callbacks:
	def buttonConnect_clicked_cb(self, widget):
		conn = self.connectionTab.buttonConnect_clicked_cb()
		self.updateButtonsSensivity(conn)
	
	def buttonDisconnect_clicked_cb(self, widget):
		self.connectionTab.buttonDisconnect_clicked_cb()
		self.updateButtonsSensivity(False) #desconectado
		
	def buttonSetLanguage_clicked_cb(self, widget):
		self.connectionTab.buttonSetLanguage_clicked_cb(widget)	
### /Configuration
	
	
	
### SensorLab Callbacks:
	def sensorPoint_edited_cb(self, cell, path, new_text, column):
		self.sensorsTab.sensorPoint_edited_cb(cell, path, new_text, column)	
		
	def edited_cb(self, cell, path, new_text, column):		
		self.sensorsTab.edited_cb(cell, path, new_text, column)		
			
	def treeviewSensors_cursor_changed_cb(self, treeviewSensors):
		self.sensorsTab.treeviewSensors_cursor_changed_cb(treeviewSensors)	
	
	def buttonAddSensor_clicked_cb(self, widget):
		self.sensorsTab.buttonAddSensor_clicked_cb(widget)		
		
	def buttonRemoveSensor_clicked_cb(self, widget):
		self.sensorsTab.buttonRemoveSensor_clicked_cb(widget)
	
	def buttonImportSensors_clicked_cb(self, widget):
		self.sensorsTab.buttonImportSensors_clicked_cb(widget)
		
	def buttonExportSensors_clicked_cb(self, widget):
		self.sensorsTab.buttonExportSensors_clicked_cb(widget)
	
	def buttonInsertPoint_clicked_cb(self, widget):
		self.sensorsTab.buttonInsertPoint_clicked_cb(widget)
			
	def buttonRemovePoint_clicked_cb(self, widget):
		self.sensorsTab.buttonRemovePoint_clicked_cb(widget)