testLayouts.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 » testLayouts.py
import time
import pyui
from pyui.locals import *

class app:
  def __init__(self):

    # create gui objects
    menu1 = pyui.widgets.Menu("Layouts")
    menu1.addItem("Flow", self.onFlowLayout)
    menu1.addItem("Grid", self.onGridLayout)
    menu1.addItem("Border", self.onBorderLayout)
    menu1.addItem("Absolute", self.onAbsoluteLayout)
                menu1.addItem("Table", self.onTableLayout)

    self.mbar = pyui.widgets.MenuBar()
    self.mbar.addMenu(menu1)

    # window slots
    self.flow = None
    self.grid = None
    self.border = None
    self.absolute = None

  def onClose(self, button):
    if self.flow:
      self.flow.destroy()
      self.flow = None
    if self.grid:
      self.grid.destroy()
      self.grid = None
    if self.border:
      self.border.destroy()
      self.border = None
    if self.absolute:
      self.absolute.destroy()
      self.absolute = None
    return 1
  
  def onButton(self, button):
    print "Button pressed", button
    return 1
  
  def onFlowLayout(self, event):
    self.flow = pyui.widgets.Frame(100,100,450,200,"Flow Layout")
    self.flow.addChild( pyui.widgets.Button("Button one", self.onButton) )
    self.flow.addChild( pyui.widgets.Button("Button two", self.onButton) )
    self.flow.addChild( pyui.widgets.Button("Button three", self.onButton) )
    self.flow.addChild( pyui.widgets.Button("Button four", self.onButton) )
    self.flow.addChild( pyui.widgets.Button("Exit", self.onClose) )
    self.flow.pack()

  def onGridLayout(self, event):
    self.grid = pyui.widgets.Frame(100,100,450,200,"Grid Layout")
    self.grid.setLayout(pyui.layouts.GridLayoutManager(3, 3))
    self.grid.addChild( pyui.widgets.Button("Button one", self.onButton) )
    self.grid.addChild( pyui.widgets.Button("Button two", self.onButton) )
    self.grid.addChild( pyui.widgets.Button("Button three", self.onButton) )
    self.grid.addChild( pyui.widgets.Button("Button four", self.onButton) )
    self.grid.addChild( pyui.widgets.Button("Button five", self.onButton) )
    self.grid.addChild( pyui.widgets.Button("Button six", self.onButton) )
    self.grid.addChild( pyui.widgets.Button("Button seven", self.onButton) )
    self.grid.addChild( pyui.widgets.Button("Button eight", self.onButton) )    
    self.grid.addChild( pyui.widgets.Button("Exit", self.onClose) )
    self.grid.pack()

  def onBorderLayout(self, event):
    self.border = pyui.widgets.Frame(100,100,450,200,"Border Layout")
    self.border.setLayout(pyui.layouts.BorderLayoutManager())
    self.border.addChild( pyui.widgets.Button("Button one", self.onButton), NORTH )
    self.border.addChild( pyui.widgets.Button("Button two", self.onButton), SOUTH )
    self.border.addChild( pyui.widgets.Button("Button four", self.onButton), WEST )
    self.border.addChild( pyui.widgets.Button("Exit", self.onClose), CENTER )
    self.border.addChild( pyui.widgets.Button("Button three", self.onButton), EAST )        
    self.border.pack()
  

  def onAbsoluteLayout(self, event):
    self.absolute = pyui.widgets.Frame(100,100,450,400,"Absolute Layout")
    self.absolute.setLayout(pyui.layouts.AbsoluteLayoutManager())
    self.absolute.addChild( pyui.widgets.Button("Button one", self.onButton), (10,10) )
    self.absolute.addChild( pyui.widgets.Button("Button two", self.onButton), (10, 50) )
    self.absolute.addChild( pyui.widgets.Button("Button three", self.onButton), (80, 10) )
    self.absolute.addChild( pyui.widgets.Button("Button seven", self.onButton), (80, 50) )
    self.absolute.addChild( pyui.widgets.Button("Exit", self.onClose), (80, 80) )
    self.absolute.pack()

        def onTableLayout(self, event):
                self.table = pyui.widgets.Frame(100,100,450,400, "Table layout")
                self.table.setLayout(pyui.layouts.TableLayoutManager(10, 10 ))
                self.table.addChild( pyui.widgets.Button("Button one", self.onButton), (2, 2, 2, 3) )
                self.table.addChild( pyui.widgets.Button("Button two", self.onButton), (4, 0, 1, 5) )
                self.table.addChild( pyui.widgets.Button("Button three", self.onButton), (7, 2, 2, 7) )
                self.table.addChild( pyui.widgets.Button("Button four", self.onButton), (0, 6, 1, 1) )
                self.table.addChild( pyui.widgets.Button("Button five", self.onButton), (1, 6, 1, 1) )
                self.table.addChild( pyui.widgets.Button("Button six", self.onButton), (0, 9, 10, 1) )                
                self.table.addChild( pyui.widgets.Button("Exit", self.onClose), (1, 7, 1, 1) )                
                self.table.pack()

def run():
    done = 1

    import testopt
    opts = testopt.parseCommandLine(800, 600)
    pyui.init(*opts)
    g = app()
    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.