File: FilterDialogDemo.py

package info (click to toggle)
editra 0.6.58-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 13,320 kB
  • sloc: python: 71,924; sql: 258; ansic: 242; sh: 187; php: 45; tcl: 38; lisp: 38; perl: 23; java: 22; pascal: 21; cpp: 20; haskell: 20; xml: 18; cs: 18; erlang: 17; ruby: 16; asm: 15; ada: 9; csh: 9; makefile: 9; ml: 9
file content (106 lines) | stat: -rw-r--r-- 3,637 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
###############################################################################
# Name: FilterDialog.py                                                       #
# Purpose: Test and demo file for eclib.FilterDialog                          #
# Author: Cody Precord <cprecord@editra.org>                                  #
# Copyright: (c) 2010 Cody Precord <staff@editra.org>                         #
# Licence: wxWindows Licence                                                  #
###############################################################################

"""
Test file for testing the FilterDialog.

"""

__author__ = "Cody Precord <cprecord@editra.org>"
__svnid__ = "$Id: FilterDialogDemo.py 63824 2010-04-02 01:10:44Z CJP $"
__revision__ = "$Revision: 63824 $"

#-----------------------------------------------------------------------------#
# Imports
import os
import sys
import wx

import IconFile

# Put local package on the path
#sys.path.insert(0, os.path.abspath('../../src'))
import eclib

#-----------------------------------------------------------------------------#

class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, wx.ID_ANY, size=(500,500))

        # Attributes
        self.btnDlg = wx.Button(self, label="Show Filter Dialog")
        self.log = log

        # Layout
        self.__DoLayout()

        # Event Handlers
        self.Bind(wx.EVT_BUTTON, self.OnShowDialogBtn)

    def __DoLayout(self):
        """Layout the panel"""
        vsizer = wx.BoxSizer(wx.VERTICAL)
        vsizer.Add(self.btnDlg, 0, wx.ALIGN_CENTER|wx.TOP, 20)
        self.SetSizer(vsizer)

    def OnShowDialogBtn(self, evt):
        """Show one of the test dialogs"""
        e_obj = evt.GetEventObject()
        if e_obj == self.btnDlg:
            dlg = eclib.FilterDialog(self, title="Filter Some Fruit",
                                     style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
            dlg.SetInitialSize()
            # Dialog is populated using a map of string to bool values
            # False means put in the not included list
            # True means put in the includes list
            values = dict(apple=True, orange=False,
                           banana=False, peach=False,
                           mango=True, strawberry=False)
            dlg.SetListValues(values)
            dlg.CenterOnParent()
            if dlg.ShowModal() == wx.ID_OK:
                includes = dlg.GetIncludes()
                excludes = dlg.GetExcludes()
                self.log.write("Include Values: %s" % ",".join(includes))
                self.log.write("Exclude Values: %s" % ",".join(excludes))

#----------------------------------------------------------------------

def runTest(frame, nb, log):
    win = TestPanel(nb, log)
    return win

class TestLog:
    def __init__(self):
        pass

    def write(self, msg):
        print msg

#----------------------------------------------------------------------

overview = eclib.filterdlg.__doc__
title = "FilterDialog"

#-----------------------------------------------------------------------------#
if __name__ == '__main__':
    try:
        import run
    except ImportError:
        app = wx.PySimpleApp(False)
        frame = wx.Frame(None, title="FilterDialog Demo")
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(TestPanel(frame, TestLog()), 1, wx.EXPAND)
        frame.CreateStatusBar()
        frame.SetSizer(sizer)
        frame.SetInitialSize((300, 300))
        frame.Show()
        app.MainLoop()
    else:
        run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])