[Pywikipedia-svn] SVN: [7213] trunk/pywikipedia/userinterfaces/wxpython_interface.py

alexsh at svn.wikimedia.org alexsh at svn.wikimedia.org
Sat Sep 5 12:45:15 UTC 2009


Revision: 7213
Author:   alexsh
Date:     2009-09-05 12:45:15 +0000 (Sat, 05 Sep 2009)

Log Message:
-----------
wxpython_interface.py: fix UI().input() and UI.inputChoice().

Modified Paths:
--------------
    trunk/pywikipedia/userinterfaces/wxpython_interface.py

Modified: trunk/pywikipedia/userinterfaces/wxpython_interface.py
===================================================================
--- trunk/pywikipedia/userinterfaces/wxpython_interface.py	2009-09-05 11:04:37 UTC (rev 7212)
+++ trunk/pywikipedia/userinterfaces/wxpython_interface.py	2009-09-05 12:45:15 UTC (rev 7213)
@@ -3,7 +3,7 @@
 
 import sys; sys.path.append('..')
 
-import config, re, sys
+import config, re, sys, terminal_interface
 import wx
 
 app = wx.App()
@@ -18,7 +18,9 @@
         question mark.
         """
         # comma at the end means "don't print newline"
-        print text.encode(config.console_encoding, 'replace'),
+        #print text.encode(config.console_encoding, 'replace'),
+        terminal_interface.UI().output(text, toStdout)
+        
 
     def input(self, question, password = False):
         """
@@ -29,13 +31,16 @@
         """
         # TODO: hide input if password = True
         
-        answer = wx.TextEntryDialog( None, question, question, '' )
+        if password:
+            answer = wx.PasswordEntryDialog( None, question, '','')
+        else:
+            answer = wx.TextEntryDialog( None, question, '', '' )
         answer.ShowModal()
-        print answer
-#tkSimpleDialog.askstring('title', question)
-        return answer or ''
+        print answer.GetValue()
+        #tkSimpleDialog.askstring('title', question)
+        return answer.GetValue() or ''
 
-    def inputChoice(self, question, options, hotkeys):
+    def inputChoice(self, question, options, hotkeys, default = None):
         goodAnswer = False
         while not goodAnswer:
             for i in range(len(options)):
@@ -49,7 +54,10 @@
                     options[i] = '%s [%s]' % (option, hotkey)
 
             prompt = '%s (%s)' % (question, ', '.join(options))
-            answer = self.input(prompt)
+            answer = wx.TextEntryDialog(None, prompt, question, '')
+            answer.ShowModal()
+            answer = answer.GetValue()
+            
             if answer.lower() in hotkeys or answer.upper() in hotkeys:
                 return answer
 





More information about the Pywikipedia-svn mailing list