def getPromptSprite(self): promptSprite = Prompt(self.result) if DEBUG: pass # print "scaling promptSprite to W:{}, H:{}".format(0.6 * self.width, 0.3 * self.height) promptSprite.image = pygame.transform.scale( promptSprite.image, (int(self.width), int(self.height))) # promptSprite.center = (0.5 * self.width, 0.5 * self.height) return promptSprite
def create_prompts(subs_file): prompts = [] with open(subs_file, 'r', encoding='iso8859_9') as f: chunks = f.read().split('\n\n') for chunk in chunks: if chunk == '': continue lines = chunk.split('\n') prompts.append(Prompt(lines[0], lines[1], lines[2:])) return prompts
def checkWinner(self, xcoord, ycoord): # if the user clicks a mine, change the reset button image and end the game if self.buttonDict[str(xcoord) + "," + str(ycoord)].cget( "state") == "disabled" and self.boardList[ycoord - 1][xcoord - 1] == "m": self.buttonReset.config(image=self.dead) # disable all the buttons for x in range(1, int(self.columns) + 1): for y in range(1, int(self.rows) + 1): if self.boardList[y - 1][x - 1] == "m" and self.buttonDict[ str(x) + "," + str(y)].getImage() != self.mine: self.buttonDict[str(x) + "," + str(y)].config(image=self.revealMine) self.buttonDict[str(x) + "," + str(y)].config(state="disabled") # stop the stopwatch self.stopwatch.stop() # show a messagebox messagebox.showinfo("LOSER", "Sorry! You lost!") else: # make an empty list checkerList = [] # for each button in buttonDict, if the state is normal, add it to checkerList for item in self.buttonDict: if self.buttonDict[item].cget("state") == "normal": checkerList.append(item) # check if length of the checkerList is equal to the number of mines, i.e. the only non-disabled buttons are all mines if len(checkerList) == self.mines: # change the image for the reset button self.buttonReset.config(image=self.glasses) # stop the stopwatch self.stopwatch.stop() # show messageboxes messagebox.showinfo("YOU WIN!", "Congratulations! You won!") messagebox.showinfo( "TIME TAKEN", "You took " + str(int(self.stopwatch.getTime())) + " seconds to win the game!") time = self.findMinTime() # make a Prompt window, asking the user for his or her name if (self.mines == 10 and self.rows == 10 and self.columns == 10 ) or (self.mines == 20 and self.rows == 10 and self.columns == 20) or (self.mines == 50 and self.rows == 25 and self.columns == 20): root2 = Tk() root2.title("High Scorers") reader = Prompt(root2, time, self.mines, self.rows, self.columns) # if there are more buttons with a normal state than the number of mines, set checkerList equal to an empty list else: checkerList = []
if __name__ == '__main__': if len(sys.argv) <= 2: print( "Ce client nécessite le port et le format de message transmis, sois xml ou Json." ) sys.exit(1) host = '138.197.156.251' port = int(sys.argv[1]) fileManager = FileManager() if (sys.argv[2] == "xml"): protocole = Protocole_xml(fileManager) elif (sys.argv[2] == "json"): protocole = Protocole_json(fileManager) else: print("Protocole invalide") sys.exit(1) connexion = Connexion(host, port) client = Client(connexion, protocole, fileManager) try: if (sys.argv[3] == "prompt"): prompt = Prompt(client) except: client.automatedSyncronisation()
def main(argv): parametro = ' usage: ulftp.py -u <user> -p <password> -s <server> -r <port>[optional]' diretorioAtual = '' usuario = '' senha = '' servidor ='' porta = 21 ftpDados = FTP() try: opts, args = getopt.getopt(argv,"hu:p:s:c:r:") except getopt.GetoptError: print 'there are invalid parameters' print'' print parametro print '' sys.exit(2) for opt,arg in opts: if opt == '-h': print '' print '2015 - Software developed by Ulisses de Castro' print 'this is a basic ftp client' print '' print 'beta version 001' print '' print parametro print '' print 'This help' print '===============================' print '-u => user to connect' print '-p => password to connect' print '-s => FTP server' print '-r => port optional default 21' print '===============================' print '' sys.exit() elif opt in ("-u"): usuario = arg elif opt in ("-p"): senha = arg elif opt in ("-s"): servidor = arg elif opt in("-c"): diretorioAtual = arg elif opt in("-r"): if arg != '': porta = arg else: print 'there are invalid parameters' print'' print parametro print '' if usuario !='' and senha !='' and servidor !='': try: print '' prompt = Prompt() prompt.open(servidor,porta,usuario,senha) prompt.prompt ='>$ ' prompt.cmdloop('Starting prompt...') except Exception, e: print str(e) sys.exit(2)