<commit_before># -*- coding: utf-8 -*-
import wx
import wx.aui as aui
import wx.grid as grid
import wx.lib.scrolledpanel as scrolled
import os
import numpy as np
import matplotlib

import matplotlib.pyplot as plt
#from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from uimpl import FigureCanvas
from matplotlib.figure import Figure

import setplot
import uimpl
import uiaux as aux
from util import isempty, rgb2hex
from _const_ import *  # String & Constants values

class NanchiNoteBook(aui.AuiNotebook):
    def __init__(self, parent):
		_styles = aui.AUI_NB_TOP | aui.AUI_NB_TAB_SPLIT | aui.AUI_NB_TAB_MOVE
		aui.AuiNotebook.__init__(self, parent=parent, style=_styles)
		
		self.graphs = GraphPanel(self)
		self.data = DataPanel(self)
		#self.setup = SetupPanel(self)

		self.AddPage(self.graphs, u"Gráficas")
		self.AddPage(self.data, u"Datos")
		#self.AddPage(self.setup, u"Configurar")

		self.axes = self.graphs.axes
		self.figure = self.graphs.figure
		self.canvas = self.graphs.canvas

		self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)

    def OnPageChanged(self, event):
		pass
		#gp = pickle.load(open("graph_properties.dat","rb"))
		#self.axes.set_xlabel(gp["xlabel"])
		#self.axes.set_ylabel(gp["ylabel"])
		#self.canvas.draw() # Draw canvas 
        


class SetupPanel(wx.Panel):
	def __init__(self,parent,*args,**kwargs):
		wx.Panel.__init__(self,parent,*args,**kwargs)
		# Fonts
		self.COMBO_BOX_FONT = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)
		
		self.initCtrls()
		self.initSizers()
		
	def initCtrls(self):
		self.plabels = wx.Panel(self, -1, style=wx.BORDER_SIMPLE)
		self.pstyles = wx.Panel(self, -1, style=wx.BORDER_SIMPLE)
		self.pbuttons = wx.Panel(self, -1, style=wx.BORDER_SIMPLE)
		
		# Labels controls
		self._xlabel = wx.StaticText(self.plabels, -1, "Etiqueta X")
		self._ylabel = wx.StaticText(self.plabels, -1, "Etiqueta Y")
		self.xlabel = wx.TextCtrl(self.plabels, -1)
		self.ylabel = wx.TextCtrl(self.plabels, -1)
		
		# Styles controls
		self._line_style = wx.StaticText(self.pstyles, -1, u"Estilo de línea")
		self.line_style = wx.ComboBox(self.pstyles, -1, choices=LINE_STYLES, 
									  size=(80,-1), value="'-'")
		self.line_style.SetFont(self.COMBO_BOX_FONT)
		
		self._line_color = wx.StaticText(self.pstyles, -1, u"Color de línea")
		self.line_color = wx.ColourPickerCtrl(self.pstyles, -1, col=LINE_COLOR)
		
		self._line_width = wx.StaticText(self.pstyles, -1, u"Grosor de línea")
		self.line_width = wx.SpinCtrl(self.pstyles, -1, min=1, max=20, 
									  initial=1, size=(60,-1))
		
		self._grid_color = wx.StaticText(self.pstyles, -1, u"Color de rejilla")
		self.grid_color = wx.ColourPickerCtrl(self.pstyles, -1, col=GRID_COLOR)
		
		# Buttons for save or discard changes
		self.save_changes = wx.Button(self.pbuttons, -1, "Aplicar cambios")
		self.default_values = wx.Button(self.pbuttons, -1, "Valores predeterminados")
		
		self.Bind(wx.EVT_BUTTON, self.OnSaveChanges, self.save_changes)
		
	def initSizers(self):
		self.mainsz = wx.BoxSizer(wx.VERTICAL)
		self.szplabels = wx.GridBagSizer(10,10)
		self.szpstyles = wx.GridBagSizer(10,10)
		self.szpbuttons = wx.BoxSizer(wx.HORIZONTAL)
		
		self.szplabels.Add(self._xlabel, (0,0), flag=wx.ALL, border=5)
		self.szplabels.Add(self.xlabel, (0,1), flag=wx.ALL, border=5)
		self.szplabels.Add(self._ylabel, (0,2), flag=wx.ALL, border=5)
		self.szplabels.Add(self.ylabel, (0,3), flag=wx.ALL, border=5)
		self.szplabels.AddGrowableRow(0)
		
		self.szpstyles.Add(self._line_style, (0,0), flag=wx.ALL, border=5)
		self.szpstyles.Add(self.line_style, (0,1), flag=wx.ALL, border=5)
		self.szpstyles.Add(self._line_color, (0,2), flag=wx.ALL, border=5)
		self.szpstyles.Add(self.line_color, (0,3), flag=wx.ALL, border=5)
		self.szpstyles.Add(self._line_width, (0,4), flag=wx.ALL, border=5)
		self.szpstyles.Add(self.line_width, (0,5), flag=wx.ALL, border=5)
		self.szpstyles.Add(self._grid_color, (1,0), flag=wx.ALL, border=5)
		self.szpstyles.Add(self.grid_color, (1,1), flag=wx.ALL, border=5)
		
		self.szpbuttons.Add(self.save_changes, 0, wx.ALIGN_CENTER|wx.ALL, 5)
		self.szpbuttons.Add(self.default_values, 0, wx.ALIGN_CENTER|wx.ALL, 5)
		
		self.mainsz.Add(self.plabels, 3, wx.EXPAND|wx.ALL, 5)
		self.mainsz.Add(self.pstyles, 3, wx.EXPAND|wx.ALL, 5)
		self.mainsz.Add(self.pbuttons, 1, wx.EXPAND|wx.ALL, 5)
		
		self.plabels.SetSizer(self.szplabels)
		self.pstyles.SetSizer(self.szpstyles)
		self.pbuttons.SetSizer(self.szpbuttons)
		self.SetSizer(self.mainsz)

	def OnSaveChanges(self,event):
		pass
		#xlabel = self.xlabel.GetValue()
		#ylabel = self.ylabel.GetValue()
		#graph_properties = {"xlabel":xlabel,"ylabel":ylabel}
		#pickle.dump(graph_properties, open('graph_properties.dat',"wb"))


