Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

inputhook: make stdin_ready() function reusable

Move it from lib.inputhookwx to lib.inputhook, as the former
module can only be loaded if wx itself is available.
  • Loading branch information...
commit 3d1dca86b3aae006f55623ec6032e84c116fff18 1 parent 80acde0
@cboos cboos authored
Showing with 18 additions and 15 deletions.
  1. +16 −0 IPython/lib/inputhook.py
  2. +2 −15 IPython/lib/inputhookwx.py
View
16 IPython/lib/inputhook.py
@@ -15,9 +15,15 @@
#-----------------------------------------------------------------------------
import ctypes
+import os
import sys
import warnings
+if os.name == 'posix':
+ import select
+elif sys.platform == 'win32':
+ import msvcrt
+
#-----------------------------------------------------------------------------
# Constants
#-----------------------------------------------------------------------------
@@ -36,6 +42,16 @@
# Utility classes
#-----------------------------------------------------------------------------
+def stdin_ready():
+ if os.name == 'posix':
+ infds, outfds, erfds = select.select([sys.stdin],[],[],0)
+ if infds:
+ return True
+ else:
+ return False
+ elif sys.platform == 'win32':
+ return msvcrt.kbhit()
+
#-----------------------------------------------------------------------------
# Main InputHookManager class
View
17 IPython/lib/inputhookwx.py
@@ -24,26 +24,13 @@
from timeit import default_timer as clock
import wx
-if os.name == 'posix':
- import select
-elif sys.platform == 'win32':
- import msvcrt
+from IPython.lib.inputhook import stdin_ready
+
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
-def stdin_ready():
- if os.name == 'posix':
- infds, outfds, erfds = select.select([sys.stdin],[],[],0)
- if infds:
- return True
- else:
- return False
- elif sys.platform == 'win32':
- return msvcrt.kbhit()
-
-
def inputhook_wx1():
"""Run the wx event loop by processing pending events only.
Please sign in to comment.
Something went wrong with that request. Please try again.