/[thuban]/branches/WIP-pyshapelib-bramz/Extensions/wms/infodialog.py
ViewVC logotype

Contents of /branches/WIP-pyshapelib-bramz/Extensions/wms/infodialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2734 - (show annotations)
Thu Mar 1 12:42:59 2007 UTC (18 years ago) by bramz
File MIME type: text/x-python
File size: 3368 byte(s)
made a copy
1 # Copyright (c) 2004 by Intevation GmbH
2 # Authors:
3 # Martin Schulze <[email protected]>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 """
20 Information dialog to display various information about a WMS layer.
21
22 class wmsInfoDialog(ThubanFrame):
23 __init__
24
25 dialog_layout(text)
26
27 calcText(layer)
28
29 """
30
31 __version__ = "$Revision$"
32 # $Source$
33 # $Id$
34
35 from Thuban import _
36 from Thuban.UI.dialogs import ThubanFrame
37
38 from wxPython.wx import wxBoxSizer, wxTextCtrl, wxVERTICAL, \
39 wxHORIZONTAL, wxTE_READONLY, wxTE_MULTILINE, wxTE_LINEWRAP, \
40 wxEXPAND, wxALL, wxButton, wxALIGN_CENTER_HORIZONTAL, wxID_OK, \
41 EVT_BUTTON
42
43
44 class wmsInfoDialog(ThubanFrame):
45 """
46 Representation for a simple information dialog
47
48 This dialog will display the title of the WMS resource
49 """
50
51 def __init__(self, parent, name, layer, *args, **kw):
52 """
53 Build the information dialog
54 """
55 title = _("WMS Information")
56 ThubanFrame.__init__(self, parent, name, title)
57
58 self.dialog_layout(self.calcText(layer))
59
60
61 def dialog_layout(self, text):
62 """
63 Set up the information dialog
64 """
65
66 vbox = wxBoxSizer(wxVERTICAL)
67
68 textBox = wxTextCtrl(self, -1, text,
69 style=wxTE_READONLY|wxTE_MULTILINE|wxTE_LINEWRAP)
70 w, h = (500, 300)
71 textBox.SetSizeHints(w, h)
72 textBox.SetSize((w, h))
73
74 vbox.Add(textBox, 1, wxEXPAND|wxALL, 10)
75
76 buttons = wxBoxSizer(wxHORIZONTAL)
77 buttons.Add(wxButton(self, wxID_OK, _("Close")), 0, wxALL, 4)
78 vbox.Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10)
79
80 EVT_BUTTON(self, wxID_OK, self.OnClose)
81
82 self.SetAutoLayout(True)
83 self.SetSizer(vbox)
84 vbox.Fit(self)
85 vbox.SetSizeHints(self)
86
87
88 def calcText(self, layer):
89 """
90 Generate the text to be displayed in the information window
91
92 It will use several nodes returned by the GetCapabilities
93 request, such as the title, the abstract, fees and access
94 constraints, if they are documented.
95 """
96
97 text = ''
98
99 foo = layer.capabilities.getTitle()
100 if foo != "":
101 text += foo.encode('latin1') + "\n\n"
102
103 foo = layer.capabilities.getAbstract()
104 if foo != "":
105 text += foo + "\n\n"
106
107 foo = layer.capabilities.getFees()
108 if foo != "":
109 text += _("Fees:") + "\n\n" + foo + "\n\n"
110
111 foo = layer.capabilities.getAccessConstraints()
112 if foo != "":
113 text += _("Acces Constraints:") + "\n\n" + foo + "\n\n"
114
115 text += "URL: " + layer.url
116
117 return text

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26