示例#1
0
class PaginaIndicarFuenteYDestino(AeroPage):
    def __init__(self, parent, data):
        AeroPage.__init__(self, parent, u"Fuente y destino de la red")
        instrucciones = AeroStaticText(
            self, -1, u"Indique el nodo origen y el nodo destino de la red.")
        self.content.Add(instrucciones, 0, wx.BOTTOM, 10)

        hb = wx.BoxSizer(wx.HORIZONTAL)
        # origen y destino
        box = wx.StaticBox(self, -1, u"Origen y Destino")
        bsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        self.combo_origen = wx.ComboBox(self, -1)
        self.combo_destino = wx.ComboBox(self, -1)
        self.combo_origen.Bind(wx.EVT_COMBOBOX, self.OnCombo)
        self.combo_destino.Bind(wx.EVT_COMBOBOX, self.OnCombo)
        fgs = wx.FlexGridSizer(2, 2, 2, 2)
        fgs.AddMany([
            wx.StaticText(self, -1, u"Origen:"), self.combo_origen,
            wx.StaticText(self, -1, u"Destino:"), self.combo_destino
        ])
        bsizer.Add(fgs)
        hb.Add(bsizer, 0, wx.EXPAND)
        hb.AddSpacer(10)

        # vista previa
        box = wx.StaticBox(self, -1, u"Vista previa")
        bsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        self.panel_vista_previa = scrolledpanel.ScrolledPanel(self,
                                                              -1,
                                                              size=(400, 300))
        self.panel_vista_previa.SetBackgroundColour("#000000")
        self.bitmap_grafo = wx.StaticBitmap(self.panel_vista_previa, -1)
        self.panel_vista_previa.SetAutoLayout(1)
        self.panel_vista_previa.SetBackgroundColour(wx.WHITE)
        self.panel_vista_previa.SetSizer(wx.BoxSizer(wx.VERTICAL))
        self.panel_vista_previa.GetSizer().Add(
            self.bitmap_grafo, 1,
            wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
        bsizer.Add(self.panel_vista_previa, 0, wx.EXPAND)
        hb.Add(bsizer, 0, wx.EXPAND)
        self.content.Add(hb, 0, wx.BOTTOM, 20)

    def OnShow(self, event):
        if event.GetShow():
            self.graficador = GraficoDeRed(data["red"])
            self.combo_origen.Clear()
            self.combo_origen.AppendItems(
                [n.nombre for n in data["red"].nodos])
            self.combo_destino.Clear()
            self.combo_destino.AppendItems(
                [n.nombre for n in data["red"].nodos])

    def OnCombo(self, event):
        self.ActualizarVistaPrevia()
        if len(self.combo_origen.GetValue()) != 0 and len(
                self.combo_destino.GetValue()) != 0:
            self.wizard.UpdateButtons()
        else:
            self.wizard.UpdateButtons()

    def ActualizarVistaPrevia(self):
        self.graficador.graficar_red()
        self.graficador.marcar_origen_y_destino(self.combo_origen.GetValue(),
                                                self.combo_destino.GetValue())

        image = self.graficador.get_wx_image()
        bitmap = wx.BitmapFromImage(image)
        self.bitmap_grafo.SetBitmap(bitmap)
        self.bitmap_grafo.GetParent().Refresh()
        self.panel_vista_previa.SetupScrolling()

    def GetNext(self):
        if len(self.combo_origen.GetValue()) == 0 or len(
                self.combo_destino.GetValue()) == 0:
            return False
        else:
            #print AeroPage.GetNext(self)
            return AeroPage.GetNext(self)
            #return self._GetNextOrDefault()

    def OnNext(self):
        data["red"].origen = self.combo_origen.GetValue()
        data["red"].destino = self.combo_destino.GetValue()
        return True
示例#2
0
class PaginaIndicarFuenteYDestino(AeroPage):
    def __init__(self, parent, data):
        AeroPage.__init__(self, parent, u"Fuente y destino de la red")
        instrucciones = AeroStaticText(self, -1, u"Indique el nodo origen y el nodo destino de la red.")
        self.content.Add(instrucciones, 0, wx.BOTTOM, 10)
        
        hb = wx.BoxSizer(wx.HORIZONTAL)
        # origen y destino
        box = wx.StaticBox(self, -1, u"Origen y Destino")
        bsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        self.combo_origen = wx.ComboBox(self, -1)
        self.combo_destino = wx.ComboBox(self, -1)
        self.combo_origen.Bind(wx.EVT_COMBOBOX, self.OnCombo)
        self.combo_destino.Bind(wx.EVT_COMBOBOX, self.OnCombo)
        fgs = wx.FlexGridSizer(2, 2, 2, 2)
        fgs.AddMany([wx.StaticText(self, -1, u"Origen:"),
                     self.combo_origen,
                     wx.StaticText(self, -1, u"Destino:"),
                     self.combo_destino
                     ])
        bsizer.Add(fgs)
        hb.Add(bsizer, 0, wx.EXPAND)
        hb.AddSpacer(10)
        
        
        # vista previa
        box = wx.StaticBox(self, -1, u"Vista previa")
        bsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        self.panel_vista_previa = scrolledpanel.ScrolledPanel(self, -1, size=(400,300))
        self.panel_vista_previa.SetBackgroundColour("#000000")
        self.bitmap_grafo = wx.StaticBitmap(self.panel_vista_previa, -1)
        self.panel_vista_previa.SetAutoLayout(1)
        self.panel_vista_previa.SetBackgroundColour(wx.WHITE)
        self.panel_vista_previa.SetSizer(wx.BoxSizer(wx.VERTICAL))
        self.panel_vista_previa.GetSizer().Add(self.bitmap_grafo, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
        bsizer.Add(self.panel_vista_previa, 0, wx.EXPAND)
        hb.Add(bsizer, 0, wx.EXPAND)
        self.content.Add(hb, 0, wx.BOTTOM, 20)
        
    def OnShow(self, event):
        if event.GetShow():
            self.graficador = GraficoDeRed(data["red"])
            self.combo_origen.Clear()
            self.combo_origen.AppendItems([n.nombre for n in data["red"].nodos])
            self.combo_destino.Clear()
            self.combo_destino.AppendItems([n.nombre for n in data["red"].nodos])
    
    def OnCombo(self, event):
        self.ActualizarVistaPrevia()
        if len(self.combo_origen.GetValue()) != 0 and len(self.combo_destino.GetValue()) != 0:
            self.wizard.UpdateButtons()
        else:
            self.wizard.UpdateButtons()
    
    def ActualizarVistaPrevia(self):
        self.graficador.graficar_red()
        self.graficador.marcar_origen_y_destino(self.combo_origen.GetValue(), self.combo_destino.GetValue()) 

        image = self.graficador.get_wx_image()
        bitmap = wx.BitmapFromImage(image)
        self.bitmap_grafo.SetBitmap(bitmap)
        self.bitmap_grafo.GetParent().Refresh()
        self.panel_vista_previa.SetupScrolling()
    
    def GetNext(self):
        if len(self.combo_origen.GetValue()) == 0 or len(self.combo_destino.GetValue()) == 0:
            return False
        else:
            #print AeroPage.GetNext(self)
            return AeroPage.GetNext(self)
            #return self._GetNextOrDefault()
    
    def OnNext(self):
        data["red"].origen = self.combo_origen.GetValue()
        data["red"].destino = self.combo_destino.GetValue()
        return True