class GraphPanel(wx.Panel):
	def __init__(self,parent,*args,**kwargs):
		wx.Panel.__init__(self,parent,-1)
		# Sizer
		self.mainsz = wx.BoxSizer(wx.VERTICAL)
		
		# Init canvas Figure & Axes
		self.initCanvas()
		
		# Color properties
		self.SetBackgroundColour(PANEL_BG_COLOR)
		
		# Configurar sizeR
		self.SetSizer(self.mainsz)
		
	def initCanvas(self):
		# Crear figure & axes
		self.figure = Figure()
		self.axes = self.figure.add_subplot(111)
		self.canvas = FigureCanvas(self, -1, self.figure)
		
		self.EVT_ON_RIGHT = self.canvas.mpl_connect('button_press_event', self.OnRightClick)
		# Graph properties
		setplot.set_default_params(self.axes,self.figure)
		# FigureCanvas
		self.mainsz.Add(self.canvas, 1, wx.EXPAND|wx.ALL, 2)
	
	def OnRightClick(self,event):
		if event.button == 3:
			self.InitPopUpMenu()
		else:
			pass
			

	def InitPopUpMenu(self):
		pum = wx.Menu()
		
		ls = wx.Menu() # Line Style
		_ls_cont = wx.MenuItem(ls, -1, u"-")
		ls.AppendItem(_ls_cont)
		_ls_dashed = wx.MenuItem(ls, -1, u"--")
		ls.AppendItem(_ls_dashed)
		_ls_dotted = wx.MenuItem(ls, -1, u"dotted")
		ls.AppendItem(_ls_dotted)
		pum.AppendMenu(-1, u"Estilo de línea", ls)
		linecolor = wx.MenuItem(pum, -1, u"Color de línea")
		pum.AppendItem(linecolor)
		linewidth = wx.MenuItem(pum, -1, u"Grosor de línea")
		pum.AppendItem(linewidth)
		
		pum.AppendSeparator()
		
		gs = wx.Menu()
		_gs_cont = wx.MenuItem(gs, -1, u"-")
		gs.AppendItem(_gs_cont)
		_gs_dashed = wx.MenuItem(gs, -1, u"--")
		gs.AppendItem(_gs_dashed)
		_gs_dotted = wx.MenuItem(gs, -1, u"dotted")
		gs.AppendItem(_gs_dotted)
		pum.AppendMenu(-1, "Estilo de rejilla", gs)
		gridcolor = wx.MenuItem(pum, -1, u"Color de rejilla")
		pum.AppendItem(gridcolor)
		
		pum.AppendSeparator()
		axbackg = wx.MenuItem(pum, -1, u"Color de fondo")
		pum.AppendItem(axbackg)
		aspax = wx.Menu()
		_aspax_auto = wx.MenuItem(aspax, -1, u"auto")
		aspax.AppendItem(_aspax_auto)		
		_aspax_equal = wx.MenuItem(aspax, -1, u"equal")
		aspax.AppendItem(_aspax_equal)
		pum.AppendMenu(-1, "Aspecto del axes", aspax)
		
		pum.AppendSeparator()
		xlabel = wx.MenuItem(pum, -1, u"Etiqueta X")
		pum.AppendItem(xlabel)
		ylabel = wx.MenuItem(pum, -1, u"Etiqueta Y")
		pum.AppendItem(ylabel)
		title = wx.MenuItem(pum, -1, u"Insertar título")
		pum.AppendItem(title)
		intext = wx.MenuItem(pum, -1, u"Insertar texto/anotación")
		pum.AppendItem(intext)
		
		pum.AppendSeparator()
		setxtick = wx.MenuItem(pum, -1, u"Modificar xticks")
		pum.AppendItem(setxtick)
		setytick = wx.MenuItem(pum, -1, u"Modificar yticks")
		pum.AppendItem(setytick)
		
		pum.AppendSeparator()
		zoom_box = wx.MenuItem(pum, -1, u"Zoom Box")
		pum.AppendItem(zoom_box)
		
		# Binds
		self.Bind(wx.EVT_MENU, self.OnText, intext)
		self.Bind(wx.EVT_MENU, self.OnBackground, axbackg)
		self.Bind(wx.EVT_MENU, self.OnGridColor, gridcolor)
		self.Bind(wx.EVT_MENU, self.OnXLabel, xlabel)
		self.Bind(wx.EVT_MENU, self.OnYLabel, ylabel)
		self.Bind(wx.EVT_MENU, self.OnTitle, title)
		self.Bind(wx.EVT_MENU, self.OnZoom, zoom_box)
		self.Bind(wx.EVT_MENU, self.OnGridStyle, _gs_cont)
		self.Bind(wx.EVT_MENU, self.OnGridStyle, _gs_dashed)	
		self.Bind(wx.EVT_MENU, self.OnGridStyle, _gs_dotted)
		self.Bind(wx.EVT_MENU, self.OnAxesAspect, _aspax_equal)
		self.Bind(wx.EVT_MENU, self.OnAxesAspect, _aspax_auto)
		
		# Lines
		self.Bind(wx.EVT_MENU, self.OnLineStyle, _ls_cont)
		self.Bind(wx.EVT_MENU, self.OnLineStyle, _ls_dashed)	
		self.Bind(wx.EVT_MENU, self.OnLineStyle, _ls_dotted)
		self.Bind(wx.EVT_MENU, self.OnLineColor, linecolor)
		self.Bind(wx.EVT_MENU, self.OnLineWidth, linewidth)
		
		# Ticks
		self.Bind(wx.EVT_MENU, self.OnXTick, setxtick)
		self.Bind(wx.EVT_MENU, self.OnYTick, setytick)
		
		# Show
		self.PopupMenu(pum)
		pum.Destroy()
			
			
	def OnText(self,event):
		self.TEXT_EVT = self.canvas.mpl_connect("button_press_event", self.set_text)
		
	def set_text(self,event):
		cx = event.xdata
		cy = event.ydata
		dialog = wx.TextEntryDialog(self,
		"Inserte el texto",
		NANCHI_MAIN_CAPTION, "", style=wx.OK|wx.CANCEL)
		if dialog.ShowModal() == wx.ID_OK:
			self.axes.text(cx, cy, unicode(dialog.GetValue()))
			self.canvas.draw()
		dialog.Destroy()
		self.canvas.mpl_disconnect(self.TEXT_EVT)
		
	def OnBackground(self,event):
		dlg = wx.ColourDialog(self)
		if dlg.ShowModal() == wx.ID_OK:
			color = dlg.GetColourData().Colour
			r,g,b = color.Red(),color.Green(),color.Blue()
			self.axes.set_axis_bgcolor(rgb2hex(r,g,b))
		dlg.Destroy()
		self.canvas.draw()
		
	def OnAxesAspect(self,event):
		aspect = event.GetEventObject().GetLabel(event.GetId())
		self.axes.set_aspect(aspect)
		self.canvas.draw()
		
	def OnGridColor(self,event):
		dlg = wx.ColourDialog(self)
		if dlg.ShowModal() == wx.ID_OK:
			color = dlg.GetColourData().Colour
			r,g,b = color.Red(),color.Green(),color.Blue()
			self.axes.grid(color=rgb2hex(r,g,b))
		dlg.Destroy()
		self.canvas.draw()
		
	def OnGridStyle(self,event):
		_gs = event.GetEventObject().GetLabel(event.GetId())
		self.axes.grid(ls=_gs)<commit_msg>Solucionado problema de posicionamiento de textos en la zona figure/canvas<commit_after># -*- coding: utf-8 -*-
