[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r24042: {arm} Presenting a text input field with python 2.5 and lower cras (arm/trunk/src/util)
Author: atagar
Date: 2011-01-06 16:03:50 +0000 (Thu, 06 Jan 2011)
New Revision: 24042
Modified:
arm/trunk/src/util/panel.py
Log:
Presenting a text input field with python 2.5 and lower crashed (caught by murble)
Modified: arm/trunk/src/util/panel.py
===================================================================
--- arm/trunk/src/util/panel.py 2011-01-06 05:30:19 UTC (rev 24041)
+++ arm/trunk/src/util/panel.py 2011-01-06 16:03:50 UTC (rev 24042)
@@ -2,6 +2,7 @@
Wrapper for safely working with curses subwindows.
"""
+import sys
import traceback
import curses
from threading import RLock
@@ -358,8 +359,16 @@
# Displays the text field, blocking until the user's done. This closes the
# text panel and returns userInput to the initial text if the user presses
- # escape.
- textbox = curses.textpad.Textbox(inputSubwindow, True)
+ # escape. Insert mode is available in Python 2.6+, before that the
+ # constructor only accepted a subwindow argument as per:
+ # https://trac.torproject.org/projects/tor/ticket/2354
+
+ majorVersion, minorVersion = sys.version_info[:2]
+ if majorVersion == 2 and minorVersion >= 6:
+ textbox = curses.textpad.Textbox(inputSubwindow, True)
+ else:
+ textbox = curses.textpad.Textbox(inputSubwindow)
+
userInput = textbox.edit(lambda key: _textboxValidate(textbox, key)).strip()
if textbox.lastcmd == curses.ascii.BEL: userInput = None