def __init__(self): super(Neighborhood, self).__init__() self.x = random.randint(2, 5) self.y = random.randint(2, 5) self.houselist = [] self.housesdefeated = 0 self.totalhousecount = self.x * self.y for i in xrange(self.y): for j in xrange(self.x): house = Home.Home() self.houselist.append(house) house.add_observer(self) self.neighborlist = [] for i in xrange(self.totalhousecount): south = i - self.y east = i + 1 north = i + self.y west = i - 1 if south < 0: south = None if east > self.totalhousecount or east % self.x == 0: east = None if west < 0 or west % self.x == (self.x - 1): west = None if north > self.totalhousecount: north = None neighbor = [north, east, south, west] self.neighborlist.append(neighbor)
def __init__(self, game): self.grid = [] for row in range(self.GRID_SIZE): self.grid.append(list()) for col in range(self.GRID_SIZE): tmp = Home.Home(game) self.grid[row].append(tmp)
def login(self, root): id_ip = self.idEntry.get() pw_ip = self.pwEntry.get() if ES.authenticate(id_ip, pw_ip): self.clear() Home.Home(root) else: messagebox.showerror("Failed Login", "Invalid Credentials")
def genHouses(self, size): neighborhood = [] for x in range(0, size): streetHomes = [] for y in range(0, size): tempHome = Home() self.monstersInHouses = self.monstersInHouses + tempHome.numMonster() streetHomes.append(tempHome) tempHome.add_observer(self) neighborhood.append(streetHomes) return neighborhood
def populateHood(self, size): neigh = [] for i in range(0, size): hood = [] for j in range(0, size): newHome = Home() self.count = self.count + newHome.getNumMonsters() hood.append(newHome) newHome.add_observer(self) neigh.append(hood) return neigh
def __init__(self, cols, rows, game, player): self._grid = [[0 for i in range(cols)] for j in range(rows)] for x in range(cols): for y in range(rows): obj = None placement = randint(0, 3) if placement is 0: obj = Home(self) else: obj = 0 self._grid[x][y] = obj self._grid[0][0] = 0 self._game = game self._player = player
def submitAction(self): with open('Account.txt', 'a') as wf: wf.write('\n%s;%s' % (self.userField.text(), self.passwordField.text())) with open('UserInfo.txt', 'a') as af: af.write('\n%s;%s' % (self.userField.text(), self.nameField.text())) msg = QMessageBox() msg.setWindowTitle("Success") msg.setText('Account Added') msg.setIcon(QMessageBox.Information) x = msg.exec_() self.openHome = home.Home() self.openHome.show() self.close()
def main(): app = QApplication(sys.argv) win = Home.Home() win.setWindowTitle("TodoList") win.show() sys.exit(app.exec_())
def fill_location(self, location): home = Home() monsters = home.gen_monsters() return monsters
# ***** 2.7 and the widgets contained in each. In this case, we use ***** # ***** a variety of frame based classes to have compartmentelized code ***** # ***** for each sub piece of the car. ***** # ***************************************************************************** from XExtraOptions import * from HeaderBar import * from Paint import * from Options import Options from PowerRange import PowerRange from Home import * from ContactInfo import * from ttk import * # each item can be called via a button, or otherwise as needed # thecar is defined in Globals.py, and acts as our common information # need to erase settings if we change model of the car HeaderBar(thecar) stuff = Notebook() stuff.add(Home(), text="Home") stuff.add(PowerRange(), text="Power") stuff.add(Paint(), text="Paint") stuff.add(Options(), text="Options") stuff.add(XInteriorOptions(), text="Interior Options") stuff.add(ContactInfo(), text="Contact") stuff.grid() thecar.mainloop()
def back(self, root): self.clear() Home.Home(root)