Fig. 11.1 in Microsoft Office Integrating QR Code JIS X 0510 in Microsoft Office Fig. 11.1

How to generate, print barcode using .NET, Java sdk library control with example project source code free download:

Fig. 11.1 use none none creator todisplay none in none iPad ScrolledList none none Box used to select an image. (Part 1 of 2.). Page 391 Friday, December 14, 2001 2:03 PM 11 . Graphical User Interface Components: Part 2 23 24 25 26 none for none 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51. # create scr olled list box with vertical scrollbar self.listBox = Pmw.ScrolledListBox( self, items = images, listbox_height = 3, vscrollmode = "static", selectioncommand = self.

switchImage ) self.listBox.pack( side = LEFT, expand = YES, fill = BOTH, padx = 5, pady = 5 ) self.

display = Label( self, image =[ 0 ] ) self.display.

pack( padx = 5, pady = 5 ) def switchImage( self ): """Change image in Label to current selection""" # get tuple containing index of selected list item chosenPicture = self.listBox.curselection() # configure label to display selected image if chosenPicture: choice = int( chosenPicture[ 0 ] ) self.

display.config( image =[ choice ] ) def main(): images = [ "bug1.

gif", "bug2.gif", "travelbug.gif", "buganim.

gif" ] ImageSelection( images ).mainloop() if __name__ == "__main__": main(). Fig. 11.1 ScrolledList Box used to select an image. (Part 2 of 2.).

Line 5 impor none for none ts module Pmw. In line 14, function Pmw.initialise initializes Pmw.

The call to function initialise enables the program to access the full functionality of the Pmw module. Testing and Debugging Tip 11.1.

A program th at uses module Pmw but does not invoke Pmw.initialise is not able to access the full functionality of module Pmw..

Method main none none (lines 45 48) creates a list of image filenames, images, that the program passes to the constructor method of class ImageSelection (lines 7 43). Lines 21 22 create a list of PhotoImage instances from the filenames in images. Lines 25 . Page 392 Friday, December 14, 2001 2:03 PM Graphical User Interface Components: Part 2 11 . 27 create a none none new ScrolledListBox component called listBox. The items option contains the list of items to be displayed in listBox. When the user selectes an entry in listBox with the left-mouse button, the method assigned to selectioncommand (switchImage) executes.

Note that the vscrollmode option for listBox is set to "static" (line 26). This setting ensures that the vertscrollbar subcomponent of the ScrolledListBox (a Tkinter Scrollbar) is always present. Other possible values are "dynamic" (which displays the vertscrollbar only if necessary) and "none" (which never displays the vertscrollbar).

The default value is "dynamic". Line 31 creates a Label to display the selected image. By default, the label contains the image of the first item in the list.

When the user selects an item in listBox, method switchImage (lines 34 43) changes the image. The call to ScrolledListBox method curselection (line 38) returns a tuple that contains one string. This string corresponds to the index of the user-selected listbox item.

For example, if the user selects the bug1.gif image (the first image in the list), method curselection returns ("0"). If the tuple is not empty, Tkinter method config changes the Label component s image attribute to the user-selected image.

The ScrolledListBox component also provides method getcurselection that returns a tuple of the currently selected values, rather than indices of those values. By default, the user can select only one option in a ScrolledListbox component. A multiple-selection list enables the user to select several items from a ScrolledListbox.

A ScrolledListbox s listbox_selectmode option determines how many items a user may select. Possible values are SINGLE, BROWSE (default), MULTIPLE and EXTENDED. Value SINGLE allows the user to select one item at a time.

Value BROWSE is the same as SINGLE, except that the user also may move the selection by dragging the mouse, rather than simply clicking an item. Value MULTIPLE allows the user to select multiple options, by clicking on multiple values. Value EXTENDED is similar to BROWSE, except that dragging the mouse selects multiple values.

To select a contiguous range of items in a multiple-selection list, select the first item then press the Shift key while selecting the last item in the range. To select multiple, nonconsecutive items, press the Ctrl key while selecting each item. To deselect an item, hold the Ctrl key while clicking the item a second time.

A multiple-selection list does not have a specific event associated with making multiple selections. Normally, an external event generated by another GUI component (e.g.

, a Button) specifies when the multiple selections in a ScrolleListbox should be processed. We illustrate an example of an external event in the next section. Look-and-Feel Observation 11.

1. Often an ext ernal event determines when a program should process the selected items in a multiple-selection ScrolledListBox..
Copyright © . All rights reserved.