1

i have a program that encodes and decodes messages with a key but i want to make it look nicer and more professional. My code is as follows:

from random import seed, shuffle
#Encoder Function
def Encoder(user_input,SEED):
    user_input = user_input.lower()
    letter = ["a","b","c","d","e","f","g","h","i","j","k",'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    Letter_code = {"a":0,"b":1,"c":2,"d":3,"e":4,"f":5,"g":6,"h":7,"i":8,"j":9,"k":10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25}
    code = ["a","b","c","d","e","f","g","h","i","j","k",'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',]
    n = []
    seed(SEED)
    shuffle(code)
    for letter in user_input:
        for let in letter:
            if letter != " ":
                if letter == let:
                    first = Letter_code[let]
                    n.append(code[first])
            else:
                n.append("~")
    return ''.join(n)
#Decoder Function
def Decoder(user_input,SEED):
    user_input = user_input.lower
    key_list = ["a","b","c","d","e","f","g","h","i","j","k",'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    final = ["a","b","c","d","e","f","g","h","i","j","k",'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    seed(SEED)
    shuffle(key_list)
    key_code = {}
    z = 0
    n = []
    for key in key_list:
        key_code[key] = z
        z += 1
    for let in user_input:
        if let != "~":
            for Ke in key_list:
                if let == Ke:
                    a = key_code[Ke]
                    n.append(final[a])
        else:
            n.append(" ")
    return ''.join(n)

i wanted a gui that would have two entry boxes,one for the message and the other for the key, and i wanted it to have two buttons, one would say encode and the other decode. and also a place in the gui where the final message would be printed and be copy-able by the user. would greatly appreciate it if someone could help me with this

  • Write the code for you? No! You should take a look at tutorials for Python GUI. Note that they are really easy & simple! You can make use of `PyQT`, `tkinter`, etc. Have a look at these tutorials - 1. http://sebsauvage.net/python/gui/ 2. http://www.tutorialspoint.com/python/python_gui_programming.htm 3. http://docs.python.org/3.3/library/tkinter.html – shad0w_wa1k3r Nov 12 '13 at 05:36
  • Thank you for the links i will have to check them out – user2784181 Nov 12 '13 at 11:04
  • i have looked at the recommended cites and i was wanting to make the GUI using glade. any tutorials on how to integrate the GUI made in glade into python – user2784181 Nov 12 '13 at 12:29
  • I think these might be helpful http://www.overclock.net/t/342279/tutorial-using-python-glade-to-create-a-simple-gui-application https://wiki.gnome.org/Glade/Tutorials http://www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm – shad0w_wa1k3r Nov 12 '13 at 12:54
  • Thank you for all of your help i was able to successfully create a GUI for my program, do you know of any way to convert it into a single exe file to be run on windows – user2784181 Nov 13 '13 at 11:09

1 Answers1

0

Following glade tutorials may help you.

  1. http://www.overclock.net/t/342279/tutorial-using-python-glade-to-create-a-simple-gui-application
  2. https://wiki.gnome.org/Glade/Tutorials
  3. http://www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm

As for converting the .py to an exe, you can use py2exe, please take a look at this answer - https://stackoverflow.com/a/14165470/2689986

Community
  • 1
  • 1
shad0w_wa1k3r
  • 12,955
  • 8
  • 67
  • 90