コード例 #1
0
class PanelMeasure(wx.Panel):

    def __init__(self, graph, settings):
        wx.Panel.__init__(self, graph)

        self.spectrum = None
        self.graph = graph
        self.settings = settings

        self.measure = None

        self.checked = {Measure.MIN: "",
                        Measure.MAX: "",
                        Measure.AVG: "",
                        Measure.GMEAN: "",
                        Measure.HBW: "",
                        Measure.OBW: ""}

        self.selected = None

        self.SetBackgroundColour('white')

        self.grid = Grid(self)
        self.grid.CreateGrid(3, 19)
        self.grid.EnableEditing(True)
        self.grid.EnableDragGridSize(False)
        self.grid.SetColLabelSize(1)
        self.grid.SetRowLabelSize(1)
        self.grid.SetColMinimalAcceptableWidth(1)
        self.grid.SetColSize(2, 1)
        self.grid.SetColSize(7, 1)
        self.grid.SetColSize(11, 1)
        self.grid.SetColSize(15, 1)
        self.grid.SetMargins(0, wx.SystemSettings.GetMetric(wx.SYS_HSCROLL_Y))

        for x in range(self.grid.GetNumberRows()):
            self.grid.SetRowLabelValue(x, '')
        for y in range(self.grid.GetNumberCols()):
            self.grid.SetColLabelValue(y, '')

        for row in range(self.grid.GetNumberRows()):
            for col in range(self.grid.GetNumberCols()):
                self.grid.SetReadOnly(row, col, True)

        self.locsDesc = {'F Start': (0, 0),
                         'F End': (1, 0),
                         'F Delta': (2, 0),
                         'P Min': (0, 4),
                         'P Max': (1, 4),
                         'P Delta': (2, 4),
                         'Mean': (0, 9),
                         'GMean': (1, 9),
                         'Flatness': (2, 9),
                         '-3dB Start': (0, 13),
                         '-3dB End': (1, 13),
                         '-3dB Delta': (2, 13),
                         'OBW Start': (0, 17),
                         'OBW End': (1, 17),
                         'OBW Delta': (2, 17)}
        self.__set_descs()

        self.locsCheck = {Measure.MIN: (0, 3), Measure.MAX: (1, 3),
                          Measure.AVG: (0, 8), Measure.GMEAN: (1, 8),
                          Measure.HBW: (0, 12),
                          Measure.OBW: (0, 16)}
        self.__set_check_editor()

        self.locsFreq = [(0, 1), (1, 1)]
        self.__set_freq_editor()

        colour = self.grid.GetBackgroundColour()
        self.grid.SetCellTextColour(2, 3, colour)
        self.grid.SetCellTextColour(2, 8, colour)
        self.grid.SetCellTextColour(1, 12, colour)
        self.grid.SetCellTextColour(2, 12, colour)
        self.grid.SetCellTextColour(1, 16, colour)
        self.grid.SetCellTextColour(2, 16, colour)

        self.__clear_checks()

        self.locsMeasure = {'start': (0, 1), 'end': (1, 1), 'deltaF': (2, 1),
                            'minFP': (0, 5), 'maxFP': (1, 5), 'deltaFP': (2, 5),
                            'minP': (0, 6), 'maxP': (1, 6), 'deltaP': (2, 6),
                            'avg': (0, 10), 'gmean': (1, 10), 'flat': (2, 10),
                            'hbwstart': (0, 14), 'hbwend': (1, 14), 'hbwdelta': (2, 14),
                            'obwstart': (0, 18), 'obwend': (1, 18), 'obwdelta': (2, 18)}

        fontCell = self.grid.GetDefaultCellFont()
        fontSize = fontCell.GetPointSize()
        fontStyle = fontCell.GetStyle()
        fontWeight = fontCell.GetWeight()
        font = wx.Font(fontSize, wx.FONTFAMILY_MODERN, fontStyle,
                       fontWeight)
        dc = wx.WindowDC(self.grid)
        dc.SetFont(font)
        widthMHz = dc.GetTextExtent('###.######')[0] * 1.2
        widthdB = dc.GetTextExtent('-##.##')[0] * 1.2
        for _desc, (_row, col) in self.locsDesc.items():
            self.grid.AutoSizeColumn(col)
        for col in [1, 5, 14, 18]:
            self.grid.SetColSize(col, widthMHz)
            for row in range(self.grid.GetNumberRows()):
                self.grid.SetCellFont(row, col, font)
        for col in [6, 10]:
            self.grid.SetColSize(col, widthdB)
            for row in range(self.grid.GetNumberRows()):
                self.grid.SetCellFont(row, col, font)
        for _desc, (_row, col) in self.locsCheck.items():
            self.grid.AutoSizeColumn(col)

        toolTips = {self.locsMeasure['start']: 'Selection start (MHz)', self.locsMeasure['end']: 'Selection end (MHz)',
                    self.locsMeasure['deltaF']: 'Selection bandwidth (MHz)',
                    self.locsMeasure['minFP']: 'Minimum power location (MHz)',
                    self.locsMeasure['maxFP']: 'Maximum power location (MHz)',
                    self.locsMeasure['deltaFP']: 'Power location difference (MHz)',
                    self.locsMeasure['minP']: 'Minimum power (dB)', self.locsMeasure['maxP']: 'Maximum power (dB)',
                    self.locsMeasure['deltaP']: 'Power difference (dB)', self.locsMeasure['avg']: 'Mean power (dB)',
                    self.locsMeasure['gmean']: 'Geometric mean power (dB)',
                    self.locsMeasure['flat']: 'Spectral flatness',
                    self.locsMeasure['hbwstart']: '-3db start location (MHz)',
                    self.locsMeasure['hbwend']: '-3db end location (MHz)',
                    self.locsMeasure['hbwdelta']: '-3db bandwidth (MHz)',
                    self.locsMeasure['obwstart']: '99% start location (MHz)',
                    self.locsMeasure['obwend']: '99% end location (MHz)',
                    self.locsMeasure['obwdelta']: '99% bandwidth (MHz)'}

        self.toolTips = GridToolTips(self.grid, toolTips)

        self.popupMenu = wx.Menu()
        self.popupMenuCopy = self.popupMenu.Append(wx.ID_ANY, "&Copy",
                                                   "Copy entry")
        self.Bind(wx.EVT_MENU, self.__on_copy, self.popupMenuCopy)

        self.Bind(EVT_GRID_CELL_RIGHT_CLICK, self.__on_popup_menu)
        self.Bind(EVT_GRID_CELL_LEFT_CLICK, self.__on_cell_click)
        if wx.VERSION >= (3, 0, 0, 0):
            self.Bind(EVT_GRID_CELL_CHANGED, self.__on_cell_change)

        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.grid, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT,
                border=10)
        self.SetSizer(box)

    def __set_descs(self):
        font = self.grid.GetCellFont(0, 0)
        font.SetWeight(wx.FONTWEIGHT_BOLD)

        for desc, (row, col) in self.locsDesc.items():
            self.grid.SetCellValue(row, col, desc)
            self.grid.SetCellFont(row, col, font)

    def __set_check_editor(self):
        for _desc, (row, col) in self.locsCheck.items():
            self.grid.SetCellEditor(row, col, GridCellBoolEditor())
            self.grid.SetCellAlignment(row, col, wx.ALIGN_RIGHT, wx.ALIGN_CENTRE)
            self.grid.SetCellRenderer(row, col, CheckBoxCellRenderer(self))

    def __set_freq_editor(self):
        for (row, col) in self.locsFreq:
            self.grid.SetReadOnly(row, col, False)
            self.grid.SetCellAlignment(row, col, wx.ALIGN_RIGHT, wx.ALIGN_CENTRE)
            self.grid.SetCellEditor(row, col, GridCellFloatEditor(precision=4))

    def __set_check_value(self, cell, value):
        (row, col) = self.locsCheck[cell]
        self.grid.SetCellValue(row, col, value)

    def __set_measure_value(self, cell, value):
        (row, col) = self.locsMeasure[cell]
        try:
            self.grid.SetCellValue(row, col, value)
        except TypeError:
            pass

    def __set_check_enable(self, cell, enable):
        (row, col) = self.locsCheck[cell]
        renderer = self.grid.GetCellRenderer(row, col)
        renderer.Enable(not enable)

    def __get_checks(self):
        checks = {}
        for cell in self.checked:
            if self.checked[cell] == '1':
                checks[cell] = True
            else:
                checks[cell] = False

        return checks

    def __update_checks(self):
        for cell in self.checked:
            self.__set_check_value(cell, self.checked[cell])

    def __clear_checks(self):
        for cell in self.checked:
            self.checked[cell] = '0'
        self.__update_checks()

    def __on_cell_click(self, event):
        self.grid.ClearSelection()
        row = event.GetRow()
        col = event.GetCol()

        if (row, col) in self.locsCheck.values():
            if self.grid.GetCellRenderer(row, col).enabled and self.measure is not None:
                check = self.grid.GetCellValue(row, col)
                if check == '1':
                    check = '0'
                else:
                    check = '1'
                self.grid.SetCellValue(row, col, check)

                for control, (r, c) in self.locsCheck.items():
                    if (r, c) == (row, col):
                        self.checked[control] = check

                if self.selected is None:
                    self.selected = self.locsMeasure['start']
                    row = self.selected[0]
                    col = self.selected[1]
                    self.grid.SetGridCursor(row, col)
                self.update_measure()
        elif (row, col) in self.locsMeasure.values():
            self.selected = (row, col)
            self.grid.SetGridCursor(row, col)
        elif self.selected is None:
            self.selected = self.locsMeasure['start']
            row = self.selected[0]
            col = self.selected[1]
            self.grid.SetGridCursor(row, col)

    def __on_cell_change(self, event):
        row = event.GetRow()
        col = event.GetCol()

        if (row, col) in self.locsFreq:
            start = None
            end = None

            try:
                start = float(self.grid.GetCellValue(self.locsFreq[0][0], self.locsFreq[0][1]))
            except ValueError:
                pass
            try:
                end = float(self.grid.GetCellValue(self.locsFreq[1][0], self.locsFreq[1][1]))
            except ValueError:
                pass

            if start is None and end is None:
                return
            elif start is None and end is not None:
                start = end - 1
            elif start is not None and end is None:
                end = start + 1
            if start > end:
                swap = start
                start = end
                end = swap

            self.graph.set_selected(start, end)
            self.set_selected(self.spectrum, start, end)

    def __on_popup_menu(self, _event):
        if self.selected:
            self.popupMenuCopy.Enable(True)
        else:
            self.popupMenuCopy.Enable(False)
        self.PopupMenu(self.popupMenu)

    def __on_copy(self, _event):
        value = self.grid.GetCellValue(self.selected[0], self.selected[1])
        clip = wx.TextDataObject(value)
        wx.TheClipboard.Open()
        wx.TheClipboard.SetData(clip)
        wx.TheClipboard.Close()

    def update_measure(self):
        show = self.__get_checks()
        self.graph.update_measure(self.measure, show)

    def clear_measurement(self):
        for control in self.locsMeasure:
            self.__set_measure_value(control, "")
        self.__clear_checks()
        self.update_measure()
        self.measure = None

    def set_selected(self, spectrum, start, end):
        self.spectrum = spectrum
        if start is None:
            return

        self.measure = Measure(spectrum, start, end)
        if not self.measure.is_valid():
            self.clear_measurement()
            return

        minF, maxF = self.measure.get_f()
        minP = self.measure.get_min_p()
        maxP = self.measure.get_max_p()
        avgP = self.measure.get_avg_p()
        gMeanP = self.measure.get_gmean_p()
        flatness = self.measure.get_flatness()
        hbw = self.measure.get_hpw()
        obw = self.measure.get_obw()

        self.__set_measure_value('start',
                                 format_precision(self.settings,
                                                  minF,
                                                  units=False))
        self.__set_measure_value('end',
                                 format_precision(self.settings,
                                                  maxF,
                                                  units=False))
        self.__set_measure_value('deltaF',
                                 format_precision(self.settings,
                                                  maxF - minF,
                                                  units=False))
        self.__set_measure_value('minFP',
                                 format_precision(self.settings,
                                                  minP[0],
                                                  units=False))
        self.__set_measure_value('maxFP',
                                 format_precision(self.settings,
                                                  maxP[0],
                                                  units=False))
        self.__set_measure_value('deltaFP',
                                 format_precision(self.settings,
                                                  maxP[0] - minP[0],
                                                  units=False))
        self.__set_measure_value('minP',
                                 format_precision(self.settings,
                                                  level=minP[1],
                                                  units=False))
        self.__set_measure_value('maxP',
                                 format_precision(self.settings,
                                                  level=maxP[1],
                                                  units=False))
        self.__set_measure_value('deltaP',
                                 format_precision(self.settings,
                                                  level=maxP[1] - minP[1],
                                                  units=False))
        self.__set_measure_value('avg',
                                 format_precision(self.settings,
                                                  level=avgP,
                                                  units=False))
        self.__set_measure_value('gmean',
                                 format_precision(self.settings,
                                                  level=gMeanP,
                                                  units=False))
        self.__set_measure_value('flat',
                                 "{0:.4f}".format(flatness))
        text = ""
        if hbw[0] is not None:
            text = format_precision(self.settings, hbw[0], units=False)
        else:
            text = ''
        self.__set_measure_value('hbwstart', text)
        if hbw[1] is not None:
            text = format_precision(self.settings, hbw[1], units=False)
        else:
            text = ''
        self.__set_measure_value('hbwend', text)
        if hbw[0] is not None and hbw[1] is not None:
            text = format_precision(self.settings, hbw[1] - hbw[0], units=False)
        else:
            text = ''
        self.__set_measure_value('hbwdelta', text)

        if obw[0] is not None:
            text = format_precision(self.settings, obw[0], units=False)
        else:
            text = ''
        self.__set_measure_value('obwstart', text)
        if obw[1] is not None:
            text = format_precision(self.settings, obw[1], units=False)
        else:
            text = ''
        self.__set_measure_value('obwend', text)
        if obw[0] is not None and obw[1] is not None:
            text = format_precision(self.settings, obw[1] - obw[0],
                                    units=False)
        else:
            text = ''
        self.__set_measure_value('obwdelta', text)

        self.update_measure()

    def show(self, show):
        if show:
            self.Show()
        else:
            self.Hide()
        self.Layout()

    def set_type(self, display):
        for cell in self.locsCheck:
            self.__set_check_enable(cell, True)
        if display == Display.PLOT:
            for cell in self.locsCheck:
                self.__set_check_enable(cell, False)
        elif display == Display.SPECT:
            self.__set_check_enable(Measure.HBW, False)
            self.__set_check_enable(Measure.OBW, False)

        self.grid.Refresh()
