#!/usr/bin/env python
# -*- coding: CP1252 -*-
#
# generated by wxGlade 0.6.7 (standalone edition) on Mon Dec 08 16:17:28 2014
#

import wx
import funciones as f
import funcionesSimu as fs
import PrincipalProf as P
# begin wxGlade: dependencies
import gettext
# end wxGlade

# begin wxGlade: extracode
# end wxGlade


class principal(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: principal.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        
        # Menu Bar
        self.frame_1_menubar = wx.MenuBar()
        self.Archivo = wx.Menu()
        self.principal = wx.MenuItem(self.Archivo, wx.ID_ANY, _("Principal"), _("Principal"), wx.ITEM_NORMAL)
        self.Archivo.AppendItem(self.principal)
        self.frame_1_menubar.Append(self.Archivo, _("Archivo"))
        self.SetMenuBar(self.frame_1_menubar)
        # Menu Bar end
        self.label_1 = wx.StaticText(self, wx.ID_ANY, _("Masa:"))
        self.txtmasa = wx.TextCtrl(self, wx.ID_ANY, "")
        self.label_2 = wx.StaticText(self, wx.ID_ANY, _("Caja:"))
        self.cobcaja = wx.ComboBox(self, wx.ID_ANY, choices=[_("Acero"), _("Aluminio"), _("Cobre"), _("Laton"), _("Cinc"), _("Caucho"), _("Madera"), _("Vidrio"), _("Cobre"), _("Hielo"), _("Teflon")], style=wx.CB_DROPDOWN | wx.CB_READONLY)
        self.label_3 = wx.StaticText(self, wx.ID_ANY, _("Piso:"))
        self.cobpiso = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN | wx.CB_READONLY)
        self.button_2 = wx.Button(self, wx.ID_ANY, _("Aceptar"))
        self.button_3 = wx.Button(self, wx.ID_ANY, _("Limpiar"))

        self.__set_properties()
        self.txtmasa.SetValidator(ContieneDatos())#activa la validacion
        self.cobpiso.SetValidator(ContieneDatos())#activa la validacion
        self.cobcaja.SetValidator(ContieneDatos())#activa la validacion
        self.__do_layout()

        self.Bind(wx.EVT_MENU, self.OnPrincipal, self.principal)
        self.Bind(wx.EVT_TEXT, self.OnCaja, self.cobcaja)
        self.Bind(wx.EVT_BUTTON, self.OnSimular, self.button_2)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: principal.__set_properties
        self.SetTitle(_("Friccion"))
        self.cobcaja.SetSelection(-1)
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: principal.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        grid_sizer_1 = wx.FlexGridSizer(3, 1, 0, 0)
        grid_sizer_4 = wx.FlexGridSizer(1, 2, 0, 0)
        grid_sizer_3 = wx.FlexGridSizer(1, 4, 0, 0)
        grid_sizer_2 = wx.FlexGridSizer(1, 2, 0, 0)
        grid_sizer_2.Add(self.label_1, 0, 0, 0)
        grid_sizer_2.Add(self.txtmasa, 0, 0, 0)
        grid_sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
        grid_sizer_3.Add(self.label_2, 0, 0, 0)
        grid_sizer_3.Add(self.cobcaja, 0, 0, 0)
        grid_sizer_3.Add(self.label_3, 0, 0, 0)
        grid_sizer_3.Add(self.cobpiso, 0, 0, 0)
        grid_sizer_1.Add(grid_sizer_3, 1, wx.EXPAND, 0)
        grid_sizer_4.Add(self.button_2, 0, 0, 0)
        grid_sizer_4.Add(self.button_3, 0, 0, 0)
        grid_sizer_4.AddGrowableCol(0)
        grid_sizer_4.AddGrowableCol(1)
        grid_sizer_1.Add(grid_sizer_4, 1, wx.EXPAND, 0)
        sizer_2.Add(grid_sizer_1, 1, wx.EXPAND, 0)
        sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        # end wxGlade

    def OnCaja(self, event):  # wxGlade: principal.<event_handler>
        f.materiales(self)

    def OnSimular(self, event):  # wxGlade: principal.<event_handler>
        if self.Validate():
        
            fs.roce(self)
    def OnPrincipal(self, event):  # wxGlade: principal.<event_handler>
        dlg = wx.MessageDialog(None, '¿Desea Salir?',
                           'Diálogo de Mensage', wx.OK|wx.CANCEL|
                            wx.ICON_QUESTION)
        #dlg.ShowModal()
        

        if dlg.ShowModal()==wx.ID_OK:
            Ventana=P.Principal(self)
            Ventana.Show()
            self.Hide()
        dlg.Destroy()  
# end of class principal
class ContieneDatos(wx.PyValidator):
    def __init__(self):
        wx.PyValidator.__init__(self)

    def Clone(self):
        """
        Note que todo validador debe implementar
        # el método Clone().
        """
        return ContieneDatos()

    def Validate(self, win):
        textCtrl = self.GetWindow()
        text = textCtrl.GetValue()
        if len(text) == 0:
            wx.MessageBox("Este campo debe contener algún texto!",
                          "Error")
            textCtrl.SetBackgroundColour("red")
            textCtrl.SetFocus()
            textCtrl.Refresh()
            return False
        else:
            textCtrl.SetBackgroundColour(
                               wx.SystemSettings_GetColour(
                               wx.SYS_COLOUR_WINDOW))
            textCtrl.Refresh()
            return True

    def TransferToWindow(self):
        return True

    def TransferFromWindow(self):
        return True
if __name__ == "__main__":
    gettext.install("app") # replace with the appropriate catalog name

    app = wx.App()
    #wx.InitAllImageHandlers()
    frame_1 = principal(None, wx.ID_ANY, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()
