Следуя советам Брайана, я смог решить методы Move_Up () и Move_Down () следующим образом. Он работает с использованием Python 3.1.3 или 2.6.6 в Mac OS X.
#swap this line with the line above it
def Move_Up():
text.config(state='normal')
# get text on current and previous lines
lineText = text.get("insert linestart", "insert lineend")
prevLineText = text.get("insert linestart -1 line", "insert -1 line lineend")
# delete the old lines
text.delete("insert linestart -1 line", "insert -1 line lineend")
text.delete("insert linestart", "insert lineend")
# insert lines in swapped order
text.insert("insert linestart -1 line", lineText)
text.insert("insert linestart", prevLineText)
#text.config(state='disabled')
#swap this line with the line below it
def Move_Down():
text.config(state='normal')
# get text on current and next lines
lineText = text.get("insert linestart", "insert lineend")
nextLineText = text.get("insert +1 line linestart", "insert +1 line lineend")
# delete text on current and next lines
text.delete("insert linestart", "insert lineend")
text.delete("insert +1 line linestart", "insert +1 line lineend")
# insert text in swapped order
text.insert("insert linestart", nextLineText)
text.insert("insert linestart + 1 line", lineText)
#text.config(state='disabled')
РЕДАКТИРОВАТЬ: Обратите внимание, что при наличии только одной строки текста Move_Up()
добавит этот текст к этой строке. И Move_Down()
ничего не делает, если есть только одна строка.