# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Wed Jun 24 20:00:54 2009

import wx

# begin wxGlade: dependencies
from MplPanel import MplPanel
# end wxGlade

# begin wxGlade: extracode

# end wxGlade

class MplFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MplFrame.__init__
        kwds["style"] = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.MAXIMIZE|wx.MAXIMIZE_BOX|wx.SYSTEM_MENU|wx.RESIZE_BORDER|wx.FULL_REPAINT_ON_RESIZE|wx.CLIP_CHILDREN
        wx.Frame.__init__(self, *args, **kwds)
        
        # Menu Bar
        self.mplmenubar = wx.MenuBar()
        self.File = wx.Menu()
        self.Open = wx.MenuItem(self.File, wx.NewId(), "Open", "", wx.ITEM_NORMAL)
        self.File.AppendItem(self.Open)
        self.File.AppendSeparator()
        self.Quit = wx.MenuItem(self.File, wx.NewId(), "Quit", "", wx.ITEM_NORMAL)
        self.File.AppendItem(self.Quit)
        self.mplmenubar.Append(self.File, "File")
        self.SetMenuBar(self.mplmenubar)
        # Menu Bar end
        self.mpltextctrl = wx.TextCtrl(self, -1, "/usr/share/dict/words")
        self.mplbutton = wx.Button(self, -1, "Parse this file")
        self.mplpanel = MplPanel(self, -1)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_MENU, self.onFileOpen, self.Open)
        self.Bind(wx.EVT_MENU, self.onFileQuit, self.Quit)
        self.Bind(wx.EVT_BUTTON, self.parse_file, self.mplbutton)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MplFrame.__set_properties
        self.SetTitle("Matplotlib In wxGlade - Count letters frequency in a file")
        self.SetSize((600, 460))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MplFrame.__do_layout
        mplsizer1 = wx.BoxSizer(wx.VERTICAL)
        mplsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        mplsizer2.Add(self.mpltextctrl, 1, wx.EXPAND, 0)
        mplsizer2.Add(self.mplbutton, 0, 0, 0)
        mplsizer1.Add(mplsizer2, 0, wx.EXPAND, 0)
        mplsizer1.Add(self.mplpanel, 1, wx.ALL|wx.EXPAND, 0)
        self.SetSizer(mplsizer1)
        self.Layout()
        # end wxGlade

    def onFileOpen(self, event): # wxGlade: MplFrame.<event_handler>
        filename = wx.FileSelector()
        if filename:
            self.mpltextctrl.SetValue(filename)

    def onFileQuit(self, event): # wxGlade: MplFrame.<event_handler>
        # closes the window
        self.Close(True)

    def parse_file(self, event): # wxGlade: MplFrame.<event_handler>
        self.mplpanel.update_graph(self.mpltextctrl.GetValue())

# end of class MplFrame


