📜  PyGTK-入门课程

📅  最后修改于: 2020-11-08 07:47:03             🧑  作者: Mango


输入小部件是单行文本输入小部件。如果输入的文本长于窗口小部件的分配,窗口小部件将滚动以使光标位置可见。

可以使用此类的set_visibility()方法以密码模式转换输入字段。输入的文本替换为invisible_char()方法选择的字符,默认为’*’。

Entry类具有以下构造函数-

gtk.Entry(max = 0)

在此,max表示字符中输入字段的最大长度。该参数采用数值(0-65536)。

下表显示了Entry类的重要方法-

S.NO Methods and Description
1

set_visibility(visible)

If false, the contents are obscured by replacing the characters with the default invisible character — ‘*’

2

set_invisible_char(char)

The default ‘*’ characters in the entry field are replaced by char

3

set_max_length(x)

This sets the “max-length” property to the value of x. (0-65536)

4

set_text(str)

This sets the “text” property to the value of str. The string in str replaces the current contents of the entry.

5

get_text()

This returns the value of the “text” property which is a string containing the contents of the entry.

6

set_alignment()

This sets the “xalign” property to the value of xalign. set_alignment() controls the horizontal positioning of the contents in the Entry field.

条目小部件发出以下信号-

activate This is emitted when the entry is activated either by user action or programmatically with the gtk.Widget.activate() method.
backspace This is emitted when the Backspace key is entered from the keyboard.
copy-clipboard This is emitted when the selection text in the entry is copied to the clipboard.
cut-clipboard This is emitted when the selection in the entry is cut and placed in the clipboard.
paste-clipboard This is emitted when the contents of the clipboard are pasted into the entry.