def setupGrid(self, grid, states, stateTypes):
     nStates = len(states)
     
     grid.SetDefaultColSize(70)
     grid.CreateGrid(nStates, nStates)
     
     for i in range(nStates):
         grid.SetRowLabelValue(i, states[i])
         grid.SetColLabelValue(i, states[i])
         grid.SetReadOnly(i, i)
         grid.SetCellBackgroundColour(i, i, wx.LIGHT_GREY)
         grid.SetCellTextColour(i, i, wx.LIGHT_GREY)
         
         if (stateTypes[i] == fluor.TO_ONLY):
             for j in range(nStates):
                 grid.SetReadOnly(i, j)
                 grid.SetCellBackgroundColour(i, j, wx.LIGHT_GREY)
                 grid.SetCellTextColour(i, j, wx.LIGHT_GREY)
         
         if (stateTypes[i] == fluor.FROM_ONLY):
             for j in range(nStates):
                 grid.SetReadOnly(j, i)
                 grid.SetCellBackgroundColour(j, i, wx.LIGHT_GREY)
                 grid.SetCellTextColour(j, i, wx.LIGHT_GREY)
                 
     grid.SetMinSize(grid.BestSize)
    def __init__(self, window):
        # This is how Python handles classes. __init__ is the special name for
        # the constructor of the class. The first parameter to every object
        # method is the object itself, called "self" by convention. self is
        # like "this" in Java/C++, except you have to explicitly mention it
        # whenever you want to use instance variables or methods.
        grid = wx.grid.Grid(parent=window)
        grid.CreateGrid(sudoku.ROW_SIZE, sudoku.ROW_SIZE)

        # Set row and column sizes, and fix them so the user can't change them
        grid.SetRowLabelSize(0)
        grid.SetColLabelSize(0)
        grid.SetDefaultRowSize(40, True)
        grid.SetDefaultColSize(40, True)
        grid.DisableDragGridSize()

        # Change cell attributes to work well for Sudoku displaying
        font = grid.GetDefaultCellFont()
        font.SetPointSize(20)
        grid.SetDefaultCellFont(font)
        grid.SetDefaultCellAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)

        self.grid = grid
Example #3
0
    def InitUI(self):
        panel = wx.Panel(self)

        font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
        font.SetPointSize(9)

        vbox = wx.BoxSizer(wx.VERTICAL)

        grid = wx.grid.Grid(panel)
        grid.CreateGrid(10, 4)
        grid.SetColLabelValue(0, "IP")
        grid.SetColLabelValue(1, "Port")
        grid.SetColLabelValue(2, "LoginName")
        grid.SetColLabelValue(3, "Password")
        grid.SetDefaultColSize(160, resizeExistingCols=True)
        for row in range(10):
            for col in range(4):
                grid.SetCellValue(row, col, "cell (%d,%d)" % (row, col))
        vbox.Add(grid, proportion=1, flag=wx.ALIGN_CENTER | wx.ALL, border=10)

        btn = wx.Button(panel, label='Detect')
        vbox.Add(btn, proportion=0, flag=wx.ALIGN_CENTER | wx.ALL, border=10)

        panel.SetSizer(vbox)
Example #4
0
    def ResetView(self):
        """
        (Grid) -> Reset the grid view.   Call this to
        update the grid if rows and columns have been added or deleted

        """

        grid = self.grid

        current_rows = self.grid.GetNumberRows()
        current_cols = self.grid.GetNumberCols()

        grid.BeginBatch()

        for current, new, delmsg, addmsg in [
            (current_rows, self.GetNumberRows(),
             wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED,
             wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),
            (current_cols, self.GetNumberCols(),
             wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED,
             wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED)
        ]:

            if new < current:
                msg = wx.grid.GridTableMessage(self, delmsg, new,
                                               current - new)
                grid.ProcessTableMessage(msg)
            elif new > current:
                msg = wx.grid.GridTableMessage(self, addmsg, new - current)
                grid.ProcessTableMessage(msg)
                self.UpdateValues()

        grid.EndBatch()

        # Reset cell sizes to standard cell size

        grid.SetDefaultRowSize(grid.GetDefaultRowSize(),
                               resizeExistingRows=True)
        grid.SetDefaultColSize(grid.GetDefaultColSize(),
                               resizeExistingCols=True)

        # Adjust rows
        row_heights = grid.code_array.row_heights
        for key in row_heights:
            if key[1] == grid.current_table and \
               key[0] < self.code_array.shape[0]:
                row = key[0]
                if row_heights[key] is None:
                    # Default row size
                    grid.SetRowSize(row, grid.GetDefaultRowSize())
                else:
                    grid.SetRowSize(row, row_heights[key])

        # Adjust columns
        col_widths = grid.code_array.col_widths
        for key in col_widths:
            if key[1] == grid.current_table and \
               key[0] < self.code_array.shape[1]:
                col = key[0]
                if col_widths[key] is None:
                    # Default row size
                    grid.SetColSize(col, grid.GetDefaultColSize())
                else:
                    grid.SetColSize(col, col_widths[key])

        # update the scrollbars and the displayed part
        # of the grid

        grid.Freeze()
        grid.AdjustScrollbars()
        grid.Refresh()
        grid.Thaw()
