1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Kỹ thuật lập trình >

[Chapter 18] 18.3 Common Widget Configuration Options

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.44 MB, 72 trang )


[Chapter 18] 18.3 Common Widget Configuration Options



of a bitmap file (with @ in front of the path). Applicable widgets: Button, Checkbutton, Label,

Menubutton, Optionmenu, Radiobutton

-borderwidth => amount

-bd => amount

Changes the width of the edge drawn around the widget. Applicable widgets: Button, Canvas,

Checkbutton, Entry, Frame, Label, Listbox, Menu, Menubutton, Optionmenu, Radiobutton, Scale,

Scrollbar, Text, Toplevel

-cursor => 'cursorname'

Mouse cursor will change to specified cursor when over the widget. Applicable widgets: Button,

Canvas, Checkbutton, Entry, Frame, Label, Listbox, Menu, Menubutton, Optionmenu,

Radiobutton, Scale, Scrollbar, Text, Toplevel

-disabledforeground => color

Sets the color of the text when the widget is disabled. Applicable widgets: Button, Checkbutton,

Menu, Menubutton, Optionmenu, Radiobutton

-exportselection => boolean

Determines whether selected text is exported to the window system's clipboard. (For a listbox,

-exportselection => 1 means two listboxes cannot have selections at the same time.)

Applicable widgets: Entry, Listbox, Text

-font => 'fontname'

Changes the font of all the text on the widget to fontname. Applicable widgets: Button,

Checkbutton, Entry, Label, Listbox, Menu, Menubutton, Optionmenu, Radiobutton, Scale, Text

-foreground => color

-fg => color

Changes the text color to color. Applicable widgets: Button, Checkbutton, Entry, Label, Listbox,

Menu, Menubutton, Optionmenu, Radiobutton, Scale, Text

-height => amount

Specifies the height of the widget. amount represents a number of characters if text is displayed,

or a screen distance if an image or bitmap is displayed. Applicable widgets: Button, Canvas,

Checkbutton, Frame, Label, Listbox, Menubutton, Optionmenu, Radiobutton, Text, Toplevel

-highlightbackground => color

Sets the color of a non-focus rectangle. Applicable widgets: Button, Canvas, Checkbutton, Entry,

Frame, Label, Listbox, Menubutton, Optionmenu, Radiobutton, Scale, Scrollbar, Text, Toplevel

-highlightcolor => color

Sets the color of the focus rectangle. Applicable widgets: Button, Canvas, Checkbutton, Entry,

Frame, Label, Listbox, Menubutton, Optionmenu, Radiobutton, Scale, Scrollbar, Text, Toplevel

-highlightthickness => amount



http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_03.htm (2 of 5) [2/7/2001 10:37:26 PM]



[Chapter 18] 18.3 Common Widget Configuration Options



Sets the thickness of the black box around the widget that indicates focus. Applicable widgets:

Button, Canvas, Checkbutton, Entry, Frame, Label, Listbox, Menubutton, Optionmenu,

Radiobutton, Scale, Scrollbar, Text, Toplevel

-image => $imgptr

Uses an image instead of text. $imgptr is a pointer to a Photo or Image object made using a GIF

or PPM file. For example:

$image = $mainwindow->Photo(-file => "image.gif");

$mainwindow->Button(-image => $arrow,

-command => sub {exit})->pack;

Applicable widgets: Button, Checkbutton, Label, Menubutton, Optionmenu, Radiobutton

-insertbackground => color

Sets the color of the insert cursor. Applicable widgets: Canvas, Entry, Text

-insertborderwidth => amount

Sets the width of the insert cursor's border. Applicable widgets: Canvas, Entry, Text

-insertofftime => milliseconds

Defines the amount of time the insert cursor is "off." Applicable widgets: Canvas, Entry, Text

-insertontime => milliseconds

Defines the amount of time the insert cursor is "on." Applicable widgets: Canvas, Entry, Text

-insertwidth => amount

The width of the insert corner (default = 2 pixels). Applicable widgets: Canvas, Entry, Text

-justify => side

Justifies text against the specified side. side can be 'left', 'right', or 'center'.

Applicable widgets: Button, Checkbutton, Entry, Label, Menubutton, Optionmenu, Radiobutton

-padx => amount

Adds extra space to left and right of the widget inside the widget edge. Applicable widgets:

Button, Checkbutton, Label, Menubutton, Optionmenu, Radiobutton, Text

-pady => amount

