~ubuntu-branches/ubuntu/lucid/thuban/lucid

« back to all changes in this revision

Viewing changes to Thuban/UI/dbdialog.py

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2007-04-07 21:03:28 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070407210328-9a20n4dmbim3c3yc
Tags: 1.2.0-1
* New upstream release.
* Patchset updated.
* Policy bumped to 3.7.2 (no changes).
* Updated for current Python Policy by using python-support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2001, 2003 by Intevation GmbH
 
1
# Copyright (c) 2001, 2003, 2004 by Intevation GmbH
2
2
# Authors:
3
3
# Martin Mueller <mmueller@intevation.de>
4
4
# Bernhard Herzog <bh@intevation.de>
11
11
 
12
12
import sys, traceback
13
13
 
14
 
from wxPython.wx import *
 
14
import wx
15
15
 
16
16
try:
17
17
    import psycopg
20
20
 
21
21
from Thuban import _
22
22
from Thuban.UI.dialogs import NonModalDialog
 
23
from Thuban.Model.table import FIELDTYPE_INT
23
24
from Thuban.Model.postgisdb import ConnectionError, PostGISConnection
24
25
from Thuban.Model.messages import DBCONN_ADDED, DBCONN_REMOVED
25
26
from messages import SESSION_REPLACED
34
35
ID_LB_DCLICK         = 9204
35
36
 
36
37
 
37
 
class ChooseDBTableDialog(wxDialog):
 
38
class ChooseDBTableDialog(wx.Dialog):
38
39
 
39
40
    def __init__(self, parent, session):
40
 
        wxDialog.__init__(self, parent, -1, _("Choose layer from database"),
41
 
                          style = wxDIALOG_MODAL|wxCAPTION)
 
41
        wx.Dialog.__init__(self, parent, -1, _("Choose layer from database"),
 
42
                          style = wx.DIALOG_MODAL|wx.CAPTION)
42
43
        self.session = session
43
44
        self.dbconns = self.session.DBConnections()
44
45
        self.tables = []
45
 
        self.list_box_4 = wxListBox(self, -1)
 
46
 
 
47
        #
 
48
        # Build the dialog
 
49
        #
 
50
 
 
51
        # Sizer for the entire dialog
 
52
        top = wx.FlexGridSizer(2, 1, 0, 0)
 
53
 
 
54
        # Sizer for the main part with the list boxes
 
55
        main_sizer = wx.BoxSizer(wx.HORIZONTAL)
 
56
        top.Add(main_sizer, 1, wx.EXPAND, 0)
 
57
 
 
58
        # The list box with the connections
 
59
        static_box = wx.StaticBoxSizer(wx.StaticBox(self, -1, _("Databases")),
 
60
                                   wx.HORIZONTAL)
 
61
        self.lb_connections = wx.ListBox(self, -1)
 
62
        static_box.Add(self.lb_connections, 0, wx.EXPAND, 0)
 
63
        main_sizer.Add(static_box, 1, wx.EXPAND, 0)
 
64
 
46
65
        for i in range(len(self.dbconns)):
47
 
            self.list_box_4.Append(self.dbconns[i].BriefDescription())
48
 
        if self.list_box_4.GetCount() > 0:
49
 
            self.list_box_4.SetSelection(0, True)
50
 
        self.DB_CHOOSE_RETRIEVE = wxButton(self, ID_DBCHOOSE_RETRIEVE,
51
 
                                           _("Retrieve"))
52
 
        self.list_box_5 = wxListBox(self, ID_LB_DCLICK)
53
 
        self.DB_CHOOSE_OK = wxButton(self, ID_DBCHOOSE_OK, _("OK"))
54
 
        self.DB_CHOOSE_CANCEL = wxButton(self, ID_DBCHOOSE_CANCEL, _("Cancel"))
55
 
        self.__do_layout()
56
 
 
57
 
        EVT_BUTTON(self, ID_DBCHOOSE_OK, self.OnOK)