import wx
import wx.aui as aui
import wx.grid as grid
import wx.lib.scrolledpanel as scrolled
import os
import numpy as np
import matplotlib

import matplotlib.pyplot as plt
#from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from uimpl import FigureCanvas
from matplotlib.figure import Figure

import setplot
import uimpl
import uiaux as aux
from util import isempty, rgb2hex
from _const_ import *  # String & Constants values

class NanchiNoteBook(aui.AuiNotebook):
    def __init__(self, parent):
		_styles = aui.AUI_NB_TOP | aui.AUI_NB_TAB_SPLIT | aui.AUI_NB_TAB_MOVE
		aui.AuiNotebook.__init__(self, parent=parent, style=_styles)
		
		self.graphs = GraphPanel(self)
		self.data = DataPanel(self)
		#self.setup = SetupPanel(self)

		self.AddPage(self.graphs, u"Gráficas")
		self.AddPage(self.data, u"Datos")
		#self.AddPage(self.setup, u"Configurar")

		self.axes = self.graphs.axes
		self.figure = self.graphs.figure
		self.canvas = self.graphs.canvas

		self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)

    def OnPageChanged(self, event):
		pass
		#gp = pickle.load(open("graph_properties.dat","rb"))
		#self.axes.set_xlabel(gp["xlabel"])
		#self.axes.set_ylabel(gp["ylabel"])
		#self.canvas.draw() # Draw canvas 
        


