test2.py :  » GUI » pyui » pyui095 » tests » 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 » GUI » pyui 
pyui » pyui095 » tests » test2.py
import time
import pyui
from pyui.locals import *

from pyui.desktop import getDesktop
import profile

class game:
    def __init__(self):

        # create gui objects
        self.grid = None
        self.makeWindow()
  #self.dbutton = pyui.widgets.Button("Delete!", self.onDelete)
        getDesktop().registerHandler(DIALOGCLOSED, self.onDialogClosed)

    def onDialogClosed(self, event):
        if self.d:
            print self.d.modal
            self.d.destroy()
            self.d = None
        if self.td:
            self.td.destroy()
            self.td = None
        
    def onDelete(self, button):
        if self.grid:
            self.grid.destroy()
            self.b3 = None
            self.b4 = None
            self.b5 = None
            self.b6 = None
            self.b7 = None
            self.grid = None
        else:
            self.makeWindow()

    def makeWindow(self):
        self.grid = pyui.widgets.Frame(10, 20, 400, 400, "border Layout")
        self.grid.setLayout( pyui.layouts.BorderLayoutManager() )
        self.b3 = pyui.widgets.Button("a long name", self.onButton)
        self.b4 = pyui.widgets.Button("Button 4", self.onButton)
        self.b5 = pyui.widgets.Button("Button 5", self.onButton)
        self.b6 = pyui.widgets.Button("Button 6", self.onButton)
        self.b7 = pyui.widgets.Button("Big Butt", self.onButton)

        self.b3.bgColor = (255,0,0,255)
        self.b4.bgColor = (255,0,255,255)
        self.b5.bgColor = (255,255,0,255)
        self.grid.addChild(self.b3, NORTH)
        self.grid.addChild(self.b5, WEST)
        self.grid.addChild(self.b7, CENTER)     
        self.grid.addChild(self.b6, EAST)
        self.grid.addChild(self.b4, SOUTH)
        self.grid.pack()

        self.d = pyui.dialogs.StdDialog("title", "Select the OK or the CANCEL button!!!")
        self.d.alpha = 100
        self.td = None
        self.d.doModal()
        

    def onButton(self, button):
        print "Button:", button
        self.td = testDialog()
        self.td.doModal()

    def onInfoButton(self, button):
        pass


class testDialog(pyui.dialogs.Dialog):
    """Dialog to setup options for a trade route"""
    def __init__(self):
        pyui.dialogs.Dialog.__init__(self, 200, 200, 200, 200, "Test Dialog")
        self.setLayout(pyui.layouts.BorderLayoutManager())
        self.topPanel = pyui.widgets.Panel()
        self.myLabel = pyui.widgets.Label("Number:")
        self.myAmount = pyui.widgets.Edit("00000", 8, self.onButton)
        self.button = pyui.widgets.Button("choose", self.onButton)
        self.aList = pyui.widgets.ListBox()
        self.aList.addItem("item 1", 1)
        self.aList.addItem("another item", 2)
        self.aList.addItem("last item", 3)
        self.topPanel.setLayout(pyui.layouts.GridLayoutManager(2,1))
        self.topPanel.addChild(self.myLabel)
        self.topPanel.addChild(self.myAmount)
        
        self.addChild(self.topPanel, NORTH)
        self.addChild(self.aList, CENTER)
        self.addChild(self.button, SOUTH)
        self.pack()

    def onButton(self, button):
        item = self.aList.getSelectedItem()
        if not item:
            return
        self.close()

    def close(self):
        self.topPanel = None
        self.myLabel = None
        self.button = None
        self.aList = None
        self.myAmount = None
        pyui.dialogs.Dialog.close(self)
        

def run():
    
    import testopt
    opts = testopt.parseCommandLine(800, 600)
    pyui.init(*opts)
    g = game()

    pyui.run()


if __name__ == '__main__':
    run()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.