コード例 #2
0
class myPanel(wx.Panel):
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id)

        # Top Sizer
        topSizer = wx.BoxSizer(wx.VERTICAL)

        # Input Label
        labelSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.inputLabel = wx.StaticText(self, -1, data.enterPadyamLabel,
                                        wx.Point(40, 20), wx.Size(720, 20))
        self.increaseFontSize(self.inputLabel, 1.5)
        labelSizer.Add(self.inputLabel, 1, wx.EXPAND | wx.ALL, 5)
        topSizer.Add(labelSizer, 0, wx.ALIGN_LEFT)

        # Input Multiline TextCtrl
        self.input = wx.TextCtrl(self, 5, '', wx.Point(40, 50),
                                 wx.Size(720, 140),
                                 wx.TE_MULTILINE | wx.TE_DONTWRAP)
        self.increaseFontSize(self.input, 1.5)
        topSizer.Add(self.input, 1, wx.EXPAND | wx.ALL, 5)

        # Output Label
        labelSizer1 = wx.BoxSizer(wx.HORIZONTAL)
        self.outputLabel = wx.StaticText(self, -1, data.seeResultsHereLabel,
                                         wx.Point(40, 20), wx.Size(720, 20))
        self.increaseFontSize(self.outputLabel, 1.5)
        labelSizer1.Add(self.outputLabel, 1, wx.EXPAND | wx.ALL, 5)
        topSizer.Add(labelSizer1, 0, wx.ALIGN_LEFT)

        # Output Multiline Grid
        self.output = Grid(self, 6, wx.Point(40, 210), wx.Size(790, 140),
                           wx.TE_MULTILINE | wx.TE_READONLY)
        self.output.SetDefaultRowSize(25)
        self.output.SetDefaultColSize(50)
        self.output.SetRowLabelSize(0)
        self.output.SetColLabelSize(0)
        self.output.CreateGrid(10, 30)
        self.output.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.evtOnCellSelected)
        topSizer.Add(self.output, 1, wx.EXPAND | wx.ALL, 5)

        # Control Sizer
        controlSizer = wx.BoxSizer(wx.HORIZONTAL)

        # Radio Box
        self.radioList = [data.findVruthamLabel, data.checkVruthamLabel]
        self.rb = wx.RadioBox(self, 50, data.whatToDoLabel, wx.Point(40, 375),
                              wx.Size(250, 90), self.radioList, 3,
                              wx.RA_SPECIFY_ROWS)
        self.increaseFontSize(self.rb, 1.5)
        controlSizer.Add(self.rb, 0, wx.ALL, 10)
        wx.EVT_RADIOBOX(self, 50, self.evtRadioBox)

        # Combobox
        self.vruthamList = data.vruthamNameList()
        self.vruthamCombo = wx.ComboBox(self, 30, data.selectVruthamLabel,
                                        wx.Point(420, 390), wx.Size(250, -1),
                                        self.vruthamList,
                                        wx.CB_DROPDOWN | wx.CB_READONLY)
        self.increaseFontSize(self.vruthamCombo, 1.5)
        controlSizer.Add(self.vruthamCombo, 0, wx.ALIGN_CENTER)
        wx.EVT_COMBOBOX(self, 30, self.evtComboBox)
        self.vruthamCombo.Enable(0)

        # Status TextCtrl
        self.status = wx.TextCtrl(self, 5, '', wx.DefaultPosition,
                                  wx.Size(250, 80),
                                  wx.TE_MULTILINE | wx.TE_READONLY)
        self.increaseFontSize(self.status, 1.5)
        self.status.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_SCROLLBAR))
        controlSizer.Add(self.status, 0, wx.EXPAND | wx.ALL, 15)

        topSizer.Add(controlSizer, 0, wx.ALIGN_CENTER)

        # Button Sizer
        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)

        # Buttons
        self.goButton = wx.Button(self, 10, data.findLabel, wx.Point(379, 470),
                                  wx.Size(117, 35))
        self.increaseFontSize(self.goButton, 1.5)
        self.increaseFontWeight(self.goButton)
        wx.EVT_BUTTON(self, 10, self.goClick)
        buttonSizer.Add(self.goButton, 0, wx.ALL, 10)

        self.clearButton = wx.Button(self, 11, data.clearLabel,
                                     wx.Point(506, 470), wx.Size(117, 35))
        self.increaseFontSize(self.clearButton, 1.5)
        self.increaseFontWeight(self.clearButton)
        wx.EVT_BUTTON(self, 11, self.clearClick)
        buttonSizer.Add(self.clearButton, 0, wx.ALL, 10)

        self.closeButton = wx.Button(self, 12, data.closeLabel,
                                     wx.Point(633, 470), wx.Size(117, 35))
        self.increaseFontSize(self.closeButton, 1.5)
        self.increaseFontWeight(self.closeButton)
        wx.EVT_BUTTON(self, 12, self.closeClick)
        buttonSizer.Add(self.closeButton, 0, wx.ALL, 10)

        topSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER)
        self.SetSizer(topSizer)
        topSizer.SetSizeHints(self)

        # Initialize Variables
        self.inVruthamName = ''
        self.checkVruthamFlg = 0
        self.checkFlgSet = 0
        self.dictErrors = {}

    def displayStatus(self, row, col):
        self.status.Clear()
        if self.output.GetNumberRows() <= 0:
            return
        if self.output.GetNumberCols() <= 0:
            return
        if self.output.GetCellValue(row, col) == '':
            return
        if self.checkFlgSet == 1:
            if self.dictErrors.has_key((row, col)):
                self.status.AppendText(self.dictErrors[(row, col)])
            elif self.output.GetCellValue(row, col) == data.rightLabel:
                self.status.AppendText(data.thisLineIsCorrectLabel)
            elif self.output.GetCellValue(row, col) == data.wrongLabel:
                self.status.AppendText(data.thisLineIsWrongLabel)
            else:
                if row == 0:
                    self.status.AppendText(data.syllableCountLabel + ' ' +
                                           self.output.GetCellValue(row, col))
                else:
                    self.status.AppendText(data.thisIsCorrectLabel)
        else:
            if row == 0:
                self.status.AppendText(self.output.GetCellValue(row, col))
            else:
                if col == 0:
                    self.status.AppendText(data.slokamLabel + ' ' +
                                           self.output.GetCellValue(row, col))
                elif col == 1:
                    self.status.AppendText(data.lineLabel + ' ' +
                                           self.output.GetCellValue(row, col))
                elif col == 2:
                    if self.output.GetCellValue(row,
                                                col) != data.iDontKnowLabel:
                        if self.dictErrors.has_key((row, col)):
                            self.status.AppendText(
                                data.lineVruthamGanangalLabel + ' ' +
                                self.output.GetCellValue(row, col) + ', ' +
                                data.yathiBhangamLabel)
                        else:
                            self.status.AppendText(
                                data.lineVruthamGanangalLabel + ' ' +
                                self.output.GetCellValue(row, col))
                    else:
                        self.status.AppendText(data.dontKnowVruthamLabel)
                else:
                    if self.output.GetCellValue(row,
                                                col) != data.iDontKnowLabel:
                        if self.dictErrors.has_key((row, col)):
                            self.status.AppendText(
                                data.slokamsVruthamLabel + ' ' +
                                self.output.GetCellValue(row, col) + ', ' +
                                data.yathiBhangamLabel)
                        else:
                            self.status.AppendText(
                                data.slokamsVruthamLabel + ' ' +
                                self.output.GetCellValue(row, col))
                    else:
                        self.status.AppendText(data.dontKnowVruthamLabel)

    def evtOnCellSelected(self, event):
        eventObject = event.GetEventObject()
        row = event.GetRow()
        col = event.GetCol()
        self.displayStatus(row, col)
        event.Skip()

    def evtRadioBox(self, event):
        if (event.GetInt() == 1):
            self.vruthamCombo.Enable(1)
            self.goButton.SetLabel(data.checkLabel)
            self.checkVruthamFlg = 1
        else:
            self.vruthamCombo.Enable(0)
            self.goButton.SetLabel(data.findLabel)
            self.checkVruthamFlg = 0

    def giveCell(self, row=0, col=0):
        if self.output.GetNumberCols() < col + 1:
            self.output.AppendCols(col + 1 - self.output.GetNumberCols())
        if self.output.GetNumberRows() < row + 1:
            self.output.AppendRows(row + 1 - self.output.GetNumberRows())

    def increaseFontSize(self, text, size):
        Font = text.GetFont()
        Font.SetPointSize(Font.GetPointSize() * size)
        text.SetFont(Font)

    def increaseFontWeight(self, text):
        Font = text.GetFont()
        Font.SetWeight(wx.FONTWEIGHT_BOLD)
        text.SetFont(Font)

    def increaseCellFontSize(self, row, col):
        Font = self.output.GetDefaultCellFont()
        Font.SetPointSize(Font.GetPointSize() * 1.5)
        self.output.SetCellFont(row, col, Font)

    def increaseCellFontWeight(self, row, col):
        Font = self.output.GetCellFont(row, col)
        Font.SetWeight(wx.FONTWEIGHT_BOLD)
        self.output.SetCellFont(row, col, Font)

    def evtComboBox(self, event):
        self.inVruthamName = event.GetString()

    def splitIntoLines(self, errLocs):
        errLocLines = []
        lineList = []
        for i in errLocs:
            if i[0] == (-1, -1):
                lineList.append(i)
                errLocLines.append(lineList)
                lineList = []
            else:
                lineList.append(i)
        errLocLines.append([((-1, -1), 'y')])
        return errLocLines

    def highLightErrors(self):
        # Print Syllable numbers and Lakshanam
        lakshanamStr = data.getVruthamLakshanam(self.inVruthamName)
        incrRow = 0
        incrCol = 1
        self.ardhaVishamaVrutham = 'n'
        lakshanamLines = lakshanamStr.split('|')
        if lakshanamLines[0] == 'ANUSHTUP':
            lakshanamLines = '        '
            anushtupVrutham = 'y'
            for i in lakshanamLines:
                self.giveCell(incrRow, incrCol)
                self.output.SetCellValue(0, incrCol, str(incrCol))
                self.increaseCellFontWeight(0, incrCol)
                self.output.SetCellAlignment(0, incrCol, wx.ALIGN_CENTRE,
                                             wx.ALIGN_CENTRE)
                self.output.SetCellBackgroundColour(
                    0, incrCol, wx.TheColourDatabase.Find('LIGHT BLUE'))
                incrCol = incrCol + 1
            # Display Ganam Grouping
            incrRow += 1
            incrCol = 1
            self.giveCell(incrRow, incrCol)
            ganamColour1 = wx.Colour(166, 166, 166)
            ganamColour2 = wx.Colour(200, 200, 200)
            self.output.SetCellBackgroundColour(incrRow, incrCol, ganamColour1)
            self.output.SetCellBackgroundColour(incrRow, incrCol + 1,
                                                ganamColour2)
            self.output.SetCellBackgroundColour(incrRow, incrCol + 2,
                                                ganamColour2)
            self.output.SetCellBackgroundColour(incrRow, incrCol + 3,
                                                ganamColour2)
            self.output.SetCellBackgroundColour(incrRow, incrCol + 4,
                                                ganamColour1)
            self.output.SetCellBackgroundColour(incrRow, incrCol + 5,
                                                ganamColour1)
            self.output.SetCellBackgroundColour(incrRow, incrCol + 6,
                                                ganamColour1)
            self.output.SetCellBackgroundColour(incrRow, incrCol + 7,
                                                ganamColour2)
        else:
            if lakshanamLines[0] == 'AV':
                self.ardhaVishamaVrutham = 'y'
                lakshanamLines = lakshanamLines[1:len(lakshanamLines)]
            for lakshanam in lakshanamLines:
                incrRow = incrRow + 1
                ganamCount = 1
                ganamStr = ''
                ganam = ''
                ganamColour1 = wx.Colour(166, 166, 166)
                ganamColour2 = wx.Colour(200, 200, 200)
                curGanamColour = ganamColour1
                for i in lakshanam:
                    self.giveCell(incrRow, incrCol)
                    self.output.SetCellValue(0, incrCol, str(incrCol))
                    self.increaseCellFontWeight(0, incrCol)
                    self.output.SetCellAlignment(0, incrCol, wx.ALIGN_CENTRE,
                                                 wx.ALIGN_CENTRE)
                    self.output.SetCellBackgroundColour(
                        0, incrCol, wx.TheColourDatabase.Find('LIGHT BLUE'))
                    self.output.SetCellValue(incrRow, incrCol, i)
                    self.increaseCellFontWeight(incrRow, incrCol)
                    self.output.SetCellAlignment(incrRow, incrCol,
                                                 wx.ALIGN_CENTRE,
                                                 wx.ALIGN_CENTRE)
                    self.output.SetCellBackgroundColour(
                        incrRow, incrCol,
                        wx.TheColourDatabase.Find('LIGHT BLUE'))
                    # Display Ganam Grouping
                    ganamStr += i
                    if incrCol % 3 == 0:
                        if data.ganamDict.has_key(ganamStr):
                            ganam = data.ganamDict[ganamStr]
                            self.dictErrors[(
                                incrRow,
                                incrCol - 2)] = ganam + ' ' + data.ganamLabel
                            self.dictErrors[(
                                incrRow,
                                incrCol - 1)] = ganam + ' ' + data.ganamLabel
                            self.dictErrors[(
                                incrRow,
                                incrCol)] = ganam + ' ' + data.ganamLabel
                            ganamStr = ''
                            self.output.SetCellBackgroundColour(
                                incrRow, incrCol - 2, curGanamColour)
                            self.output.SetCellBackgroundColour(
                                incrRow, incrCol - 1, curGanamColour)
                            self.output.SetCellBackgroundColour(
                                incrRow, incrCol, curGanamColour)
                            if curGanamColour == ganamColour1:
                                curGanamColour = ganamColour2
                            else:
                                curGanamColour = ganamColour1
                        ganamCount += 1
                    elif ganamCount > len(lakshanam) / 3:
                        if ganamStr == '-':
                            self.dictErrors[(incrRow,
                                             incrCol)] = data.guruLabel
                        else:
                            self.dictErrors[(incrRow,
                                             incrCol)] = data.laghuLabel
                        ganamStr = ''
                        self.output.SetCellBackgroundColour(
                            incrRow, incrCol, curGanamColour)
                        if curGanamColour == ganamColour1:
                            curGanamColour = ganamColour2
                        else:
                            curGanamColour = ganamColour1
                        ganamCount += 1
                    incrCol = incrCol + 1
                incrCol = 1
        gridRow = incrRow + 1
        gridCol = 1

        # Print Padyam
        lineNum = 0
        lakshanam = ''
        bgColour = wx.Colour(255, 212, 160)
        errLocLines = self.splitIntoLines(self.errLocs)
        for oneErrLocLine in errLocLines:
            if oneErrLocLine == [((-1, -1), 'y')]:
                if self.ardhaVishamaVrutham == 'y':
                    if lineNum != 0:
                        for i in range(0, 4 - lineNum):
                            gridCol = 1
                            self.giveCell(gridRow, gridCol)
                            self.output.SetCellValue(gridRow, 0,
                                                     data.wrongLabel)
                            self.increaseCellFontSize(gridRow, 0)
                            self.increaseCellFontWeight(gridRow, 0)
                            self.output.SetCellBackgroundColour(
                                gridRow, 0, wx.RED)
                            lakshanam = lakshanamLines[lineNum + i]
                            while gridCol <= len(lakshanam):
                                self.output.SetCellBackgroundColour(
                                    gridRow, gridCol, wx.RED)
                                self.dictErrors[(gridRow,
                                                 gridCol)] = data.emptySylLabel
                                gridCol = gridCol + 1
                            gridRow = gridRow + 1
                lineNum = 0
                gridCol = 1
                if self.output.GetCellValue(gridRow - 1, 0) != '':
                    gridRow = gridRow + 1
                    self.giveCell(gridRow, gridCol)
                continue
            if self.ardhaVishamaVrutham == 'y':
                lakshanam = lakshanamLines[lineNum % 4]
            else:
                lakshanam = lakshanamStr
            if lineNum == 4:
                lineNum = 1
                gridRow = gridRow + 1
                self.giveCell(gridRow, gridCol)
            else:
                lineNum = lineNum + 1
            if lineNum == 1:
                if bgColour.Green() == 212:
                    bgColour = wx.Colour(255, 255, 160)
                else:
                    bgColour = wx.Colour(255, 212, 160)
            yathiInPrevChar = 0
            for i in oneErrLocLine:
                if i[0] == (-1, -1):
                    yathiInPrevChar = 0
                    while gridCol > 1 and gridCol <= len(lakshanam):
                        self.output.SetCellValue(gridRow, 0, data.wrongLabel)
                        self.increaseCellFontSize(gridRow, 0)
                        self.increaseCellFontWeight(gridRow, 0)
                        self.output.SetCellBackgroundColour(gridRow, 0, wx.RED)
                        self.output.SetCellBackgroundColour(
                            gridRow, gridCol, wx.RED)
                        self.dictErrors[(gridRow,
                                         gridCol)] = data.emptySylLabel
                        gridCol = gridCol + 1
                    if gridCol == 1:
                        self.giveCell(gridRow, gridCol)
                        self.output.SetCellValue(gridRow, 0, '')
                        self.output.SetCellBackgroundColour(
                            gridRow, 0, wx.WHITE)
                    gridRow = gridRow + 1
                    gridCol = 1
                    continue
                if gridCol == 1:
                    self.giveCell(gridRow, gridCol)
                    self.output.SetCellValue(gridRow, 0, data.rightLabel)
                    self.increaseCellFontSize(gridRow, 0)
                    self.increaseCellFontWeight(gridRow, 0)
                    self.output.SetCellBackgroundColour(gridRow, 0, wx.GREEN)
                self.giveCell(gridRow, gridCol)
                if i[1] == 'n':
                    yathiInPrevChar = 0
                    self.output.SetCellValue(
                        gridRow, gridCol,
                        self.input.GetValue()[i[0][0]:i[0][1] + 1])
                    self.output.SetCellBackgroundColour(
                        gridRow, gridCol, wx.RED)
                    if gridCol - 1 < len(lakshanam):
                        if lakshanam[gridCol - 1] == '-':
                            self.dictErrors[(
                                gridRow,
                                gridCol)] = data.wronglyPlacedLaghuLabel
                        else:
                            self.dictErrors[(
                                gridRow,
                                gridCol)] = data.wronglyPlacedGuruLabel
                    else:
                        self.dictErrors[(gridRow,
                                         gridCol)] = data.extraSylLabel
                    self.output.SetCellValue(gridRow, 0, data.wrongLabel)
                    self.increaseCellFontSize(gridRow, 0)
                    self.increaseCellFontWeight(gridRow, 0)
                    self.output.SetCellBackgroundColour(gridRow, 0, wx.RED)
                elif i[1] == 'g':
                    self.output.SetCellValue(
                        gridRow, gridCol,
                        self.input.GetValue()[i[0][0]:i[0][1] + 1])
                    self.output.SetCellBackgroundColour(
                        gridRow, gridCol, wx.RED)
                    self.dictErrors[(gridRow, gridCol)] = data.wrongGanamLabel
                    self.output.SetCellValue(gridRow, 0, data.wrongLabel)
                    self.increaseCellFontSize(gridRow, 0)
                    self.increaseCellFontWeight(gridRow, 0)
                    self.output.SetCellBackgroundColour(gridRow, 0, wx.RED)
                else:
                    self.output.SetCellValue(
                        gridRow, gridCol,
                        self.input.GetValue()[i[0][0]:i[0][1] + 1])
                    self.output.SetCellBackgroundColour(
                        gridRow, gridCol, bgColour)
                    if yathiInPrevChar == 1:
                        yathiInPrevChar = 0
                        if ' ' not in self.input.GetValue()[yathiStartPos:i[0][0]] and \
                         '/' not in self.input.GetValue()[yathiStartPos:i[0][0]]:
                            self.output.SetCellValue(gridRow, 0,
                                                     data.wrongLabel)
                            self.increaseCellFontSize(gridRow, 0)
                            self.increaseCellFontWeight(gridRow, 0)
                            self.output.SetCellBackgroundColour(
                                gridRow, 0, wx.RED)
                            self.output.SetCellBackgroundColour(
                                gridRow, gridCol, wx.RED)
                            self.dictErrors[(
                                gridRow, gridCol)] = data.yathiRequiredLabel
                    if i[1] == 't':
                        yathiInPrevChar = 1
                        yathiStartPos = i[0][1] + 1
                self.increaseCellFontSize(gridRow, gridCol)
                gridCol = gridCol + 1
        while self.output.GetCellValue(gridRow, 0) == '':
            self.output.DeleteRows(gridRow, 1)
            gridRow -= 1
        self.output.SetGridCursor(0, 0)

    def printVruthamNames(self, vruthamNames):
        gRows, gCols = 0, 0
        # Print Header
        self.giveCell(gRows, 3)
        self.output.SetCellValue(0, 0, data.slokamLabel)
        self.increaseCellFontSize(0, 0)
        self.increaseCellFontWeight(0, 0)
        self.output.SetCellAlignment(0, 0, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        self.output.SetCellBackgroundColour(
            0, 0, wx.TheColourDatabase.Find('LIGHT BLUE'))
        self.output.SetCellValue(0, 1, data.lineLabel)
        self.increaseCellFontSize(0, 1)
        self.increaseCellFontWeight(0, 1)
        self.output.SetCellAlignment(0, 1, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        self.output.SetCellBackgroundColour(
            0, 1, wx.TheColourDatabase.Find('LIGHT BLUE'))
        self.output.SetCellValue(0, 2, data.lineVruthamGanangalLabel)
        self.increaseCellFontSize(0, 2)
        self.increaseCellFontWeight(0, 2)
        self.output.SetCellAlignment(0, 2, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        self.output.SetCellBackgroundColour(
            0, 2, wx.TheColourDatabase.Find('LIGHT BLUE'))
        self.output.SetCellValue(0, 3, data.slokaVruthamLabel)
        self.increaseCellFontSize(0, 3)
        self.increaseCellFontWeight(0, 3)
        self.output.SetCellAlignment(0, 3, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        self.output.SetCellBackgroundColour(
            0, 3, wx.TheColourDatabase.Find('LIGHT BLUE'))
        gRows = gRows + 1
        yathiBhangamSlokam = -1
        for i in vruthamNames:
            yathiBhangam = 'n'
            self.giveCell(gRows, 1)
            self.output.SetDefaultColSize(190, 1)
            self.output.SetCellValue(gRows, 0, i[0])
            self.increaseCellFontWeight(gRows, 0)
            self.output.SetCellAlignment(gRows, 0, wx.ALIGN_CENTRE,
                                         wx.ALIGN_CENTRE)
            self.output.SetCellValue(gRows, 1, i[1])
            self.increaseCellFontWeight(gRows, 1)
            self.output.SetCellAlignment(gRows, 1, wx.ALIGN_CENTRE,
                                         wx.ALIGN_CENTRE)
            if i[2] != -1:
                self.output.SetCellValue(gRows, 2, data.vruthamTable[i[2]][1])
            else:
                self.output.SetCellValue(gRows, 2, data.iDontKnowLabel)
            self.increaseCellFontSize(gRows, 2)
            self.increaseCellFontWeight(gRows, 2)
            self.output.SetCellAlignment(gRows, 2, wx.ALIGN_CENTRE,
                                         wx.ALIGN_CENTRE)
            if i[3] == -1:
                self.output.SetCellValue(gRows, 3, data.iDontKnowLabel)
            elif i[3] == -2:
                self.output.SetCellValue(gRows, 3, '')
            else:
                self.output.SetCellValue(gRows, 3, data.vruthamTable[i[3]][1])
            self.increaseCellFontSize(gRows, 3)
            self.increaseCellFontWeight(gRows, 3)
            self.output.SetCellAlignment(gRows, 3, wx.ALIGN_CENTRE,
                                         wx.ALIGN_CENTRE)
            if int(i[0]) % 2 != 0:
                bgColour = wx.Colour(255, 255, 160)  # HTML value ffffa0
            else:
                bgColour = wx.Colour(255, 212, 160)  # HTML value ffd4a0
            self.output.SetCellBackgroundColour(gRows, 0, bgColour)
            self.output.SetCellBackgroundColour(gRows, 1, bgColour)
            if i[2] != -1:
                self.output.SetCellBackgroundColour(gRows, 2, bgColour)
                if i[4] == 'n':
                    self.output.SetCellBackgroundColour(gRows, 2, wx.RED)
                    self.dictErrors[(gRows, 2)] = data.yathiBhangamLabel
                    yathiBhangamSlokam = i[0]
                if i[0] == yathiBhangamSlokam:
                    yathiBhangam = 'y'
            else:
                self.output.SetCellBackgroundColour(gRows, 2, wx.RED)
            if i[3] != -1:
                self.output.SetCellBackgroundColour(gRows, 3, bgColour)
                if yathiBhangam == 'y':
                    curSlokam = self.output.GetCellValue(gRows, 0)
                    for i in range(0, 4):
                        if self.output.GetCellValue(gRows - i, 0) != curSlokam:
                            break
                        self.output.SetCellBackgroundColour(
                            gRows - i, 3, wx.RED)
                        self.dictErrors[(gRows - i,
                                         3)] = data.yathiBhangamLabel
            else:
                curSlokam = self.output.GetCellValue(gRows, 0)
                for i in range(0, 4):
                    if self.output.GetCellValue(gRows - i, 0) != curSlokam:
                        break
                    self.output.SetCellBackgroundColour(gRows - i, 3, wx.RED)
            gRows = gRows + 1
        self.output.AutoSizeColumns()

    def goClick(self, event):
        self.checkFlgSet = 0
        if self.output.GetNumberRows() != 0:
            self.dictErrors = {}
            self.output.DeleteRows(0, self.output.GetNumberRows())
            self.output.DeleteCols(0, self.output.GetNumberCols())
        self.output.SetDefaultRowSize(25, 1)
        self.output.SetDefaultColSize(50, 1)
        if self.input.GetValue() == '':
            self.output.SetDefaultColSize(790, 1)
            self.giveCell()
            self.output.SetCellValue(0, 0, data.noPadyamGivenLabel)
            self.increaseCellFontSize(0, 0)
            return
        if filter(lambda x: x > u'\u0d00' and x < u'\u0d65',
                  self.input.GetValue()) == '':
            self.output.SetDefaultColSize(790, 1)
            self.giveCell()
            self.output.SetCellValue(0, 0, data.givePadyamInMalLabel)
            self.increaseCellFontSize(0, 0)
            return
        if self.checkVruthamFlg == 1:
            if self.inVruthamName == '':
                self.output.SetDefaultColSize(790, 1)
                self.giveCell()
                self.output.SetCellValue(0, 0, data.noVruthamGivenLabel)
                self.increaseCellFontSize(0, 0)
                return
            self.checkFlgSet = 1
            self.outVruthamName, self.errLocs = getVrutham(
                self.input.GetValue(), self.inVruthamName)
            self.highLightErrors()
        else:
            self.checkFlgSet = 0
            self.outVruthamName, self.errLocs = getVrutham(
                self.input.GetValue(), '')
            self.printVruthamNames(self.outVruthamName)

    def clearClick(self, event):
        self.status.Clear()
        if self.output.GetNumberRows() != 0:
            self.dictErrors = {}
            self.output.DeleteRows(0, self.output.GetNumberRows())
            self.output.DeleteCols(0, self.output.GetNumberCols())
        self.output.SetDefaultRowSize(25, 1)
        self.output.SetDefaultColSize(50, 1)
        if self.input.GetValue() != '':
            diag = wx.MessageDialog(
                self, data.clearAreYouSureLabel, data.pleaseConfirmLabel,
                wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
            if diag.ShowModal() == wx.ID_YES:
                self.input.Clear()

    def closeClick(self, event):
        dlg = wx.MessageDialog(self, data.quitAreYouSureLabel,
                               data.pleaseConfirmLabel,
                               wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
        if dlg.ShowModal() == wx.ID_YES:
            self.GetParent().Close(True)