2016-10-12 8 views
1

/usr/lib/perl5/vendor_perlに ":0" /5.22/x86_64-cygwin-threads/Tk/MainWindow.pmライン53 MainWindow->新しい()のコードがある6私のUIデザインでPerl Tkを使用し始めています。perlで小さなコードを作成し、次のエラーが発生しました

./PerlUI.plラインで:あなたが必要

#!/usr/bin/perl -w 

use strict; 
use Tk; 

my $mw=MainWindow->new; 
$mw->geometry("200x100"); 
$mw->title("Hello World!!"); 
$mw->Label(-text=>"Hello World")->pack(); 
$mw->Button(-text=>"Close",-command=>sub{exit})->pack(); 
MainLoop; 
+1

我々はssr1012コード@ /分析 – Jens

+0

に設定されていないように、端末cgywinはbashに取り組ん – ssr1012

+0

を確認するため、最小限のコードに必要なあなたは何X11がインストールされていないか、DISPLAY変数が – BrainsOfSteel

答えて

2

最初にXを開始してください。

perl hello_world_tk.pl 
couldn't connect to display ":0" at /usr/lib/perl5/vendor_perl/5.22/i686- cygwin-threads-64int/Tk/MainWindow.pm line 53. 
MainWindow->new() at hello_world_tk.pl line 6. 

Xを起動してXを起動すると、新しいウィンドウが開き、スクリプトが実行されます。

X & 

Vendor: The Cygwin/X Project 
Release: 1.18.4.0 
OS: CYGWIN_NT-6.1 EAPB8CA3AA75D7E 2.6.0(0.304/5/3) 2016-08-31 14:27 i686 
OS: Windows 7 Service Pack 1 [Windows NT 6.1 build 7601] (Win32) 
Package: version 1.18.4-1 built 2016-07-22 

winInitializeScreenDefaults - primary monitor w 1280 h 1024 
winInitializeScreenDefaults - native DPI x 96 y 96 
XWin was started with the following command line: 

X 

.... more X output 

# Now run your script 

perl hello_world_tk.pl 

Hello World

+0

ありがとうございました....... u r a diamond – BrainsOfSteel

関連する問題