python - Generating consecutive bitmaps with wxPython trouble -


well, while don't consider myself experienced programmer, when comes multimedia applications, had image viewer sort of program displays images fullscreen, , images change when users press <- or -> arrows.

the general idea make listbox images contained in folder (imgs) shown, , when double click or hits return new, fullscreen frame generated containing, @ first, image selected in listbox after user hits arrows images change in conecutive order, in regular image viewer.

at beginning, when first 15 - 20 images generated, goes well, after that, although program still works intermediary, unpleasant , highly unwanted, effect appears between image generations, images got generated displayed on screen , after right, consecutive image appears. on first apparitions effect barelly noticeble, after while takes longer , longer between generations.

here's code runs when double click on listbox entry:

def lbclick(self, eve): frm = wx.frame(none, -1, '') frm.showfullscreen(true) self.sel = self.lstb.getselection() # getting selection listbox def pressk(eve): keys = eve.getkeycode() if keys == wx.wxk_left: self.sel = self.sel - 1 if self.sel < 0: self.sel = len(self.chk) - 1 imgs() # invocking function made displaying fullscreen images when left arrow key pressed elif keys == wx.wxk_right: self.sel = self.sel + 1 if self.sel > len(self.chk) - 1: self.sel = 0 imgs() # doing same right arrow elif keys == wx.wxk_escape: frm.destroy() eve.skip() frm.bind(wx.evt_char_hook, pressk) def imgs(): # building function imgsl = self.chk[self.sel] itm = wx.image(str('imgs/{0}'.format(imgsl)), wx.bitmap_type_jpeg).converttobitmap() # obtaining name of image stored in list self.chk mar = itm.size # because not images landscaped had figure method rescale them after height dimension, common images frsz = frm.getsize() marx = float(mar[0]) mary = float(mar[1]) val = frsz[1] / mary vsize = int(mary * val) hsize = int(marx * val) panl = wx.panel(frm, -1, size = (hsize, vsize), pos = (frsz[0] / 2 - hsize / 2, 0)) # making panel container panl.setbackgroundcolour('#000000') imag = wx.image(str('imgs/{0}'.format(imgsl)), wx.bitmap_type_jpeg).scale(hsize, vsize, quality = wx.image_quality_normal).converttobitmap() def destr(eve): # unprofessionaly trying destroy panel container when new image generated hopeing unvanted effect, previous generated images disappear. doesn't. keycd = eve.getkeycode() if keycd == wx.wxk_left or keycd == wx.wxk_right: try: panl.destroy() except: pass eve.skip() panl.bind(wx.evt_char_hook, destr) # end of futile tries if vsize > hsize: # if image portrait instead of landscaped have put black image container, otherwise in background previous image remain, if use refresh() on container (the black bitmap named fundal) intermed = wx.image('./res/null.jpg', wx.bitmap_type_jpeg).scale(frsz[0], frsz[1]).converttobitmap() fundal = wx.staticbitmap(frm, 101, intermed) stimag = wx.staticbitmap(fundal, -1, imag, size = (hsize, vsize), pos = (frsz[0] / 2 - hsize / 2, 0)) fundal.refresh() stimag.settooltip(wx.tooltip('esc = exits fullscreen\n<- -> arrows = quick navigation')) def destr(eve): # same lame attempt destroy container in portarit images situation keycd = eve.getkeycode() if keycd == wx.wxk_left or keycd == wx.wxk_right: try: fundal.destroy() except: pass eve.skip() frm.bind(wx.evt_char_hook, destr) else: # case when images landscape stimag = wx.staticbitmap(panl, -1, imag) stimag.refresh() stimag.settooltip(wx.tooltip('esc = exits fullscreen\n<- -> arrows = quick navigation')) imgs() # invocking function imgs situation when double click frm.center() frm.show(true) 

thanks advice in advance.

added later:

the catch i'm trying autorun presentation dvd lots of images on it. anyway it's not necessarely make above piece of code work if there other options. i've tried use windows image viewer, strangely enough doesn't recognizes relative paths , when this

path = os.getcwd() # getting path of current working directory sel = listbox.getselection() # geting value of current selection list box imgname = memlist[sel] # retrieving name of images stored in list, using listbox selection, uses choices same list os.popen(str('rundll32.exe c:\windows\system32\shimgvw.dll,imageview_fullscreen {0}/imgsdir/{1}'.format(path, imgname))) # oepning images bloody windows image viewer 

it opens images when program on hard disk, if it's on cd / image drive doesn't anything.

there's image viewer included wxpython demo package. wrote simple 1 here. either 1 should in journey. suspect you're not reusing panels/frames , instead you're seeing old ones never destroyed.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -