Exemple #1
0
 def __init__(self):
     wx.grid.PyGridTableBase.__init__(self)
     self.data = RedDeFlujo()
     # precargar
     self.data.agregar_nuevo_nodo("A")
     self.data.agregar_nuevo_nodo("B")
     self.data.agregar_nuevo_nodo("C")
Exemple #2
0
 def __init__(self):
     wx.grid.PyGridTableBase.__init__(self)
     self.data = RedDeFlujo()
     # precargar
     self.data.agregar_nuevo_nodo("A")
     self.data.agregar_nuevo_nodo("B")
     self.data.agregar_nuevo_nodo("C")
Exemple #3
0
class TablaDeArcos(wx.grid.PyGridTableBase):
    '''
    Tabla donde se almacenan la cantidad de nodos y los arcos (con su capacidad)
    '''
    def __init__(self):
        wx.grid.PyGridTableBase.__init__(self)
        self.data = RedDeFlujo()
        # precargar
        self.data.agregar_nuevo_nodo("A")
        self.data.agregar_nuevo_nodo("B")
        self.data.agregar_nuevo_nodo("C")
        
    def GetRed(self):
        '''Retornar la red almacenada en esta tabla'''
        return self.data
    
    def SetSize(self, i):
        if (i < len(self.data.nodos)):
            change = len(self.data.nodos) - i
            while (len(self.data.nodos) > i):
                self.data.quitar_nodo(chr(65 + len(self.data.nodos) - 1))
            # notify!
            msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, len(self.data.nodos) + change, change)
            self.GetView().ProcessTableMessage(msg)
            msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, len(self.data.nodos) + change, change)
            self.GetView().ProcessTableMessage(msg)
        if (i > len(self.data.nodos)):
            change = i - len(self.data.nodos)
            while (len(self.data.nodos) < i):
                self.data.agregar_nuevo_nodo(chr(65 + len(self.data.nodos)))
            # notify!
            msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED, change)
            self.GetView().ProcessTableMessage(msg)
            msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, change)
            self.GetView().ProcessTableMessage(msg)
    
    # -----------
    # Cosas requeridas por PyGridTable
    
    def GetNumberRows(self):
        return len(self.data.nodos)
    
    def GetNumberCols(self):
        return len(self.data.nodos)
    
    def IsEmptyCell(self, row, col):
        return False
    
    def GetValue(self, row, col):
        return self.data.obtener_arco(chr(65+row), chr(65+col))
    
    def SetValue(self, row, col, value):
        try:
            self.data.conectar_nodos(chr(65+row), chr(65+col), value, False)
        except ValueError:
            return False
        finally:
            return True
    
    # -------------
    # etiquetas!
    
    def GetColLabelValue(self, col):
        return chr(col + 65)
    
    def GetRowLabelValue(self, row):
        return chr(row + 65)
Exemple #4
0
class TablaDeArcos(wx.grid.PyGridTableBase):
    '''
    Tabla donde se almacenan la cantidad de nodos y los arcos (con su capacidad)
    '''
    def __init__(self):
        wx.grid.PyGridTableBase.__init__(self)
        self.data = RedDeFlujo()
        # precargar
        self.data.agregar_nuevo_nodo("A")
        self.data.agregar_nuevo_nodo("B")
        self.data.agregar_nuevo_nodo("C")

    def GetRed(self):
        '''Retornar la red almacenada en esta tabla'''
        return self.data

    def SetSize(self, i):
        if (i < len(self.data.nodos)):
            change = len(self.data.nodos) - i
            while (len(self.data.nodos) > i):
                self.data.quitar_nodo(chr(65 + len(self.data.nodos) - 1))
            # notify!
            msg = wx.grid.GridTableMessage(
                self, wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED,
                len(self.data.nodos) + change, change)
            self.GetView().ProcessTableMessage(msg)
            msg = wx.grid.GridTableMessage(
                self, wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED,
                len(self.data.nodos) + change, change)
            self.GetView().ProcessTableMessage(msg)
        if (i > len(self.data.nodos)):
            change = i - len(self.data.nodos)
            while (len(self.data.nodos) < i):
                self.data.agregar_nuevo_nodo(chr(65 + len(self.data.nodos)))
            # notify!
            msg = wx.grid.GridTableMessage(
                self, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED, change)
            self.GetView().ProcessTableMessage(msg)
            msg = wx.grid.GridTableMessage(
                self, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, change)
            self.GetView().ProcessTableMessage(msg)

    # -----------
    # Cosas requeridas por PyGridTable

    def GetNumberRows(self):
        return len(self.data.nodos)

    def GetNumberCols(self):
        return len(self.data.nodos)

    def IsEmptyCell(self, row, col):
        return False

    def GetValue(self, row, col):
        return self.data.obtener_arco(chr(65 + row), chr(65 + col))

    def SetValue(self, row, col, value):
        try:
            self.data.conectar_nodos(chr(65 + row), chr(65 + col), value,
                                     False)
        except ValueError:
            return False
        finally:
            return True

    # -------------
    # etiquetas!

    def GetColLabelValue(self, col):
        return chr(col + 65)

    def GetRowLabelValue(self, row):
        return chr(row + 65)