Example #5
0
            self._stackPtr += 1


if __name__ == '__main__':
    import sys
    app = wx.PySimpleApp()
    frame = wx.Frame(None, -1, size=(700, 500), title="wx.Grid example")

    grid = wx.grid.Grid(frame)
    grid.CreateGrid(20, 6)

    # To add capability, mix it in, then set key handler, or add call to grid.Key() in your own handler
    wx.grid.Grid.__bases__ += (PyWXGridEditMixin, )
    grid.__init_mixin__()

    grid.SetDefaultColSize(70, 1)
    grid.EnableDragGridSize(False)

    grid.SetCellValue(0, 0, "Col is")
    grid.SetCellValue(1, 0, "Read Only")
    grid.SetCellValue(1, 1, "hello")
    grid.SetCellValue(2, 1, "23")
    grid.SetCellValue(4, 3, "greren")
    grid.SetCellValue(5, 3, "geeges")

    # make column 1 multiline, autowrap
    cattr = wx.grid.GridCellAttr()
    cattr.SetEditor(wx.grid.GridCellAutoWrapStringEditor())
    #cattr.SetRenderer(wx.grid.GridCellAutoWrapStringRenderer())
    grid.SetColAttr(1, cattr)
Example #6
0
def gridview(array, title="2d viewer", originLeftBottom=1):
    try:
        from scipy.sparse import spmatrix
        if not isinstance(array, spmatrix):
            array = N.asanyarray(array)
    except:
        array = N.asanyarray(array)

    if array.ndim == 1:
        array = array.view()
        array.shape = (-1, len(array))
    if len(array.shape) != 2:
        raise ValueError, "array must be of dimension 2"

    ###########size = (400,400)
    frame = wx.Frame(None, -1, title)
    #    grid = wx.Window(frame, -1)
    global grid
    grid = HugeTableGrid(frame, array, originLeftBottom)

    grid.EnableDragRowSize(0)
    grid.SetDefaultCellAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
    grid.SetFont(wx.SWISS_FONT)
    #grid.AutoSizeColumns()

    grid.SetDefaultColSize(40, True)
    grid.SetRowLabelSize(30)

    p1 = wx.Panel(frame, -1)
    p1_sizer = wx.BoxSizer(wx.HORIZONTAL)

    nz = 1
    if nz == 1:
        label = wx.StaticText(p1, -1, "---------->")
        #label.SetHelpText("This is the help text for the label")
        p1_sizer.Add(label, 0, wx.GROW | wx.ALL, 2)
        #z0 = 0
        #self.z = z0  ## CHECK worker thread

    else:
        #self.lastZ = -1 # remember - for checking if update needed
        #z0 = 0
        #self.z = z0
        #slider = wx.Slider(panel1, 1001, z0, 0, self.nz-1,
        #                   wx.DefaultPosition, wx.DefaultSize,
        #                   #wx.SL_VERTICAL
        #                   wx.SL_HORIZONTAL
        #                   | wx.SL_AUTOTICKS | wx.SL_LABELS )
        #slider.SetTickFreq(5, 1)
        #box.Add(slider, 1, wx.EXPAND)
        #box.Add(slider, 0, wx.GROW|wx.ALL, 2)
        #box.Add(slider, 1, wx.EXPAND)
        #wx.EVT_SLIDER(frame, slider.GetId(), self.OnSlider)
        #self.slider = slider
        pass

    label2 = wx.StaticText(p1, -1, "<- move mouse over image ->")
    #label2.SetHelpText("This is the help text for the label")

    #p1_sizer.Add(label2, 0, wx.GROW|wx.ALL, 2)
    p1.SetAutoLayout(True)
    p1.SetSizer(p1_sizer)

    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(label2, 0, wx.GROW | wx.ALL, 2)
    sizer.Add(p1, 0, wx.GROW | wx.ALL, 2)
    sizer.Add(grid, 1, wx.EXPAND | wx.ALL, 5)

    frame.SetSizer(sizer)
    # sizer.SetSizeHints(frame)
    #2.4auto  frame.SetAutoLayout(1)
    sizer.Fit(frame)

    frame.Show(1)
    frame.Layout()  # hack for Linux-GTK
