Ejemplo n.º 1
0
 def startGui(self):
     frame = JFrame("Life", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     self.gridPanel = JPanel(GridLayout(self.numRows, self.numCols))
     self.cellButtons = self._doForAllCells(self._createCellButton)
     self.grid = self._doForAllCells(lambda r, c: False)
     frame.add(self.gridPanel)
     buttonPanel = JPanel(FlowLayout())
     stepButton = JButton("Step", actionPerformed=self._step)
     runButton = JToggleButton("Run", actionPerformed=self._run)
     buttonPanel.add(stepButton)
     buttonPanel.add(runButton)
     frame.add(buttonPanel, SOUTH)
     frame.pack()
     frame.locationRelativeTo = None
     frame.visible = True
Ejemplo n.º 2
0
 def startGui(self):
     frame = JFrame("Life", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     (R, C) = (self.numRows, self.numCols)
     gridPanel = JPanel(GridLayout(R, C))
     self.checkBoxes = [[JCheckBox() for c in range(C)] for r in range(R)]
     self.grid = [[False for c in range(C)] for r in range(R)]
     for r in range(R):
         for c in range(C):
             gridPanel.add(self.checkBoxes[r][c])
     frame.add(gridPanel)
     buttonPanel = JPanel(FlowLayout())
     stepButton = JButton("Step", actionPerformed=self._step)
     runButton = JToggleButton("Run", actionPerformed=self._run)
     buttonPanel.add(stepButton)
     buttonPanel.add(runButton)
     frame.add(buttonPanel, SOUTH)
     frame.pack()
     frame.locationRelativeTo = None
     frame.visible = True
Ejemplo n.º 3
0
 def startGui(self):
     frame = JFrame("Life", defaultCloseOperation=JFrame.EXIT_ON_CLOSE)
     (R, C) = (self.numRows, self.numCols)
     gridPanel = JPanel(GridLayout(R, C))
     self.checkBoxes = [[JCheckBox() for c in range(C)] for r in range(R)]
     self.grid = [[False for c in range(C)] for r in range(R)]
     for r in range(R):
         for c in range(C):
             gridPanel.add(self.checkBoxes[r][c])
     frame.add(gridPanel)
     buttonPanel = JPanel(FlowLayout())
     stepButton = JButton("Step", actionPerformed=self._step)
     runButton = JToggleButton("Run", actionPerformed=self._run)
     buttonPanel.add(stepButton)
     buttonPanel.add(runButton)
     frame.add(buttonPanel, SOUTH)
     frame.pack()
     frame.locationRelativeTo = None
     frame.visible = True