Popups.py :  » Ajax » pyjamas » src » examples » kitchensink » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Ajax » pyjamas 
pyjamas » src » examples » kitchensink » Popups.py
from Sink import Sink,SinkInfo
from pyjamas.ui.Button import Button
from pyjamas.ui.VerticalPanel import VerticalPanel
from pyjamas.ui.PopupPanel import PopupPanel
from pyjamas.ui.ListBox import ListBox
from pyjamas.ui.HTML import HTML
from pyjamas.ui.DockPanel import DockPanel
from pyjamas.ui.DialogBox import DialogBox
from pyjamas.ui.Frame import Frame
from pyjamas.ui import HasAlignment
from pyjamas import DOM

class Popups(Sink):
    def __init__(self):
        Sink.__init__(self)

        self.fDialogButton = Button("Show Dialog", self)
        self.fPopupButton = Button("Show Popup", self)
        
        panel = VerticalPanel()
        panel.add(self.fPopupButton)
        panel.add(self.fDialogButton)
        
        list = ListBox()
        list.setVisibleItemCount(5)
        for i in range(10):
            list.addItem("list item %d" % i)
        panel.add(list)
        
        panel.setSpacing(8)
        self.initWidget(panel)

    def onShow(self):
        pass

    def onClick(self, sender):
        if sender == self.fPopupButton:
            p = MyPopup()
            left = sender.getAbsoluteLeft() + 10
            top = sender.getAbsoluteTop() + 10
            p.setPopupPosition(left, top)
            p.show()
        elif sender == self.fDialogButton:
            dlg = MyDialog(self.baseURL())
            left = self.fDialogButton.getAbsoluteLeft() + 10
            top = self.fDialogButton.getAbsoluteTop() + 10
            dlg.setPopupPosition(left, top)
            dlg.show()


def init():
    text="This page demonstrates GWT's built-in support for in-page "
    text+="popups.  The first is a very simple informational popup that closes "
    text+="itself automatically when you click off of it.  The second is a more "
    text+="complex draggable dialog box. If you're wondering why there's "
    text+="a list box at the bottom, it's to demonstrate that you can drag the "
    text+="dialog box over it.  "
    text+="This is noteworthy because some browsers render lists and combos in "
    text+="a funky way that, if GWT didn't do some magic for you, would "
    text+="normally cause the dialog box to appear to hover <i>underneath</i> "
    text+="the list box.  Fortunately, you don't have to worry about it -- "
    text+="just use the GWT <code>DialogBox</code> class."
    return SinkInfo("Popups", text, Popups)


class MyDialog(DialogBox):
    def __init__(self, baseURL):
        DialogBox.__init__(self)
        self.setText("Sample DialogBox with embedded Frame")
        
        iframe = Frame(baseURL + "rembrandt/LaMarcheNocturne.html")
        closeButton = Button("Close", self)
        msg = HTML("<center>This is an example of a standard dialog box component.<br>  You can put pretty much anything you like into it,<br>such as the following IFRAME:</center>", True)
        
        dock = DockPanel()
        dock.setSpacing(4)
        
        dock.add(closeButton, DockPanel.SOUTH)
        dock.add(msg, DockPanel.NORTH)
        dock.add(iframe, DockPanel.CENTER)
        
        dock.setCellHorizontalAlignment(closeButton, HasAlignment.ALIGN_RIGHT)
        dock.setCellWidth(iframe, "100%")
        dock.setWidth("100%")
        iframe.setWidth("36em")
        iframe.setHeight("20em")
        self.setWidget(dock)

    def onClick(self, sender):
        self.hide()


class MyPopup(PopupPanel):
    def __init__(self):
        PopupPanel.__init__(self, True)
        
        contents = HTML("Click anywhere outside this popup to make it disappear.")
        contents.setWidth("128px")
        self.setWidget(contents)
        
        self.setStyleName("ks-popups-Popup")
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.