Example #7
0
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, size=(400, 300))
        #self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
        self.statusbar = self.CreateStatusBar(
        )  # A Statusbar in the bottom of the window

        # Setting up the menu.
        filemenu = wx.Menu()
        # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets.
        filemenu.Append(wx.ID_ABOUT, "&About",
                        " Information about this program")
        filemenu.AppendSeparator()
        filemenu.Append(wx.ID_EXIT, "E&xit", " Terminate the program")

        # Creating the menubar.
        menuBar = wx.MenuBar()
        menuBar.Append(filemenu,
                       "&File")  # Adding the "filemenu" to the MenuBar
        self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame content.
        panel = wx.Panel(self)

        # Create a wxGrid object
        self.grid = grid = wx.grid.Grid()
        # Then we call CreateGrid to set the dimensions of the grid
        # (100 rows and 10 columns in this example)
        grid.Create(panel)
        grid.CreateGrid(1, 10)
        grid.SetDefaultColSize(50, True)
        grid.SetDefaultRowSize(20, True)

        grid.HideRowLabels()
        grid.EnableGridLines(False)

        grid.AppendRows(grid.GetNumberCols())
        for i in range(1, grid.GetNumberCols()):
            grid.SetColLabelValue(i, "")
        grid.SetColLabelValue(0, "Filename")
        grid.SetColLabelValue(1, "Page")
        grid.SetColLabelValue(2, "New name")
        grid.AutoSizeColumns()

        # Let's lay out the space.  We fill the panel with a vertical sizer so things in it are stcked vertically.
        # Inside that we have a top sizer for small controls and a secon sizer below it for the grid.
        gbs = wx.GridBagSizer(4, 2)

        # The top gridbag row gets buttons
        self.buttonLoad = wx.Button(panel, id=wx.ID_ANY, label="Load")
        gbs.Add(self.buttonLoad, (0, 0))
        self.buttonLoad.Bind(wx.EVT_BUTTON, self.OnLoadButtonClicked)
        self.buttonGenerate = wx.Button(panel, id=wx.ID_ANY, label="Rename")
        gbs.Add(self.buttonGenerate, (0, 1))

        # Now put a pair of buttons with labels above them in the middle two gridbag rows
        gbs.Add(wx.StaticText(panel, label=" Fanzine name"), (1, 0))
        self.fanzineNameTextbox = wx.TextCtrl(panel, id=wx.ID_ANY)
        gbs.Add(self.fanzineNameTextbox, (2, 0))
        self.fanzineNameTextbox.Bind(wx.EVT_TEXT,
                                     self.OnFanzinenameOrIssueTextboxChanged)

        gbs.Add(wx.StaticText(panel, label=" Issue number"), (1, 1))
        self.fanzineIssuenumber = wx.TextCtrl(panel, id=wx.ID_ANY)
        gbs.Add(self.fanzineIssuenumber, (2, 1))
        self.fanzineIssuenumber.Bind(wx.EVT_TEXT,
                                     self.OnFanzinenameOrIssueTextboxChanged)

        # And the grid itself goes in the bottom gridbag row, spanning both columns
        gbs.Add(grid, (3, 0), span=(2, 2))

        panel.SetSizerAndFit(gbs)

        self.Show(True)
