当前位置: 首页 > 工具软件 > Ruby/Tk > 使用案例 >

windows tcl/tk安装(塔卡)

黄弘新
2023-12-01

在Windows中,最简单的方法的Tcl / Tk的到你的机器是要安装“ActiveTcl”从ActiveState,其中包括TCL,传统知识,加上其他扩展库数分布。

In your web browser, go to www.activestate.com , and follow along the links to download the standard version of ActiveTcl for Windows.在Web浏览器,转到www.activestate.com,沿链接遵循下载ActiveTcl标准版本的Windows。 Make sure you're downloading an 8.5.x version, not an older 8.4.x version.确保您下载一个8.5.x版本,而不是旧的8.4.x版本。

Run the installer, and follow along.运行安装程序,并按照沿。 You'll end up with a fresh install of ActiveTcl, usually located in C:\Tcl.你会拥有一个新的安装ActiveTcl,通常位于C:\ Tcl的。 From a DOS command prompt, or the Start Menu's "Run..."从DOS命令提示符,或开始菜单的“运行...” command, you should then be able to run a Tcl/Tk 8.5 shell via:命令,你应该能够运行Tcl / Tk的8.5外壳通过:

% C:\Tcl\bin\wish85 %ç:\的Tcl \本\ wish85

 

This should pop up a small window titled "wish85", which will contain your application.这应该弹出一个小窗口,标题为“wish85”,其中将包含您的应用程序。 A second, larger window titled "Console" is where you can type in Tcl/Tk commands.第二,更大的窗口标题为“控制台”在这里,您可以输入Tcl / Tk的命令。 Type "exit" in the console window to exit. You may also want to add C:\Tcl\bin to your PATH environment variable.键入“exit在控制台窗口中退出”。您可能还需要添加C:\ Tcl的\ bin到你的PATH环境变量。

RubyTk is a binding that links against an existing but separate Tk library. RubyTk是有约束力的联系,对现有的但独立的塔卡库。 So, to get the latest version of Tk for Ruby, we're going to have to do two things, first download the latest 8.5.x Tcl/Tk version from ActiveState, and then compile Ruby to use it.因此,要获取最新塔卡的Ruby版本,我们将不得不做两件事,首先下载最新的8.5.x Tcl / Tk的从ActiveState版本,然后编译Ruby的使用它。

Install ActiveTcl安装ActiveTcl

