本文整理汇总了Python中pyjamas.ui.Image.Image.addLoadListener方法的典型用法代码示例。如果您正苦于以下问题:Python Image.addLoadListener方法的具体用法?Python Image.addLoadListener怎么用?Python Image.addLoadListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Image.Image
的用法示例。
在下文中一共展示了Image.addLoadListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Images
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import addLoadListener [as 别名]
class Images(Sink):
def __init__(self):
Sink.__init__(self)
self.curImage=0
self.image=Image()
self.loadingImage = Image(self.baseURL() + "images/blanksearching.gif")
self.nextButton = Image(self.baseURL() + "rembrandt/forward.gif")
self.prevButton = Image(self.baseURL() + "rembrandt/back.gif")
self.sImages=["rembrandt/JohannesElison.jpg", "rembrandt/LaMarcheNocturne.jpg", "rembrandt/SelfPortrait1628.jpg", "rembrandt/SelfPortrait1640.jpg", "rembrandt/TheArtistInHisStudio.jpg", "rembrandt/TheReturnOfTheProdigalSon.jpg"]
for i in range(len(self.sImages)):
self.sImages[i]=self.baseURL() + self.sImages[i]
self.image.addLoadListener(self)
self.prevButton.addClickListener(self)
self.nextButton.addClickListener(self)
topPanel = DockPanel()
topPanel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
topPanel.add(self.prevButton, DockPanel.WEST)
topPanel.add(self.nextButton, DockPanel.EAST)
topPanel.add(self.loadingImage, DockPanel.CENTER)
panel = VerticalPanel()
panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER)
panel.add(HTML("<h2>A Bit of Rembrandt</h2>", True))
panel.add(topPanel)
panel.add(self.image)
panel.setWidth("100%")
self.initWidget(panel)
self.image.setStyleName("ks-images-Image")
self.nextButton.setStyleName("ks-images-Button")
self.prevButton.setStyleName("ks-images-Button")
self.loadImage(0)
def onClick(self, sender):
if sender==self.prevButton:
self.loadImage(self.curImage - 1)
elif sender == self.nextButton:
self.loadImage(self.curImage + 1)
def onError(self, sender):
pass
def onLoad(self, sender=None):
self.loadingImage.setUrl(self.baseURL() + "images/blanksearching.gif")
def loadImage(self, index):
if index < 0:
index = len(self.sImages) - 1
elif index > len(self.sImages) - 1:
index = 0
self.curImage = index
self.loadingImage.setUrl(self.baseURL() + "images/searching.gif")
self.image.setUrl(self.sImages[self.curImage])
示例2: prepareImage
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import addLoadListener [as 别名]
def prepareImage(self, url):
img = Image()
img.__isLoaded = False
img.addLoadListener(self)
# normally, event listeners are only set up when the widget
# is attached to part of the DOM (see Widget.onAttach). but,
# in this case, we want a load even _even though_ the Image
# widget is not yet attached (and quite likely won't be).
DOM.setEventListener(img.getElement(), img)
return img
示例3: kMeans
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import addLoadListener [as 别名]
class kMeans(Algorithm):
def __init__(self):
Algorithm.__init__(self)
self.MLAlgorithmService = MLAlgorithmService(self)
self.image=Image(self.baseURL() + "services/kMeansPictures/lenna.png",Width="320px", Height="360px")
self.resultImage=Image("",Width="320px", Height="360px")
self.loadingImage = Image(self.baseURL() + "images/blanksearching.gif")
self.calculateButton = Button("RUN", self.onButtonClick)
self.log = Button("SHOW LOG", self.openLogFile)
self.log.setEnabled(False)
self.image.addLoadListener(self)
topPanel = DockPanel()
topPanel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
topPanel.add(self.calculateButton, DockPanel.WEST)
topPanel.add(self.loadingImage, DockPanel.CENTER)
topPanel.add(self.log, DockPanel.EAST)
panel = DockPanel()
panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER)
panel.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
#panel.add(HTML("<h2>Image compression</h2>", True))
panel.add(topPanel, DockPanel.NORTH)
panel.add(self.image, DockPanel.WEST)
panel.add(self.resultImage, DockPanel.EAST)
panel.setWidth("100%")
self.initWidget(panel)
self.image.setStyleName("ks-images-Image")
self.calculateButton.setStyleName("ks-images-Button")
self.loadImage("picturem.png")
def onButtonClick(self, sender):
Window.alert("Starting image compression...")
self.MLAlgorithmService.callMethod("lenna.png")
def onError(self, sender):
pass
def onLoad(self, sender=None):
self.loadingImage.setUrl(self.baseURL() + "images/blanksearching.gif")
def loadImage(self, picture):
self.loadingImage.setUrl(self.baseURL() + "images/searching.gif")
self.image.setUrl(self.baseURL() + "services/kMeansPictures/lenna.png")
self.resultImage.setUrl(self.baseURL() + "services/kMeansPictures/lenna.png")
self.resultImage.setUrl(self.baseURL() + "services/kMeansPictures/" + picture)
def onImageClicked(self):
Window.alert("picture!")
def openLogFile(self, sender):
###TODO: make logging output
fileLocation = self.baseURL() + "services/contactjson.txt"
dlg = FileOpenDlg(fileLocation=fileLocation)
dlg.show()
def showStatus(self, msg):
Window.alert(msg)