Example #8
0
    def __init__(self, parent, input_para):

        rect_parent = parent.GetRect()
        print rect_parent
        pos_target = rect_parent.GetTopRight()
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          "Resource Grid",
                          pos=pos_target,
                          size=(1000, 700))
        panel = wx.Panel(self, -1)

        sizer_grid = wx.GridBagSizer(0, 0)
        usr_style = wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL
        grid = wx.grid.Grid(self, -1)
        grid.CreateGrid(12 * 2, 14)
        cell_width = 20

        grid.DisableDragColSize()
        grid.DisableDragGridSize()
        grid.DisableDragRowSize()
        grid.SetRowLabelAlignment(wx.CENTER, wx.CENTER)

        clo_num = grid.GetNumberCols()
        row_num = grid.GetNumberRows()

        for i in range(0, row_num):
            grid.SetRowLabelValue(i, str(row_num - i - 1))
            grid.AutoSizeRowLabelSize(i)
        grid.SetRowLabelSize(cell_width)
        grid.SetDefaultRowSize(cell_width)
        for j in range(0, clo_num):
            grid.SetColLabelValue(j, str(j))
            grid.AutoSizeColLabelSize(j)
        grid.SetRowLabelSize(cell_width)
        grid.SetDefaultColSize(cell_width)
        grid.SetDefaultCellBackgroundColour(wx.Colour(192, 192, 192))

        #pdcch
        for i in range(0, row_num):
            for j in range(0, clo_num):
                grid.SetReadOnly(i, j)
                if (j < input_para['pdcch_symbol']):
                    grid.SetCellBackgroundColour(i, j, wx.GREEN)
                    if ((int(grid.GetRowLabelValue(i)) - 1) % 4 == 0):
                        grid.SetCellBackgroundColour(i, j,
                                                     wx.Colour(66, 66, 111))
        #pdsch
        for i in range(0, row_num):
            for j in range(input_para['start_symbol'], clo_num):
                if (j - input_para['start_symbol'] <
                        input_para['symbol_length']):
                    grid.SetCellBackgroundColour(i, j,
                                                 wx.Colour(255, 255, 255))
        #pdsch dmrs
        for j in range(0, len(input_para['dmrs_pos_list'])):
            for i in range(0, row_num):
                if input_para['dmrs_length'] == 0 and j == 0:
                    grid.SetCellBackgroundColour(
                        i, input_para['dmrs_pos_list'][j],
                        wx.Colour(153, 204, 50))
                    continue
                if input_para['dmrs_length'] == 1 and (j == 1 or j == 0):
                    grid.SetCellBackgroundColour(
                        i, input_para['dmrs_pos_list'][j],
                        wx.Colour(153, 204, 50))
                    continue
                else:
                    grid.SetCellBackgroundColour(
                        i, input_para['dmrs_pos_list'][j],
                        wx.Colour(234, 234, 173))

        sizer_grid.Add(grid,
                       pos=(0, 0),
                       span=(5, 5),
                       flag=wx.EXPAND | usr_style)

        lbl_pdcch = wx.StaticText(self, -1, u'  PDCCH  ', style=usr_style)
        lbl_pdcch.SetBackgroundColour(wx.GREEN)
        sizer_grid.Add(lbl_pdcch,
                       pos=(7, 0),
                       span=(1, 1),
                       flag=wx.EXPAND | usr_style)

        lbl_pdcch_dmrs = wx.StaticText(
            self,
            -1,
            u'  PDCCH DMRS  ',
            style=usr_style,
        )
        lbl_pdcch_dmrs.SetBackgroundColour(wx.Colour(66, 66, 111))
        lbl_pdcch_dmrs.SetForegroundColour(wx.Colour(255, 255, 255))
        sizer_grid.Add(
            lbl_pdcch_dmrs,
            pos=(7, 1),
            span=(1, 1),
            flag=wx.EXPAND | usr_style,
        )

        lbl_pdsch = wx.StaticText(self, -1, u'  PDXCH  ', style=usr_style)
        lbl_pdsch.SetBackgroundColour(wx.Colour(255, 255, 255))
        lbl_pdsch.SetForegroundColour(wx.Colour(0, 0, 0))
        sizer_grid.Add(lbl_pdsch,
                       pos=(7, 2),
                       span=(1, 1),
                       flag=wx.EXPAND | usr_style)

        lbl_fl_dmrs = wx.StaticText(self,
                                    -1,
                                    u'Front Loaded DMRS',
                                    style=usr_style)
        lbl_fl_dmrs.SetBackgroundColour(wx.Colour(153, 204, 50))
        lbl_fl_dmrs.SetForegroundColour(wx.Colour(255, 255, 255))
        sizer_grid.Add(lbl_fl_dmrs,
                       pos=(8, 0),
                       span=(1, 1),
                       flag=wx.EXPAND | usr_style)

        lbl_add_dmrs = wx.StaticText(self, -1, u'Add DMRS', style=usr_style)
        lbl_add_dmrs.SetBackgroundColour(wx.Colour(234, 234, 173))
        lbl_add_dmrs.SetForegroundColour(wx.Colour(0, 0, 0))
        sizer_grid.Add(lbl_add_dmrs,
                       pos=(8, 1),
                       span=(1, 1),
                       flag=wx.EXPAND | usr_style)

        b_close = wx.Button(self, -1, "Close")
        self.Bind(wx.EVT_BUTTON, self.close_window, b_close)
        sizer_grid.Add(b_close,
                       pos=(10, 0),
                       span=(2, 5),
                       flag=wx.EXPAND | usr_style)
        self.equal = b_close

        self.SetSizer(sizer_grid)
        sizer_grid.Fit(self)

        self.Show()
Example #9
0
    def __init__(self, parent, square, size):
        self.size = size
        grid = wx.grid.Grid(parent, -1)
        grid.CreateGrid(self.size + 2, self.size + 2)

        # Set Sizer
        '''Sizer = wx.BoxSizer(wx.HORIZONTAL)
        Sizer.Add(grid, 0, wx.ALIGN_CENTER|wx.ALL, 5)
        parent.SetSizerAndFit(Sizer)'''

        # Set Labels not visible
        grid.SetRowLabelSize(0)
        grid.SetColLabelSize(0)
        
        # Set Row and Column size
        grid.SetDefaultRowSize(40)
        grid.SetDefaultColSize(40)

        # Print Square Values as string
        for j in range(2, self.size + 2):
            for i in range(2, self.size + 2):
                grid.SetCellAlignment(i-1, j-1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
                grid.SetCellValue(i-1, j-1, str(square[(i-1,j-1)]))
                grid.SetReadOnly(i-1, j-1)
        
        # Evaluate Rows Sum
        for i in range(1, self.size + 1):
            mg_num = self.evaluateRowSum(square, i)
            grid.SetCellAlignment(i, self.size+1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
            grid.SetCellBackgroundColour(i, self.size+1, wx.YELLOW)
            grid.SetCellValue(i, self.size+1, str(mg_num))
            grid.SetCellAlignment(i, 0, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
            grid.SetCellBackgroundColour(i, 0, wx.YELLOW)
            grid.SetCellValue(i, 0, str(mg_num))
            grid.SetReadOnly(i, 0)
            
        # Evaluate Columns Sum  
        for j in range(1, self.size + 1):
            mg_num = self.evaluateColSum(square, j)
            grid.SetCellAlignment(self.size+1, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
            grid.SetCellBackgroundColour(self.size+1, j, wx.GREEN)
            grid.SetCellValue(self.size+1, j, str(mg_num))
            grid.SetCellAlignment(0, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER) 
            grid.SetCellBackgroundColour(0, j, wx.GREEN)
            grid.SetCellValue(0, j, str(mg_num)) 
            grid.SetReadOnly(0, j)
        
        #Evaluate Diagonal 1
        diag1 = self.evaluateDiag1(square)
        grid.SetCellAlignment(self.size+1, self.size+1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
        grid.SetCellBackgroundColour(self.size+1, self.size+1, wx.BLUE)
        grid.SetCellTextColour(self.size+1, self.size+1, wx.WHITE)
        grid.SetCellValue(self.size+1, self.size+1, str(diag1))
        grid.SetReadOnly(self.size+1, self.size+1)
        grid.SetCellAlignment(0, 0, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
        grid.SetCellBackgroundColour(0, 0, wx.BLUE)
        grid.SetCellTextColour(0, 0, wx.WHITE)
        grid.SetCellValue(0, 0, str(diag1))
        grid.SetReadOnly(0, 0)
        
        #Evaluate Diagonal 2
        diag2 = self.evaluateDiag2(square)
        grid.SetCellAlignment(0, self.size+1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
        grid.SetCellBackgroundColour(0, self.size+1, wx.RED)
        grid.SetCellTextColour(0, self.size+1, wx.WHITE)
        grid.SetCellValue(0, self.size+1, str(diag2))
        grid.SetReadOnly(0, self.size+1)
        grid.SetCellAlignment(self.size+1, 0, wx.ALIGN_CENTER, wx.ALIGN_CENTER) 
        grid.SetCellBackgroundColour(self.size+1, 0, wx.RED)
        grid.SetCellTextColour(self.size+1, 0, wx.WHITE)
        grid.SetCellValue(self.size+1, 0, str(diag2))   
        grid.SetReadOnly(self.size+1, 0)     

        parent.Show()