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, id, title): self._parent = parent self._data = {} self._import_data = None self._buttons = [] super(ImportCalendarPresetDialog, self).__init__(parent, id, title, size=(500, 500)) _vbs = wx.BoxSizer(wx.VERTICAL) _static_bs = wx.StaticBoxSizer( wx.StaticBox(self, -1, 'Available Presets:'), wx.VERTICAL) self._name_lb = wx.ListBox(self, -1, style=wx.LB_SINGLE | wx.LB_NEEDED_SB) wx.EVT_LISTBOX(self, self._name_lb.GetId(), self._set_button_states) _static_bs.Add(self._name_lb, 0, wx.EXPAND | wx.ALL, 5) _vbs.Add(_static_bs, 0, wx.EXPAND | wx.ALL, 5) _vbs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) _hbs = wx.BoxSizer(wx.HORIZONTAL) _btn = wx.Button(self, -1, 'Import') wx.EVT_BUTTON(self, _btn.GetId(), self._OnRun) self._buttons.append(_btn) _hbs.Add(_btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5) _btn = wx.Button(self, wx.ID_NEW) wx.EVT_BUTTON(self, _btn.GetId(), self._OnNew) _hbs.Add(_btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5) _btn = wx.Button(self, -1, 'Edit') wx.EVT_BUTTON(self, _btn.GetId(), self._OnEdit) self._buttons.append(_btn) _hbs.Add(_btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5) _btn = wx.Button(self, wx.ID_DELETE) self._buttons.append(_btn) wx.EVT_BUTTON(self, _btn.GetId(), self._OnDel) _hbs.Add(_btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5) _hbs.Add(wx.Button(self, wx.ID_CANCEL), 0, wx.ALIGN_CENTRE | wx.ALL, 5) _vbs.Add(_hbs, 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.SetSizerAndFit(_vbs) if guihelper.IsGtk(): # On Linux, without this, the dialog clips the buttons self.SetSizeHints(-1, 175) self._get_from_fs() self._populate()
def Draw(self, dc, width, height, selected): # uncomment to see exactly what size is given #dc.DrawRectangle(0,0,width,height) us=dc.GetUserScale() dc.SetClippingRegion(0,0,width,height) hdc=wx.html.HtmlDCRenderer() hdc.SetDC(dc, 1) hdc.SetSize(9999, 9999) # width is deliberately wide so that no wrapping happens hdc.SetHtmlText(self.genhtml(selected), '.', True) hdc.Render(0,0) del hdc # restore scale hdc messes dc.SetUserScale(*us) dc.DestroyClippingRegion() # Linux gets bounding box wrong, so we deliberately return actual size if guihelper.IsGtk(): return (0,0,width,height) elif guihelper.IsMSWindows(): return max(0,dc.MinX()), max(0, dc.MinY()), min(width, dc.MaxX()), min(height, dc.MaxY())