def __init__(self): #super(GridLayout(0,1)) # 1 column, as many rows as necessary super(RoiGroupTable, self).__init__(GridLayout( 0, 1)) # 1 column, as many rows as necessary #super() #self.setLayout(GridLayout(0,1)) ### Table Panel ### # Prepare table data headers = ["Group number", "Name"] listNames = Roi.getGroupNames().split(",") # groupNames is a list then dataRows = [[item[0] + 1, item[1]] for item in enumerate(listNames) ] # +1 since the group actually start at 1 #print dataRows # Make the table pane table = JTable(dataRows, headers) #table.setPreferredScrollableViewportSize( Dimension(500, 70) ) #table.setFillsViewportHeight(true) # Create the scroll pane and add the table to it. tablePane = JScrollPane(table) #tablePane = ScrollPane() #tablePane.add(table) # Add the scrollpane to the main panel. self.add(tablePane)
def __init__(self): if IJ.getFullVersion() < "1.53b": message = "ImageJ with at least version 1.53b required. Update with Help > Update ImageJ..." IJ.error(message) raise Exception(message) super(TableModel, self).__init__() self.headers = ["Group", "Name"] groupNames = Roi.getGroupNames() # groupNames can be None ! groupNames = groupNames.split(",") if groupNames else [ "ExampleName-doubleClick to edit" ] # groupNames is a list self.nRows = len(groupNames) self.columns = [[], []] # 2 columns self.columns[0] = range(1, len(groupNames) + 1) self.columns[1] = groupNames