-
Notifications
You must be signed in to change notification settings - Fork 0
/
Manager.py
599 lines (443 loc) · 22 KB
/
Manager.py
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
import wx
import wx.aui
import pickle
import os
import re
import glob
import time
import urllib
import shutil
import gzip
import json
from wxtbx import bitmaps, metallicbutton, icons
from iotbx import mtz, cif, reflection_file_reader
from Constants import *
from Shelx import CIFImporter, PDBImporter
from Refinement import Refinement
from Project import Project
from Tab import Tab
from Processing import Summary
from Controls import FileBrowser
class Manager(Tab):
def __init__(self, nb):
Tab.__init__(self, nb)
self._tabs = wx.aui.AuiNotebook(self, -1, style=wx.NB_TOP, size=(850,750))
self.sheet1 = Projects(self._tabs)
self.sheet2 = Jobs(self._tabs)
self._tabs.AddPage(self.sheet1, "Projects")
self._tabs.AddPage(self.sheet2, "Job List")
self.main = wx.BoxSizer(wx.HORIZONTAL)
self.main.Add(self._tabs, 1, wx.EXPAND)
self.SetSizer(self.main)
def get_project(self):
return self._project
def load_project(self):
self.sheet1.retrieve()
# ---------------------------------------------------------------------------
# Current Project Job List
class Jobs(Tab):
@staticmethod
def set_load_refinement(func):
Jobs.load_refinement = func
@staticmethod
def set_new_refinement(func):
Jobs.new_refinement = func
@staticmethod
def set_auto_refinement(func):
Jobs.auto_refinement = func
def __init__(self, nb):
Tab.__init__(self, nb)
self.job_list = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.LC_SINGLE_SEL, size=(700, 400))
self.job_list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._load_job)
titles = ['ID', 'Date', 'Title', 'Type', 'Status', 'R']
sizes = [65,135,225,130,80,60]
for i,t in enumerate(titles):
self.job_list.InsertColumn(i, t, width=sizes[i])
new = metallicbutton.MetallicButton(self, -1, 'New', '', bitmaps.fetch_icon_bitmap("actions", "window_new"), size=(120,40))
load = metallicbutton.MetallicButton(self, -1, 'Load', '', bitmaps.fetch_icon_bitmap("actions", "fileopen"), size=(120,40))
delete = metallicbutton.MetallicButton(self, -1, 'Delete', '', bitmaps.fetch_icon_bitmap("actions", "fileclose"), size=(120,40))
sum = metallicbutton.MetallicButton(self, -1, 'Summary', '', bitmaps.fetch_icon_bitmap("actions", "info"), size=(120,40))
self.Bind(wx.EVT_BUTTON, self._new_job, new)
self.Bind(wx.EVT_BUTTON, self._load_job, load)
self.Bind(wx.EVT_BUTTON, self._delete_job, delete)
self.Bind(wx.EVT_BUTTON, self._show_summary, sum)
import_cif = metallicbutton.MetallicButton(self, -1, 'Import HKL', '', icons.hkl_file.GetBitmap(), size=(120,40))
import_pdb = metallicbutton.MetallicButton(self, -1, 'Import PDB', '', icons.pdb_file.GetBitmap(), size=(120,40))
rcsb_dl = metallicbutton.MetallicButton(self, -1, 'RCSB PDB', '', bitmaps.fetch_icon_bitmap("actions", "down"), size=(120,40))
self.Bind(wx.EVT_BUTTON, self._import_pbd, import_pdb)
self.Bind(wx.EVT_BUTTON, self._import_cif, import_cif)
self.Bind(wx.EVT_BUTTON, self._download_files, rcsb_dl)
self.sidebar = wx.BoxSizer(wx.VERTICAL)
self.sidebar.Add(new, 0, wx.EXPAND | wx.ALL, 5)
self.sidebar.Add(load, 0, wx.EXPAND | wx.ALL, 5)
self.sidebar.Add(sum, 0, wx.EXPAND | wx.ALL, 5)
self.sidebar.Add(delete, 0, wx.EXPAND | wx.ALL, 5)
self.sidebar.AddSpacer(20)
self.sidebar.Add(import_cif, 0, wx.EXPAND | wx.ALL, 5)
self.sidebar.Add(import_pdb, 0, wx.EXPAND | wx.ALL, 5)
self.sidebar.AddSpacer(10)
self.sidebar.Add(rcsb_dl, 0, wx.EXPAND | wx.ALL, 5)
self.main = wx.BoxSizer(wx.HORIZONTAL)
self.main.Add(self.job_list, 0, wx.EXPAND|wx.ALL, 5)
self.main.Add(self.sidebar, 0, wx.EXPAND|wx.ALL, 5)
self.SetSizer(self.main)
@Tab.wproj
def _show_summary(self, event):
ids, files, dirs = self._get_inputs()
sel = self.job_list.GetFirstSelected()
dlg = Summary(files[sel], dirs[sel], self._project.root())
dlg.Show()
def _test(self):
self.job_list.SetItemState(0, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
self._load_job('')
@Tab.wproj
def _delete_job(self, event):
ids, files, dirs = self._get_inputs()
sel = self.job_list.GetFirstSelected()
if sel > -1:
shutil.rmtree(self._project.root() + '/' + dirs[sel])
#self._project.job_count(-1)
self.refresh_tabs()
@Tab.wproj
def _load_job(self, event):
if hasattr(self, 'load_refinement'):
ids, files, dirs = self._get_inputs()
sel = self.job_list.GetFirstSelected()
if sel > -1:
self.load_refinement(str(files[sel]), dirs[sel])
@Tab.wproj
def _new_job(self, event):
if hasattr(self, 'new_refinement'):
sel = self.job_list.GetFirstSelected()
hkl = None
ins = None
res = None
if sel > -1:
ids, files, dirs = self._get_inputs()
if os.path.exists(files[sel]):
r = pickle.load(open(files[sel], 'rb'))
p = r.parameters()
hkl = os.path.basename(p['hkl'])
ins = dirs[sel].replace(self._project.root(), '')+'/Output'
res = p['res']
self.new_refinement(hkl=hkl,ins=ins,resh=res)
@Tab.wproj
def _auto_job(self, event):
if hasattr(self, 'auto_refinement'):
self.auto_refinement()
@Tab.wproj
def refresh(self):
#print 'refreshing job list...'
self.job_list.DeleteAllItems()
ids, files, dirs = self._get_inputs()
for i,d in enumerate(files):
r = pickle.load(open(d, 'rb'))
p = r.parameters()
self.job_list.InsertStringItem(i, str(ids[i]))
p['time'] = time.strftime('%H:%M %d-%m-%Y', time.localtime(p['time']))
self.job_list.SetStringItem(i, 1, p['time'])
self.job_list.SetStringItem(i, 2, p['title'])
self.job_list.SetStringItem(i, 3, REFINEMENT_TYPES[p['type']])
self.job_list.SetStringItem(i, 4, p['status'])
p['r'] = 'N/A' if p['r'] == -1 else (p['r'] if type(p['r']) == type(str()) else str('%.4f' % p['r']))
self.job_list.SetStringItem(i, 5, p['r'])
@Tab.wproj
def _import_pbd(self, event):
dlg = NewPDB(self, -1, 'Import PDB File')
dlg.CentreOnParent()
val = dlg.ShowModal()
if val == 1:
print dlg.get_file(), self._project.root()
p = PDBImporter(dlg.get_file(), self._project.root(), self)
if p.finished():
self.set_status('PDB file sucessfully imported')
wx.MessageBox('Model file successfully imported', 'Sucess', style=wx.OK | wx.CENTRE)
dlg.Destroy()
@Tab.wproj
def _import_cif(self, event):
dlg = NewCIF(self, -1, 'Import CIF File')
val = dlg.ShowModal()
if val == 1:
cif, f_lab, r_lab = dlg.get_values()
if cif and f_lab and r_lab:
c = CIFImporter(cif, f_lab, r_lab, self._project.root())
if c.finished():
self.set_status('Reflection file successfully imported')
wx.MessageBox('Reflection file successfully imported', 'Sucess', style=wx.OK | wx.CENTRE)
dlg.Destroy()
@Tab.wproj
def _download_files(self, events):
dlg = Retrieve(self, -1, 'Download from RCSB', self._project.root())
val = dlg.ShowModal()
dlg.Destroy()
def _get_inputs(self):
id = []
files = []
dirs = []
for f in sorted(os.listdir(self._project.root()), key=self.sort_dirs):
m = re.match('(\d+)_', f)
if m:
res = sorted(glob.glob(self._project.root() + os.sep + f + os.sep + '*.dat'))
if len(res) > 0:
id.append(m.group(1))
files.append(res[0])
dirs.append(f)
return id, files, dirs
def sort_dirs(self, item):
l = item.split('_')
if l[0].isdigit():
i = int(l[0])
else:
i = item
return i
# ----------------------------------------------------------------------------
# Project Manager
class Projects(Tab):
def __init__(self, nb):
Tab.__init__(self, nb)
self.project_list = wx.ListCtrl(self, -1, style=wx.LC_REPORT, size=(700, 400))
self.project_list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._load_project)
self._il = wx.ImageList(16,16)
self._il.Add(bitmaps.fetch_icon_bitmap("actions", "agt_action_success", scale=(16,16)))
self.project_list.SetImageList(self._il, wx.IMAGE_LIST_SMALL)
titles = ['', 'Title', '# Jobs', 'Last Action']
sizes = [20,400, 100,140]
for i,t in enumerate(titles):
self.project_list.InsertColumn(i, t)
self.project_list.SetColumnWidth(i, sizes[i])
self.sidebar = wx.BoxSizer(wx.VERTICAL)
new = metallicbutton.MetallicButton(self, -1, 'New', '', bitmaps.fetch_icon_bitmap("actions", "folder_new"), size=(120,40))
delete = metallicbutton.MetallicButton(self, -1, 'Delete', '', bitmaps.fetch_icon_bitmap("actions", "fileclose"), size=(120,40))
load = metallicbutton.MetallicButton(self, -1, 'Load', '', bitmaps.fetch_icon_bitmap("actions", "folder"), size=(120,40))
self.Bind(wx.EVT_BUTTON, self._new_project, new)
self.Bind(wx.EVT_BUTTON, self._load_project, load)
self.Bind(wx.EVT_BUTTON, self._delete_project, delete)
self.sidebar.Add(new, 0, wx.EXPAND|wx.ALL, 5)
self.sidebar.Add(load, 0, wx.EXPAND|wx.ALL, 5)
self.sidebar.Add(delete, 0, wx.EXPAND|wx.ALL, 5)
self.sizer = wx.BoxSizer(wx.HORIZONTAL)
self.sizer.Add(self.project_list, 0, wx.EXPAND | wx.ALL, 5)
self.sizer.Add(self.sidebar, 0, wx.EXPAND | wx.ALL, 5)
self.SetSizer(self.sizer)
def retrieve(self):
print self.s.current
if self.s.current is not None:
if os.path.exists(self.s.current) and os.path.exists(self.s.current + '/.proton8') and self.s.current in self.s.projects:
Tab._project = Project(self.s.current, cwd=True)
self._update_sb('Project: ' + Tab._project.title(), 1)
else:
self.s.current = None
self.s.del_project(self.s.current)
self._update_sb('Project: None', 1)
self.refresh()
else:
self._update_sb('Project: None', 1)
self.refresh()
def get_project(self):
return self._project
def _delete_project(self, event):
sel = self.project_list.GetFirstSelected()
if sel < len(self.s.projects):
self.s.del_project(self.s.projects[sel])
self.refresh_tabs()
def _new_project(self, event):
dlg = NewProject(self, -1, 'New Project')
v = dlg.ShowModal()
if v:
title, root = dlg.vals()
self.s.add_project(root, title)
self.refresh_tabs()
def _load_project(self, event):
sel = self.project_list.GetFirstSelected()
if sel < len(self.s.projects):
self.s.load_project(self.s.projects[sel])
self.refresh_tabs()
def refresh(self):
self.project_list.DeleteAllItems()
i = 0
for r in self.s.projects:
if os.path.exists(r + '/.proton8/project.json'):
proj = Project(r)
t = time.strftime('%H:%M %d-%m-%Y', time.localtime(proj.last_time())) if proj.last_time() > -1 else 'N/A'
self.project_list.InsertStringItem(i, '')
self.project_list.SetStringItem(i, 1, str(proj.title()))
self.project_list.SetStringItem(i, 2, str(proj.job_count()))
self.project_list.SetStringItem(i, 3, t)
if self.s.current == r:
self.project_list.SetItemImage(i, 0)
i +=1
self._update_sb('Project: ' + Tab._project.title() if Tab._project else 'None', 1)
class NewProject(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title)
self._root = None
self.input_sizer = wx.FlexGridSizer(cols=2, rows=0, vgap=5, hgap=5)
self.input_sizer.Add(wx.StaticText(self, -1, 'Title'), 0, wx.EXPAND|wx.ALL, 5)
self._title = wx.TextCtrl(self, -1, '')
self.input_sizer.Add(self._title, 0, wx.EXPAND|wx.ALL, 5)
self.input_sizer.Add(wx.StaticText(self, -1, 'Project Root'), 0, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
self._browser = FileBrowser(self, '', 'Select a Project Directory', dir=True)
self.input_sizer.Add(self._browser.sizer(), 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
self._buttons = wx.BoxSizer(wx.HORIZONTAL)
self._buttons.Add(wx.Button(self, 0, 'Create'), 1, wx.EXPAND|wx.ALL, 5)
self._buttons.Add(wx.Button(self, 1, 'Cancel'), 1, wx.EXPAND|wx.ALL, 5)
self.Bind(wx.EVT_BUTTON, self._create, id=0)
self.Bind(wx.EVT_BUTTON, self._cancel, id=1)
self.input_sizer.Add((10,10), 1, wx.EXPAND)
self.input_sizer.Add(self._buttons, 1, wx.EXPAND|wx.ALL, 5)
self.SetSizer(self.input_sizer)
self.Fit()
def vals(self):
return self._title.GetValue(), self._browser.file()
def _create(self, event):
self.EndModal(1)
def _cancel(self, event):
self.EndModal(0)
# ----------------------------------------------------------------------------
# Retrieve PDB/SF from PDB Dialog
class Retrieve(wx.Dialog):
def __init__(self, parent, id, title, root):
wx.Dialog.__init__(self, parent, id, title)
self._root = str(root)
self._pdb_label = wx.StaticText(self, -1, 'PDB Code')
self._pdb_entry = wx.TextCtrl(self, -1)
self._pdb_sizer = wx.BoxSizer(wx.HORIZONTAL)
self._pdb_sizer.Add(self._pdb_label, 0, wx.EXPAND|wx.ALL, 5)
self._pdb_sizer.Add(self._pdb_entry, 0, wx.EXPAND|wx.ALL, 5)
self._gauge_label = wx.StaticText(self, -1, '')
self._gauge = wx.Gauge(self, -1, 9)
self._gauge.Hide()
self._gauge_label.Hide()
self._buttons = wx.BoxSizer(wx.HORIZONTAL)
self._buttons.Add(wx.Button(self, 0, 'Import'), 0, wx.EXPAND|wx.ALL, 5)
self._buttons.Add(wx.Button(self, 1, 'Close'), 0, wx.EXPAND|wx.ALL, 5)
self.Bind(wx.EVT_BUTTON, self._import, id=0)
self.Bind(wx.EVT_BUTTON, self._close, id=1)
self.main = wx.BoxSizer(wx.VERTICAL)
self.main.Add(self._pdb_sizer, 0, wx.EXPAND|wx.ALL, 5)
self.main.Add(self._gauge_label, 0, wx.EXPAND|wx.ALL, 5)
self.main.Add(self._gauge, 0, wx.EXPAND|wx.ALL, 5)
self.main.Add(self._buttons, 0, wx.EXPAND|wx.ALL, 5)
self.SetSizer(self.main)
self.Fit()
def _import(self, event):
self._gauge.Show()
self._gauge_label.Show()
self.Fit()
pdb = str(self._pdb_entry.GetValue())
if not os.path.exists(self._root + '/temp'):
os.mkdir(self._root + '/temp')
self._set_status(0, 'Downloading PDB')
urllib.urlretrieve('http://www.rcsb.org/pdb/files/' + pdb.lower() + '.pdb.gz', self._root + '/temp/' + pdb.lower() + '.pdb.gz')
self._set_status(1, 'Uncompressing PDB')
out = open(self._root + '/temp/' + pdb.lower() + '.pdb', 'wb')
out.write(gzip.open(self._root + '/temp/' + pdb.lower() + '.pdb.gz', 'rb').read())
out.close()
self._set_status(2, 'Converting PDB to INS')
PDBImporter(self._root + '/temp/' + pdb.lower() + '.pdb', self._root)
self._set_status(3, 'Downloading SFs')
urllib.urlretrieve('http://www.rcsb.org/pdb/files/r' + pdb.upper() + 'sf.ent.gz', self._root + '/temp/r' + pdb.upper() + 'sf.ent.gz')
self._set_status(4, 'Uncompressing SFs')
sff = self._root + '/temp/' + pdb.lower() + '.cif'
out = open(sff, 'wb')
out.write(gzip.open(self._root + '/temp/r' + pdb.upper() + 'sf.ent.gz', 'rb').read())
out.close()
self._set_status(5, 'Finding Columns')
if os.path.exists(sff):
m = reflection_file_reader.any_reflection_file(sff)
fs = []
rs = []
for col in m.as_miller_arrays():
if (col.is_xray_intensity_array() or col.is_xray_amplitude_array()) and not col.anomalous_flag():
fs.append(col.info().label_string())
elif col.info().label_string().find('status') > -1:
rs.append(col.info().label_string())
self._set_status(6, 'Converting CIF to HKL')
if len(fs) > 0:
for f in fs:
if len(rs) > 0:
CIFImporter(sff, f, rs[0], self._root)
else:
CIFImporter(sff, f, '', self._root, True)
self._set_status(7, 'Cleaning Up...')
os.remove(self._root + '/temp/' + pdb.lower() + '.pdb.gz')
os.remove(self._root + '/temp/' + pdb.lower() + '.pdb')
os.remove(self._root + '/temp/r' + pdb.upper() + 'sf.ent.gz')
os.remove(self._root + '/temp/' + pdb.lower() + '.cif')
self._set_status(8, 'Finished')
self._close('')
wx.MessageBox('Input files successfully generated for ' + pdb, 'Sucess', style=wx.OK | wx.CENTRE)
def _close(self, event):
self.EndModal(1)
def _set_status(self, point, text):
self._gauge_label.SetLabel(text)
self._gauge.SetValue(point)
# ----------------------------------------------------------------------------
# Import Reflections Dialog
class NewCIF(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title)#, size=(330,340))
self._browse = FileBrowser(self, 'CIF File (*.cif)|*.cif|MTZ File (*.mtz)|*.mtz', 'Select a reflection file', callback=self._refresh)
self._input_sizer = wx.FlexGridSizer(cols=2, rows=0, hgap=5, vgap=5)
self._inputs = [
wx.StaticText(self, -1, 'Reflection'),
self._browse.sizer(),
wx.StaticText(self, -1, 'F, SigF'),
wx.ComboBox(self, -1, choices=[], style=wx.CB_READONLY),
wx.StaticText(self, -1, 'FreeR'),
wx.ComboBox(self, -1, choices=[], style=wx.CB_READONLY),
]
for i in range(len(self._inputs)):
self._input_sizer.Add(self._inputs[i], 0, wx.EXPAND)
self._buttons = wx.BoxSizer(wx.HORIZONTAL)
self._buttons.Add(wx.Button(self, 0, 'Import'), 1, wx.EXPAND|wx.ALL, 5)
self._buttons.Add(wx.Button(self, 1, 'Cancel'), 1, wx.EXPAND|wx.ALL, 5)
self._input_sizer.Add((10,10), 1, wx.EXPAND)
self._input_sizer.Add(self._buttons, 1, wx.EXPAND)
self.Bind(wx.EVT_BUTTON, self._import, id=0)
self.Bind(wx.EVT_BUTTON, self._close, id=1)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self._input_sizer, 1, wx.EXPAND|wx.ALL, 5)
self.SetSizer(self.sizer)
self.Fit()
def _close(self, event):
self.EndModal(0)
def _import(self, event):
self.EndModal(1)
def get_values(self):
return self._browse.file(), self._inputs[3].GetValue(), self._inputs[5].GetValue()
def _refresh(self):
m = reflection_file_reader.any_reflection_file(self._browse.file())
self._inputs[3].Clear()
self._inputs[5].Clear()
for col in m.as_miller_arrays():
if col.is_xray_intensity_array() or col.is_xray_amplitude_array():
self._inputs[3].Append(col.info().label_string())
else:
self._inputs[5].Append(col.info().label_string())
# ----------------------------------------------------------------------------
# Import PDB File
class NewPDB(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title)#, size=(330,340))
self._input_sizer = wx.FlexGridSizer(cols=2, rows=0, hgap=5, vgap=5)
self._browse = FileBrowser(self, '*.pdb', 'Select a PDB File')
self._input_sizer.Add(wx.StaticText(self, -1, 'PDB File'), 0, wx.EXPAND|wx.TOP|wx.LEFT, 5)
self._input_sizer.Add(self._browse.sizer())
self._buttons = wx.BoxSizer(wx.HORIZONTAL)
self._buttons.Add(wx.Button(self, 0, 'Import'), 1, wx.EXPAND|wx.ALL, 5)
self._buttons.Add(wx.Button(self, 1, 'Cancel'), 1, wx.EXPAND|wx.ALL, 5)
self._input_sizer.Add((10,10), 1, wx.EXPAND)
self._input_sizer.Add(self._buttons, 1, wx.EXPAND)
self.Bind(wx.EVT_BUTTON, self._import, id=0)
self.Bind(wx.EVT_BUTTON, self._close, id=1)
self.main = wx.BoxSizer(wx.VERTICAL)
self.main.Add(self._input_sizer, 0, wx.EXPAND|wx.ALL, 5)
self.SetSizer(self.main)
self.Fit()
def _close(self, event):
self.EndModal(0)
def _import(self, event):
self.EndModal(1)
def get_file(self):
return self._browse.file()