基于esky实现python应用的自动升级详解.docx

上传人:b****1 文档编号:2413917 上传时间:2022-10-29 格式:DOCX 页数:15 大小:20.24KB
下载 相关 举报
基于esky实现python应用的自动升级详解.docx_第1页
第1页 / 共15页
基于esky实现python应用的自动升级详解.docx_第2页
第2页 / 共15页
基于esky实现python应用的自动升级详解.docx_第3页
第3页 / 共15页
基于esky实现python应用的自动升级详解.docx_第4页
第4页 / 共15页
基于esky实现python应用的自动升级详解.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

基于esky实现python应用的自动升级详解.docx

《基于esky实现python应用的自动升级详解.docx》由会员分享,可在线阅读,更多相关《基于esky实现python应用的自动升级详解.docx(15页珍藏版)》请在冰豆网上搜索。

基于esky实现python应用的自动升级详解.docx

基于esky实现python应用的自动升级详解

基于esky实现python应用的自动升级

一、esky介绍

Eskyisanauto-updateframeworkforfrozenPythonapplications.ItprovidesasimpleAPIthroughwhichappscanfind,fetchandinstallupdates,andabootstrappingmechanismthatkeepstheappsafeinthefaceoffailedorpartialupdates.Updatescanalsobesentasdifferentialpatches.

Eskyiscurrentlycapableoffreezingappswithpy2exe,py2app,cxfreezeandbbfreeze.Addingsupportforotherfreezerprogramsshouldbeeasy;patcheswillbegratefullyaccepted.

WearetestedandrunningonPython2.7Py2appwillworkonpython3fine,theotherfreezersnotsomuch.

Esky是一个python编译程序的自动升级框架,提供简单的api实现应用的自动更新(包括比较版本、更新版本),esky支持py2exe,py2app,cxfreeze以及bbfreeze等多种python打包框架。

二、esky安装及说明

1、pip安装

pipinstallesky

2、esky说明

3、esky教学视频

http:

//pyvideo.org/pycon-au-2010/pyconau-2010--esky--keep-your-frozen-apps-fresh.html

三、esky用法示例

esky用起来比较简单,我们这里以常用的基于wx的windows应用举例。

wxpython下有个wx.lib.softwareupdate类,对wxpython应用的esky升级进行了二次封装。

网上有个现成的示范例子,具体网址:

http:

//www.blog.pythonlibrary.org/2013/07/12/wxpython-updating-your-application-with-esky/

代码很简单,对其中的关键部分进行注释说明(红色字体部分):

复制代码

#----------------------------------------

#image_viewer2.py

#

#Created03-20-2010

#

#Author:

MikeDriscoll

#----------------------------------------

importglob

importos

importwx

fromwx.lib.pubsubimportsetuparg1

fromwx.lib.pubsubimportpubasPublisher

#申明语句

fromwx.lib.softwareupdateimportSoftwareUpdate

importversion

########################################################################

classViewerPanel(wx.Panel):

""""""

#----------------------------------------------------------------------

def__init__(self,parent):

"""Constructor"""

wx.Panel.__init__(self,parent)

width,height=wx.DisplaySize()

self.picPaths=[]

self.currentPicture=0

self.totalPictures=0

self.photoMaxSize=height-200

Publisher.subscribe(self.updateImages,("updateimages"))

self.slideTimer=wx.Timer(None)

self.slideTimer.Bind(wx.EVT_TIMER,self.update)

self.layout()

#----------------------------------------------------------------------

deflayout(self):

"""

Layoutthewidgetsonthepanel

"""

self.mainSizer=wx.BoxSizer(wx.VERTICAL)

btnSizer=wx.BoxSizer(wx.HORIZONTAL)

img=wx.EmptyImage(self.photoMaxSize,self.photoMaxSize)

self.imageCtrl=wx.StaticBitmap(self,wx.ID_ANY,

wx.BitmapFromImage(img))

self.mainSizer.Add(self.imageCtrl,0,wx.ALL|wx.CENTER,5)

self.imageLabel=wx.StaticText(self,label="")

self.mainSizer.Add(self.imageLabel,0,wx.ALL|wx.CENTER,5)

btnData=[("Previous",btnSizer,self.onPrevious),

("SlideShow",btnSizer,self.onSlideShow),

("Next",btnSizer,self.onNext)]

fordatainbtnData:

label,sizer,handler=data

self.btnBuilder(label,sizer,handler)

self.mainSizer.Add(btnSizer,0,wx.CENTER)

self.SetSizer(self.mainSizer)

#----------------------------------------------------------------------

defbtnBuilder(self,label,sizer,handler):

"""

Buildsabutton,bindsittoaneventhandlerandaddsittoasizer

"""

btn=wx.Button(self,label=label)

btn.Bind(wx.EVT_BUTTON,handler)

sizer.Add(btn,0,wx.ALL|wx.CENTER,5)

#----------------------------------------------------------------------

defloadImage(self,image):

""""""

image_name=os.path.basename(image)

img=wx.Image(image,wx.BITMAP_TYPE_ANY)

#scaletheimage,preservingtheaspectratio

W=img.GetWidth()

H=img.GetHeight()

ifW>H:

NewW=self.photoMaxSize

NewH=self.photoMaxSize*H/W

else:

NewH=self.photoMaxSize

NewW=self.photoMaxSize*W/H

img=img.Scale(NewW,NewH)

self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))

self.imageLabel.SetLabel(image_name)

self.Refresh()

Publisher.sendMessage("resize","")

#----------------------------------------------------------------------

defnextPicture(self):

"""

Loadsthenextpictureinthedirectory

"""

ifself.currentPicture==self.totalPictures-1:

self.currentPicture=0

else:

self.currentPicture+=1

self.loadImage(self.picPaths[self.currentPicture])

#----------------------------------------------------------------------

defpreviousPicture(self):

"""

Displaysthepreviouspictureinthedirectory

"""

ifself.currentPicture==0:

self.currentPicture=self.totalPictures-1

else:

self.currentPicture-=1

self.loadImage(self.picPaths[self.currentPicture])

#----------------------------------------------------------------------

defupdate(self,event):

"""

CalledwhentheslideTimer'stimereventfires.Loadsthenext

picturefromthefolderbycallingthnextPicturemethod

"""

self.nextPicture()

#----------------------------------------------------------------------

defupdateImages(self,msg):

"""

UpdatesthepicPathslisttocontainthecurrentfold

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 面试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1