dialog.py :  » GUI » FXPy » FXPy-1.0.5 » examples » 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 » FXPy 
FXPy » FXPy 1.0.5 » examples » dialog.py
#! /usr/bin/env python

from FXPy.fox import *

# Our dialog box
class FXTestDialog(FXDialogBox):
    def __init__(self, owner):
        FXDialogBox.__init__(self,owner,"Test of Dialog Box",DECOR_TITLE|DECOR_BORDER)

        # Bottom buttons
        buttons = FXHorizontalFrame(self,LAYOUT_SIDE_BOTTOM|FRAME_NONE|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,0,0,0,0,40,40,20,20)

        # Separator
        FXHorizontalSeparator(self,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|SEPARATOR_GROOVE)

        # Contents
        contents = FXHorizontalFrame(self,LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH)

        submenu = FXMenuPane(self)
        FXMenuCommand(submenu,"One")
        FXMenuCommand(submenu,"Two")
        FXMenuCommand(submenu,"Three")

        # Menu
        menu = FXMenuPane(self)
        FXMenuCommand(menu,"&Accept",None,self,self.ID_ACCEPT)
        FXMenuCommand(menu,"&Cancel",None,self,self.ID_CANCEL)
        FXMenuCascade(menu,"Submenu",None,submenu)
        FXMenuCommand(menu,"&Quit",None,self.getApp(),FXApp.ID_QUIT)

        # Popup menu
        pop = FXPopup(self)
        FXOption(pop,"One",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
        FXOption(pop,"Two",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
        FXOption(pop,"Three",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
        FXOption(pop,"Four",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
        FXOption(pop,"Five",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
        FXOption(pop,"Six",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
        FXOption(pop,"Seven",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
        FXOption(pop,"Eight",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
        FXOption(pop,"Nine",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)
        FXOption(pop,"Ten",opts=JUSTIFY_HZ_APART|ICON_AFTER_TEXT)

        # Option menu
        FXOptionMenu(contents,pop,FRAME_RAISED|FRAME_THICK|JUSTIFY_HZ_APART|ICON_AFTER_TEXT|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)

        # Button to pop menu
        FXMenuButton(contents,"&Menu",None,menu,MENUBUTTON_DOWN|JUSTIFY_LEFT|LAYOUT_TOP|FRAME_RAISED|FRAME_THICK|ICON_AFTER_TEXT|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)

        # Accept
        FXButton(buttons,"&Accept",None,self,self.ID_ACCEPT,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)

        # Cancel
        FXButton(buttons,"&Cancel",None,self,self.ID_CANCEL,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y);

# Main window class
class DialogTester(FXMainWindow):
    ID_SHOWDIALOG = FXMainWindow.ID_LAST
    ID_SHOWDIALOGMODAL = ID_SHOWDIALOG + 1

    def __init__(self, app):
        FXMainWindow.__init__(self,app,"Dialog Box Test",w=400,h=200)

        # Message map
        FXMAPFUNC(self,SEL_COMMAND,DialogTester.ID_SHOWDIALOG,DialogTester.onCmdShowDialog)
        FXMAPFUNC(self,SEL_COMMAND,DialogTester.ID_SHOWDIALOGMODAL,DialogTester.onCmdShowDialogModal)

        # Tooltip
        FXTooltip(self.getApp())

        # Menubar
        menubar = FXMenubar(self,LAYOUT_SIDE_TOP|LAYOUT_FILL_X)

        # Separator
        FXHorizontalSeparator(self,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|SEPARATOR_GROOVE)

        # File Menu
        filemenu = FXMenuPane(self)
        FXMenuCommand(filemenu,"&Quit",None,self.getApp(),FXApp.ID_QUIT,0)
        FXMenuTitle(menubar,"&File",None,filemenu)

        # Contents
        contents = FXHorizontalFrame(self,LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH)

        # Button to pop normal dialog
        FXButton(contents,"&Non-Modal Dialog...\tDisplay normal dialog",None,self,self.ID_SHOWDIALOG,FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)

        # Button to pop modal dialog
        FXButton(contents,"&Modal Dialog...\tDisplay modal dialog",None,self,self.ID_SHOWDIALOGMODAL,FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X|LAYOUT_CENTER_Y)

        # Build a dialog box
        self.dialog = FXTestDialog(self)

    # Display modelessly
    def onCmdShowDialog(self,sender,sel,ptr):
        self.dialog.show()

    # Display modally
    def onCmdShowDialogModal(self,sender,sel,ptr):
        self.dialog.execute()

    # Start
    def create(self):
        FXMainWindow.create(self)
        self.show()

def runme():
    import sys
    app = FXApp("Dialog", "Test")
    app.init(sys.argv)
    DialogTester(app)
    app.create()
    app.run()

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