mainwindow.html
来自「perl教程」· HTML 代码 · 共 119 行
HTML
119 行
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>Tk::MainWindow - Root widget of a widget tree</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>
<body>
<script>writelinks('__top__',2);</script>
<h1><a>Tk::MainWindow - Root widget of a widget tree</a></h1>
<p><a name="__index__"></a></p>
<!-- INDEX BEGIN -->
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#methods">METHODS</a></li>
<li><a href="#missing">MISSING</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
</ul>
<!-- INDEX END -->
<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Tk::MainWindow - Root widget of a widget tree</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
<span class="keyword">use</span> <span class="variable">Tk</span><span class="operator">;</span>
</pre>
<pre>
<span class="keyword">my</span> <span class="variable">$mw</span> <span class="operator">=</span> <span class="variable">MainWindow</span><span class="operator">-></span><span class="variable">new</span><span class="operator">(</span> <span class="operator">...</span> <span class="variable">options</span> <span class="operator">...</span> <span class="operator">);</span>
</pre>
<pre>
<span class="keyword">my</span> <span class="variable">$this</span> <span class="operator">=</span> <span class="variable">$mw</span><span class="operator">-></span><span class="variable">ThisWidget</span> <span class="operator">-></span> <span class="keyword">pack</span> <span class="operator">;</span>
<span class="keyword">my</span> <span class="variable">$that</span> <span class="operator">=</span> <span class="variable">$mw</span><span class="operator">-></span><span class="variable">ThatWidget</span><span class="operator">;</span>
<span class="operator">...</span>
</pre>
<pre>
<span class="variable">MainLoop</span><span class="operator">;</span>
</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>Perl/Tk applications (which have windows associated with them) create
one or more <strong>MainWindow</strong>s which act as the containers and parents
of the other widgets.</p>
<p><strong>Tk::MainWindow</strong> is a special kind of <a href="../../lib/Tk/Toplevel.html">Toplevel</a> widget. It is
the root of a widget tree. Therefore <code>$mw->Parent</code> returns
<a href="../../lib/Pod/perlfunc.html#item_undef"><code>undef</code></a>.</p>
<p>The default title of a MainWindow is the basename of the script
(actually the Class name used for options lookup, i.e. with basename
with inital caps) or 'Ptk' as the fallback value. If more than one MainWindow is created
or several instances of the script are running at the same time the
string <code>" #n"</code> is appended where the number <a href="../../lib/Pod/perlguts.html#item_n"><code>n</code></a> is set to get
a unique value.</p>
<p>Unlike the standard Tcl/Tk's wish, perl/Tk allows you to create
several MainWindows. When the <em>last</em> <strong>MainWindow</strong> is destroyed
the Tk eventloop exits (the eventloop is entered with the call of
<code>MainLoop</code>). Various resources (bindings, fonts, images, colors) are
maintained or cached for each MainWindow, so each MainWindow consumes more
resources than a Toplevel. However multiple MainWindows can make sense when
the user can destroy them independently.</p>
<p>
</p>
<hr />
<h1><a name="methods">METHODS</a></h1>
<p>You can apply all methods that a <a href="../../lib/Tk/Toplevel.html">Toplevel</a> widget accepts.</p>
<p>The method <em>$w</em>-><strong>MainWindow</strong> applied to any widget will return the
<strong>MainWindow</strong> to which the widget belongs (the MainWindow belongs to itself).</p>
<p>
</p>
<hr />
<h1><a name="missing">MISSING</a></h1>
<p>Documentation is incomplete.
Here are <em>some</em> missing items that should be explained in
more detail:</p>
<ul>
<li>
<p>The new mechanism for MainWindows is slightly different to
other widgets.</p>
</li>
<li>
<p>There no explanation about what resources are bound
to a MainWindow (e.g., ClassInit done per MainWindow)</p>
</li>
<li>
<p>Passing of command line options to override or augment
arguments of the <code>new</code> method (see <a href="../../lib/Tk/CmdLine.html">the Tk::CmdLine manpage</a>).</p>
</li>
</ul>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p><a href="../../lib/Tk/Toplevel.html">Tk::Toplevel</a>
<a href="../../lib/Tk/CmdLine.html">Tk::CmdLine</a></p>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?