58
 
        EVT_BUTTON(self, ID_DBCHOOSE_CANCEL, self.OnCancel)
59
 
        EVT_BUTTON(self, ID_DBCHOOSE_RETRIEVE, self.OnRetrieve)
60
 
        EVT_LISTBOX_DCLICK(self, ID_LB_DCLICK, self.OnLBDClick)
61
 
 
62
 
    def __do_layout(self):
63
 
        grid_sizer_1 = wxFlexGridSizer(2, 1, 0, 0)
64
 
        grid_sizer_3 = wxFlexGridSizer(1, 2, 0, 0)
65
 
        grid_sizer_2 = wxFlexGridSizer(1, 3, 0, 0)
66
 
        sizer_4 = wxStaticBoxSizer(wxStaticBox(self, -1, _("Tables")),
67
 
                                   wxHORIZONTAL)
68
 
        grid_sizer_4 = wxFlexGridSizer(3, 1, 0, 0)
69
 
        sizer_3 = wxStaticBoxSizer(wxStaticBox(self, -1, _("Databases")),
70
 
                                   wxHORIZONTAL)
71
 
        sizer_3.Add(self.list_box_4, 0, wxEXPAND, 0)
72
 
        grid_sizer_2.Add(sizer_3, 1, wxEXPAND, 0)
73
 
        grid_sizer_4.Add(20, 80, 0, wxEXPAND, 0)
74
 
        grid_sizer_4.Add(self.DB_CHOOSE_RETRIEVE, 0, wxALL
75
 
                        |wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4)
76
 
        grid_sizer_4.Add(20, 80, 0, wxEXPAND, 0)
77
 
        grid_sizer_2.Add(grid_sizer_4, 1, wxEXPAND, 0)
78
 
        sizer_4.Add(self.list_box_5, 0, wxEXPAND, 0)
79
 
        grid_sizer_2.Add(sizer_4, 1, wxEXPAND, 0)
80
 
        grid_sizer_1.Add(grid_sizer_2, 1, wxEXPAND, 0)
81
 
        grid_sizer_3.Add(self.DB_CHOOSE_OK, 0, wxALL|wxALIGN_RIGHT, 4)
82
 
        grid_sizer_3.Add(self.DB_CHOOSE_CANCEL, 0, wxALL, 4)
83
 
        grid_sizer_1.Add(grid_sizer_3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL, 4)
 
66
            self.lb_connections.Append(self.dbconns[i].BriefDescription())
 
67
        if self.lb_connections.GetCount() > 0:
 
68
            self.lb_connections.SetSelection(0, True)
 
69
 
 
70
        # The button box between the connections list box and the table
 
71
        # list box
 
72
        buttons = wx.FlexGridSizer(3, 1, 0, 0)
 
73
        buttons.Add( (20, 80), 0, wx.EXPAND, 0)
 
74
        retrieve_button = wx.Button(self, ID_DBCHOOSE_RETRIEVE, _("Retrieve"))
 
75
        self.Bind(wx.EVT_BUTTON, self.OnRetrieve, id=ID_DBCHOOSE_RETRIEVE)
 
76
        buttons.Add(retrieve_button, 0, wx.ALL
 
77
                    |wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 4)
 
78
        buttons.Add( (20, 80), 0, wx.EXPAND, 0)
 
79
        main_sizer.Add(buttons, 0, wx.EXPAND, 0)
 
80
 
 
81
        # The list box with the tables
 
82
        static_box = wx.StaticBoxSizer(wx.StaticBox(self, -1, _("Tables")),
 
83
                                   wx.HORIZONTAL)
 
84
        self.lb_tables = wx.ListBox(self, ID_LB_DCLICK)
 
85
        self.Bind(wx.EVT_LISTBOX, self.OnTableSelect, id=ID_LB_DCLICK)
 
86
        self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnLBDClick, id=ID_LB_DCLICK)
 
87
        static_box.Add(self.lb_tables, 0, wx.EXPAND, 0)
 
88
        main_sizer.Add(static_box, 1, wx.EXPAND, 0)
 
89
 
 
90
        # id column and geometry column selection
 
91
        box = wx.BoxSizer(wx.VERTICAL)
 
92
        box.Add(wx.StaticText(self, -1, _("ID Column")), 0,
 
93
                wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
 
94
        self.text_id_column = wx.ComboBox(self, -1, "")
 
95
        box.Add(self.text_id_column, 0,
 
96
                wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
 
97
 
 
98
        box.Add(wx.StaticText(self, -1, _("Geometry Column")), 0,
 
99
                wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
 
100
        self.text_geo_column = wx.ComboBox(self, -1, "")
 
101
        box.Add(self.text_geo_column, 0,
 
102
                wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
 
103
        main_sizer.Add(box, 1, wx.EXPAND, 0)
 
104
 
 
105
        # The standard button box at the bottom of the dialog
 
106
        buttons = wx.FlexGridSizer(1, 2, 0, 0)
 
107
        ok_button = wx.Button(self, ID_DBCHOOSE_OK, _("OK"))
 
108
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=ID_DBCHOOSE_OK)
 
109
        buttons.Add(ok_button, 0, wx.ALL|wx.ALIGN_RIGHT, 4)
 
110
        cancel_button = wx.Button(self, ID_DBCHOOSE_CANCEL, _("Cancel"))
 
111
        self.Bind(wx.EVT_BUTTON, self.OnCancel, id=ID_DBCHOOSE_CANCEL)
 
112
        buttons.Add(cancel_button, 0, wx.ALL, 4)
 
113
        top.Add(buttons, 1, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 4)
 
114
 
 
115
        # Autosizing
84
116
        self.SetAutoLayout(1)
85
 
        self.SetSizer(grid_sizer_1)
86
 
        grid_sizer_1.Fit(self)
87
 
        grid_sizer_1.SetSizeHints(self)
 
117
        self.SetSizer(top)
 
118
        top.Fit(self)
 
119
        top.SetSizeHints(self)
88
120
        self.Layout()
89
121
 
 
122
 
90
123
    def GetTable(self):
91
 
        i = self.list_box_5.GetSelection()
 
124
        i = self.lb_tables.GetSelection()
92
125
        if i >= 0:
93
 
            return self.selected_conn, self.tables[i]
 
126
            return (self.selected_conn, self.tables[i],
 
127
                    self.text_id_column.GetValue(),
 
128
                    self.text_geo_column.GetValue())
94
129
        return None
95
130
 
96
131
    def OnRetrieve(self, event):
97
 
        i = self.list_box_4.GetSelection()
 
132
        i = self.lb_connections.GetSelection()
98
133
        if i >= 0:
99
134
            self.selected_conn = self.dbconns[i]
100
135
            self.tables = self.selected_conn.GeometryTables()
101
 
            self.list_box_5.Set(self.tables)
 
136
            self.lb_tables.Set(self.tables)
 
137
 
 
138
    def OnTableSelect(self, event):
 
139
        i = self.lb_tables.GetSelection()
 
140
        self.text_id_column.Clear()
 
141
        self.text_geo_column.Clear()
 
142
        if i >= 0:
 
143
            for name, typ in self.selected_conn.table_columns(self.tables[i]):
 
144
                if typ == "geometry":
 
145
                    self.text_geo_column.Append(name)
 
146
                elif typ == FIELDTYPE_INT:
 
147
                    self.text_id_column.Append(name)
102
148
 
103
149
    def OnLBDClick(self, event):
104
 
        if self.list_box_5.GetSelection() >= 0:
105
 
            self.EndModal(wxID_OK)
 
150
        if self.lb_tables.GetSelection() >= 0:
 
151
            self.EndModal(wx.ID_OK)
106
152
            self.Show(False)
107
153
 
108
154
    def OnOK(self, event):
109
 
        self.EndModal(wxID_OK)
 
155
        self.EndModal(wx.ID_OK)
110
156
        self.Show(False)
111
157
 
112
158
    def OnCancel(self, event):
113
 
        self.EndModal(wxID_CANCEL)
 
159
        self.EndModal(wx.ID_CANCEL)
114
160
        self.Show(False)
115
161
 
116
162
 
117
 
class DBDialog(wxDialog):
 
163
class DBDialog(wx.Dialog):
118
164
 
119
165
    """Dialog for the parameters of a database connection"""
120
166
 
129
175
        using the dialog to ask for correct parameters when the
130
176
        connection can't be established.
131
177
        """
132
 
        wxDialog.__init__(self, parent, -1, title)
 
178
        wx.Dialog.__init__(self, parent, -1, title)
133
179
 
134
 
        top = wxBoxSizer(wxVERTICAL)
 
180
        top = wx.BoxSizer(wx.VERTICAL)
135
181
 
136
182
        if message:
137
 
            top.Add(wxStaticText(self, -1, message), 0,
138
 
                    wxALL|wxALIGN_CENTER_VERTICAL, 4)
139
 
 
140
 
        box = wxBoxSizer(wxHORIZONTAL)
141
 
        box.Add(wxStaticText(self, -1, _("Hostname:")), 0,
142
 
                wxALL|wxALIGN_CENTER_VERTICAL, 4)
143
 
        self.text_host = wxTextCtrl(self, -1, parameters.get("host", ""))
144
 
        box.Add(self.text_host, 2, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
145
 
        box.Add(wxStaticText(self, -1, _("Port:")), 0,
146
 
                wxALL|wxALIGN_CENTER_VERTICAL, 4)
147
 
        self.text_port = wxTextCtrl(self, -1, parameters.get("port", ""))
148
 
        box.Add(self.text_port, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
149
 
        top.Add(box, 0, wxEXPAND)
150
 
 
151
 
        box = wxBoxSizer(wxHORIZONTAL)
152
 
        box.Add(wxStaticText(self, -1, _("Database Name:")), 0,
153
 
                wxALL|wxALIGN_CENTER_VERTICAL, 4)
154
 
        self.text_dbname = wxTextCtrl(self, -1,
 
183
            top.Add(wx.StaticText(self, -1, message), 0,
 
184
                    wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
 
185
 
 
186
        box = wx.BoxSizer(wx.HORIZONTAL)
 
187
        box.Add(wx.StaticText(self, -1, _("Hostname:")), 0,
 
188
                wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
 
189
        self.text_host = wx.TextCtrl(self, -1, parameters.get("host", ""))
 
190
        box.Add(self.text_host, 2, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
 
191
        box.Add(wx.StaticText(self, -1, _("Port:")), 0,
 
192
                wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
 
193
        self.text_port = wx.TextCtrl(self, -1, parameters.get("port", ""))
 
194
        box.Add(self.text_port, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
 
195
        top.Add(box, 0, wx.EXPAND)
 
196
 
 
197
        box = wx.BoxSizer(wx.HORIZONTAL)
 
198
        box.Add(wx.StaticText(self, -1, _("Database Name:")), 0,
 
199
                wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
 
200
        self.text_dbname = wx.TextCtrl(self, -1,
155
201
                                      parameters.get("dbname", ""))
156
 
        box.Add(self.text_dbname, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
157
 
        top.Add(box, 0, wxEXPAND)
 
202
        box.Add(self.text_dbname, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
 
203
        top.Add(box, 0, wx.EXPAND)
158
204
 
159
 
        box = wxBoxSizer(wxHORIZONTAL)
160
 
        box.Add(wxStaticText(self, -1, _("User:")), 0,
161
 
                wxALL|wxALIGN_CENTER_VERTICAL, 4)
162
 
        self.text_user = wxTextCtrl(self, -1,
 
205
        box = wx.BoxSizer(wx.HORIZONTAL)
 
206
        box.Add(wx.StaticText(self, -1, _("User:")), 0,
 
207
                wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
 
208
        self.text_user = wx.TextCtrl(self, -1,
163
209
                                    parameters.get("user", ""))
164
 
        box.Add(self.text_user, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 4)
165
 
        box.Add(wxStaticText(self, -1, _("Password:")), 0,
166
 
                wxALL|wxALIGN_CENTER_VERTICAL, 4)
167
 
        self.text_password = wxTextCtrl(self, -1,
 
210
        box.Add(self.text_user, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 4)
 
211
        box.Add(wx.StaticText(self, -1, _("Password:")), 0,
 
212
                wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4)
 
213
        self.text_password = wx.TextCtrl(self, -1,
168
214
                                        parameters.get("password", ""),
169
 
                                        style = wxTE_PASSWORD)
170
 
        box.Add(self.text_password, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND,
 
215
                                        style = wx.TE_PASSWORD)
 
216
        box.Add(self.text_password, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND,
171
217
                4)
172
 
        top.Add(box, 0, wxEXPAND)
 
218
        top.Add(box, 0, wx.EXPAND)
173
219
 
174
 
        buttons = wxBoxSizer(wxHORIZONTAL)
175
 
        button = wxButton(self, wxID_OK, _("OK"))
176
 
        buttons.Add(button, 0, wxALL, 4)
177
 
        button = wxButton(self, wxID_CANCEL, _("Cancel"))
178
 
        buttons.Add(button, 0, wxALL, 4)
179
 
        top.Add(buttons, 0, wxALIGN_RIGHT, 4)
 
220
        buttons = wx.BoxSizer(wx.HORIZONTAL)
 
221
        button = wx.Button(self, wx.ID_OK, _("OK"))
 
222
        buttons.Add(button, 0, wx.ALL, 4)
 
223
        button = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
 
224
        buttons.Add(button, 0, wx.ALL, 4)
 
225
        top.Add(buttons, 0, wx.ALIGN_RIGHT, 4)
180
226
 
181
227
        self.SetAutoLayout(1)
182
228
        self.SetSizer(top)
183
229
        top.Fit(self)
184
230
        top.SetSizeHints(self)
185
231
 
186
 
        EVT_BUTTON(self, wxID_OK, self.OnOK)
187
 
        EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
 
232
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK)
 
233
        self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)
188
234
 
189
235
    def RunDialog(self):
190
236
        self.ShowModal()
194
240
    def end_dialog(self, result):
195
241
        self.result = result
196
242
        if result is not None:
197
 
            self.EndModal(wxID_OK)
 
243
            self.EndModal(wx.ID_OK)
198
244
        else:
199
 
            self.EndModal(wxID_CANCEL)
 
245
            self.EndModal(wx.ID_CANCEL)
200
246
        self.Show(False)
201
247
 
202
248
    def OnOK(self, event):
215
261
    """Databse connection management dialog"""
216
262
 
217
263
    def __init__(self, parent, name, session, *args, **kwds):
218
 
        kwds["style"] = wxICONIZE|wxCAPTION|wxMINIMIZE
 
264
        kwds["style"] = wx.ICONIZE|wx.CAPTION|wx.MINIMIZE
219
265
        NonModalDialog.__init__(self, parent, name, "")
220
266
        self.session = session
221
267
        self.app = self.parent.application
223
269
        self.app.Subscribe(SESSION_REPLACED, self.session_replaced)
224
270
        self.subscribe_session()
225
271
 
226
 
        self.DB_ListBox = wxListBox(self, -1,
227
 
                              style=wxLB_SINGLE|wxLB_HSCROLL|wxLB_ALWAYS_SB)
228
 
        self.DB_Add = wxButton(self, ID_DB_ADD, _("Add"))
229
 
        self.DB_Remove = wxButton(self, ID_DB_REMOVE, _("Remove"))
230
 
        self.DB_CLOSE = wxButton(self, wxID_CLOSE, _("Close"))
 
272
        self.DB_ListBox = wx.ListBox(self, -1,
 
273
                              style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.LB_ALWAYS_SB)
 
274
        self.DB_Add = wx.Button(self, ID_DB_ADD, _("Add"))
 
275
        self.DB_Remove = wx.Button(self, ID_DB_REMOVE, _("Remove"))
 
276
        self.DB_CLOSE = wx.Button(self, wx.ID_CLOSE, _("Close"))
231
277
        self.__set_properties()
232
278
        self.__do_layout()
233
 
        EVT_BUTTON(self, ID_DB_ADD, self.OnAdd)
234
 
        EVT_BUTTON(self, ID_DB_REMOVE, self.OnRemove)
235
 
        EVT_BUTTON(self, wxID_CLOSE, self.OnClose)
 
279
        self.Bind(wx.EVT_BUTTON, self.OnAdd, id=ID_DB_ADD)
 
280
        self.Bind(wx.EVT_BUTTON, self.OnRemove, id=ID_DB_REMOVE)
 
281
        self.Bind(wx.EVT_BUTTON, self.OnClose, id=wx.ID_CLOSE)
236
282
 
237
283
        self.conns_changed()
238
284
 
241
287
        self.DB_ListBox.SetSize((200, 157))
242
288
 
243
289
    def __do_layout(self):
244
 
        top = wxBoxSizer(wxVERTICAL)
245
 
 
246
 
        box = wxBoxSizer(wxHORIZONTAL)
247
 
 
248
 
        box.Add(self.DB_ListBox, 1, wxALL|wxEXPAND
249
 
                |wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 4)
250
 
 
251
 
        buttons = wxBoxSizer(wxVERTICAL)
252
 
        buttons.Add(self.DB_Add, 0, wxALL, 4)
253
 
        buttons.Add(self.DB_Remove, 0, wxALL, 4)
254
 
 
255
 
        box.Add(buttons, 0, wxEXPAND)
256
 
        top.Add(box, 1, wxEXPAND)
257
 
 
258
 
        buttons = wxBoxSizer(wxHORIZONTAL)
259
 
        buttons.Add(self.DB_CLOSE, 1, wxALL|wxALIGN_RIGHT, 4)
260
 
        top.Add(buttons, 0, wxALIGN_RIGHT)
 
290
        top = wx.BoxSizer(wx.VERTICAL)
 
291
 
 
292
        box = wx.BoxSizer(wx.HORIZONTAL)
 
293
 
 
294
        box.Add(self.DB_ListBox, 1, wx.ALL|wx.EXPAND
 
295
                |wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 4)
 
296
 
 
297
        buttons = wx.BoxSizer(wx.VERTICAL)
 
298
        buttons.Add(self.DB_Add, 0, wx.ALL, 4)
 
299
        buttons.Add(self.DB_Remove, 0, wx.ALL, 4)
 
300
 
 
301
        box.Add(buttons, 0, wx.EXPAND)
 
302
        top.Add(box, 1, wx.EXPAND)
 
303
 
 
304
        buttons = wx.BoxSizer(wx.HORIZONTAL)
 
305
        buttons.Add(self.DB_CLOSE, 1, wx.ALL|wx.ALIGN_RIGHT, 4)
 
306
        top.Add(buttons, 0, wx.ALIGN_RIGHT)
261
307
 
262
308
        self.SetAutoLayout(1)
263
309
        self.SetSizer(top)
299
345
        self.app.Unsubscribe(SESSION_REPLACED, self.session_replaced)
300
346
        NonModalDialog.OnClose(self, event)
301
347
 
302
 
    def RunMessageBox(self, title, text, flags = wxOK | wxICON_INFORMATION):
 
348
    def RunMessageBox(self, title, text, flags = wx.OK | wx.ICON_INFORMATION):
303
349
        """Run a modal message box with the given text, title and flags
304
350
        and return the result"""
305
351
        dlg = wxMessageDialog(self, text, title, flags)