class RobotFrame(Frame): def __init__(self, parent): Frame.__init__(self, parent, background="white") self.parent = parent # Initialize to default robot self.robot = Robot() # Initialize empty list for limb frames self.limbFrames = [] self.initUI() # Start the update cycle self.update() def initUI(self): self.rowconfigure(0, pad=3, weight=1) self.columnconfigure(0, pad=3, weight=1) # Create a vertically scrolling frame to hold all of the limb frames self.scrollFrame = VerticalScrolledFrame(self, background="white") # Generate a limb frame for each limb in the robot for limb in self.robot.getLimbs(): newLimbFrame = LimbFrame(self.scrollFrame.interior, limb) newLimbFrame.grid(row=len(self.limbFrames), column=0) self.limbFrames.append(newLimbFrame) # Set the scrolling frame to fill the window self.scrollFrame.grid(row=0, column=0, sticky=N+S+W+E) # Add a button to store the state of the robot in the active macro self.btnSaveState = Button(self, text="Save State", command=self.saveState) self.btnSaveState.grid(row=1, column=0) # Saves the state of the current robot in the macro frame def saveState(self): self.parent.macroFrame.addState(self.robot) # Continuously update the limb frames def update(self): for limbFrame in self.limbFrames: limbFrame.update() self.after(20, self.update)
class RobotFrame(Frame): def __init__(self, parent): Frame.__init__(self, parent, background="white") self.parent = parent # Initialize to default robot self.robot = Robot() # Initialize empty list for limb frames self.limbFrames = [] self.initUI() # Start the update cycle self.update() def initUI(self): self.rowconfigure(0, pad=3, weight=1) self.columnconfigure(0, pad=3, weight=1) # Create a vertically scrolling frame to hold all of the limb frames self.scrollFrame = VerticalScrolledFrame(self, background="white") # Generate a limb frame for each limb in the robot for limb in self.robot.getLimbs(): newLimbFrame = LimbFrame(self.scrollFrame.interior, limb) newLimbFrame.grid(row=len(self.limbFrames), column=0) self.limbFrames.append(newLimbFrame) # Set the scrolling frame to fill the window self.scrollFrame.grid(row=0, column=0, sticky=N + S + W + E) # Add a button to store the state of the robot in the active macro self.btnSaveState = Button(self, text="Save State", command=self.saveState) self.btnSaveState.grid(row=1, column=0) # Saves the state of the current robot in the macro frame def saveState(self): self.parent.macroFrame.addState(self.robot) # Continuously update the limb frames def update(self): for limbFrame in self.limbFrames: limbFrame.update() self.after(20, self.update)