The "ActiveTcl" distribution from ActiveState contains the latest Tk, as well as the latest version of Tcl (which Ruby's Tk bindings use internally to talk to Tk).在“ActiveTcl”从ActiveState分配包含最新的塔卡,以及Tcl的最新版本(Ruby的内部使用塔卡绑定交谈塔卡)。 In your web browser, go to www.activestate.com , and follow along the links to download the standard version of ActiveTcl for Windows.在Web浏览器,转到www.activestate.com,沿链接遵循下载ActiveTcl标准版本的Windows。 Again, make sure you're downloading an 8.5.x version, not an older 8.4.x version.同样,请确保你下载一个8.5.x版本,而不是旧的8.4.x版本。

Run the installer and ActiveTcl will be loaded onto your machine, in "C:\Tcl".运行安装程序并ActiveTcl将加载到你的机器,在“C:\ Tcl的”。

Compile Ruby编译红宝石

In this section, we'll describe how to compile Ruby using Visual C++ (usually available as part of Visual Studio).在本节中,我们将描述如何编译红宝石使用Visual C + +(通常作为Visual Studio的一部分提供)。

Yes, it can be done using tools like cygwin, but I still recommend doing it with Visual C++. This shouldn't be an issue even for the rabid "free software" types since they wouldn't touch a Windows machine anyway...是的,这是可以做到使用类似Cygwin的工具,但我还是推荐做它用Visual C + +。这是不应该即使是狂热的“自由软件”类型,因为他们不会触及Windows机器反正一个问题...

Compiling Ruby so that it finds the correct Tk distribution and so on is incredibly finicky, and depends on environment variables that have to be defined before compiling.编译红宝石,以便找到正确的Tk的分布等,是令人难以置信的挑剔,和有环境变量的定义取决于在编译之前。 If everything isn't just right, it will compile okay, but doing "require 'tk'" will fail.如果一切不仅是正确的,将编译好的,但是这样做“需要'传统知识'”将失败。

Install Visual C++安装Visual C + +

Make sure you have a version of Visual C++ installed on your machine, including the command line tools (eg nmake).请确保你有一个版本的Visual C + +在机器上安装,包括命令行工具(例如nmake)。 This can be done for example by installing Visual Studio.这可以例如通过安装Visual Studio。

Even fairly old versions (but at least 5.0) of Visual C++ should work.即使是小幅度(但至少有5.0)的Visual C + +旧版本应该工作。 As well, Microsoft does offer an "Express" edition of Visual C++ for free, which also works just fine.此外,微软也提供了一个“快速的Visual C 版”+ +自由,这也工作得很好。

Make sure the Visual C++ environment variables are set, and that the Visual C++ tools are in your PATH; this can normally be done by running the "vcvars32.bat" script that is installed as part of Visual C++ (depending on your system, you may need to use the "vcvarsall.bat" script instead).确保在Visual C + +环境变量设置,并在Visual C + +工具在您的路径,这通常可以通过运行“的vcvars32.bat”脚本是一部分的Visual C + +安装完成(取决于您的系统,您可能需要使用“vcvarsall.bat”脚本而不是)。

Download Ruby Source下载Ruby源

Go to www.ruby-lang.org and download the latest stable (1.8.x, not 1.9.x) source code version of Ruby.转到www.ruby - lang.org和下载最新的稳定(1.8.x,而不是1.9.x)Ruby的源代码版本。

Create a directory that will contain both the source and compiled version, eg "C:\ruby".创建一个目录将包含源和编译的版本,如的“C:\红宝石”。 Unpack the source into a subdirectory of that eg "C:\ruby\ruby187".解压缩源成子目录,例如的“C:\红宝石\ ruby187”。

The download will be in the form of a ".tar.gz" or ".tar.bz2" file; Winzip can unpack this for you.下载将在一个“。tar.gz”或形式“。tar.bz2保存”文件; WinZip可以为你解开这个。

Set Environment Variables设置环境变量

Open a command line, and execute the following DOS commands.打开命令行,并执行下面的DOS命令。 Again, this is so that when you compile Ruby it will find the appropriate version of Tcl/Tk on your system.这又是这样,当您编译红宝石会找到相应版本的Tcl / Tk的您的系统上。 We add these items to the beginning of each environment variable to ensure they are found before anything else that might already by on our paths.我们将这些项目每个环境开始变量,以确保他们在任何可能对我们已经找到其他途径。

set INCLUDE=c:\tcl\include;%INCLUDE%设置的INCLUDE = ç:\ TCL集团\包括:%包括% 
 set LIB=c:\ruby\lib;c:\tcl\lib;%LIB%设置LIB = ç:\红宝石\ lib;荤:\ TCL集团\ lib;%LIB% 
 set LIBPATH=c:\ruby\lib;c:\tcl\bin;c:\tcl\lib;%LIBPATH%设置LIBPATH = ç:\红宝石\ lib;荤:\ TCL集团\本;荤:\ TCL集团\ lib;%LIBPATH% 
 set PATH=c:\ruby\bin;c:\tcl\bin;%PATH%设置路径= C:\红宝石\本;荤:\ TCL集团\本;%路径% 
 set RUBYPATH=c:\ruby设置RUBYPATH = ç:\红宝石

You and your users will probably want most of these environment variables set to run your program, even after you've compiled Ruby.您和您的用户将可能需要一套运行程序,这些环境变量大多数,即使你已经编译红宝石。 If you later get errors, particularly when trying to do a "require 'tk'", checking these environment variables is a good first step at troubleshooting.如果您以后发现错误,特别是在试图做一个“需要'传统知识'”,检查这些环境变量是一个善于解决的第一步。

 

Compile and Install编译和安装

In the same command line window, type the following:在同一命令行窗口,键入以下内容:

cd \ruby\ruby187光盘\红宝石\ ruby187 
 win32\configure.bat --prefix=c:\ruby win32 \ configure.bat -前缀=荤:\红宝石 
 nmake nmake即可 
 nmake DESTDIR=c:\ruby install nmake即可了DESTDIR = ç:\ ruby的安装

To verify that everything worked, start up your newly compiled copy of 'irb' (which would have been installed in "c:\ruby\bin" which is on your PATH), and type:要确认一切正常工作,启动你的新编译的'副本内部评级'(将已在“安装在C:\红宝石\本”,这是你的路径),然后键入:

% require 'tk'需要'传统知识' 
 % Tk::TK_PATCHLEVEL塔卡::TK_PATCHLEVEL

 

The first line should load RubyTk; typically if there was a problem with compiling it would show up here.第一行应加载RubyTk;通常如果有一个编制,将在这里显示的问题。 The second line will return the version of Tk that you're running, which should be something like "8.5.2".第二行将返回塔卡的版本正在运行,应该像“8.5.2”。

For modern Tk programming using Perl, the "Tkx" module is highly recommended, and we'll be using that here.现代Tk编程使用Perl的“Tkx”模块强烈建议,我们将使用在这里。 The easiest way to get set up is to use the "ActivePerl" distribution from www.activestate.com .最简单的方法获取设置是使用“的ActivePerl”从www.activestate.com分配。

Install ActivePerl >= 5.10安装的ActivePerl“= 5.10

The "ActivePerl" distribution from ActiveState includes not only Perl, but also recent versions of Tk and Tcl (which Tkx uses internally to talk to Tk).在“你是ActivePerl”从ActiveState的分配不仅包括Perl的,但也塔卡和Tcl最新版本(其中Tkx内部使用的交谈塔卡)。 In your web browser, go to www.activestate.com , and follow along the links to download the standard version of ActivePerl.在Web浏览器,转到www.activestate.com,沿遵循的链接下载的是ActivePerl标准版本。

Run the installer and everything will be loaded onto your machine.运行安装程序,一切都将载入到您的机器。

To find out what version of Tk Perl and Tkx are using, run this from the command line:要了解什么样的Perl和Tkx塔卡正在使用的版本,运行在命令行是:

% perl -MTkx -e 'print Tkx::info("patchlevel");' %perl的- MTkx娥'打印Tkx::信息(“patchlevel”);'

 

We want this to be returning something like "8.5.4".我们希望这是返回如“8.5.4的东西”。

Versions of ActivePerl prior to 5.10 (and some of the first 5.10 builds) included earlier versions of Tcl/Tk (8.4.x rather than 8.5.x).在之前的ActivePerl版本5.10(和一些基础的第一个5.10),包括早期版本的Tcl / Tk的(8.4.x,而不是8.5.x)。 We therefore very highly recommend upgrading to at least ActivePerl 5.10, and verify that you do have Tk 8.5 or newer.因此,我们非常强烈建议升级到至少是ActivePerl 5.10,并确认您有塔卡8.5或更新版本。

Tkinter (and, since Python 3.1, ttk) are included with all standard Python distributions. Tkinter(和,因为Python 3.1,报警科技)中包括了所有标准的Python发行。 It is important that you use a version of Python supporting Tk 8.5 or greater, and ttk.重要的是,您使用的Python版本支持塔卡8.5或更高版本,并报警科技。 We recommend installing the "ActivePython" distribution from ActiveState, which includes everything you'll need.我们建议您安装“从ActiveState的ActivePython,其中包括您需要的一切”的分配。

In your web browser, go to www.activestate.com , and follow along the links to download the standard version of ActivePython for Windows.在Web浏览器,转到www.activestate.com,沿链接遵循下载的ActivePython标准版本的Windows。 Make sure you're downloading a 3.1 or newer version.确保您下载一个3.1或更新版本。

Run the installer, and follow along.运行安装程序,并按照沿。 You'll end up with a fresh install of ActivePython, usually located in C:\python31.你会拥有一个新安装的ActivePython,通常位于C:\ python31。 From a DOS command prompt, or the Start Menu's "Run..."从DOS命令提示符,或开始菜单的“运行...” command, you should then be able to run a Python shell via:命令,你应该能够运行一个Python外壳通过:

% C:\python31\python %ç:\ python31 \的python

 

This should give you the Python command prompt.这应该给您的Python命令提示符。 From the prompt, enter these two commands:从提示,输入这两个命令:

>>> import tkinter “”>“ 导入tkinter 
 >>> tkinter._test() “”“tkinter._test()

 

This should pop up a small window; the first line at the top of the window should say "This is Tcl/Tk version 8.5"; make sure it is not 8.4!这应该弹出一个小窗口,在窗口顶部的第一行应该说:“这是Tcl / Tk的8.5版”,以确保它不是8.4!

 类似资料: