我已经让 tkinter 在 Windows 上编译(在 Windows 8 64 位上进行了测试,但我相信它也可以在 Windows 7 上运行)。
以下是我采取的步骤:
安装 Microsoft Visual Studio C++ 2008 SP1 速成版
**KS:可在此处获得:http: //go.microsoft.com/ ?linkid=7729279
安装 TclTk 8.5(ActiveTcl 社区版 8.5.13)
**KS:如果您安装了 pypy 32 位,请确保安装 32 位版本。
解压 pypy-c-jit-latest-win32(或 2.0 beta 之一)
下载http://python-distribute.org/distribute_setup.py
运行 pypy.exe Distribute_setup.py
下载并解压https://bitbucket.org/pypy/tkinter/get/default.zip
修改pypy-tkinter/setup.py如下:
将“c:/tcl”替换为用于 ActiveTcl 的安装位置,将“c:/pypy-c-jit-latest-win32”替换为 pypy 的安装位置
更改库以使用它们的 Windows 文件名,并引用 pypy 中包含的“python27”库:(我的条目如下所示)
library_dirs=["c:/tcl/lib", "c:/pypy-c-jit-latest-win32/include"]
include_dirs=["c:/tcl/include", "c:/pypy-c-jit-latest-win32/include"]
libraries=["tk85", "tcl85", "python27"]
从 pypy-tkinter 目录运行 pypy.exe setup.py install。它应该编译并安装 site-packages\tkinter_pypy-0.1-py2.7-win32.egg。
注意:我还将 Python 2.7.3 (CPython) 安装中的“tcl”文件夹复制到包含 pypy.exe 可执行文件的文件夹中。
我刚刚在我的 pypy 安装上运行了 lib-tk\test\runtktests.py,结果如下:
testLoadTk (test_tkinter.test_loadtk.TkLoadTest) ... skipped 'No $DISPLAY set.'
testLoadTkFailure (test_tkinter.test_loadtk.TkLoadTest) ... ok
test_search (test_tkinter.test_text.TextTest) ... ok
test_horizontal_range (test_ttk.test_extensions.LabeledScaleTest) ... ok
test_initialization (test_ttk.test_extensions.LabeledScaleTest) ... ok
test_resize (test_ttk.test_extensions.LabeledScaleTest) ... ok
test_variable_change (test_ttk.test_extensions.LabeledScaleTest) ... ok
test_widget_destroy (test_ttk.test_extensions.LabeledScaleTest) ... FAIL
test_initialization (test_ttk.test_extensions.OptionMenuTest) ... ok
test_menu (test_ttk.test_extensions.OptionMenuTest) ... ok
test_widget_destroy (test_ttk.test_extensions.OptionMenuTest) ... FAIL
test_convert_stringval (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_dict_from_tcltuple (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_format_elemcreate (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_format_layoutlist (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_format_mapdict (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_format_optdict (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_list_from_layouttuple (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_list_from_statespec (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_script_from_settings (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_val_or_dict (test_ttk.test_functions.InternalFunctionsTest) ... ok
test_multivalues (test_ttk.test_functions.TclObjsToPyTest) ... ok
test_nosplit (test_ttk.test_functions.TclObjsToPyTest) ... ok
test_unicode (test_ttk.test_functions.TclObjsToPyTest) ... ok
test_configure (test_ttk.test_style.StyleTest) ... ok
test_layout (test_ttk.test_style.StyleTest) ... ok
test_lookup (test_ttk.test_style.StyleTest) ... ok
test_map (test_ttk.test_style.StyleTest) ... ok
test_theme_use (test_ttk.test_style.StyleTest) ... ok
test_identify (test_ttk.test_widgets.WidgetTest) ... ok
test_widget_state (test_ttk.test_widgets.WidgetTest) ... ok
test_invoke (test_ttk.test_widgets.ButtonTest) ... ok
test_invoke (test_ttk.test_widgets.CheckbuttonTest) ... ok
test_invoke (test_ttk.test_widgets.RadiobuttonTest) ... ok
test_postcommand (test_ttk.test_widgets.ComboboxTest) ... ok
test_values (test_ttk.test_widgets.ComboboxTest) ... ok
test_virtual_event (test_ttk.test_widgets.ComboboxTest) ... ok
test_bbox (test_ttk.test_widgets.EntryTest) ... ok
test_identify (test_ttk.test_widgets.EntryTest) ... ok
test_revalidation (test_ttk.test_widgets.EntryTest) ... ok
test_validation (test_ttk.test_widgets.EntryTest) ... ok
test_validation_options (test_ttk.test_widgets.EntryTest) ... ok
test_add (test_ttk.test_widgets.PanedwindowTest) ... ok
test_forget (test_ttk.test_widgets.PanedwindowTest) ... ok
test_insert (test_ttk.test_widgets.PanedwindowTest) ... ok
test_pane (test_ttk.test_widgets.PanedwindowTest) ... ok
test_sashpos (test_ttk.test_widgets.PanedwindowTest) ... ok
test_custom_event (test_ttk.test_widgets.ScaleTest) ... ok
test_get (test_ttk.test_widgets.ScaleTest) ... ok
test_set (test_ttk.test_widgets.ScaleTest) ... FAIL
test_add_and_hidden (test_ttk.test_widgets.NotebookTest) ... ok
test_forget (test_ttk.test_widgets.NotebookTest) ... ok
test_index (test_ttk.test_widgets.NotebookTest) ... ok
test_insert (test_ttk.test_widgets.NotebookTest) ... ok
test_select (test_ttk.test_widgets.NotebookTest) ... ok
test_tab (test_ttk.test_widgets.NotebookTest) ... ok
test_tab_identifiers (test_ttk.test_widgets.NotebookTest) ... ok
test_tabs (test_ttk.test_widgets.NotebookTest) ... ok
test_traversal (test_ttk.test_widgets.NotebookTest) ... ok
test_bbox (test_ttk.test_widgets.TreeviewTest) ... ok
test_children (test_ttk.test_widgets.TreeviewTest) ... ok
test_column (test_ttk.test_widgets.TreeviewTest) ... ok
test_delete (test_ttk.test_widgets.TreeviewTest) ... ok
test_detach_reattach (test_ttk.test_widgets.TreeviewTest) ... ok
test_exists (test_ttk.test_widgets.TreeviewTest) ... ok
test_focus (test_ttk.test_widgets.TreeviewTest) ... ok
test_heading (test_ttk.test_widgets.TreeviewTest) ... ok
test_heading_callback (test_ttk.test_widgets.TreeviewTest) ... skipped 'skipping pending resolution of Issue #10734'
test_index (test_ttk.test_widgets.TreeviewTest) ... ok
test_insert_item (test_ttk.test_widgets.TreeviewTest) ... ok
test_set (test_ttk.test_widgets.TreeviewTest) ... ok
test_tag_bind (test_ttk.test_widgets.TreeviewTest) ... ok
test_tag_configure (test_ttk.test_widgets.TreeviewTest) ... ok
======================================================================
FAIL: test_widget_destroy (test_ttk.test_extensions.LabeledScaleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\pypy-c-jit-latest-win32\lib-python\2.7\lib-tk\test\test_ttk\test_extensions.py", line 25, in test_widget_destroy
self.assertRaises(Tkinter.TclError, x.tk.globalgetvar, var)
AssertionError: TclError not raised
======================================================================
FAIL: test_widget_destroy (test_ttk.test_extensions.OptionMenuTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\pypy-c-jit-latest-win32\lib-python\2.7\lib-tk\test\test_ttk\test_extensions.py", line 202, in test_widget_destroy
self.assertRaises(Tkinter.TclError, optmenu.tk.globalgetvar, name)
AssertionError: TclError not raised
======================================================================
FAIL: test_set (test_ttk.test_widgets.ScaleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\pypy-c-jit-latest-win32\lib-python\2.7\lib-tk\test\test_ttk\test_widgets.py", line 522, in test_set
self.assertEqual(self.scale.get(), max + 10)
AssertionError: 6.0 != 11.0
----------------------------------------------------------------------
Ran 73 tests in 2.214s