<commit_before>import wx
import wx.grid
from matplotlib.figure import Figure
import matplotlib.animation as animation
import networkx as nx
import numpy as np
import math
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
import creategraph
from projectdata import DataManager

class AnalysisDemo(wx.Frame):
    APP_EXIT = 0
    APP_PREVVERSION = 1
    APP_NEXTVERSION = 2
    APP_PACKAGE = 3
    APP_CLASS = 4
    def __init__(self, *args, **kw):
        super(AnalysisDemo, self).__init__(*args, **kw)
        self.dataManage = DataManager()
        self.versionArray = ["6.0.0", "6.0.43", "7.0.0", "7.0.61", "8.0.0", "8.0.21"]
        self.curPackage = ''
        self.initMain()

    def initMenuBar(self):
        menubar = wx.MenuBar()
        fileMenu = wx.Menu()
        quitProg = wx.MenuItem(fileMenu, self.APP_EXIT, '&Quit\tCtrl+Q')
        fileMenu.AppendItem(quitProg)

        ctrlMenu = wx.Menu()
        prevVer = wx.MenuItem(ctrlMenu, self.APP_PREVVERSION, '&Prev Version\tCtrl+P')
        nextVer = wx.MenuItem(ctrlMenu, self.APP_NEXTVERSION, '&Next Version\tCtrl+N')
        orgInPackage = wx.MenuItem(ctrlMenu, self.APP_PACKAGE, 'Organize in &Package\tF5')
        orgInClass = wx.MenuItem(ctrlMenu, self.APP_CLASS, 'Organize in &File\tF6')
        ctrlMenu.AppendItem(prevVer)
        ctrlMenu.AppendItem(nextVer)
        ctrlMenu.AppendSeparator()
        ctrlMenu.AppendItem(orgInPackage)
        ctrlMenu.AppendItem(orgInClass)

        self.Bind(wx.EVT_MENU, self.movePrevVersion, id=self.APP_PREVVERSION)
        self.Bind(wx.EVT_MENU, self.moveNextVersion, id=self.APP_NEXTVERSION)
        self.Bind(wx.EVT_MENU, self.onQuit, id=self.APP_EXIT)
        self.Bind(wx.EVT_MENU, self.organizeInPackage, id=self.APP_PACKAGE)
        self.Bind(wx.EVT_MENU, self.organizeInClass, id=self.APP_CLASS)

        menubar.Append(fileMenu, '&File')
        menubar.Append(ctrlMenu, '&Ctrl')
        self.SetMenuBar(menubar)

    def initMain(self):
        pn = wx.Panel(self)

        self.initMenuBar()

        self.showPackage = wx.RadioButton(pn, label='Organize in package')
        self.showFile = wx.RadioButton(pn, label='Organize in file')
        self.create = wx.Button(pn, label='Create Figure')

        self.prevVersion = wx.Button(pn, label='Previous Version')
        self.nextVersion = wx.Button(pn, label='Next Version')
        self.versionSlider = wx.Slider(pn, minValue=0, maxValue=5, size=(150,-1), style=wx.SL_AUTOTICKS)
        self.version = wx.TextCtrl(pn, value=self.versionArray[0], size=(50,-1))
        self.version.SetEditable(False)

        self.figure = Figure(facecolor='#f3f3f3')
        self.canvas = FigureCanvas(pn, -1, self.figure)
        self.nameList = wx.ListBox(pn, choices=['All packages...', 'All files...'] + self.dataManage.getPackages())
        self.codeField = wx.TextCtrl(pn, style=wx.TE_MULTILINE | wx.HSCROLL)
        self.attrField = wx.grid.Grid(pn)
        self.attrField.CreateGrid(1, len(self.dataManage.listPackageAttr()))
        self.attrField.SetRowLabelValue(0, 'Package name')
        self.attrField.SetRowLabelSize(200)
        readonlyAttr = wx.grid.GridCellAttr()
        readonlyAttr.SetReadOnly(True)
        self.attrField.SetRowAttr(0, readonlyAttr)
        for i in xrange(len(self.dataManage.listPackageAttr())):
            self.attrField.SetColSize(i, 100)
            self.attrField.SetColLabelValue(i, self.dataManage.listPackageAttr()[i])

        self.showPackage.Bind(wx.EVT_RADIOBUTTON, self.onRadioButton)
        self.showFile.Bind(wx.EVT_RADIOBUTTON, self.onRadioButton)
        self.prevVersion.Bind(wx.EVT_BUTTON, self.movePrevVersion)
        self.nextVersion.Bind(wx.EVT_BUTTON, self.moveNextVersion)
        self.nameList.Bind(wx.EVT_LISTBOX, self.onNameList)
        self.nameList.Bind(wx.EVT_LISTBOX_DCLICK, self.onDNameList)
        self.versionSlider.Bind(wx.EVT_SCROLL_CHANGED, self.onVersionScroll)

        contextBoxSizer = wx.BoxSizer(wx.VERTICAL)
        contextBoxSizer.Add(self.canvas, proportion=1, flag=wx.EXPAND | wx.ALL, border=0)
        contextBoxSizer.Add(self.attrField, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER, border=0)

        bodyBoxSizer = wx.BoxSizer()
        bodyBoxSizer.Add(self.nameList, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        bodyBoxSizer.Add(contextBoxSizer, proportion=3, flag=wx.EXPAND | wx.ALL, border=5)
        bodyBoxSizer.Add(self.codeField, proportion=2, flag=wx.EXPAND | wx.ALL, border=5)

        optionBoxSizer = wx.BoxSizer()
        optionBoxSizer.Add(self.showPackage, proportion=0, flag=wx.ALL, border=0)
        optionBoxSizer.Add(self.showFile, proportion=0, flag=wx.ALL, border=0)
        optionBoxSizer.Add(self.create, proportion=0, flag=wx.LEFT, border=5)

        versionCtrlBoxSizer = wx.BoxSizer()
        versionCtrlBoxSizer.Add(self.prevVersion, proportion=0, flag=wx.ALL, border=0)
        versionCtrlBoxSizer.Add(self.versionSlider, proportion=1, flag=wx.ALL, border=0)
        versionCtrlBoxSizer.Add(self.version, proportion=0, flag=wx.ALL, border=0)
        versionCtrlBoxSizer.Add(self.nextVersion, proportion=0, flag=wx.ALL, border=0)

        topSizer = wx.GridSizer()
        topSizer.Add(optionBoxSizer, proportion=0, flag=wx.LEFT | wx.RIGHT, border=5)
        topSizer.Add(versionCtrlBoxSizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.ALIGN_RIGHT, border=5)

        mainBoxSizer = wx.BoxSizer(wx.VERTICAL)
        mainBoxSizer.Add(topSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
        mainBoxSizer.Add(bodyBoxSizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        pn.SetSizer(mainBoxSizer)
        self.SetTitle('Analysis Demo')
        self.SetSize((1280,700))
        self.Centre()
        self.Show(True)

    def organizeInPackage(self, event):
        self.showPackage.SetValue(True)
        self.onRadioButton(event)

    def organizeInClass(self, event):
        self.showFile.SetValue(True)
        self.onRadioButton(event)

    def onRadioButton(self, event):
        if self.showPackage.GetValue() == True:
            self.nameList.Clear()
            self.nameList.InsertItems(pos=0, items=['All files...', 'All packages...'] + self.dataManage.getPackages())
            if len(self.dataManage.listPackageAttr()) == self.attrField.GetNumberCols():
                return
            elif len(self.dataManage.listPackageAttr()) > len(self.dataManage.listFileAttr()):
                self.attrField.AppendCols(len(self.dataManage.listPackageAttr()) - len(self.dataManage.listFileAttr()))
            elif len(self.dataManage.listPackageAttr()) < len(self.dataManage.listFileAttr()):
                self.attrField.DeleteCols(len(self.dataManage.listFileAttr())-1, len(self.dataManage.listFileAttr()) - len(self.dataManage.listPackageAttr()))
            self.attrField.SetRowLabelValue(0, 'Package name')
            for i in xrange(len(self.dataManage.listPackageAttr())):
                self.attrField.SetColSize(i, 100)
                self.attrField.SetColLabelValue(i, self.dataManage.listPackageAttr()[i])
                self.attrField.SetCellValue(0, i, '')
        else:
            self.curPackage = ''
            self.nameList.Clear()
            self.nameList.InsertItems(pos=0, items=['Packages...', 'Files...'] + self.dataManage.getFilenames())
            if len(self.dataManage.listFileAttr()) == self.attrField.GetNumberCols():
                return
            elif len(self.dataManage.listFileAttr()) > len(self.dataManage.listPackageAttr()):
                self.attrField.AppendCols(len(self.dataManage.listFileAttr()) - len(self.dataManage.listPackageAttr()))
            elif len(self.dataManage.listFileAttr()) < len(self.dataManage.listPackageAttr()):
                self.attrField.DeleteCols(len(self.dataManage.listPackageAttr())-1, len(self.dataManage.listPackageAttr()) - len(self.dataManage.listFileAttr()))
            self.attrField.SetRowLabelValue(0, 'File name')
            for i in xrange(len(self.dataManage.listFileAttr())):
                self.attrField.SetColSize(i, 100)
                self.attrField.SetColLabelValue(i, self.dataManage.listFileAttr()[i])
                self.attrField.SetCellValue(0, i, '')

    def onNameList(self, event):
        # TODO Center the current selection
        curChoice = self.nameList.GetString(self.nameList.GetSelection()).encode('ascii', 'ignore')
        if self.showPackage.GetValue() == True:
            if curChoice == 'All files...' or curChoice == 'All packages...':
                self.attrField.SetRowLabelValue(0, 'Package Name')
                for i in xrange(len(self.dataManage.listPackageAttr())):
                    self.attrField.SetCellValue(0, i, '')
            else:
                self.attrField.SetRowLabelValue(0, curChoice)
                for i in xrange(len(self.dataManage.listPackageAttr())):
                    self.attrField.SetCellValue(0, i, self.dataManage.getPackageAttr(curChoice)[self.attrField.GetColLabelValue(i)])
        else:
            if curChoice == 'Files...' or curChoice == 'Packages...':
                self.attrField.SetRowLabelValue(0, 'File Name')
                for i in xrange(len(self.dataManage.listFileAttr())):
                    self.attrField.SetCellValue(0, i, '')
            else:
                self.attrField.SetRowLabelValue(0, curChoice)
                for i in xrange(len(self.dataManage.listFileAttr())):
                    self.attrField.SetCellValue(0, i, self.dataManage.getFileAttr(curChoice)[self.attrField.GetColLabelValue(i)])

    def onDNameList(self, event):
        namestr = self.nameList.GetString(self.nameList.GetSelection()).encode('ascii', 'ignore')
        if self.showPackage.GetValue() == True:
            # TODO Select package here, update figure
            if namestr == 'All files...':
                # TODO Back to all file figure
                self.showFile.SetValue(True)
                self.nameList.Clear()
                self.nameList.InsertItems(pos=0, items=['Packages...', 'Files...'] + self.dataManage.getFilenames())
                if len(self.dataManage.listFileAttr()) > len(self.dataManage.listPackageAttr()):
                    self.attrField.AppendCols(len(self.dataManage.listFileAttr()) - len(self.dataManage.listPackageAttr()))
                elif len(self.dataManage.listFileAttr()) < len(self.dataManage.listPackageAttr()):
                    self.attrField.DeleteCols(len(self.dataManage.listPackageAttr())-1, len(self.dataManage.listPackageAttr()) - len(self.dataManage.listFileAttr()))
                self.attrField.SetRowLabelValue(0, 'File name')
                for i in xrange(len(self.dataManage.listFileAttr())):
                    self.attrField.SetColSize(i, 100)
                    self.attrField.SetColLabelValue(i, self.dataManage.listFileAttr()[i])
                    self.attrField.SetCellValue(0, i, '')
            elif namestr == 'All packages...':
                # TODO Back to all package figure
                pass
            else:
                # TODO Update figure here
                self.curPackage = namestr
                self.showFile.SetValue(True)
                self.nameList.Clear()
                self.nameList.InsertItems(pos=0, items=['Packages...', 'Files...'] + self.dataManage.getFilesOfPackage(namestr))
                if len(self.dataManage.listFileAttr()) > len(self.dataManage.listPackageAttr()):
                    self.attrField.AppendCols(len(self.dataManage.listFileAttr()) - len(self.dataManage.listPackageAttr()))<commit_msg>Fix an unexpected exception in GUI<commit_after>import wx
import wx.grid
from matplotlib.figure import Figure
import matplotlib.animation as animation
import networkx as nx
import numpy as np
import math
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
import creategraph
from projectdata import DataManager

class AnalysisDemo(wx.Frame):
    APP_EXIT = 0
    APP_PREVVERSION = 1
    APP_NEXTVERSION = 2
    APP_PACKAGE = 3
    APP_CLASS = 4
    def __init__(self, *args, **kw):
        super(AnalysisDemo, self).__init__(*args, **kw)
        self.dataManage = DataManager()
        self.versionArray = ["6.0.0", "6.0.43", "7.0.0", "7.0.61", "8.0.0", "8.0.21"]
        self.curPackage = ''
        self.initMain()

    def initMenuBar(self):
        menubar = wx.MenuBar()
        fileMenu = wx.Menu()
        quitProg = wx.MenuItem(fileMenu, self.APP_EXIT, '&Quit\tCtrl+Q')
        fileMenu.AppendItem(quitProg)

        ctrlMenu = wx.Menu()
        prevVer = wx.MenuItem(ctrlMenu, self.APP_PREVVERSION, '&Prev Version\tCtrl+P')
        nextVer = wx.MenuItem(ctrlMenu, self.APP_NEXTVERSION, '&Next Version\tCtrl+N')
        orgInPackage = wx.MenuItem(ctrlMenu, self.APP_PACKAGE, 'Organize in &Package\tF5')
        orgInClass = wx.MenuItem(ctrlMenu, self.APP_CLASS, 'Organize in &File\tF6')
        ctrlMenu.AppendItem(prevVer)
        ctrlMenu.AppendItem(nextVer)
        ctrlMenu.AppendSeparator()
        ctrlMenu.AppendItem(orgInPackage)
        ctrlMenu.AppendItem(orgInClass)

        self.Bind(wx.EVT_MENU, self.movePrevVersion, id=self.APP_PREVVERSION)
        self.Bind(wx.EVT_MENU, self.moveNextVersion, id=self.APP_NEXTVERSION)
        self.Bind(wx.EVT_MENU, self.onQuit, id=self.APP_EXIT)
        self.Bind(wx.EVT_MENU, self.organizeInPackage, id=self.APP_PACKAGE)
        self.Bind(wx.EVT_MENU, self.organizeInClass, id=self.APP_CLASS)

        menubar.Append(fileMenu, '&File')
        menubar.Append(ctrlMenu, '&Ctrl')
        self.SetMenuBar(menubar)

    def initMain(self):
        pn = wx.Panel(self)

        self.initMenuBar()

        self.showPackage = wx.RadioButton(pn, label='Organize in package')
        self.showFile = wx.RadioButton(pn, label='Organize in file')
        self.create = wx.Button(pn, label='Create Figure')

        self.prevVersion = wx.Button(pn, label='Previous Version')
        self.nextVersion = wx.Button(pn, label='Next Version')
        self.versionSlider = wx.Slider(pn, minValue=0, maxValue=5, size=(150,-1), style=wx.SL_AUTOTICKS)
        self.version = wx.TextCtrl(pn, value=self.versionArray[0], size=(50,-1))
        self.version.SetEditable(False)

        self.figure = Figure(facecolor='#f3f3f3')
        self.canvas = FigureCanvas(pn, -1, self.figure)
        self.nameList = wx.ListBox(pn, choices=['All packages...', 'All files...'] + self.dataManage.getPackages())
        self.codeField = wx.TextCtrl(pn, style=wx.TE_MULTILINE | wx.HSCROLL)
        self.attrField = wx.grid.Grid(pn)
        self.attrField.CreateGrid(1, len(self.dataManage.listPackageAttr()))
        self.attrField.SetRowLabelValue(0, 'Package name')
        self.attrField.SetRowLabelSize(200)
        readonlyAttr = wx.grid.GridCellAttr()
        readonlyAttr.SetReadOnly(True)
        self.attrField.SetRowAttr(0, readonlyAttr)
        for i in xrange(len(self.dataManage.listPackageAttr())):
            self.attrField.SetColSize(i, 100)
            self.attrField.SetColLabelValue(i, self.dataManage.listPackageAttr()[i])

        self.showPackage.Bind(wx.EVT_RADIOBUTTON, self.onRadioButton)
        self.showFile.Bind(wx.EVT_RADIOBUTTON, self.onRadioButton)
        self.prevVersion.Bind(wx.EVT_BUTTON, self.movePrevVersion)
        self.nextVersion.Bind(wx.EVT_BUTTON, self.moveNextVersion)
        self.nameList.Bind(wx.EVT_LISTBOX, self.onNameList)
        self.nameList.Bind(wx.EVT_LISTBOX_DCLICK, self.onDNameList)
        self.versionSlider.Bind(wx.EVT_SCROLL_CHANGED, self.onVersionScroll)

        contextBoxSizer = wx.BoxSizer(wx.VERTICAL)
        contextBoxSizer.Add(self.canvas, proportion=1, flag=wx.EXPAND | wx.ALL, border=0)
        contextBoxSizer.Add(self.attrField, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER, border=0)

        bodyBoxSizer = wx.BoxSizer()
        bodyBoxSizer.Add(self.nameList, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
        bodyBoxSizer.Add(contextBoxSizer, proportion=3, flag=wx.EXPAND | wx.ALL, border=5)
        bodyBoxSizer.Add(self.codeField, proportion=2, flag=wx.EXPAND | wx.ALL, border=5)

        optionBoxSizer = wx.BoxSizer()
        optionBoxSizer.Add(self.showPackage, proportion=0, flag=wx.ALL, border=0)
        optionBoxSizer.Add(self.showFile, proportion=0, flag=wx.ALL, border=0)
        optionBoxSizer.Add(self.create, proportion=0, flag=wx.LEFT, border=5)

        versionCtrlBoxSizer = wx.BoxSizer()
        versionCtrlBoxSizer.Add(self.prevVersion, proportion=0, flag=wx.ALL, border=0)
        versionCtrlBoxSizer.Add(self.versionSlider, proportion=1, flag=wx.ALL, border=0)
        versionCtrlBoxSizer.Add(self.version, proportion=0, flag=wx.ALL, border=0)
        versionCtrlBoxSizer.Add(self.nextVersion, proportion=0, flag=wx.ALL, border=0)

        topSizer = wx.GridSizer()
        topSizer.Add(optionBoxSizer, proportion=0, flag=wx.LEFT | wx.RIGHT, border=5)
        topSizer.Add(versionCtrlBoxSizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.ALIGN_RIGHT, border=5)

        mainBoxSizer = wx.BoxSizer(wx.VERTICAL)
        mainBoxSizer.Add(topSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
        mainBoxSizer.Add(bodyBoxSizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)

        pn.SetSizer(mainBoxSizer)
        self.SetTitle('Analysis Demo')
        self.SetSize((1280,700))
        self.Centre()
        self.Show(True)

    def organizeInPackage(self, event):
        self.showPackage.SetValue(True)
        self.onRadioButton(event)

    def organizeInClass(self, event):
        self.showFile.SetValue(True)
        self.onRadioButton(event)

    def onRadioButton(self, event):
        if self.showPackage.GetValue() == True:
            self.nameList.Clear()
            self.nameList.InsertItems(pos=0, items=['All files...', 'All packages...'] + self.dataManage.getPackages())
            if len(self.dataManage.listPackageAttr()) == self.attrField.GetNumberCols():
                return
            elif len(self.dataManage.listPackageAttr()) > len(self.dataManage.listFileAttr()):
                self.attrField.AppendCols(len(self.dataManage.listPackageAttr()) - len(self.dataManage.listFileAttr()))
            elif len(self.dataManage.listPackageAttr()) < len(self.dataManage.listFileAttr()):
                self.attrField.DeleteCols(len(self.dataManage.listFileAttr())-1, len(self.dataManage.listFileAttr()) - len(self.dataManage.listPackageAttr()))
            self.attrField.SetRowLabelValue(0, 'Package name')
            for i in xrange(len(self.dataManage.listPackageAttr())):
                self.attrField.SetColSize(i, 100)
                self.attrField.SetColLabelValue(i, self.dataManage.listPackageAttr()[i])
                self.attrField.SetCellValue(0, i, '')
        else:
            self.curPackage = ''
            self.nameList.Clear()
            self.nameList.InsertItems(pos=0, items=['Packages...', 'Files...'] + self.dataManage.getFilenames())
            if len(self.dataManage.listFileAttr()) == self.attrField.GetNumberCols():
                return
            elif len(self.dataManage.listFileAttr()) > len(self.dataManage.listPackageAttr()):
                self.attrField.AppendCols(len(self.dataManage.listFileAttr()) - len(self.dataManage.listPackageAttr()))
            elif len(self.dataManage.listFileAttr()) < len(self.dataManage.listPackageAttr()):
                self.attrField.DeleteCols(len(self.dataManage.listPackageAttr())-1, len(self.dataManage.listPackageAttr()) - len(self.dataManage.listFileAttr()))
            self.attrField.SetRowLabelValue(0, 'File name')
            for i in xrange(len(self.dataManage.listFileAttr())):
                self.attrField.SetColSize(i, 100)
                self.attrField.SetColLabelValue(i, self.dataManage.listFileAttr()[i])
                self.attrField.SetCellValue(0, i, '')

    def onNameList(self, event):
        # TODO Center the current selection
        curChoice = self.nameList.GetString(self.nameList.GetSelection()).encode('ascii', 'ignore')
        if curChoice == '':
            return
        if self.showPackage.GetValue() == True:
            if curChoice == 'All files...' or curChoice == 'All packages...':
                self.attrField.SetRowLabelValue(0, 'Package Name')
                for i in xrange(len(self.dataManage.listPackageAttr())):
                    self.attrField.SetCellValue(0, i, '')
            else:
                self.attrField.SetRowLabelValue(0, curChoice)
                for i in xrange(len(self.dataManage.listPackageAttr())):
                    self.attrField.SetCellValue(0, i, self.dataManage.getPackageAttr(curChoice)[self.attrField.GetColLabelValue(i)])
        else:
            if curChoice == 'Files...' or curChoice == 'Packages...':
                self.attrField.SetRowLabelValue(0, 'File Name')
                for i in xrange(len(self.dataManage.listFileAttr())):
                    self.attrField.SetCellValue(0, i, '')
            else:
                self.attrField.SetRowLabelValue(0, curChoice)
                for i in xrange(len(self.dataManage.listFileAttr())):
                    self.attrField.SetCellValue(0, i, self.dataManage.getFileAttr(curChoice)[self.attrField.GetColLabelValue(i)])

    def onDNameList(self, event):
        namestr = self.nameList.GetString(self.nameList.GetSelection()).encode('ascii', 'ignore')
        if namestr == '':
            return
        if self.showPackage.GetValue() == True:
            # TODO Select package here, update figure
            if namestr == 'All files...':
                # TODO Back to all file figure
                self.showFile.SetValue(True)
                self.nameList.Clear()
                self.nameList.InsertItems(pos=0, items=['Packages...', 'Files...'] + self.dataManage.getFilenames())
                if len(self.dataManage.listFileAttr()) > len(self.dataManage.listPackageAttr()):
                    self.attrField.AppendCols(len(self.dataManage.listFileAttr()) - len(self.dataManage.listPackageAttr()))
                elif len(self.dataManage.listFileAttr()) < len(self.dataManage.listPackageAttr()):
                    self.attrField.DeleteCols(len(self.dataManage.listPackageAttr())-1, len(self.dataManage.listPackageAttr()) - len(self.dataManage.listFileAttr()))
                self.attrField.SetRowLabelValue(0, 'File name')
                for i in xrange(len(self.dataManage.listFileAttr())):
                    self.attrField.SetColSize(i, 100)
                    self.attrField.SetColLabelValue(i, self.dataManage.listFileAttr()[i])
                    self.attrField.SetCellValue(0, i, '')
            elif namestr == 'All packages...':
                # TODO Back to all package figure
                pass
            else:
                # TODO Update figure here
                self.curPackage = namestr
                self.showFile.SetValue(True)
                self.nameList.Clear()
                self.nameList.InsertItems(pos=0, items=['Packages...', 'Files...'] + self.dataManage.getFilesOfPackage(namestr))
                if len(self.dataManage.listFileAttr()) > len(self.dataManage.listPackageAttr()):
                    self.attrField.AppendCols(len(self.dataManage.listFileAttr()) - len(self.dataManage.listPackageAttr()))
{'fraction_non_alphanumeric': 0.12936987946639214, 'fraction_numerical': 0.010294685368678419, 'mean_word_length': 2.8045039164490864, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '754699', 'n_tokens_mistral': 7535, 'n_tokens_neox': 7344, 'n_words': 1100}