# Anthony Kawecki # How To Make Almost Anything, Fall 2015 # 12/12/15 #give user interface window #allowed to type in a string of characters and hit enter #sends a string of characters to the thing #ascii value of character: ord('a') = 97 #go from value to character: chr(97)=a #48-57 is 0-9 #65-90 is A-Z #psi # # =58 # $ =59 # . =60 # ! =61 # ' '= 62 # ? = 63 # @ = 64 #so use a charcter list of 48-91 #The resulting index list should index from 0-43, to ease with spots on the machine import sys from Tkinter import * funkyList=['#', '$', '.', '!', ' '] AlphabetLength = 44 alphabet = {} #Creates a dictionary with keys equal to a list of indeces and values equal to their correlating characters #returns the dictionary def createAlphabet(): placeInFunky = 0 for i in xrange(48, 92): if i >57 and i<63: alphabet[i]=funkyList[placeInFunky] placeInFunky+=1 else: alphabet[i]=chr(i) return alphabet #print createAlphabet() #value from users input is e1.get() #show_entry_fields is called when the button called "Submit" is pressed #It prints the string the user enters along with the list of correlating indices for each character in the string #It returns the list of correlating indeces to the splitFlap cards for the string def show_entry_fields(): listIndexs = [] #build your dictionary alphabet = createAlphabet() user_input= e1.get() #go through each character in the string inputted by the user for character in user_input: #go through the alphabet keys for char in alphabet: #if the value at your key is equal to your character, you've found your index, zero it as necessary and append it to your list val = alphabet[char] if character == val: listIndexs.append(char-48) listIndexs.append(0) print"Entry: %s" % (e1.get())+",", listIndexs return listIndexs #Creating the GUI master = Tk() Label(master, text="Please only use capitol Letters, numbers, space, #, $, .,[, and ! \n \n would you like to print in Split-Flap?").grid(row=0) e1 = Entry(master) e1.grid(row=0, column=1) Button(master, text='Quit', command=master.quit).grid(row=3, column=0, sticky=W, pady=4) Button(master, text='Submit', command=show_entry_fields).grid(row=3, column=1, sticky=W, pady=4) mainloop( ) ########## C Psuedocode ############### #own creation of steps, this will depend on the size of the flap machine #int step_forward(){ # step_cw(); # step_cw(); # // or however many steps you would like it to move forward (unidirectional) #} #currentIndex = 0 where you are now when you start the logic #indexs = returned from Python program #for(i=0; i