]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/MultipleChoiceDialog.py
demo tweaks
[wxWidgets.git] / wxPython / demo / MultipleChoiceDialog.py
CommitLineData
8fa876ca
RD
1
2import wx
33785d9f 3import wx.lib.dialogs
cf694132
RD
4
5#---------------------------------------------------------------------------
6
34a544a6
RD
7class TestPanel(wx.Panel):
8 def __init__(self, parent, log):
9 self.log = log
10 wx.Panel.__init__(self, parent, -1)
11
12 b = wx.Button(self, -1, "Create and Show a MultipleChoiceDialog", (50,50))
13 self.Bind(wx.EVT_BUTTON, self.OnButton, b)
14
15
16 def OnButton(self, evt):
17 lst = [ 'apple', 'pear', 'banana', 'coconut', 'orange', 'grape', 'pineapple',
18 'blueberry', 'raspberry', 'blackberry', 'snozzleberry',
19 'etc', 'etc..', 'etc...' ]
20
21 dlg = wx.lib.dialogs.MultipleChoiceDialog(
22 self,
23 "Pick some from\n this list\nblah blah...",
24 "m.s.d.", lst)
8fa876ca 25
34a544a6
RD
26 if (dlg.ShowModal() == wx.ID_OK):
27 self.log.write("Selection: %s -> %s\n" % (dlg.GetValue(), dlg.GetValueString()))
8fa876ca 28
34a544a6 29 dlg.Destroy()
da65a439 30
34a544a6
RD
31
32
33#---------------------------------------------------------------------------
34
35def runTest(frame, nb, log):
36 win = TestPanel(nb, log)
37 return win
cf694132
RD
38
39#---------------------------------------------------------------------------
40
41
42
8fa876ca
RD
43overview = """\
44<html>
45<body>
cf694132 46
8fa876ca
RD
47This is a Python implementation of a dialog that is not yet implemented in wxWindows
48proper, so don't let the wxWindows documentation mislead you.
cf694132 49
33785d9f 50<p><code><b>MultipleChoiceDialog</b>(self, parent, msg, title, lst,
95bfd958 51pos = wx.wxDefaultPosition, size = (200,200), style = wx.DEFAULT_DIALOG_STYLE)
8fa876ca 52</code>
cf694132 53
8fa876ca
RD
54<dl>
55<dt><code>parent</code>
56<dd>The parent window
cf694132 57
8fa876ca
RD
58<dt><code>msg</code>
59<dd>The message that will be displayed above the list
cf694132 60
8fa876ca
RD
61<dt><code>title</code>
62<dd>The text that will appear on the title bar
cf694132 63
8fa876ca
RD
64<dt><code>lst</code>
65<dd>A Python list of choices that will appear in the dialog.
66
67<dt><code>pos</code>
68<dd>The position of the dialog
1fded56b 69
8fa876ca
RD
70<dt><code>size</code>
71<dd>The size of the dialog
1fded56b 72
8fa876ca
RD
73<dt><code>style</code>
74<dd>The style for the dialog. Only styles normally available to wxDialog are
75available.
1fded56b 76
8fa876ca 77</dl>
1fded56b 78
8fa876ca
RD
79<b><font size=+1><code>Methods</code></font></b>
80
81<dl>
82<dt><code>GetValue</code>
83<dd>Returns a tuple containing the indices of the selected items
84
85<dt><code>GetValueString</code>
86<dd>Returns a tuple containing the text of the selected items
87
88</dl>
89
33785d9f 90Additionally, MultipleChoiceDialog.lbox is a standard wx.ListBox which supports all
8fa876ca
RD
91methods applicable to that class.
92
93</body>
94</html>
95"""
1fded56b
RD
96
97if __name__ == '__main__':
98 import sys,os
99 import run
8eca4fef 100 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])