# Path: plasticity/run_sim.py
# def Plot(sim):
#     gray=pylab.cm.gray
#     pylab.ion()
#     
#     try:
#         if not sim['params']['display']:
#             return
#     except TypeError:  # sent a string
#         sim=zpickle.load(sim)
# 
#         
#     try:
#         if sim['params']['display_module']:
#             pass
#     except:
#         sim['params']['display_module']=False
#         
#     if sim['params']['display_module']:
#         try:
#             module=__import__(sim['params']['display_module'],fromlist=['UserPlot'])
#         except ImportError:
#             sim['params']['display']=False
#             print("Error","Error in Import: %s.  Turning display off.  %s" % (
#                                 sim['params']['display_module'],
#                                 sys.exc_info()))
#             return
#         
#         try:
#             module.UserPlot(None,sim)
#             pylab.draw()
#             return
#         except ValueError:
#             sim['params']['display']=False
#             print("Error in display.  Turning display off")
#             return
#     
#     try:
#     
#         im=weights2image(sim['params'],sim['weights'])
#         ax=pylab.subplot(221)
#         pylab.pcolor(im,cmap=gray)
#         ax.set_axis_bgcolor('k')
#         pylab.axis('equal')
#         
#         num_moments=sim['moments_mat'].shape[0]
# 
#         
#         ax=pylab.subplot(222)
#         ax.hold(False)
#         if num_moments==1:
#             num_neurons=sim['moments_mat'].shape[1]
#             for k in range(num_neurons):
#                 pylab.plot(sim['t_mat'],sim['moments_mat'][0,k,:],'-o')
#                 ax.hold(True)
#         elif num_moments==2:
#             num_neurons=sim['moments_mat'].shape[1]
#             for k in range(num_neurons):
#                 pylab.plot(sim['t_mat'],sim['moments_mat'][0,k,:],'b-o')
#                 ax2=pylab.twinx(ax)
#                 pylab.plot(sim['t_mat'],sim['moments_mat'][1,k,:],'g-o')
#                 ax2.yaxis.tick_right()
# 
#         else:
#             num_neurons=sim['moments_mat'].shape[1]
#             for k in range(num_neurons):
#                 for i in range(num_moments):
#                     pylab.plot(sim['t_mat'],sim['moments_mat'][i,k,:],'-o')
#                     ax.hold(True)
#         
#         
#     
#         pylab.subplot(223)
#         pylab.hold(False)
#         response_mat=sim['response_mat']
#         response_var_list=sim['response_var_list']
#         
#         
#         styles=['b-','g-','r-','k-']
#         ls=len(styles)
#         for i,r in enumerate(response_var_list[-1]):
#             x=r[1]
#             y=r[2]
#         
#             pylab.plot(x,y,styles[i % ls]+"o")
#             pylab.hold(True)
#     
#         pylab.subplot(224)
#         pylab.hold(False)
#         for i,r in enumerate(response_mat):
#             pylab.plot(r,styles[i % ls])
#             pylab.hold(True)
#     
#     
#         pylab.draw()
# 
# 
#     except ValueError:
#         sim['params']['display']=False
#         print("Error in display.  Turning display off")
#         return


