1. Trang chủ
  2. » Công Nghệ Thông Tin

Perl in a Nutshell phần 10 ppsx

72 284 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 72
Dung lượng 6,45 MB

Nội dung

closest Finds the item closest to the specified x,y coordinate. enclosed Finds all items that are completely enclosed within the specified bounding box. overlapping Finds all items that are even partially inside the specified bounding box. withtag Finds all items with the specified tag. gettags Retrieves a list of all tags associated with an item. type Determines the type of the specified item. focus Assigns the keyboard focus to the specified item. postscript Renders the canvas as PostScript. Options are: -colormap => \@colorcommand Specifies a PostScript command for setting color values. -colormode => mode Sets the mode to "color" (full color), "gray" (grayscale), or "mono" (black and white). -file => filename The name of the file to store the PostScript output. -fontmap => \@fontspec Specifies a font name and point size. -height => size The height of the area to print. -pageanchor => position The anchor position of the page. Values are "center" (default), "n", "e", "s", and "w". -pageheight => height The height of the printed page. [Chapter 18] 18.12 The Canvas Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_12.htm (10 of 12) [2/7/2001 10:38:00 PM] -pagewidth => width The width of the printed page. -pagex => x The x positioning point. -pagey => y The y positioning point. -rotate => boolean Whether to rotate to landscape orientation. Default is 0. -width => size The width of the area to print. -x => x The left edge of the canvas. -y => y The top edge of the canvas. scale Changes the scaling of the canvas or any individual items. For example, to scale the entire canvas to half its dimensions: $canvas->scale("all", 0, 0, .5, .5); xview Manipulates the canvas area in view. With no arguments, returns a list of two numbers between 0 and 1, defining what portion of the canvas is currently hidden on the left and right sides, respectively. With arguments, the function of xview changes: moveto Moves the specified fraction of the text to the left of the visible portion. scroll Scrolls the canvas left or right by the specified number of units or pages. Used primarily as a callback to a scrollbar; pressing on an arrow would move by units (characters), and pressing on the trough would move by pages. The number is either 1 or -1, to move forwards or backwards, respectively. yview Manipulates the canvas in view. With no arguments, returns a list of two numbers between 0 and 1, defining what portion of the canvas is currently hidden on the top and bottom, respectively. With arguments, its function changes: moveto [Chapter 18] 18.12 The Canvas Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_12.htm (11 of 12) [2/7/2001 10:38:00 PM] Moves the specified fraction of the canvas area to the top of the visible portion. scroll Scrolls the canvas up or down by the specified number of units or pages. Used primarily as a callback to a scrollbar; pressing on an arrow would move by units (lines), and pressing on the trough would move by pages. The number is either 1 or -1, to move forwards or backwards, respectively. 18.11 The Text Widget 18.13 The Scale Widget [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 18] 18.12 The Canvas Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_12.htm (12 of 12) [2/7/2001 10:38:00 PM] Chapter 18 Perl/Tk 18.13 The Scale Widget Create a "slider" widget representing a numeric value with the Scale method. $parent->Scale(options); The standard configuration options that apply to Scale are: -activebackground, -background, -bg, -borderwidth, -bw, -cursor, -font, -foreground, -fg, -highlightbackground, -highlightcolor, -highlightthickness, -relief, -state, -takefocus, and -width. Other options are: -bigincrement => amount The amount to change the slider when using large increments. Default is 0, which means 1/10 of the scale. -command => callback Pointer to a function that will be called for every incremental change in the slider. -digits => amount The number of digits to keep when converting from a number to a string. -from => n Low end of the scale (default = 0). -label => string The string to use as a label for the slider. -length => amount The length of the slider. -orient => direction The orientation of the slider. Values can be either 'vertical' (default) or 'horizontal'. -repeatdelay => milliseconds Determines the number of milliseconds to hold down an arrow before it will auto-repeat. Default is 300. [Chapter 18] 18.13 The Scale Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_13.htm (1 of 3) [2/7/2001 10:38:02 PM] -repeatinterval => milliseconds Determines the number of milliseconds between auto-repeats once it is started. Default is 100. -resolution => value The increments that the scale will change by (default = 1). -showvalue => boolean Whether to show the current value of the slider (default = 1). -sliderlength => amount The size of the slider. Default is 25 pixels. -tickinterval => n The number of "ticks" to display for the slider. Default is 0 (no ticks). -to => n The top value of the scale (default is 100). -troughcolor => color Changes the color of the trough. -variable => \$variable Assigns the value of the slider to the specified variable. 18.13.1 Scale Methods In addition to configure and cget, the following methods are defined for the Scale widget: get Returns the current value if given no arguments. If given x and y coordinates as the first and second arguments, returns the value of the scale at that position. set Assigns the value associated with the scale. coords Returns the x and y coordinates associated with the value given in the first argument. identify Returns "slider", "trough1", "trough2", or "", depending on which part of the scale corresponds to the given x, y coordinates. 18.12 The Canvas Widget 18.14 The Menubutton Widget [Chapter 18] 18.13 The Scale Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_13.htm (2 of 3) [2/7/2001 10:38:02 PM] [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 18] 18.13 The Scale Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_13.htm (3 of 3) [2/7/2001 10:38:02 PM] Chapter 18 Perl/Tk 18.14 The Menubutton Widget Create a menubutton with the Menubutton method. For example: $mainwindow->Menubutton(-text => "File", -menuitems => [ [ 'command' => "New", "-command" => \&newfile, "-underline" => 0 ], [ 'command' => "Open", "-command" => \&openfile, "-underline" => 0 ], "-", [ 'command' => "Save", "-command" => \&savefile, "-underline" => 0 ], [ 'command' => "SaveAs", "-command" => \&saveasfile, "-underline" => 4 ] ] ); The -menuitems option takes a list of lists describing the menu items. For each menu item, an embedded anonymous list describes the type of menu item, the label to use, and the action to take when it is selected along with any other options desired to configure the menu item. In this example, each of the menu items is the 'command' type, and we use the -command option for each item to point to the callback to execute when the menu item is selected. We also use the -underline option to enable the user to select a menu item using keystrokes. (The \[quotedbl]-" represents a separator between menu items.) In addition to 'command', other types of menus are: 'cascade' Embeds a cascade menu. 'checkbutton' Treats the menu item as a checkbutton. 'command' Executes a callback. 'radiobutton' Treats the menu item as a radiobutton. [Chapter 18] 18.14 The Menubutton Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_14.htm (1 of 4) [2/7/2001 10:38:06 PM] You can configure both the menu itself and the individual menu items. The configuration options that apply to Menubutton are: -activebackground, -activeforeground, -anchor, -background, -bg, -bitmap, -borderwidth, -bw, -cursor, -disabledforeground, -font, -foreground, -fg, -height, -highlightbackground, -highlightcolor, -highlightthickness, -image, -justify, -padx, -pady, -relief, -state, -takefocus, -underline, -width, and -wraplength. Other Menubutton options are: -indicatoron => boolean Determines whether or not to display an indicator. -menu => $menu Display the menu associated with $menu. -menuitems => list Specifies items to create in the menu as a list of lists. See the description at the beginning of this section. -tearoff => boolean Whether or not to allow the menu to be "torn off." Default is 1. -text => string Specifies the text to display as a label for the button. -textvariable => \$variable Points to the variable containing text to be displayed in the menubutton. Button text will change as $variable does. 18.14.1 Menu Item Options In addition to the menu itself, each individual menu item can be configured. The widget configuration options that apply to menu items are: -activebackground, -background, -bg, -bitmap, -font, -foreground, -fg, -image, -state, and -underline. Other options are: -accelerator Displays an accelerator key sequence for the menu item. The key sequence must be independently defined with a bind. -command => callback Pointer to a function that will be called when the menu item is selected. -indicatoron => boolean Determines whether or not to display an indicator. -label => string The string to use as a label for the menu item. -menu => $submenu For a cascade menu, points to the menu to embed. -offvalue => newvalue [Chapter 18] 18.14 The Menubutton Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_14.htm (2 of 4) [2/7/2001 10:38:06 PM] For a checkbutton, specifies the value used when the checkbutton is "off." -onvalue => newvalue For a checkbutton, specifies the value used when the checkbutton is "on." -selectcolor => color For a checkbutton or radiobutton, color of the indicator when "on." -selectimage => imgptr For a checkbutton or radiobutton, defines the image to be displayed instead of text when the radiobutton is "on". Ignored if -image is not used. -value => value For a radiobutton, sets $variable to the specified value when the radiobutton is selected (default is 1). -variable => \$variable Associates the value of the menu item to the specified variable. 18.14.2 Menubutton Methods In addition to configure and cget, the following methods are defined for Menubutton widgets: AddItems Adds menu items to the end of the menu. The arguments to AddItems are lists configuring each menu item, similar to the lists defined with the -menuitem option. $menubutton->AddItems(["command" => "Print", "-command" => \&printscreen ], ["command" => "Exit", "-command" => \&exitclean ]); command Adds a command item to the end of the menu. The above example could have read: $menubutton->command(-label => "Print", -command => \&printscreen); $menubutton->command(-label => "Exit", -command => \&exitclean); checkbutton Adds a checkbutton item to the end of the menu. $menubutton->checkbutton(-label => "Show Toolbar", [-variable => \$toolbar"); radiobutton Adds a radiobutton item to the end of the menu. $menubutton->radiobutton(-label => "Red", -variable => \$color"); $menubutton->radiobutton(-label => "Blue", -variable => \$color"); separator Adds a separator line to the end of a menu. cascade [Chapter 18] 18.14 The Menubutton Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_14.htm (3 of 4) [2/7/2001 10:38:06 PM] Adds a cascade item to the end of the menu. menu Returns a reference to the menu. entrycget Gets information on a menu entry given an index and option to query. entryconfigure Changes information on a specific menu item given an index. 18.13 The Scale Widget 18.15 The Menu Widget [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 18] 18.14 The Menubutton Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch18_14.htm (4 of 4) [2/7/2001 10:38:06 PM] [...]... displayed in the option menu -variable => \$variable Points to a variable containing a stored value, distinct from the value shown in the option menu 18.15 The Menu Widget 18.17 The Frame 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_16.htm... options are: -class => name The class associated with the frame -colormap => \$window Specifies another window to share the colormap with You can point to another window or use the value "new" to specify a new colormap Default is undef -label => string The string to use as a label for the frame "-labelPack Specifies options for the pack command -labelVariable => \$variable Specifies a variable containing... (creating/deleting/renaming) LAST_WRITE Any change to a file's last write time SECURITY Any security descriptor change SIZE Any change in a file's size The following methods are used on notification objects created by new: q close q reset q wait 19.2 Win32::Console 19.4 Win32::Eventlog [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl. .. Manage Windows NT services Win32::Shortcut Provide shell link interface The reference material for the Clipboard, Console, Internet, and Shortcut modules was graciously provided by Aldo Capini, author and maintainer of many Win32 modules (http://www.divinf.it/dada /perl/ ) The final section of this chapter describes OLE automation in Perl programs and details the Win32::OLE modules 19.1 Win32::Clipboard... window manager requested its current size state Returns "normal", "iconic", or "withdrawn", indicating the current state of the window title Changes the title at the top of the window transient Indicates to the window manager that the window is transient withdraw Makes the window non-visible 18.17 The Frame Widget VIII Win32 [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32... single entity $text = Win32::Clipboard::Get(); Win32::Clipboard::Set("blah blah blah"); Win32::Clipboard::Empty(); Alternatively, you can use the clipboard as an object with this syntax: $Clip = Win32::Clipboard(); $text = $Clip->Get(); $Clip->Set("blah blah blah"); $Clip->Empty(); VIII Win32 19.2 Win32::Console [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming... whether it is a hash or a scalar The following methods can be used on event log objects: q Backup q Read q Report q GetOldest q GetNumber q Clear 19.3 Win32::ChangeNotification 19.5 Win32::File [ 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/ch19_04.htm... Win32::Clipboard module allows you to manipulate the Windows clipboard You can use the clipboard as an object with the following syntax: $clip = Win32::Clipboard(); This functions as an implicit constructor If you include a text string as an argument, that text will be placed on the clipboard You can just use the package-qualified method names instead of the object syntax, since the clipboard is a. .. Win32::ChangeNotification [ 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/ch19_02.htm (3 of 3) [2/7/2001 10: 38:28 PM] [Chapter 19] 19.3 Win32::ChangeNotification Chapter 19 Win32 Modules and Extensions 19.3 Win32::ChangeNotification This... GetAttributes (filename, \$atts) Returns the attribute settings for file filename and saves them as the variable referenced by $atts, which will contain an ORed combination of one or more of the following values: ARCHIVE DIRECTORY HIDDEN NORMAL READONLY SYSTEM SetAttributes (filename, atts) Set the attributes for the file filename to the values contained in atts The attributes are given as an ORed combination of . 10: 38:02 PM] [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 18] 18.13 The Scale Widget http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch18_13.htm. forwards or backwards, respectively. 18.11 The Text Widget 18.13 The Scale Widget [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming. on a specific menu item given an index. 18.13 The Scale Widget 18.15 The Menu Widget [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl

Ngày đăng: 12/08/2014, 21:21