def openLibrary(self, widget): fileName = ChooseFile(self.window, "Plant files", ["*.pla"]) if fileName == None: return print "Opening", fileName ucursor.cursor_startWait() try: plants = uplant.PlantLoader().loadPlantsFromFile(fileName, inPlantMover=1, justLoad=1) self.fileName = fileName self.setPlantListContents(plants) finally: ucursor.cursor_stopWait()
def __init__(self): JFrame.__init__(self, "Plant Viewer", windowClosing=self.OnClose) self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE ) # HIDE_ON_CLOSE DO_NOTHING_ON_CLOSE self.plants = None self.setSize(750, 500) self.window = self.contentPane hbox = MakeHorizontalBox(self.window) self.plantList = MakeList(hbox, "Plant name", self.selectionChanged) vbox = MakeVerticalBox(hbox) self.drawingArea = PlantDrawingArea() PackBox(vbox, self.drawingArea) hbox = MakeHorizontalBox(vbox) MakeButton(hbox, "=0", self.grow, -1) MakeButton(hbox, "+1", self.grow, 1) MakeButton(hbox, "+5", self.grow, 5) MakeButton(hbox, "+10", self.grow, 10) MakeButton(hbox, "+30", self.grow, 30) MakeButton(hbox, "+100", self.grow, 100) hbox = MakeHorizontalBox(vbox) MakeButton(hbox, "<<", self.turn, -8) MakeButton(hbox, ">>", self.turn, 8) MakeButton(vbox, "Open library...", self.openLibrary) #self.fileName = "test.pla" #self.fileName = "test tree.pla" #self.fileName = "Garden flowers.pla" self.fileName = "Garden plants.pla" plants = uplant.PlantLoader().loadPlantsFromFile(self.fileName, inPlantMover=1, justLoad=1) self.setPlantListContents(plants) ShowWindow(self.window) ucursor.windowsToWaitWith.append(self)
def __init__(self): self.plants = None self.window = MakeWindow("Garden Simulator for OLPC", 750, 500) hbox = MakeHorizontalBox(self.window) self.plantList = MakeList(hbox, "Plant name", self.selectionChanged) vbox = MakeVerticalBox(hbox) self.drawingArea = PlantDrawingArea(self.mouseDown) PackBox(vbox, self.drawingArea) hbox = MakeHorizontalBox(vbox) MakeButton(hbox, "=0", self.grow, -1) MakeButton(hbox, "+1", self.grow, 1) MakeButton(hbox, "+5", self.grow, 5) MakeButton(hbox, "+10", self.grow, 10) MakeButton(hbox, "+30", self.grow, 30) MakeButton(hbox, "+100", self.grow, 100) hbox = MakeHorizontalBox(vbox) MakeButton(hbox, "Clear", self.clear, -8) #MakeButton(hbox, ">>", self.turn, 8) MakeButton(vbox, "Open library...", self.openLibrary) self.fileName = "test.pla" #self.fileName = "test tree.pla" #self.fileName = "Garden flowers.pla" #self.fileName = "Garden flowers.pla" plants = uplant.PlantLoader().loadPlantsFromFile(self.fileName, inPlantMover=1, justLoad=1) self.setPlantListContents(plants) ShowWindow(self.window) ucursor.windowsToWaitWith.append(self.window.window)