def set_picture (self, image): """I.set_picture (...) -> None Sets the image to be displayed on the ImageLabel. The image can be either a valid pygame.Surface object or the path to an image file. If the argument is a file, the 'path' attribute will be set to the file path, otherwise it will be None. Raises a TypeError, if the passed argument is not a string, unicode or pygame.Surface. """ if image: if type (image) in (str, unicode): self._path = image self._picture = Image.load_image (image) elif isinstance (image, Surface): self._path = None self._picture = image else: raise TypeError ("image must be a string, unicode or a " \ "pygame.Surface") else: self._path = None self._picture = None self.dirty = True
def set_picture(self, image): """I.set_picture (...) -> None Sets the image to be displayed on the ImageMap. The image can be either a valid pygame.Surface object or the path to an image file. If the argument is a file, the 'path' attribute will be set to the file path, otherwise it will be None. Raises a TypeError, if the passed argument is not a string, unicode or pygame.Surface. """ if image: if type(image) in (str, unicode): self._path = image self._picture = Image.load_image(image) elif isinstance(image, Surface): self._path = None self._picture = image else: raise TypeError ("image must be a string, unicode or a " \ "pygame.Surface") else: self._path = None self._picture = None self.dirty = True
def create_imagelabel_view (): image = Image.load_image ("./image.png") table = Table (1, 3) table.spacing = 5 table.set_row_align (0, ALIGN_TOP) # Frame with the states. frm_states = _create_vframe ("States") for i, s in enumerate (STATE_TYPES): lbl = ImageLabel (image) if s == STATE_INSENSITIVE: lbl.sensitive = False else: lbl.state = s frm_states.add_child (lbl) table.add_child (0, 0, frm_states) # Frame with different padding. frm_padding = _create_vframe ("Padding") for i in xrange (5): lbl = ImageLabel (image) lbl.border = BORDER_FLAT lbl.padding = i * 2 frm_padding.add_child (lbl) table.add_child (0, 1, frm_padding) # Borders. frm_borders = _create_vframe ("Borders") for border in BORDER_TYPES: lbl = ImageLabel (image) lbl.border = border frm_borders.add_child (lbl) table.add_child (0, 2, frm_borders) return table
def __init__(self, filename, filetype): TextListItem.__init__(self, filename) if type(filetype) != int: raise TypeError("filetype must be an integer") self._filetype = filetype self._icon = None iconpath = base.GlobalStyle.engine.get_icon_path("16x16") if stat.S_ISDIR(filetype): self._icon = Image.load_image(os.path.join(iconpath, Icons16x16.FOLDER), True) elif stat.S_ISLNK(filetype): self._icon = Image.load_image(os.path.join(Icons16x16.ICONPATH, Icons16x16.FILE_LINK), True) elif stat.S_ISSOCK(filetype) or stat.S_ISFIFO(filetype): self._icon = Image.load_image(os.path.join(iconpath, Icons16x16.FILE_SOCKET), True) elif stat.S_ISCHR(filetype): self._icon = Image.load_image(os.path.join(iconpath, Icons16x16.FILE_CHAR), True) else: self._icon = Image.load_image(os.path.join(iconpath, Icons16x16.FILE), True)
def create_button_view (): states = ("STATE_NORMAL", "STATE_ENTERED", "STATE_ACTIVE", "STATE_INSENSITIVE") image = Image.load_image ("./image.png") table = Table (2, 2) table.spacing = 5 table.set_row_align (0, ALIGN_TOP) table.set_row_align (1, ALIGN_TOP) # Frame with the states. frm_states = _create_vframe ("States") for i, s in enumerate (states): btn = ImageButton (image) if STATE_TYPES[i] == STATE_INSENSITIVE: btn.sensitive = False else: btn.state = STATE_TYPES[i] btn.text = s frm_states.add_child (btn) table.add_child (0, 0, frm_states) # Frame with different padding. frm_padding = _create_vframe ("Padding") for i in xrange (4): btn = ImageButton (image) btn.padding = i * 2 frm_padding.add_child (btn) table.add_child (0, 1, frm_padding) # Mnemonics. frm_mnemonic = _create_vframe ("Mnemonics") btn = ImageButton (image) btn.text = "#Simple Mnemonic" btn2 = ImageButton (image) btn2.text = "#Activate using <ALT><Underlined Key>" frm_mnemonic.add_child (btn, btn2) table.add_child (1, 0, frm_mnemonic) # Multiline labeled ImageButton frm_multiline = _create_vframe ("Multiline label") button = ImageButton (image) button.text = "Multiple lines\nwith a #mnemonic" button.child.multiline = True frm_multiline.add_child (button) table.add_child (1, 1, frm_multiline) return table
radioTable.add_child(0, i, TblLabel) # Add them to the table, row 1 graphRateBtn = RadioButton(None, radiogroup) # Create the radio buttons graphRateBtn.connect_signal(SIG_TOGGLED, updateRate) if i == 5: radiogroup = graphRateBtn # Assign the radio button(s) to the group radioTable.add_child(1, i, graphRateBtn) # Add them to the table, row 2 frame_2.add_child(radioTable) # Add the radio button table to the frame # ====================================================================================================================== # Setup Still Image Controls frame_3 = HFrame( Label("Still Imaging")) # Create a frame for the still image controls frame_3.minsize = (214, 117) frame_3.topleft = 3, 263 stillBox = Box(190, 90) image_1 = guiImage.load_image("camera2.png") stillSnapBtn = ImageButton(image_1) stillSnapBtn.connect_signal(SIG_CLICKED, stillShot) # Entry box for output file name lbl_5 = Label("Save Filename:") fileOutEntry = Entry('ThermImg_1.png') fileOutEntry.minsize = (100, 5) stillSnapBtn.topleft = 0, 0 lbl_5.topleft = 60, 0 fileOutEntry.topleft = 60, 15 lbl_14 = Label("Open Image Filename:") lbl_14.topleft = 3, 42 fileEntry = Entry() fileEntry.minsize = 120, 5 fileEntry.topleft = 3, 60
# Image.load_image () usage example. import pygame, pygame.locals from ocempgui.draw import Image # Initialize the drawing window. pygame.init() screen = pygame.display.set_mode((120, 100)) screen.fill((250, 250, 250)) pygame.display.set_caption("Image.load_image ()") # Load an image and blit it on the screen. image = Image.load_image("./image.png") screen.blit(image, (10, 10)) # Show anything. pygame.display.flip() # Wait for input. while not pygame.event.get([pygame.locals.QUIT]): pass