📄 gtklabel.html
字号:
<a name="id3454426"></a><h3><a name="gtk-label-new"></a>gtk_label_new ()</h3><a class="indexterm" name="id3454438"></a><pre class="programlisting"><a class="link" href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* gtk_label_new (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *str);</pre><p>Creates a new label with the given text inside it. You canpass <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to get an empty label widget.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>str</code></em> :</span></p></td><td> The text of the label</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the new <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3454518"></a><h3><a name="gtk-label-set-text"></a>gtk_label_set_text ()</h3><a class="indexterm" name="id3454531"></a><pre class="programlisting">void gtk_label_set_text (<a class="link" href="GtkLabel.html" title="GtkLabel">GtkLabel</a> *label, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *str);</pre><p>Sets the text within the <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a> widget. It overwrites any text thatwas there before. </p><p>This will also clear any previously set mnemonic accelerators.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>label</code></em> :</span></p></td><td> a <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>str</code></em> :</span></p></td><td> The text you want to set</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3454623"></a><h3><a name="gtk-label-set-attributes"></a>gtk_label_set_attributes ()</h3><a class="indexterm" name="id3454636"></a><pre class="programlisting">void gtk_label_set_attributes (<a class="link" href="GtkLabel.html" title="GtkLabel">GtkLabel</a> *label, <ahref="/usr/share/gtk-doc/html/pango/pango-Text-Attributes.html#PangoAttrList">PangoAttrList</a> *attrs);</pre><p>Sets a <ahref="/usr/share/gtk-doc/html/pango/pango-Text-Attributes.html#PangoAttrList"><span class="type">PangoAttrList</span></a>; the attributes in the list are applied to thelabel text. The attributes set with this function will be ignoredif the <a class="link" href="GtkLabel.html#GtkLabel--use-underline"><span class="type">"use-underline"</span></a>" or <a class="link" href="GtkLabel.html#GtkLabel--use-markup"><span class="type">"use-markup"</span></a> propertiesare set to <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>label</code></em> :</span></p></td><td> a <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>attrs</code></em> :</span></p></td><td> a <ahref="/usr/share/gtk-doc/html/pango/pango-Text-Attributes.html#PangoAttrList"><span class="type">PangoAttrList</span></a></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3454762"></a><h3><a name="gtk-label-set-markup"></a>gtk_label_set_markup ()</h3><a class="indexterm" name="id3454775"></a><pre class="programlisting">void gtk_label_set_markup (<a class="link" href="GtkLabel.html" title="GtkLabel">GtkLabel</a> *label, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *str);</pre><p>Parses <em class="parameter"><code>str</code></em> which is marked up with the <ahref="/usr/share/gtk-doc/html/pango/PangoMarkupFormat.html">Pango text markup language</a>, setting thelabel's text and attribute list based on the parse results. If the <em class="parameter"><code>str</code></em> isexternal data, you may need to escape it with <ahref="/usr/share/gtk-doc/html/glib/glib-Simple-XML-Subset-Parser.html#g-markup-escape-text"><code class="function">g_markup_escape_text()</code></a> or<ahref="/usr/share/gtk-doc/html/glib/glib-Simple-XML-Subset-Parser.html#g-markup-printf-escaped"><code class="function">g_markup_printf_escaped()</code></a>:</p><div class="informalexample"><pre class="programlisting">char *markup;markup = g_markup_printf_escaped ("<span style=\"italic\">%s</span>", str);gtk_label_set_markup (GTK_LABEL (label), markup);g_free (markup);</pre></div><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>label</code></em> :</span></p></td><td> a <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>str</code></em> :</span></p></td><td> a markup string (see <ahref="/usr/share/gtk-doc/html/pango/PangoMarkupFormat.html">Pango markup format</a>)</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3454921"></a><h3><a name="gtk-label-set-markup-with-mnemonic"></a>gtk_label_set_markup_with_mnemonic ()</h3><a class="indexterm" name="id3454935"></a><pre class="programlisting">void gtk_label_set_markup_with_mnemonic (<a class="link" href="GtkLabel.html" title="GtkLabel">GtkLabel</a> *label, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *str);</pre><p>Parses <em class="parameter"><code>str</code></em> which is marked up with the <ahref="/usr/share/gtk-doc/html/pango/PangoMarkupFormat.html">Pango text markup language</a>,setting the label's text and attribute list based on the parse results.If characters in <em class="parameter"><code>str</code></em> are preceded by an underscore, they are underlinedindicating that they represent a keyboard accelerator called a mnemonic.</p><p>The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using <a class="link" href="GtkLabel.html#gtk-label-set-mnemonic-widget"><code class="function">gtk_label_set_mnemonic_widget()</code></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>label</code></em> :</span></p></td><td> a <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>str</code></em> :</span></p></td><td> a markup string (see <ahref="/usr/share/gtk-doc/html/pango/PangoMarkupFormat.html">Pango markup format</a>)</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3455060"></a><h3><a name="gtk-label-set-pattern"></a>gtk_label_set_pattern ()</h3><a class="indexterm" name="id3455073"></a><pre class="programlisting">void gtk_label_set_pattern (<a class="link" href="GtkLabel.html" title="GtkLabel">GtkLabel</a> *label, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *pattern);</pre><p>The pattern of underlines you want under the existing text within the<a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a> widget. For example if the current text of the label says"FooBarBaz" passing a pattern of "___ ___" will underline"Foo" and "Baz" but not "Bar".</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>label</code></em> :</span></p></td><td>The <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a> you want to set the pattern to.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>pattern</code></em> :</span></p></td><td>The pattern as described above.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3455164"></a><h3><a name="gtk-label-set-justify"></a>gtk_label_set_justify ()</h3><a class="indexterm" name="id3455177"></a><pre class="programlisting">void gtk_label_set_justify (<a class="link" href="GtkLabel.html" title="GtkLabel">GtkLabel</a> *label, <a class="link" href="gtk-Standard-Enumerations.html#GtkJustification">GtkJustification</a> jtype);</pre><p>Sets the alignment of the lines in the text of the label relative toeach other. <a class="link" href="gtk-Standard-Enumerations.html#GTK-JUSTIFY-LEFT:CAPS"><code class="literal">GTK_JUSTIFY_LEFT</code></a> is the default value when thewidget is first created with <a class="link" href="GtkLabel.html#gtk-label-new"><code class="function">gtk_label_new()</code></a>. If you instead wantto set the alignment of the label as a whole, use<a class="link" href="GtkMisc.html#gtk-misc-set-alignment"><code class="function">gtk_misc_set_alignment()</code></a> instead. <a class="link" href="GtkLabel.html#gtk-label-set-justify"><code class="function">gtk_label_set_justify()</code></a> has noeffect on labels containing only a single line.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>label</code></em> :</span></p></td><td> a <a class="link" href="GtkLabel.html" title="GtkLabel"><span class="type">GtkLabel</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>jtype</code></em> :</span></p></td><td> a <a class="link" href="gtk-Standard-Enumerations.html#GtkJustification"><span class="type">GtkJustification</span></a></td></tr></tbody>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -