示例#1
0
 def doshow(self):
     """here I can build the windows"""
     # I cannot be built at object __init__
     # as it is triggered by an Ivy thread and not a Qt signal
     # thus doshow must be called within Qt
     self.window = QtWidgets.QWidget()
     self.ui = Ui_Agent()
     self.ui.setupUi(self.window)
     self.ui.nameLabel.setText(self.name)
     self.ui.ipLabel.setText(str(self.agent.ip))
     self.ui.portLabel.setText(str(self.agent.port))
     self.ui.addressLabel.setText(self.agent.fqdn)
     self.update_regex()
     self.window.show()
示例#2
0
class Agent():
    """a helper class holding the ivy agent, the list item, and a handle to a
    Qt Window
    """

    def __init__(self, agent):
        """ the constructor
        cannot use Qt logic so far, as it's called from an Ivy thread
        """
        self.agent = agent
        self.name = agent.agent_name
        self.item = QtWidgets.QListWidgetItem(self.name)
        self.window = None

    def doshow(self):
        """here I can build the windows"""
        # I cannot be built at object __init__
        # as it is triggered by an Ivy thread and not a Qt signal
        # thus doshow must be called within Qt
        self.window = QtWidgets.QWidget()
        self.ui = Ui_Agent()
        self.ui.setupUi(self.window)
        self.ui.nameLabel.setText(self.name)
        self.ui.ipLabel.setText(str(self.agent.ip))
        self.ui.portLabel.setText(str(self.agent.port))
        self.ui.addressLabel.setText(self.agent.fqdn)
        self.update_regex()
        self.window.show()

    def update_regex(self):
        """called each time a regex is added or deleted, starts from zero"""
        if self.window is None:
            return
        self.ui.regexpList.clear()
        for re in self.agent.regexps.values():
            self.ui.regexpList.addItem(QtWidgets.QListWidgetItem(re[0]))