class MonitorMainWindow(QtGui.QMainWindow): """ Main window class """ def __init__(self): QtGui.QMainWindow.__init__(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle("OAC monitor") # Menu self.file_menu = QtGui.QMenu("&File", self) self.file_menu.addAction("&Quit", self.file_quit, QtCore.Qt.CTRL + QtCore.Qt.Key_Q) self.help_menu = QtGui.QMenu("&Help", self) self.help_menu.addAction("&About", self.help_about) self.menuBar().addMenu(self.file_menu) self.menuBar().addSeparator() self.menuBar().addMenu(self.help_menu) # Create and layout all sorts of widgets, each is responsible for a mind agent self.add_widgets() # Status bar self.statusBar().showMessage("OAC monitor", 2000) def add_widgets(self): self.zmq_context = zmq.Context() self.main_widget = QtGui.QWidget(self) grid_layout = QtGui.QGridLayout(self.main_widget) plaza_publish_endpoint = "tcp://127.0.0.1:18002" # Add PsiModulatorUpdaterAgentMonitor self.PsiModulatorUpdaterAgentMonitor = MonitorThread( self.zmq_context, plaza_publish_endpoint, "PsiModulatorUpdaterAgent", self.main_widget, width=5, height=4, dpi=100) grid_layout.addWidget(self.PsiModulatorUpdaterAgentMonitor.widget, 0, 0) # Add PsiFeelingUpdaterAgentMonitor self.PsiFeelingUpdaterAgentMonitor = MonitorThread( self.zmq_context, plaza_publish_endpoint, "PsiFeelingUpdaterAgent", self.main_widget, width=5, height=4, dpi=100) grid_layout.addWidget(self.PsiFeelingUpdaterAgentMonitor.widget, 0, 1) # Add PsiDemandUpdaterAgentMonitor self.PsiDemandUpdaterAgentMonitor = MonitorThread( self.zmq_context, plaza_publish_endpoint, "PsiDemandUpdaterAgent", self.main_widget, width=5, height=4, dpi=100) grid_layout.addWidget(self.PsiDemandUpdaterAgentMonitor.widget, 1, 0) # Add StimulusUpdaterAgentMonitor self.StimulusUpdaterAgentMonitor = MonitorThread( self.zmq_context, plaza_publish_endpoint, "StimulusUpdaterAgent", self.main_widget, width=5, height=4, dpi=100) grid_layout.addWidget(self.StimulusUpdaterAgentMonitor.widget, 1, 1) self.main_widget.setFocus() self.setCentralWidget(self.main_widget) # Don't forget start the threads of all the monitors, # otherwise you will get nothing! self.PsiModulatorUpdaterAgentMonitor.start() self.PsiFeelingUpdaterAgentMonitor.start() self.PsiDemandUpdaterAgentMonitor.start() self.StimulusUpdaterAgentMonitor.start() def file_quit(self): self.close() def help_about(self): QtGui.QMessageBox.about( self, "About %s" % program_name, """This is a simple monitor which facilities watching internal states and parameters within OAC such as modulators, emotional states etc.""" )
class MonitorMainWindow(QtGui.QMainWindow): """ Main window class """ def __init__(self): QtGui.QMainWindow.__init__(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle("OAC monitor") # Menu self.file_menu = QtGui.QMenu("&File", self) self.file_menu.addAction("&Quit", self.file_quit, QtCore.Qt.CTRL+QtCore.Qt.Key_Q) self.help_menu = QtGui.QMenu("&Help", self) self.help_menu.addAction("&About", self.help_about) self.menuBar().addMenu(self.file_menu) self.menuBar().addSeparator() self.menuBar().addMenu(self.help_menu) # Create and layout all sorts of widgets, each is responsible for a mind agent self.add_widgets() # Status bar self.statusBar().showMessage("OAC monitor", 2000) def add_widgets(self): self.zmq_context = zmq.Context() self.main_widget = QtGui.QWidget(self) grid_layout = QtGui.QGridLayout(self.main_widget) plaza_publish_endpoint = "tcp://127.0.0.1:18002" # Add PsiModulatorUpdaterAgentMonitor self.PsiModulatorUpdaterAgentMonitor = MonitorThread(self.zmq_context, plaza_publish_endpoint, "PsiModulatorUpdaterAgent", self.main_widget, width=5, height=4, dpi=100 ) grid_layout.addWidget(self.PsiModulatorUpdaterAgentMonitor.widget, 0, 0) # Add PsiFeelingUpdaterAgentMonitor self.PsiFeelingUpdaterAgentMonitor = MonitorThread(self.zmq_context, plaza_publish_endpoint, "PsiFeelingUpdaterAgent", self.main_widget, width=5, height=4, dpi=100 ) grid_layout.addWidget(self.PsiFeelingUpdaterAgentMonitor.widget, 0, 1) # Add PsiDemandUpdaterAgentMonitor self.PsiDemandUpdaterAgentMonitor = MonitorThread(self.zmq_context, plaza_publish_endpoint, "PsiDemandUpdaterAgent", self.main_widget, width=5, height=4, dpi=100 ) grid_layout.addWidget(self.PsiDemandUpdaterAgentMonitor.widget, 1, 0) # Add StimulusUpdaterAgentMonitor self.StimulusUpdaterAgentMonitor = MonitorThread(self.zmq_context, plaza_publish_endpoint, "StimulusUpdaterAgent", self.main_widget, width=5, height=4, dpi=100 ) grid_layout.addWidget(self.StimulusUpdaterAgentMonitor.widget, 1, 1) self.main_widget.setFocus() self.setCentralWidget(self.main_widget) # Don't forget start the threads of all the monitors, # otherwise you will get nothing! self.PsiModulatorUpdaterAgentMonitor.start() self.PsiFeelingUpdaterAgentMonitor.start() self.PsiDemandUpdaterAgentMonitor.start() self.StimulusUpdaterAgentMonitor.start() def file_quit(self): self.close() def help_about(self): QtGui.QMessageBox.about(self, "About %s" % program_name, """This is a simple monitor which facilities watching internal states and parameters within OAC such as modulators, emotional states etc.""")