1 |
jonathan |
888 |
# Copyright (c) 2003 by Intevation GmbH |
2 |
|
|
# Authors: |
3 |
|
|
# Jonathan Coles <[email protected]> |
4 |
|
|
# |
5 |
|
|
# This program is free software under the GPL (>=v2) |
6 |
|
|
# Read the file COPYING coming with Thuban for details. |
7 |
|
|
|
8 |
|
|
import os, sys, math |
9 |
|
|
from wxPython.wx import * |
10 |
|
|
|
11 |
|
|
from Thuban import _ |
12 |
|
|
|
13 |
|
|
ID_TABLE1 = 4001 |
14 |
|
|
ID_TABLE2 = 4002 |
15 |
|
|
|
16 |
|
|
class JoinDialog(wxDialog): |
17 |
|
|
|
18 |
|
|
def __init__(self, parent, title, session, layer = None): |
19 |
|
|
wxDialog.__init__(self, parent, -1, title, |
20 |
|
|
style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) |
21 |
|
|
|
22 |
|
|
self.choice_table1 = wxChoice(self, ID_TABLE1) |
23 |
|
|
self.choice_table2 = wxChoice(self, ID_TABLE2) |
24 |
|
|
|
25 |
|
|
self.choice_fields1 = wxChoice(self, -1) |
26 |
|
|
self.choice_fields2 = wxChoice(self, -1) |
27 |
|
|
|
28 |
|
|
self.button_join = wxButton(self, wxID_OK, _("Join")) |
29 |
|
|
self.button_join.SetDefault() |
30 |
|
|
self.button_close = wxButton(self, wxID_CANCEL, _("Close")) |
31 |
|
|
|
32 |
|
|
tablenames = ["Picard", "Worf", "LaForge", "Troy"] |
33 |
|
|
for name in tablenames: |
34 |
|
|
self.choice_table1.Append(name, None) |
35 |
|
|
self.choice_table2.Append(name, None) |
36 |
|
|
|
37 |
|
|
EVT_CHOICE(self, ID_TABLE1, self.OnTable1) |
38 |
|
|
EVT_CHOICE(self, ID_TABLE2, self.OnTable2) |
39 |
|
|
|
40 |
|
|
self.choice_table1.SetSelection(0) |
41 |
|
|
self.choice_table2.SetSelection(0) |
42 |
|
|
self.button_join.Enable(False) |
43 |
|
|
|
44 |
|
|
topBox = wxBoxSizer(wxVERTICAL) |
45 |
|
|
|
46 |
|
|
sizer = wxFlexGridSizer(2, 4) |
47 |
|
|
sizer.Add(wxStaticText(self, -1, _("Table Name:")), 0, wxALL, 4) |
48 |
|
|
sizer.Add(self.choice_table1, 1, wxEXPAND|wxALL, 4) |
49 |
|
|
sizer.Add(wxStaticText(self, -1, _("Table Name:")), 0, wxALL, 4) |
50 |
|
|
sizer.Add(self.choice_table2, 1, wxEXPAND|wxALL, 4) |
51 |
|
|
sizer.Add(wxStaticText(self, -1, _("Field Name:")), 0, wxALL, 4) |
52 |
|
|
sizer.Add(self.choice_fields1, 1, wxEXPAND|wxALL, 4) |
53 |
|
|
sizer.Add(wxStaticText(self, -1, _("Field Name:")), 0, wxALL, 4) |
54 |
|
|
sizer.Add(self.choice_fields2, 1, wxEXPAND|wxALL, 4) |
55 |
|
|
|
56 |
|
|
sizer.AddGrowableCol(1) |
57 |
|
|
sizer.AddGrowableCol(3) |
58 |
|
|
|
59 |
|
|
topBox.Add(sizer, 1, wxEXPAND|wxALL, 4) |
60 |
|
|
|
61 |
|
|
sizer = wxBoxSizer(wxHORIZONTAL) |
62 |
|
|
sizer.Add(self.button_join, 0, wxEXPAND|wxALL, 4) |
63 |
|
|
sizer.Add(60, 20, 0, wxEXPAND|wxALL, 4) |
64 |
|
|
sizer.Add(self.button_close, 0, wxEXPAND|wxALL, 4) |
65 |
|
|
|
66 |
|
|
topBox.Add(sizer, 0, wxALIGN_CENTER|wxALL, 4) |
67 |
|
|
|
68 |
|
|
self.SetAutoLayout(True) |
69 |
|
|
self.SetSizer(topBox) |
70 |
|
|
topBox.Fit(self) |
71 |
|
|
topBox.SetSizeHints(self) |
72 |
|
|
|
73 |
|
|
self.valid = False |
74 |
|
|
|
75 |
|
|
def OnOK(self, event): |
76 |
|
|
print "OnOK" |
77 |
|
|
|
78 |
|
|
def OnCancel(self, event): |
79 |
|
|
print "OnCancel" |
80 |
|
|
|
81 |
|
|
def OnTable1(self, event): |
82 |
|
|
print "OnTable1" |
83 |
|
|
#table = self.choice_table1.GetClientData() |
84 |
|
|
#self.choice_fields1.Clear() |
85 |
|
|
#for col in table.Columns(): |
86 |
|
|
#self.choice_fields1.Append(col.name, col) |
87 |
|
|
|
88 |
|
|
sel = self.choice_table1.GetSelection() |
89 |
|
|
self.valid = sel != -1 and sel != self.choice_table2.GetSelection() |
90 |
|
|
self.button_join.Enable(self.valid) |
91 |
|
|
|
92 |
|
|
def OnTable2(self, event): |
93 |
|
|
print "OnTable2" |
94 |
|
|
#table = self.choice_table2.GetClientData() |
95 |
|
|
#self.choice_fields2.Clear() |
96 |
|
|
#for col in table.Columns(): |
97 |
|
|
#self.choice_fields2.Append(col.name, col) |
98 |
|
|
|
99 |
|
|
sel = self.choice_table2.GetSelection() |
100 |
|
|
self.valid = sel != -1 and sel != self.choice_table1.GetSelection() |
101 |
|
|
self.button_join.Enable(self.valid) |
102 |
|
|
|
103 |
|
|
def GetJoin(self): |
104 |
|
|
pass |
105 |
|
|
# if self.valid: |
106 |
|
|
#return ((self.choice_table1.GetClientData |
107 |
|
|
|