def setup(self): ''' Slight modifcation to the default setup to better suit this game ''' super().setup() for i in range(2): super().framelist[1].destroy del super().framelist[1] super().framelist[1] = desktop.Frame( height=(super().getScreenH() / 10) * (self.columns * 2 / 8), width=super().getScreenW() * self.rows / 10, bg=super().backgroundC) super().framelist[1].pack_propagate(False) super().framelist[1].place(anchor='center', x=super().getScreenW() / 2, y=super().getScreenH() / 2) bottomFrame = desktop.Frame(height=super().getScreenH() / 10, width=super().getScreenW(), bg=super().backgroundC) bottomFrame.pack_propagate(False) bottomFrame.place(y=super().getScreenH() * 8 / 10, x=0) super().addFrame(bottomFrame)
def setup(self): def get_ip_address(): ''' Obtains the IP address for all platforms, so players know where to connect and for the generation of the QR code ''' s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) return s.getsockname()[0] super().setup() super().framelist[1] = desktop.Frame( height=(super().getScreenH() / 10) * 8, width=super().getScreenW() / 3, bg=super().backgroundC) super().framelist[1].pack_propagate(False) super().framelist[1].place(x=0, y=super().getScreenH() / 10) super().framelist[2] = desktop.Frame( height=(super().getScreenH() / 10) * 8, width=super().getScreenW() / 3, bg=super().backgroundC) super().framelist[2].pack_propagate(False) super().framelist[2].place(x=(super().getScreenW() / 3) * 2, y=super().getScreenH() / 10) super().framelist[3] = desktop.Frame( height=(super().getScreenH() / 10) * 8, width=(super().getScreenW() / 3), bg=super().backgroundC) super().framelist[3].pack_propagate(False) super().framelist[3].place(x=(super().getScreenW() / 3), y=super().getScreenH() / 10) IP = get_ip_address() label1 = desktop.Label( super().framelist[0], text="Go to http://" + str(IP) + ":5000 or scan the below code to enter the lobby", bg=super().framelist[0]['bg'], fg="white", font=self.window.deffont) label1.place(x=super().getScreenW() / 2, y=super().getScreenH() / 20, anchor='center') img = qrcode.make("http://" + str(IP) + ":5000") resImg = desktop.ImageTk.PhotoImage(img) label2 = desktop.Label(super().framelist[3], image=resImg) label2.image = resImg # needed so images aren't garbage collected, thus not showing up label2.place(anchor='center', x=super().getScreenW() / 6, y=super().getScreenH() * 2 / 5)
def __init__(self, ui, instructions): ''' Will show the insturctions for the game the players are about to play ''' self.window = ui super().setWindow(ui.win) super().setscreen(ui.screenW, ui.screenH) super().reset() windowFrame = desktop.Frame(height=super().getScreenH(), width=super().getScreenW(), bg=self.backgroundC) windowFrame.pack_propagate(False) windowFrame.place(x=0, y=0) super().addFrame(windowFrame) instr = desktop.Label(windowFrame, text=instructions, font=super().setFontSize(super().getScreenH() / 30), bg=super().backgroundC, fg='white', justify='left', wraplength=super().getScreenW()) instr.place(anchor='center', x=super().getScreenW() / 2, y=super().getScreenH() / 2)
def setup(self): ''' Slight modification of the default layout to better suit this game ''' super().setup() super().framelist[3].destroy del super().framelist[3] super().framelist[1] = desktop.Frame(height = (super().getScreenH() / 10) * 8, width = super().getScreenW() / 3, bg = super().backgroundC) super().framelist[1].pack_propagate(False) super().framelist[1].place(x = 0, y = self.screenH / 10) super().framelist[2] = desktop.Frame(height = (super().getScreenH() / 10) * 8, width = super().getScreenW() / 3, bg = super().backgroundC) super().framelist[2].pack_propagate(False) super().framelist[2].place(x = 2/3 * super().getScreenW(), y = super().getScreenH() / 10)
def updateCard(self, card, position, highlighted): ''' Displays the cards for the board ''' if highlighted: # i.e. cursor is on that card cardFrame = desktop.Frame(super().framelist[1], height=super().getScreenH() / 5 - 20, width=super().getScreenW() / 10 - 20, bg=super().backgroundC, highlightthickness=10) cardImage = super().imageCreation(self.getCardImgName(card), super().getScreenH() / 5 - 45, super().getScreenW() / 10 - 45, "/match/cards") cardFrame.pack_propagate(False) cardFrame.grid(row=position[0], column=position[1], padx=10, pady=10) label2 = desktop.Label(cardFrame, image=cardImage, bg=super().backgroundC) label2.img = cardImage label2.place(x=0, y=0) else: cardFrame = desktop.Frame(super().framelist[1], height=super().getScreenH() / 5 - 20, width=super().getScreenW() / 10 - 20, bg=super().backgroundC) cardImage = super().imageCreation(self.getCardImgName(card), super().getScreenH() / 5 - 20, super().getScreenW() / 10 - 20, "/match/cards") cardFrame.pack_propagate(False) cardFrame.grid(row=position[0], column=position[1], padx=10, pady=10) label = desktop.Label(cardFrame, image=cardImage, bg=super().backgroundC) label.img = cardImage label.place(x=0, y=0)