本文整理汇总了Python中pyjamas.ui.Image.Image.setStyleName方法的典型用法代码示例。如果您正苦于以下问题:Python Image.setStyleName方法的具体用法?Python Image.setStyleName怎么用?Python Image.setStyleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Image.Image
的用法示例。
在下文中一共展示了Image.setStyleName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MechDrawing
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import setStyleName [as 别名]
class MechDrawing(VerticalPanel):
def __init__(self, handle, idx, image, variables = None, code = None,
perspective = '', checkOptions = [False, True]):
VerticalPanel.__init__(self)
self._handle = handle
self.idx = idx
# set style
self.setStyleName('os-mech-drawing')
# create widgets
self._img = Image(image)
self._img.setStyleName('os-mech-thumb')
self._img.addClickListener(self.onClickDrawing)
self._perspective = '%d - %s'%(idx, perspective.capitalize())
self._optionPanel = MechOptionPanel(handle, idx, checkOptions)
textArea = TextArea(code)
textArea.setText(code)
textArea.setStyleName('os-mech-code-locked')
textArea.setReadonly(self, True)
# populate drawing
self.add(self._img)
self.add(self._optionPanel)
self.add(textArea)
def actRatioChange(self, ratio):
self._optionPanel.actRatioChange(ratio)
def onClickDrawing(self, sender, event):
Window.open(self._img.getUrl() + '&render=html&title=%s'%self._perspective, self._perspective, "status=1,resizeable=1,scrollbars=1")
示例2: createImage
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import setStyleName [as 别名]
def createImage(self, imageUrl):
image = Image(imageUrl)
image.setStyleName("ks-images-Image")
p = VerticalPanel()
p.setHorizontalAlignment(HasAlignment.ALIGN_CENTER)
p.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
p.add(image)
return p
示例3: Images
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import setStyleName [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])
示例4: ControlButton
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import setStyleName [as 别名]
class ControlButton(Composite):
def __init__(self, up_url, down_url, up_msg, down_msg):
Composite.__init__(self)
self.state = "up"
self.up_url = up_url
self.down_url = down_url
self.up_msg = up_msg
self.down_msg = down_msg
self.control = VerticalPanel()
self.image = Image(up_url)
self.image.setStyleName("gwt-Image-Cell")
self.text = HTML(up_msg)
self.image.base = self
self.text.base = self
self.text.horzAlign = "center"
self.control.add(self.image)
self.control.add(self.text)
self.initWidget(self.control)
def toggleImage(self):
if self.state == "up":
new_url = self.down_url
new_msg = self.down_msg
self.state = "down"
elif self.state == "down":
new_url = self.up_url
new_msg = self.up_msg
self.state = "up"
self.image.setUrl(new_url)
self.text.setHTML(new_msg)
def toggleTimer(self):
self.base.base.display_panel.timer.toggle()
def addMouseListener(self, listner):
self.image.addMouseListener(listner)
示例5: DialogWindow
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import setStyleName [as 别名]
class DialogWindow(DialogBox):
_props = [
("caption", "Caption", "HTML", None),
]
def __init__(self, autoHide=None, modal=True, centered=False,
caption=None, minimize=None, maximize=None, close=None,
captionStyle=None,
**kwargs):
# Init section
DialogBox.__init__(self, autoHide, modal, centered, **kwargs)
self._dialogListeners = []
self._minimized = None
self._maximized = None
# Arguments section
if isinstance(caption, basestring):
self.caption.setText(caption)
elif caption is not None:
self.caption = caption
self.caption.addMouseListener(self)
if captionStyle is not None:
self.caption.setStyleName(captionStyle)
else:
self.caption.addStyleName('WindowCaption')
self.setControls(minimize, maximize, close)
def createDefaultControl(self, control_type):
if control_type == 'minimize':
return Button("_")
elif control_type == 'maximize':
return Button("^")
elif control_type == 'close':
return Button("X")
raise ValueError("Invalid control '%s'" % control_type)
def setControls(self, minimize, maximize, close):
if minimize is True:
self.minimizeWidget = self.createDefaultControl('minimize')
elif isinstance(minimize, basestring):
self.minimizeWidget = Image(minimize)
else:
self.minimizeWidget = minimize
if maximize is True:
self.maximizeWidget = self.createDefaultControl('maximize')
elif isinstance(maximize, basestring):
self.maximizeWidget = Image(maximize)
else:
self.maximizeWidget = maximize
if close is True:
self.closeWidget = self.createDefaultControl('close')
elif isinstance(close, basestring):
self.closeWidget = Image(close)
else:
self.closeWidget = close
if (isinstance(self.minimizeWidget, UIObject) or
isinstance(self.maximizeWidget, UIObject) or
isinstance(self.closeWidget, UIObject)):
cf = self.panel.getCellFormatter()
captionStyle = self.caption.getStyleName()
captionPanel = FlexTable(
Width="99%",
BorderWidth="0",
CellPadding="0",
CellSpacing="0",
)
controls = HorizontalPanel()
controls.setStyleName("Controls")
controls.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
if isinstance(self.minimizeWidget, UIObject):
self.minimizeWidget.setStyleName("Minimize")
controls.add(self.minimizeWidget)
self.minimizeWidget.addClickListener(
getattr(self, "onMinimize"),
)
if isinstance(self.maximizeWidget, UIObject):
self.maximizeWidget.setStyleName("Maximize")
controls.add(self.maximizeWidget)
self.maximizeWidget.addClickListener(
getattr(self, "onMaximize"),
)
if isinstance(self.closeWidget, UIObject):
self.closeWidget.setStyleName("Close")
controls.add(self.closeWidget)
self.closeWidget.addClickListener(
getattr(self, "onClose"),
)
self.closeable = True
self.caption.removeStyleName(captionStyle)
self.panel.setWidget(0, 0, captionPanel)
captionPanel.setWidget(0, 0, self.caption)
captionPanel.setWidget(0, 1, controls)
captionPanel.setStyleName(captionStyle)
cf = captionPanel.getCellFormatter()
cf.setWidth(0, 1, '1%')
def getDialogListeners(self, listener):
return self._dialogListeners
def addDialogListener(self, listener):
#.........这里部分代码省略.........
示例6: DialogBoxModal
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import setStyleName [as 别名]
class DialogBoxModal(PopupPanel):
def __init__(self, identifier, autoHide=None, modal=False, rootpanel=None):
PopupPanel.__init__(self, autoHide, modal, rootpanel)
self.identifier = identifier
self.caption = HTML()
self.child = None
self.showing = False
self.dragging = False
self.dragStartX = 0
self.dragStartY = 0
self.panel = FlexTable()
self.closeButton = Image('cancel.png')
self.closeButton.addClickListener(self)
dock = DockPanel()
dock.setSpacing(0)
dock.add(self.closeButton, DockPanel.EAST)
dock.add(self.caption, DockPanel.WEST)
dock.setCellHorizontalAlignment(self.closeButton,
HasAlignment.ALIGN_RIGHT)
dock.setCellHorizontalAlignment(self.caption, HasAlignment.ALIGN_LEFT)
dock.setCellWidth(self.caption, '100%')
dock.setWidth('100%')
self.panel.setWidget(0, 0, dock)
self.panel.setHeight('100%')
self.panel.setBorderWidth(0)
self.panel.setCellPadding(0)
self.panel.setCellSpacing(0)
self.panel.getCellFormatter().setHeight(1, 0, '100%')
self.panel.getCellFormatter().setWidth(1, 0, '100%')
#self.panel.getCellFormatter().setAlignment(1, 0,
# HasHorizontalAlignment.ALIGN_CENTER,
# HasVerticalAlignment.ALIGN_MIDDLE)
PopupPanel.setWidget(self, self.panel)
self.setStyleName('gwt-DialogBox')
self.caption.setStyleName('Caption')
self.closeButton.setStyleName('Close')
dock.setStyleName('Header')
self.caption.addMouseListener(self)
def getHTML(self):
return self.caption.getHTML()
def getText(self):
return self.caption.getText()
def onMouseDown(self, sender, x, y):
self.dragging = True
DOM.setCapture(self.caption.getElement())
self.dragStartX = x
self.dragStartY = y
def onMouseEnter(self, sender):
pass
def onMouseLeave(self, sender):
pass
def onMouseMove(self, sender, x, y):
if self.dragging:
absX = x + self.getAbsoluteLeft()
absY = y + self.getAbsoluteTop()
self.setPopupPosition(absX - self.dragStartX,
absY - self.dragStartY)
def onMouseUp(self, sender, x, y):
self.dragging = False
DOM.releaseCapture(self.caption.getElement())
def remove(self, widget):
if self.child != widget:
return False
self.panel.remove(widget)
self.child = None
return True
def setHTML(self, html):
self.caption.setHTML(html)
def setText(self, text):
self.caption.setText(text)
def doAttachChildren(self):
PopupPanel.doAttachChildren(self)
self.caption.onAttach()
def doDetachChildren(self):
PopupPanel.doDetachChildren(self)
self.caption.onDetach()
def setWidget(self, widget):
if self.child is not None:
self.panel.remove(self.child)
#.........这里部分代码省略.........
示例7: kMeans
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import setStyleName [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)
示例8: CollapserPanel
# 需要导入模块: from pyjamas.ui.Image import Image [as 别名]
# 或者: from pyjamas.ui.Image.Image import setStyleName [as 别名]
class CollapserPanel(SimplePanel):
def __init__(self, sink):
SimplePanel.__init__(self)
self.sink = sink
self.caption = HTML()
self.child = None
self.showing = False
self.dragging = False
self.dragStartX = 0
self.dragStartY = 0
self.panel = FlexTable()
self.collapse = Image("./images/cancel.png")
self.collapse.addClickListener(self)
dock = DockPanel()
dock.setSpacing(0)
dock.add(self.collapse, DockPanel.EAST)
dock.add(self.caption, DockPanel.WEST)
dock.setCellHorizontalAlignment(self.collapse, HasAlignment.ALIGN_RIGHT)
dock.setCellVerticalAlignment(self.collapse, HasAlignment.ALIGN_TOP)
dock.setCellHorizontalAlignment(self.caption, HasAlignment.ALIGN_LEFT)
dock.setCellWidth(self.caption, "100%")
dock.setWidth("100%")
dock.setHeight("100%")
self.panel.setWidget(0, 0, dock)
self.panel.setHeight("100%")
self.panel.setWidth("100%")
self.panel.setBorderWidth(0)
self.panel.setCellPadding(0)
self.panel.setCellSpacing(0)
self.panel.getCellFormatter().setHeight(1, 0, "100%")
self.panel.getCellFormatter().setWidth(1, 0, "100%")
self.panel.getCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP)
SimplePanel.setWidget(self, self.panel)
self.setStyleName("gwt-DialogBox")
self.caption.setStyleName("Caption")
self.collapse.setStyleName("Close")
dock.setStyleName("Header")
#self.caption.addMouseListener(self)
self.collapsed = False
self.collapsed_width = "15px"
self.uncollapsed_width = "100%"
def setInitialWidth(self, width):
self.uncollapsed_width = width
SimplePanel.setWidth(self, width)
self.sink.setCollapserWidth(self, width)
def setHeight(self, height):
SimplePanel.setHeight(self, height)
def onClick(self, sender):
if self.collapsed == False:
self.collapse.setUrl("./tree_closed.gif")
self.collapsed = True
self.caption.setVisible(False)
if self.child:
self.child.setVisible(False)
self.setWidth(self.collapsed_width)
self.sink.setCollapserWidth(self, self.collapsed_width)
else:
self.collapse.setUrl("./images/cancel.png")
self.collapsed = False
self.caption.setVisible(True)
if self.child:
self.child.setVisible(True)
self.setWidth(self.uncollapsed_width)
self.sink.setCollapserWidth(self, self.uncollapsed_width)
def setHTML(self, html):
self.caption.setHTML(html)
def setText(self, text):
self.caption.setText(text)
def remove(self, widget):
if self.child != widget:
return False
self.panel.remove(widget)
return True
def doAttachChildren(self):
SimplePanel.doAttachChildren(self)
self.caption.onAttach()
def doDetachChildren(self):
SimplePanel.doDetachChildren(self)
self.caption.onDetach()
def setWidget(self, widget):
if self.child is not None:
self.panel.remove(self.child)
if widget is not None:
#.........这里部分代码省略.........