mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Define execfile, file, long, raw_input, xrange for Python 3
This commit is contained in:
@@ -7,7 +7,6 @@ Sample-launcher application.
|
||||
# Python 2/3 compatibility
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
# local modules
|
||||
from common import splitfn
|
||||
@@ -17,11 +16,11 @@ import webbrowser
|
||||
from glob import glob
|
||||
from subprocess import Popen
|
||||
|
||||
if PY3:
|
||||
import tkinter as tk
|
||||
try:
|
||||
import tkinter as tk # Python 3
|
||||
from tkinter.scrolledtext import ScrolledText
|
||||
else:
|
||||
import Tkinter as tk
|
||||
except ImportError:
|
||||
import Tkinter as tk # Python 2
|
||||
from ScrolledText import ScrolledText
|
||||
|
||||
|
||||
@@ -116,10 +115,10 @@ class App:
|
||||
name = self.demos_lb.get( self.demos_lb.curselection()[0] )
|
||||
fn = self.samples[name]
|
||||
loc = {}
|
||||
if PY3:
|
||||
exec(open(fn).read(), loc)
|
||||
else:
|
||||
execfile(fn, loc)
|
||||
try:
|
||||
execfile(fn, loc) # Python 2
|
||||
except NameError:
|
||||
exec(open(fn).read(), loc) # Python 3
|
||||
descr = loc.get('__doc__', 'no-description')
|
||||
|
||||
self.linker.reset()
|
||||
|
||||
Reference in New Issue
Block a user