class SetupPanel(wx.Panel):
	def __init__(self,parent,*args,**kwargs):
		wx.Panel.__init__(self,parent,*args,**kwargs)
		# Fonts
		self.COMBO_BOX_FONT = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)
		
		self.initCtrls()
		self.initSizers()
		
	def initCtrls(self):
		self.plabels = wx.Panel(self, -1, style=wx.BORDER_SIMPLE)
		self.pstyles = wx.Panel(self, -1, style=wx.BORDER_SIMPLE)
		self.pbuttons = wx.Panel(self, -1, style=wx.BORDER_SIMPLE)
		
		# Labels controls
		self._xlabel = wx.StaticText(self.plabels, -1, "Etiqueta X")
		self._ylabel = wx.StaticText(self.plabels, -1, "Etiqueta Y")
		self.xlabel = wx.TextCtrl(self.plabels, -1)
		self.ylabel = wx.TextCtrl(self.plabels, -1)
		
		# Styles controls
		self._line_style = wx.StaticText(self.pstyles, -1, u"Estilo de línea")
		self.line_style = wx.ComboBox(self.pstyles, -1, choices=LINE_STYLES, 
									  size=(80,-1), value="'-'")
		self.line_style.SetFont(self.COMBO_BOX_FONT)
		
		self._line_color = wx.StaticText(self.pstyles, -1, u"Color de línea")
		self.line_color = wx.ColourPickerCtrl(self.pstyles, -1, col=LINE_COLOR)
		
		self._line_width = wx.StaticText(self.pstyles, -1, u"Grosor de línea")
		self.line_width = wx.SpinCtrl(self.pstyles, -1, min=1, max=20, 
									  initial=1, size=(60,-1))
		
		self._grid_color = wx.StaticText(self.pstyles, -1, u"Color de rejilla")
		self.grid_color = wx.ColourPickerCtrl(self.pstyles, -1, col=GRID_COLOR)
		
		# Buttons for save or discard changes
		self.save_changes = wx.Button(self.pbuttons, -1, "Aplicar cambios")
		self.default_values = wx.Button(self.pbuttons, -1, "Valores predeterminados")
		
		self.Bind(wx.EVT_BUTTON, self.OnSaveChanges, self.save_changes)
		
	def initSizers(self):
		self.mainsz = wx.BoxSizer(wx.VERTICAL)
		self.szplabels = wx.GridBagSizer(10,10)
		self.szpstyles = wx.GridBagSizer(10,10)
		self.szpbuttons = wx.BoxSizer(wx.HORIZONTAL)
		
		self.szplabels.Add(self._xlabel, (0,0), flag=wx.ALL, border=5)
		self.szplabels.Add(self.xlabel, (0,1), flag=wx.ALL, border=5)
		self.szplabels.Add(self._ylabel, (0,2), flag=wx.ALL, border=5)
		self.szplabels.Add(self.ylabel, (0,3), flag=wx.ALL, border=5)
		self.szplabels.AddGrowableRow(0)
		
		self.szpstyles.Add(self._line_style, (0,0), flag=wx.ALL, border=5)
		self.szpstyles.Add(self.line_style, (0,1), flag=wx.ALL, border=5)
		self.szpstyles.Add(self._line_color, (0,2), flag=wx.ALL, border=5)
		self.szpstyles.Add(self.line_color, (0,3), flag=wx.ALL, border=5)
		self.szpstyles.Add(self._line_width, (0,4), flag=wx.ALL, border=5)
		self.szpstyles.Add(self.line_width, (0,5), flag=wx.ALL, border=5)
		self.szpstyles.Add(self._grid_color, (1,0), flag=wx.ALL, border=5)
		self.szpstyles.Add(self.grid_color, (1,1), flag=wx.ALL, border=5)
		
		self.szpbuttons.Add(self.save_changes, 0, wx.ALIGN_CENTER|wx.ALL, 5)
		self.szpbuttons.Add(self.default_values, 0, wx.ALIGN_CENTER|wx.ALL, 5)
		
		self.mainsz.Add(self.plabels, 3, wx.EXPAND|wx.ALL, 5)
		self.mainsz.Add(self.pstyles, 3, wx.EXPAND|wx.ALL, 5)
		self.mainsz.Add(self.pbuttons, 1, wx.EXPAND|wx.ALL, 5)
		
		self.plabels.SetSizer(self.szplabels)
		self.pstyles.SetSizer(self.szpstyles)
		self.pbuttons.SetSizer(self.szpbuttons)
		self.SetSizer(self.mainsz)

	def OnSaveChanges(self,event):
		pass
		#xlabel = self.xlabel.GetValue()
		#ylabel = self.ylabel.GetValue()
		#graph_properties = {"xlabel":xlabel,"ylabel":ylabel}
		#pickle.dump(graph_properties, open('graph_properties.dat',"wb"))


