def __init__(self, parent, name, x, y, radius, color='red'): Sprite.__init__(self, parent) self.name = name self.name2 = name + "-2" self.x = x self.y = y self.oldx = x self.oldy = y self.radius = radius self.color = color self.xspeed = random.random() * 30 self.yspeed = random.random() * 30 self.gravity = 2 self.drag = .85 self.bounce = .9 self.dragging = False self.canvas = self.parent.components.bufOff ## self.canvas = self.parent.panel x, y = self.canvas.position ## self.parent.components[name] = {'type':'Image', 'name':name, 'file':'wing1.png', 'position':(self.x + x, self.y + y)} ## self.image = self.parent.components[name] ## self.image.visible = True ## self.parent.components[self.name2] = {'type':'Image', 'name':self.name2, 'file':'wing2.png', 'position':(self.x + x, self.y + y)} ## self.image2 = self.parent.components[self.name2] ## self.image.visible = False self.image = graphic.Bitmap('wing1.png') self.image2 = graphic.Bitmap('wing2.png') self.count = 0
def openFile(self): wildcard = "All files (*.*)|*.*" result = dialog.openFileDialog(None, "Import which file?", '', '', wildcard) if result.accepted: path = result.paths[0] os.chdir(os.path.dirname(path)) try: self.filename = path filename = os.path.splitext(os.path.basename(path))[0] if filename.startswith('spiro'): items = filename[5:].split('_') comp = self.components comp.sldFixedCircleRadius.value = int(items[0]) comp.sldMovingCircleRadius.value = int(items[1]) comp.sldMovingCircleOffset.value = int(items[2]) comp.btnColor.backgroundColor = eval(items[3]) comp.chkDarkCanvas.checked = int(items[4]) if items[5] == 'L': comp.radDrawingStyle.stringSelection = 'Lines' else: comp.radDrawingStyle.stringSelection = 'Points' comp.sldRevolutionsInRadians.value = int(items[6]) self.setSliderLabels() bmp = graphic.Bitmap(self.filename) self.components.bufOff.drawBitmap(bmp, (0, 0)) except IOError, msg: pass
def __init__(self, aParent, aResource): self._bitmap = graphic.Bitmap(aResource.file, aResource.size) self._file = aResource.file self._size = tuple(aResource.size) w = aResource.size[0] if w == -2: w = self._bitmap.getWidth() h = aResource.size[1] if h == -2: h = self._bitmap.getHeight() size = (w, h) #size = wx.Size( self._bitmap.GetWidth(), self._bitmap.GetHeight() ) ##if aResource.border == 'transparent': ## mask = wx.MaskColour(self._bitmap, wxBLACK) ## self._bitmap.SetMask(mask) StaticBitmap.__init__(self, aParent, widget.makeNewId(aResource.id), self._bitmap.getBits(), aResource.position, size, style=wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS, name=aResource.name) widget.Widget.__init__(self, aParent, aResource) wx.EVT_WINDOW_DESTROY(self, self._OnDestroy) self._bindEvents(event.WIDGET_EVENTS)
def openFile(self): result = dialog.openFileDialog(None, "Import which file?") if result.accepted: path = result.paths[0] os.chdir(os.path.dirname(path)) self.filename = path bmp = graphic.Bitmap(self.filename) self.components.bufOff.drawBitmap(bmp, (0, 0))
def __init__(self, aParent, aResource): self._border = aResource.border self._bitmap = graphic.Bitmap(aResource.file, aResource.size) self._file = aResource.file # KEA # should we modify aResource instead? # is aResource used again later? #print aResource.size self._size = tuple(aResource.size) w = aResource.size[0] if w == -2: w = self._bitmap.getWidth() h = aResource.size[1] if h == -2: h = self._bitmap.getHeight() size = (w, h) # KEA need to check all possible variations on Win32 and Linux if aResource.border == '3d': style = wx.BU_AUTODRAW # Windows specific ?! else: style = 0 wx.BitmapButton.__init__(self, aParent, widget.makeNewId(aResource.id), self._bitmap.getBits(), aResource.position, size, style | wx.NO_FULL_REPAINT_ON_RESIZE | wx.CLIP_SIBLINGS, name=aResource.name) widget.Widget.__init__(self, aParent, aResource) wx.EVT_WINDOW_DESTROY(self, self._OnDestroy) # KEA 2001-07-27 # we should only be binding this if the button # is supposed to be transparent # so maybe a setTransparent method with true/false parameter? # keep track of _transparent attribute and if _transparent # then unbind EVT_ERASE_BACKGROUND # before changing _transparent to false # same kind of thing for setTransparent # don't rebind events if not needed # getTransparent as well # setBorder/getBorder #print aResource.border if aResource.border == 'transparent': #print aResource.border wx.EVT_ERASE_BACKGROUND(self, lambda evt: None) #adapter = button.ButtonEventBinding(self) #adapter.bindEvents() self._bindEvents(event.WIDGET_EVENTS + (button.ButtonMouseClickEvent, ))
def openFile(self, path, slideNumber=None): self.filename = path if htmlFile(self.filename): title = os.path.split(self.filename)[-1] else: if self.zip: data = self.zip.read(self.filename) tags = EXIF.process_file(StringIO(data)) log.debug("Getting %s from zip file" % self.filename) self.bmp = graphic.Bitmap() self.bmp.setImageBits(wx.ImageFromStream(StringIO(data))) else: if not os.path.exists(self.filename): return f = open(self.filename, 'rb') tags = EXIF.process_file(f) f.close() log.debug("Getting %s from file" % self.filename) self.bmp = graphic.Bitmap(self.filename) if tags.has_key('Image Orientation'): # the repr() is something like # (0x0112) Short=8 @ 54 # but the str() is just 1, 8, etc. orientation = int(str(tags['Image Orientation'])) else: orientation = 1 log.debug('Image Orientation: %d' % orientation) if tags.has_key('Thumbnail Orientation'): log.debug('Thumbnail Orientation: %s' % tags['Thumbnail Orientation']) if orientation == 8: # need to rotate the image # defaults to clockwise, 0 means counter-clockwise self.bmp.rotate90(0) elif orientation == 6: self.bmp.rotate90(1) size = self.bmp.getSize() title = os.path.split(self.filename)[-1] + " %d x %d" % size if slideNumber is not None: title = title + " Slide: %d of %d" % (slideNumber + 1, len(self.fileList)) self.title = title self.displayFile()
def openFile(self, path): #os.chdir(os.path.dirname(path)) self.filename = path f = open(path, 'rb') tags = EXIF.process_file(f) f.close() if tags.has_key('Image Orientation'): # the repr() is something like # (0x0112) Short=8 @ 54 # but the str() is just 1, 8, etc. orientation = int(str(tags['Image Orientation'])) #print path #print 'Image Orientation: %d' % orientation #print 'Thumbnail Orientation: %s' % tags['Thumbnail Orientation'] else: orientation = 1 self.bmp = graphic.Bitmap(self.filename) if orientation == 8: # need to rotate the image # defaults to clockwise, 0 means counter-clockwise #print "rotating" self.bmp.rotate90(0) elif orientation == 6: self.bmp.rotate90(1) size = self.bmp.getSize() title = os.path.split(self.filename)[-1] + " %d x %d" % size self.title = title # if either dimension of the image is beyond our maximum # then display the image fit to the screen if size[0] > self.maximumSize[0] or size[1] > self.maximumSize[1]: self.fitToScreen() else: self.displayFile()
def _setFile(self, aFile): self._file = aFile self._setBitmap(graphic.Bitmap(aFile))