def main(
  title,
  shell,
  world,
  text=None,
  text_file_name=None,
  initial=None,
  save_file=None,
  commit_thing=None,
  ):

  tk = Tk()
  tk.title(title)
  t = shell(tk, text_file_name)
  w = world(
    t.text,
    t.view,
    initial=initial,
    save_file=save_file,
    commit_thing=commit_thing,
    )

  if text is None:
    stack, dictionary = w.getCurrentState()
    words = (name for name, value in items(dictionary))
    text = 'Words: ' + ' '.join(words) + '\n'

  t.text.insert(END, text)

  tk.mainloop()
Exemple #2
0
def listwords(interpreter):
    '''
    Print the list of words in the dictionary to stdout.
    '''
    dictionary = interpreter[1]
    for name, func in items(dictionary):
        print name
    print
    return interpreter
def listwords(interpreter):
    '''
    Print the list of words in the dictionary to stdout.
    '''
    dictionary = interpreter[1]
    for name, func in items(dictionary):
        print name
    print
    return interpreter
Exemple #4
0
def rebalance((stack, dictionary)):
    '''
    This "rebalances" a dictionary.  It makes it more efficient to access
    commands in the dictionary if you've added a lot of new ones.

    It's a good idea to use this command before creating a pickle to
    save so that the saved pickle's dictionary is already balanced.
    '''
    dictionary = fill_tree((), items(dictionary))
    return stack, dictionary
def rebalance((stack, dictionary)):
    '''
    This "rebalances" a dictionary.  It makes it more efficient to access
    commands in the dictionary if you've added a lot of new ones.

    It's a good idea to use this command before creating a pickle to
    save so that the saved pickle's dictionary is already balanced.
    '''
    dictionary = fill_tree((), items(dictionary))
    return stack, dictionary
def list_words(dictionary):
    words = sorted(name for name, value in items(dictionary))
    return 'Words: ' + '   '.join(words) + '\n'
def list_words(dictionary):
  words = sorted(name for name, value in items(dictionary))
  return 'Words: ' + '   '.join(words) + '\n'
            self._flushers.append(lambda n=stream.fileno(): os.fsync(n))


# This is a proof-of-concept frame for interacting with
# a xerblin interpreter.
if __name__ == "__main__":

    from xerblin.btree import items

    # Create a world with the basic view function.
    w = HistoryListWorld(view0)

    # For convenience print out the commands in the dictionary at
    # startup.
    dictionary = w.getCurrentState()[1]
    print ' '.join(name for name, value in items(dictionary))
    print

    # Drop into an event loop.
    while True:
        
        try:
            # Get a command and split it up.
            command = raw_input('> ').split()
        
        except EOFError:
            # User is done, quit.
            break
        
        # Run the command, the World object handles all the details for
        # us.
Exemple #9
0
            self._flushers.append(lambda n=stream.fileno(): os.fsync(n))


# This is a proof-of-concept frame for interacting with
# a xerblin interpreter.
if __name__ == "__main__":

    from xerblin.btree import items

    # Create a world with the basic view function.
    w = HistoryListWorld(view0)

    # For convenience print out the commands in the dictionary at
    # startup.
    dictionary = w.getCurrentState()[1]
    print ' '.join(name for name, value in items(dictionary))
    print

    # Drop into an event loop.
    while True:

        try:
            # Get a command and split it up.
            command = raw_input('> ').split()

        except EOFError:
            # User is done, quit.
            break

        # Run the command, the World object handles all the details for
        # us.
Exemple #10
0
        top.title(T.get(last_line, END).strip())

        T.pack(expand=1, fill='both')
        T.see(END)


def isNumerical(s):
    try:
        float(s)
    except ValueError:
        return False
    return True


if __name__ == "__main__":
    from pigeon.xerblin.btree import items
    from pigeon.xerblin.world import HistoryListWorld, view0

    class World(TextViewerWorldMixin, HistoryListWorld, object):
        pass

    t = TextViewerWidget()
    w = World(t, view0)

    stack, dictionary = w.getCurrentState()
    words = 'Words: ' + ' '.join(name for name, value in items(dictionary))
    t.insert(END, words)
    t.pack()
    t.mainloop()
        T.pack(expand=1, fill='both')
        T.see(END)


def isNumerical(s):
    try:
        float(s)
    except ValueError:
        return False
    return True


if __name__ == "__main__":
    from pigeon.xerblin.btree import items
    from pigeon.xerblin.world import HistoryListWorld, view0

    class World(TextViewerWorldMixin, HistoryListWorld, object):
        pass

    t = TextViewerWidget()
    w = World(t, view0)

    stack, dictionary = w.getCurrentState()
    words = 'Words: ' + ' '.join(
        name
        for name, value in items(dictionary)
        )
    t.insert(END, words)
    t.pack()
    t.mainloop()