Adds extra space to top and bottom of the widget inside the widget edge. Applicable widgets:

Button, Checkbutton, Label, Menubutton, Optionmenu, Radiobutton, Text

-relief => type

Changes the type of edges drawn around the widget. Values for type are 'flat', 'groove',

'raised', 'ridge', and 'sunken'. Applicable widgets: Button, Canvas, Checkbutton,

Entry, Frame, Label, Listbox, Menu, Menubutton, Optionmenu, Radiobutton, Scale, Scrollbar,

Text, Toplevel

-selectbackground => color



http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_03.htm (3 of 5) [2/7/2001 10:37:26 PM]



[Chapter 18] 18.3 Common Widget Configuration Options



Determines the background color of selected text in the entry widget. Applicable widgets: Canvas,

Entry, Listbox, Text

-selectborderwidth => amount

Determines the width of the selection highlight's border. Applicable widgets: Canvas, Entry,

Listbox, Text

-selectforeground => color

Determines the text color of selected text in the entry widget. Applicable widgets: Canvas, Entry,

Listbox, Text

-state => state

Sets the state of responsiveness of the widget. Values for state are 'normal', 'disabled',

and 'active'. (disabled makes it not respond.) Applicable widgets: Button, Checkbutton,

Entry, Menubutton, Optionmenu, Scale, Text

-takefocus => focus

Determines whether the widget gets focus. Values for focus are 0 (the widget will never get the

focus), 1 (the widget always gets the focus), and the null string ("") (which lets the application

decide). Applicable widgets: Button, Canvas, Checkbutton, Entry, Frame, Label, Listbox, Menu,

Menubutton, Optionmenu, Scale, Scrollbar, Text, Toplevel

-underline => n

Underlines the nth character in the text string. Allows keyboard input via that character when the

widget has the focus. Applicable widgets: Button, Checkbutton, Label, Menubutton, Optionmenu,

Radiobutton

-width => amount

Width of the widget, represented in characters if text displayed, or as a screen distance if an image

or bitmap is displayed. Applicable widgets: Button, Canvas, Checkbutton, Frame, Label, Listbox,

Menubutton, Optionmenu, Radiobutton, Scale, Scrollbar, Text, Toplevel

-wraplength => amount

Defines the maximum amount of text to be displayed on one line. Applicable widgets: Button,

Checkbutton, Label, Menubutton, Optionmenu, Radiobutton

-xscrollcommand => callback

Assigns a callback to use when scrolling back and forth. Applicable widgets: Canvas, Entry,

Listbox, Text

-yscrollcommand => callback

Determines a command to run when scrolled in the vertical direction. Applicable widgets: Canvas,

Listbox, Text



18.2 Geometry Managers



18.4 The Button Widget



http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_03.htm (4 of 5) [2/7/2001 10:37:26 PM]



[Chapter 18] 18.3 Common Widget Configuration Options



[ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl

Programming | Perl Cookbook ]



http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_03.htm (5 of 5) [2/7/2001 10:37:26 PM]



[Chapter 18] 18.4 The Button Widget



Chapter 18

Perl/Tk



18.4 The Button Widget

Create a simple button with the Button method:

$parentwidget->Button (options)

The standard configuration options that apply to Button are: -activebackground,

-activeforeground, -anchor, -background, -bg, -bitmap, -borderwidth, -bd,

-cursor, -disabledforeground, -font, -foreground, -fg, -height,

-highlightbackground, -highlightcolor, -highlightthickness, -image,

-justify, -padx, -pady, -relief, -state, -takefocus, -underline, -width, and

-wraplength.

Other options are:

-command => callback

Pointer to a function that will be called when the button is pressed.

-text => 'text'

Defines the text string displayed on the button. See also -textvariable.

-textvariable => \$variable

Points to the variable containing text to be displayed in the button. Button text will change as

$variable does.



18.4.1 Button Methods

In addition to configure and cget, the following methods can be used for Button:

flash

Causes the button to flash from the normal to active state colors.

invoke

Invokes the callback command as if the button were clicked.



http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_04.htm (1 of 2) [2/7/2001 10:37:28 PM]



[Chapter 18] 18.4 The Button Widget



18.3 Common Widget

Configuration Options



18.5 The Checkbutton Widget



[ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl

Programming | Perl Cookbook ]



http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_04.htm (2 of 2) [2/7/2001 10:37:28 PM]



Xem Thêm
Tải bản đầy đủ (.pdf) (72 trang)

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×