from .dialogs.waxy import *
from .run_sim import Plot
import os,sys
import glob
    def __init__(self,parent=None,title='',direction='v',
                    size=(200,800),default_wildcard=None):

        self.default_wildcard=default_wildcard
        Frame.__init__(self,parent,title,direction,size)
        
    def Body(self):
        
        menubar = MenuBar(self)
        menu1 = Menu(self)
        menu1.Append("E&xit", self.CloseWindow, "Exit demo",hotkey="Ctrl+Q")
        menubar.Append(menu1, "&File")

        if not self.default_wildcard:
            self.default_wildcard='sims/'
            
        wildcard=self.default_wildcard
        
        self.textbox = TextBox(self,Value=wildcard)
        self.textbox.OnText=self.OnChar
        if '*' not in wildcard:
            wildcard+='*'
        
        files=glob.glob(wildcard)
        
        self.AddComponent(self.textbox, border=3, expand='h')
        
        
        
        self.listbox = ListBox(self, choices=files, 

# Path: plasticity/run_sim.py
# def Plot(sim):
#     gray=pylab.cm.gray
#     pylab.ion()
#     
#     try:
#         if not sim['params']['display']:
#             return
#     except TypeError:  # sent a string
#         sim=zpickle.load(sim)
# 
#         
#     try:
#         if sim['params']['display_module']:
#             pass
#     except:
#         sim['params']['display_module']=False
#         
#     if sim['params']['display_module']:
#         try:
#             module=__import__(sim['params']['display_module'],fromlist=['UserPlot'])
#         except ImportError:
#             sim['params']['display']=False
#             print("Error","Error in Import: %s.  Turning display off.  %s" % (
#                                 sim['params']['display_module'],
#                                 sys.exc_info()))
#             return
#         
#         try:
#             module.UserPlot(None,sim)
#             pylab.draw()
#             return
#         except ValueError:
#             sim['params']['display']=False
#             print("Error in display.  Turning display off")
#             return
#     
#     try:
#     
#         im=weights2image(sim['params'],sim['weights'])
#         ax=pylab.subplot(221)
#         pylab.pcolor(im,cmap=gray)
#         ax.set_axis_bgcolor('k')
#         pylab.axis('equal')
#         
#         num_moments=sim['moments_mat'].shape[0]
# 
#         
#         ax=pylab.subplot(222)
#         ax.hold(False)
#         if num_moments==1:
#             num_neurons=sim['moments_mat'].shape[1]
#             for k in range(num_neurons):
#                 pylab.plot(sim['t_mat'],sim['moments_mat'][0,k,:],'-o')
#                 ax.hold(True)
#         elif num_moments==2:
#             num_neurons=sim['moments_mat'].shape[1]
#             for k in range(num_neurons):
#                 pylab.plot(sim['t_mat'],sim['moments_mat'][0,k,:],'b-o')
#                 ax2=pylab.twinx(ax)
#                 pylab.plot(sim['t_mat'],sim['moments_mat'][1,k,:],'g-o')
#                 ax2.yaxis.tick_right()
# 
#         else:
#             num_neurons=sim['moments_mat'].shape[1]
#             for k in range(num_neurons):
#                 for i in range(num_moments):
#                     pylab.plot(sim['t_mat'],sim['moments_mat'][i,k,:],'-o')
#                     ax.hold(True)
#         
#         
#     
#         pylab.subplot(223)
#         pylab.hold(False)
#         response_mat=sim['response_mat']
#         response_var_list=sim['response_var_list']
#         
#         
#         styles=['b-','g-','r-','k-']
#         ls=len(styles)
#         for i,r in enumerate(response_var_list[-1]):
#             x=r[1]
#             y=r[2]
#         
#             pylab.plot(x,y,styles[i % ls]+"o")
#             pylab.hold(True)
#     
#         pylab.subplot(224)
#         pylab.hold(False)
#         for i,r in enumerate(response_mat):
#             pylab.plot(r,styles[i % ls])
#             pylab.hold(True)
#     
#     
#         pylab.draw()
# 
# 
#     except ValueError:
#         sim['params']['display']=False
#         print("Error in display.  Turning display off")
#         return


# Path: plasticity/plot_sims.py
from .dialogs.waxy import *
from .run_sim import Plot
import os,sys
import glob

    def __init__(self,parent=None,title='',direction='v',
                    size=(200,800),default_wildcard=None):

        self.default_wildcard=default_wildcard
        Frame.__init__(self,parent,title,direction,size)
        
    def Body(self):
        
        menubar = MenuBar(self)
        menu1 = Menu(self)
        menu1.Append("E&xit", self.CloseWindow, "Exit demo",hotkey="Ctrl+Q")
        menubar.Append(menu1, "&File")

        if not self.default_wildcard:
            self.default_wildcard='sims/'
            
        wildcard=self.default_wildcard
        
        self.textbox = TextBox(self,Value=wildcard)
        self.textbox.OnText=self.OnChar
        if '*' not in wildcard:
            wildcard+='*'
        
        files=glob.glob(wildcard)
        
        self.AddComponent(self.textbox, border=3, expand='h')
        
        
        
        self.listbox = ListBox(self, choices=files, 

                            size=(250, 450), 