[Tutor] Witch gui to choose for this script?

Kent Johnson kent37 at tds.net
Fri Oct 27 11:52:20 CEST 2006


rolando wrote:
> Well, I don't know if I can ask this question here, but never mind that :)

Yes, it's fine.
> 
> It´s like this, I created this python script that translates "human 
> language" to Al-bhed language (it's a language from the game Final 
> Fantasy 10, it's basicly a change in the letters for example A becomes W 
> or B become H).
> 
> Since I like the script, and it's my first "program", I am now trying to 
> create a GUI for it.
> 
> So what do you recommend?

I think Tkinter is the easiest to get started with. You might also like 
to try PythonCard which is a wrapper around wxPython that makes it 
easier to use.
> 
> I'm going to attach the script, just in case you want to see it.

I have a few comments below.
> 
> 
> ------------------------------------------------------------------------
> 
> #!/usr/bin/python
> #V 0.4
> import string
> 
> contador = "s" # Cria um contador que verifica que deve ou nao executar o script
> 
> while contador.lower() == "s" or contador.lower() == "sim": # Enquanto o valor for "s" ou "sim" o programa nao sai (converte a palavra em minusculas)
> 
> 	print "Escolhe a lingua que queres traduzir. [p]ortugues ou [a]l-bhed"
> 
> 	lingua = raw_input() # Escolhe a lingua
> 	
> 	if lingua.isspace() == True: # Se "lingua" e constituida por espacos em branco
> 
> 		print "Tens de escrever alguma coisa ok?"
> 
> 	if lingua == "": # Se lingua estiver vazia
> 		
> 		print "Tens de escrever alguma coisa ok?"

These two tests could be combined into
   if not lingua.strip():
     print "Tens de escrever alguma coisa ok?"

> 
> 	if lingua.lower() == "a" or lingua.lower() == "al-bhed":
> 		lista = string.maketrans('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'epstiwknuvgclrybxhmdofzqajEPSTIWKNUVGCLRYBXHMDOFZQAJ') # Cria a lista de palavra e de que maneira vao ser trocadas
> 
> 		print "Escreve a palavra que queres traduzir."
> 
> 		palavra = raw_input() # Pede por uma palavra
> 
> 		print "" + palavra.translate(lista) + "" # Imprime as palavras trocadas
> 
> 	if lingua.lower() == "p" or lingua.lower() == "portugues":
> 		lista = string.maketrans('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ypltavkrezgmshubxncdijfqowYPLTAVkREZGMSHUBXNCDIJFQOW') # Cria a lista de palavra e de que maneira vao ser trocadas

I would define the two listas outside the loop at the top of the program 
and give them more descriptive names like portugueseToAlBled. I think it 
would make the loop easier to read.

Kent
> 
> 		print "Escreve a palavra que queres traduzir."
> 
> 		palavra = raw_input() # Pede por uma palavra
> 
> 		print "" + palavra.translate(lista) + "" # Imprime as palavras trocadas

You don't need the extra "", just print palavra.translate(lista).

Kent
> 	
> 
> 	print "Ainda tens mais alguma coisa para traduzir? [S/N]"
> 	
> 	contador = raw_input() # Modifica o contador que esta inicio do script
> 
> if contador.lower() == "n" or contador.lower() == "nao": # Se contador igual a "n" ou "nao" minusculos
> 	print "Entao adeus."
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor




More information about the Tutor mailing list