def __init__(self, parent, datasource, watermark=None): wx.ScrolledWindow.__init__(self, parent, id=wx.NewId(), style=wx.FULL_REPAINT_ON_RESIZE|wx.SUNKEN_BORDER) self.exceptioncount=0 self.EnableScrolling(False, False) self.datasource=datasource self._bufbmp=None self.active_section=None self._w, self._h=-1,-1 self.vheight, self.maxheight=self._h,self._h self.sections=[] self.sectionheights=[] self._scrollbarwidth=wx.SystemSettings_GetMetric(wx.SYS_VSCROLL_X) wx.EVT_SIZE(self, self.OnSize) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) wx.EVT_LEFT_DOWN(self, self.OnLeftDown) wx.EVT_LEFT_DCLICK(self, self.OnLeftDClick) wx.EVT_RIGHT_DOWN(self, self.OnRightDown) if watermark is not None: wx.EVT_SCROLLWIN(self, self.OnScroll) bgcolour=wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW) if guihelper.IsMac(): bgcolour=wx.WHITE self.bgbrush=wx.TheBrushList.FindOrCreateBrush(bgcolour, wx.SOLID) if watermark: self.watermark=guihelper.getbitmap(watermark) else: self.watermark=None self.UpdateItems()
def OnStop(self, _=None): self.timer.Stop() if self.sound is not None: if guihelper.IsMac(): # There is no stop method for Mac so we play a one centisecond wav # which cancels the existing playing sound self.sound=None sound=wx.Sound(self.zerolenwav) sound.Play(wx.SOUND_ASYNC) else: self.sound.Stop() self.sound=None
def InitAttributes(self): "Initialise our font and colours" self.font=wx.TheFontList.FindOrCreateFont(20, family=wx.SWISS, style=wx.NORMAL, weight=wx.NORMAL) self.font2=wx.TheFontList.FindOrCreateFont(20, family=wx.SWISS, style=wx.NORMAL, weight=wx.LIGHT) self.fontcolour=wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNTEXT) self.font2colour=wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNSHADOW) dc=wx.MemoryDC() # mac needs a bitmap selected in order to return textextent! if guihelper.IsMac(): dc.SelectObject(wx.EmptyBitmap(100,100)) w,h,d,l=dc.GetFullTextExtent("I", font=self.font) self.height=h+3 self.descent=d
def check_update(update_url=None, current_version=None, platform=None, flavor=''): # get info from current version if current_version is None: current_version = version.version # set flavor to blank for now, should be flavor=version.flavor if platform is None: if guihelper.IsMSWindows(): platform = 'windows' elif guihelper.IsGtk(): platform = 'linux' elif guihelper.IsMac(): platform = 'mac' else: raise ValueError, 'Invalid platform' # todo: need to figure out how to do flavor, comment out for now ## flavor=version.vendor # retrieve and parse update info print 'Checking update for BitPim ', current_version, ' running on ', \ platform, '-', flavor with guihelper.WXDialogWrapper( wx.ProgressDialog('BitPim Update', 'Retrieving BitPim Update Information...', style=wx.PD_AUTO_HIDE)) as dlg: bp_update = BitPimUpdate() s = None try: if update_url is None: bp_update.get_update_info() else: bp_update.get_update_info(update_url) dlg.Update(100) except: s = 'Failed to get BitPim update info.' if s is None: s = bp_update.display_update_info(current_version, platform, flavor) latest_version = bp_update.latest_version else: latest_version = '' if s is not None: # error messages being return, display them guihelper.MessageDialog(None, s, 'BitPim Update', wx.OK | wx.ICON_INFORMATION) return latest_version
def __init__(self, parent, file, convertinfo): wx.Dialog.__init__(self, parent, title="Convert Audio File", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.MAXIMIZE_BOX) self.file=file self.convertinfo=convertinfo self.afi=None self.temporaryfiles=[] self.wavfile=common.gettempfilename("wav") # full length wav equivalent self.clipwavfile=common.gettempfilename("wav") # used for clips from full length wav self.temporaryfiles.extend([self.wavfile, self.clipwavfile]) getattr(self, self.PARAMETERS[convertinfo.format]['setup'])() vbs=wx.BoxSizer(wx.VERTICAL) # create the covert controls self.create_convert_pane(vbs, file, convertinfo) # and the crop controls self.create_crop_panel(vbs) vbs.Add(self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.HELP), 0, wx.ALL|wx.ALIGN_RIGHT, 5) self.SetSizer(vbs) vbs.Fit(self) # diable various things self.FindWindowById(wx.ID_OK).Enable(False) for i in self.cropids: self.FindWindowById(i).Enable(False) # Events wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk) wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel) wx.EVT_TIMER(self, self.ID_TIMER, self.OnTimer) wx.EVT_BUTTON(self, wx.ID_HELP, lambda _: wx.GetApp().displayhelpid(helpids.ID_DLG_AUDIOCONVERT)) # timers and sounds self.sound=None self.timer=wx.Timer(self, self.ID_TIMER) # wxPython wrapper on Mac raises NotImplemented for wx.Sound.Stop() so # we hack around that by supplying a zero length wav to play instead if guihelper.IsMac(): self.zerolenwav=guihelper.getresourcefile("zerolen.wav")