7 |
|
|
8 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
9 |
|
|
10 |
from wxPython.wx import * |
import wx |
11 |
|
|
12 |
from Thuban import _ |
from Thuban import _ |
13 |
|
|
20 |
self.fill_list(table, shape) |
self.fill_list(table, shape) |
21 |
|
|
22 |
|
|
23 |
class LabelDialog(wxDialog): |
class LabelDialog(wx.Dialog): |
24 |
|
|
25 |
def __init__(self, parent, table, shape_index): |
def __init__(self, parent, table, shape_index): |
26 |
wxDialog.__init__(self, parent, -1, _("Label Values"), |
wx.Dialog.__init__(self, parent, -1, _("Label Values"), |
27 |
wxDefaultPosition, |
wx.DefaultPosition, |
28 |
style = wxRESIZE_BORDER|wxCAPTION|wxDIALOG_MODAL) |
style = wx.RESIZE_BORDER|wx.CAPTION|wx.DIALOG_MODAL) |
29 |
|
|
30 |
self.parent = parent |
self.parent = parent |
31 |
self.dialog_layout(table, shape_index) |
self.dialog_layout(table, shape_index) |
32 |
|
|
33 |
def dialog_layout(self, table, shape_index): |
def dialog_layout(self, table, shape_index): |
34 |
top_box = wxBoxSizer(wxVERTICAL) |
top_box = wx.BoxSizer(wx.VERTICAL) |
35 |
|
|
36 |
self.list = LabelListCtrl(self, -1, table, shape_index) |
self.list = LabelListCtrl(self, -1, table, shape_index) |
37 |
self.list.SetSize(wxSize(305,200)) |
self.list.SetSize(wx.Size(305,200)) |
38 |
top_box.Add(self.list, 1, wxEXPAND|wxALL, 4) |
top_box.Add(self.list, 1, wx.EXPAND|wx.ALL, 4) |
39 |
|
|
40 |
box = wxBoxSizer(wxHORIZONTAL) |
box = wx.BoxSizer(wx.HORIZONTAL) |
41 |
box.Add(wxButton(self, wxID_OK, _("OK")), 0, wxALL, 4) |
box.Add(wx.Button(self, wx.ID_OK, _("OK")), 0, wx.ALL, 4) |
42 |
box.Add(wxButton(self, wxID_CANCEL, _("Cancel")), 0, wxALL, 4) |
box.Add(wx.Button(self, wx.ID_CANCEL, _("Cancel")), 0, wx.ALL, 4) |
43 |
top_box.Add(box, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10) |
top_box.Add(box, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 10) |
44 |
|
|
45 |
EVT_BUTTON(self, wxID_OK, self.OnOK) |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=wx.ID_OK) |
46 |
EVT_BUTTON(self, wxID_CANCEL, self.OnCancel) |
self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL) |
47 |
|
|
48 |
self.SetAutoLayout(True) |
self.SetAutoLayout(True) |
49 |
self.SetSizer(top_box) |
self.SetSizer(top_box) |
53 |
def OnOK(self, event): |
def OnOK(self, event): |
54 |
result = self.list.GetValue() |
result = self.list.GetValue() |
55 |
if result is not None: |
if result is not None: |
56 |
self.end_dialog(wxID_OK, str(result)) |
self.end_dialog(wx.ID_OK, str(result)) |
57 |
else: |
else: |
58 |
self.end_dialog(wxID_CANCEL, None) |
self.end_dialog(wx.ID_CANCEL, None) |
59 |
|
|
60 |
def OnCancel(self, event): |
def OnCancel(self, event): |
61 |
self.end_dialog(wxID_CANCEL, None) |
self.end_dialog(wx.ID_CANCEL, None) |
62 |
|
|
63 |
def end_dialog(self, wx_result, result): |
def end_dialog(self, wx_result, result): |
64 |
self.result = result |
self.result = result |
66 |
|
|
67 |
def run_label_dialog(parent, table, shape_index): |
def run_label_dialog(parent, table, shape_index): |
68 |
dialog = LabelDialog(parent, table, shape_index) |
dialog = LabelDialog(parent, table, shape_index) |
69 |
if dialog.ShowModal() == wxID_OK: |
if dialog.ShowModal() == wx.ID_OK: |
70 |
return dialog.result |
return dialog.result |
71 |
else: |
else: |
72 |
return None |
return None |