class GraphPanel(wx.Panel):
	def __init__(self,parent,*args,**kwargs):
		wx.Panel.__init__(self,parent,-1)
		# Sizer
		self.mainsz = wx.BoxSizer(wx.VERTICAL)
		
		# Init canvas Figure & Axes
		self.initCanvas()
		
		# Color properties
		self.SetBackgroundColour(PANEL_BG_COLOR)
		
		# Configurar sizeR
		self.SetSizer(self.mainsz)
		
	def initCanvas(self):
		# Crear figure & axes
		self.figure = Figure()
		self.axes = self.figure.add_subplot(111)
		self.canvas = FigureCanvas(self, -1, self.figure)
		
		self.EVT_ON_RIGHT = self.canvas.mpl_connect('button_press_event', self.OnRightClick)
		# Graph properties
		setplot.set_default_params(self.axes,self.figure)
		# FigureCanvas
		self.mainsz.Add(self.canvas, 1, wx.EXPAND|wx.ALL, 2)
	
	def OnRightClick(self,event):
		if event.button == 3:
			self.InitPopUpMenu()
		else:
			pass
			

	def InitPopUpMenu(self):
		pum = wx.Menu()
		
		ls = wx.Menu() # Line Style
		_ls_cont = wx.MenuItem(ls, -1, u"-")
		ls.AppendItem(_ls_cont)
		_ls_dashed = wx.MenuItem(ls, -1, u"--")
		ls.AppendItem(_ls_dashed)
		_ls_dotted = wx.MenuItem(ls, -1, u"dotted")
		ls.AppendItem(_ls_dotted)
		pum.AppendMenu(-1, u"Estilo de línea", ls)
		linecolor = wx.MenuItem(pum, -1, u"Color de línea")
		pum.AppendItem(linecolor)
		linewidth = wx.MenuItem(pum, -1, u"Grosor de línea")
		pum.AppendItem(linewidth)
		
		pum.AppendSeparator()
		
		gs = wx.Menu()
		_gs_cont = wx.MenuItem(gs, -1, u"-")
		gs.AppendItem(_gs_cont)
		_gs_dashed = wx.MenuItem(gs, -1, u"--")
		gs.AppendItem(_gs_dashed)
		_gs_dotted = wx.MenuItem(gs, -1, u"dotted")
		gs.AppendItem(_gs_dotted)
		pum.AppendMenu(-1, "Estilo de rejilla", gs)
		gridcolor = wx.MenuItem(pum, -1, u"Color de rejilla")
		pum.AppendItem(gridcolor)
		
		pum.AppendSeparator()
		axbackg = wx.MenuItem(pum, -1, u"Color de fondo")
		pum.AppendItem(axbackg)
		aspax = wx.Menu()
		_aspax_auto = wx.MenuItem(aspax, -1, u"auto")
		aspax.AppendItem(_aspax_auto)		
		_aspax_equal = wx.MenuItem(aspax, -1, u"equal")
		aspax.AppendItem(_aspax_equal)
		pum.AppendMenu(-1, "Aspecto del axes", aspax)
		
		pum.AppendSeparator()
		xlabel = wx.MenuItem(pum, -1, u"Etiqueta X")
		pum.AppendItem(xlabel)
		ylabel = wx.MenuItem(pum, -1, u"Etiqueta Y")
		pum.AppendItem(ylabel)
		title = wx.MenuItem(pum, -1, u"Insertar título")
		pum.AppendItem(title)
		intext = wx.MenuItem(pum, -1, u"Insertar texto/anotación")
		pum.AppendItem(intext)
		
		pum.AppendSeparator()
		setxtick = wx.MenuItem(pum, -1, u"Modificar xticks")
		pum.AppendItem(setxtick)
		setytick = wx.MenuItem(pum, -1, u"Modificar yticks")
		pum.AppendItem(setytick)
		
		pum.AppendSeparator()
		zoom_box = wx.MenuItem(pum, -1, u"Zoom Box")
		pum.AppendItem(zoom_box)
		
		# Binds
		self.Bind(wx.EVT_MENU, self.OnText, intext)
		self.Bind(wx.EVT_MENU, self.OnBackground, axbackg)
		self.Bind(wx.EVT_MENU, self.OnGridColor, gridcolor)
		self.Bind(wx.EVT_MENU, self.OnXLabel, xlabel)
		self.Bind(wx.EVT_MENU, self.OnYLabel, ylabel)
		self.Bind(wx.EVT_MENU, self.OnTitle, title)
		self.Bind(wx.EVT_MENU, self.OnZoom, zoom_box)
		self.Bind(wx.EVT_MENU, self.OnGridStyle, _gs_cont)
		self.Bind(wx.EVT_MENU, self.OnGridStyle, _gs_dashed)	
		self.Bind(wx.EVT_MENU, self.OnGridStyle, _gs_dotted)
		self.Bind(wx.EVT_MENU, self.OnAxesAspect, _aspax_equal)
		self.Bind(wx.EVT_MENU, self.OnAxesAspect, _aspax_auto)
		
		# Lines
		self.Bind(wx.EVT_MENU, self.OnLineStyle, _ls_cont)
		self.Bind(wx.EVT_MENU, self.OnLineStyle, _ls_dashed)	
		self.Bind(wx.EVT_MENU, self.OnLineStyle, _ls_dotted)
		self.Bind(wx.EVT_MENU, self.OnLineColor, linecolor)
		self.Bind(wx.EVT_MENU, self.OnLineWidth, linewidth)
		
		# Ticks
		self.Bind(wx.EVT_MENU, self.OnXTick, setxtick)
		self.Bind(wx.EVT_MENU, self.OnYTick, setytick)
		
		# Show
		self.PopupMenu(pum)
		pum.Destroy()
			
			
	def OnText(self,event):
		self.TEXT_EVT = self.canvas.mpl_connect("button_press_event", self.set_text)
		
	def set_text(self,event):
		cx = event.xdata
		cy = event.ydata
		dialog = wx.TextEntryDialog(self,"Inserte el texto",
		NANCHI_MAIN_CAPTION, "", style=wx.OK|wx.CANCEL)
		if dialog.ShowModal() == wx.ID_OK:
			if not cx is None and not cy is None:
				self.axes.text(cx, cy, unicode(dialog.GetValue()))
				self.canvas.draw()
			else:
				msg = wx.MessageDialog(self,u"Seleccione una posición dentro del axes",
				caption=DEFAULT_DIALOG_CAPTION, style=wx.ICON_ERROR|wx.OK)
				msg.ShowModal()
				msg.Destroy()
		dialog.Destroy()
		self.canvas.mpl_disconnect(self.TEXT_EVT)
		
	def OnBackground(self,event):
		dlg = wx.ColourDialog(self)
		if dlg.ShowModal() == wx.ID_OK:
			color = dlg.GetColourData().Colour
			r,g,b = color.Red(),color.Green(),color.Blue()
			self.axes.set_axis_bgcolor(rgb2hex(r,g,b))
		dlg.Destroy()
		self.canvas.draw()
		
	def OnAxesAspect(self,event):
		aspect = event.GetEventObject().GetLabel(event.GetId())
		self.axes.set_aspect(aspect)
		self.canvas.draw()
		
	def OnGridColor(self,event):
		dlg = wx.ColourDialog(self)
		if dlg.ShowModal() == wx.ID_OK:
			color = dlg.GetColourData().Colour
			r,g,b = color.Red(),color.Green(),color.Blue()
			self.axes.grid(color=rgb2hex(r,g,b))
		dlg.Destroy()
		self.canvas.draw()
		
	def OnGridStyle(self,event):
		_gs = event.GetEventObject().GetLabel(event.GetId())
		self.axes.grid(ls=_gs)
{'fraction_non_alphanumeric': 0.14850486611870303, 'fraction_numerical': 0.011900559729716102, 'mean_word_length': 4.374525745257452, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3344303', 'n_tokens_mistral': 9023, 'n_tokens_neox': 8107, 'n_words': 1295}