[GRASS-SVN] r47321 - grass-addons/grass7/gui/wxpython/wx.wms

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jul 30 15:16:27 EDT 2011


Author: sudeepsingh
Date: 2011-07-30 12:16:26 -0700 (Sat, 30 Jul 2011)
New Revision: 47321

Added:
   grass-addons/grass7/gui/wxpython/wx.wms/passwordPopUp.py
Modified:
   grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
Log:
password popup frame added and integerated

Added: grass-addons/grass7/gui/wxpython/wx.wms/passwordPopUp.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/passwordPopUp.py	                        (rev 0)
+++ grass-addons/grass7/gui/wxpython/wx.wms/passwordPopUp.py	2011-07-30 19:16:26 UTC (rev 47321)
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# generated by wxGlade 0.6.3 on Sat Jul 30 22:23:14 2011
+
+import wx
+
+# begin wxGlade: extracode
+# end wxGlade
+
+
+
+class PopUpFrame(wx.Frame):
+    def __init__(self, *args, **kwds):
+        # begin wxGlade: PopUpFrame.__init__
+        kwds["style"] = wx.DEFAULT_FRAME_STYLE
+        wx.Frame.__init__(self, *args, **kwds)
+        self.passworddescription = wx.StaticText(self, -1, "   Enter password")
+        self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD)
+        self.passwordEnter = wx.Button(self, -1, "Enter")
+
+        self.__set_properties()
+        self.__do_layout()
+        # end wxGlade
+
+    def __set_properties(self):
+        # begin wxGlade: PopUpFrame.__set_properties
+        self.SetTitle("EnterPassword")
+        self.text_ctrl_1.SetMinSize((200, 25))
+        # end wxGlade
+
+    def __do_layout(self):
+        # begin wxGlade: PopUpFrame.__do_layout
+        sizer_1 = wx.BoxSizer(wx.VERTICAL)
+        sizer_1.Add(self.passworddescription, 0, 0, 0)
+        sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
+        sizer_1.Add(self.passwordEnter, 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
+        self.SetSizer(sizer_1)
+        sizer_1.Fit(self)
+        self.Layout()
+        # end wxGlade
+
+# end of class PopUpFrame
+
+
+if __name__ == "__main__":
+    app = wx.PySimpleApp(0)
+    wx.InitAllImageHandlers()
+    frame_1 = PopUpFrame(None, -1, "")
+    app.SetTopWindow(frame_1)
+    frame_1.Show()
+    app.MainLoop()
+
+def PasswordPopUpFrame():
+    app = wx.PySimpleApp(0)
+    wx.InitAllImageHandlers()
+    frame_1 = PopUpFrame(None, -1, "")
+    app.SetTopWindow(frame_1)
+    frame_1.Show()
+    app.MainLoop()
\ No newline at end of file


Property changes on: grass-addons/grass7/gui/wxpython/wx.wms/passwordPopUp.py
___________________________________________________________________
Added: svn:executable
   + *

Modified: grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py	2011-07-30 17:19:35 UTC (rev 47320)
+++ grass-addons/grass7/gui/wxpython/wx.wms/wmsmenu.py	2011-07-30 19:16:26 UTC (rev 47321)
@@ -8,6 +8,7 @@
 from parse import parsexml, isServiceException
 from WMSMapDisplay import NewImageFrame
 from addserver import AddServerFrame
+from passwordPopUp import PasswordPopUpFrame
 
 # begin wxGlade: extracode
 # end wxGlade
@@ -41,7 +42,7 @@
         
         #Sudeep's Code Starts
         #self.urlInput.SetValue('http://www.gisnet.lv/cgi-bin/topo')
-	self.__populate_Url_List(self.ServerList)
+        self.__populate_Url_List(self.ServerList)
         self.selectedURL="No server selected"
         self.layerTreeRoot = self.LayerTree.AddRoot("Layers")
         #items = ["a", "b", "c"]
@@ -74,17 +75,17 @@
         self.Layout()
         # end wxGlade
     def update_Url_List(self, name):
-	ComboBox = self.ServerList
-    	ComboBox.Append(name)
+        ComboBox = self.ServerList
+        ComboBox.Append(name)
     def __populate_Url_List(self, ComboBox):
-    	f = open('serverList.txt','r')
+        f = open('serverList.txt','r')
         lines = f.readlines()
         self.servers = {}
         for line in lines:
             row = line.split()
             print row
             if(len(row) == 4) :
-	            self.servers[row[0]] = row[1]
+                self.servers[row[0]] = row[1]
             name = row[0]+" "+row[1][7:45]
             ComboBox.Append(name)
         f.close()
@@ -92,72 +93,75 @@
     def OnGetCapabilities(self, event): # wxGlade: wmsFrame.<event_handler>
         #Sudeep's Code Starts
         #url = 'http://www.gisnet.lv/cgi-bin/topo?request=GetCapabilities&service=wms&version=1.1.1'
-    	self.LayerTree.CollapseAndReset(self.layerTreeRoot)
-    	#url = self.urlInput.GetValue() 
-    	url = self.selectedURL
-    	url = url + '?request=GetCapabilities&service=wms&version=1.1.1'
-    	print url
-	req = Request(url)
-	try:
-	    response = urlopen(req)
-	    xml = response.read()
-	    #self.statusbar.SetStatusText(xml) 
-	    reslist = parsexml(xml)
-	    st = ''
-	    for res in reslist:
-	    	   st = st + res + '\n'
-	    	   self.LayerTree.AppendItem(self.layerTreeRoot, res)
-	    #self.Layers.SetValue(st) 
-	    #print xml
-	    self.LayerTree.Expand(self.layerTreeRoot)
-	except HTTPError, e:
-	    print 'The server couldn\'t fulfill the request.'
-	    print 'Error code: ', e.code
-	except URLError, e: 
-	    print 'We failed to reach a server.'
-	    print 'Reason: ', e.reason
-	else:
-	    print 'Successful'
-	    #Sudeep's Code Ends
+        self.LayerTree.CollapseAndReset(self.layerTreeRoot)
+        #url = self.urlInput.GetValue() 
+        url = self.selectedURL
+        url = url + '?request=GetCapabilities&service=wms&version=1.1.1'
+        print url
+        req = Request(url)
+        try:
+            response = urlopen(req)
+            xml = response.read()
+            #self.statusbar.SetStatusText(xml) 
+            reslist = parsexml(xml)
+            st = ''
+            for res in reslist:
+                   st = st + res + '\n'
+                   self.LayerTree.AppendItem(self.layerTreeRoot, res)
+            #self.Layers.SetValue(st) 
+            #print xml
+            self.LayerTree.Expand(self.layerTreeRoot)
+        except HTTPError, e:
+            print 'The server couldn\'t fulfill the request.'
+            print 'Error code: ', e.code
+        except URLError, e: 
+            print 'We failed to reach a server.'
+            print 'Reason: ', e.reason
+        else:
+            print 'Successful'
+            #Sudeep's Code Ends
         event.Skip()
-
+        
+        
     def OnGetMaps(self, event): # wxGlade: wmsFrame.<event_handler>
         #Sudeep's Code Starts
         #self.layerName = self.layerSelected.GetValue()
         #url = self.urlInput.GetValue()
-    	
-    	self.url_in = self.selectedURL
-        getMap_request_url = self.url_in+'?service=WMS&request=GetMap&version=1.1.1&format=image/png&width=800&height=600&srs=EPSG:3059&layers='+self.layerName+'&bbox=584344,397868,585500,398500'
+        PasswordPopUpFrame()
         
+        self.url_in = self.selectedURL
+        getMap_request_url = self.url_in
+        getMap_request_url += '?service=WMS&request=GetMap&version=1.1.1&format=image/png&width=800&height=600&srs=EPSG:3059&layers='
+        getMap_request_url += self.layerName+'&bbox=584344,397868,585500,398500'
         
-        
-	print getMap_request_url
-	
-	req = Request(getMap_request_url)
-	try:
-	    response = urlopen(req)
-	    image = response.read()
-	    #print image
-	    if(isServiceException(image)):
-	    	print 'Service Exception has occured'
-	    else:
-	    	outfile = open('map.png','wb')
-	    	outfile.write(image)
-	    	outfile.close()
-	    	NewImageFrame()
-	    
-	    
-	except HTTPError, e:
-	    print 'The server couldn\'t fulfill the request.'
-	    print 'Error code: ', e.code
-	except URLError, e:
-	    print 'We failed to reach a server.'
-	    print 'Reason: ', e.reason
-	else:
-	    print 'Successful'
-        #Sudeep's Code Ends
-        event.Skip()
+        print getMap_request_url
+    
+        req = Request(getMap_request_url)
+        try:
+            response = urlopen(req)
+            image = response.read()
+            #print image
+            if(isServiceException(image)):
+                print 'Service Exception has occured'
+            else:
+                outfile = open('map.png','wb')
+                outfile.write(image)
+                outfile.close()
+                NewImageFrame()
+            
+            
+        except HTTPError, e:
+            print 'The server couldn\'t fulfill the request.'
+            print 'Error code: ', e.code
+        except URLError, e:
+            print 'We failed to reach a server.'
+            print 'Reason: ', e.reason
+        else:
+            print 'Successful'
+            #Sudeep's Code Ends
+            event.Skip()
 
+    
     def OnServerListEnter(self, event): # wxGlade: wmsFrame.<event_handler>
         print "Event handler `OnServerListEnter' not implemented"
         #Sudeep's Code Starts
@@ -218,7 +222,7 @@
         event.Skip()
 
     def OnAddServer(self, event): # wxGlade: wmsFrame.<event_handler>
-    	AddServerFrame()
+        AddServerFrame()
         #print "Event handler `OnAddServer' not implemented"
         event.Skip()
 
@@ -226,12 +230,12 @@
 
 #Sudeep's Code Starts
 def DisplayWMSMenu():
-     	app = wx.PySimpleApp(0)
-    	wx.InitAllImageHandlers()
-    	wms_Frame = wmsFrame(None, -1, "")
+        app = wx.PySimpleApp(0)
+        wx.InitAllImageHandlers()
+        wms_Frame = wmsFrame(None, -1, "")
         app.SetTopWindow(wms_Frame)
-    	wms_Frame.Show()
-    	app.MainLoop()
+        wms_Frame.Show()
+        app.MainLoop()
 #Sudeep's Code Ends
 
 if __name__ == "__main__":



More information about the grass-commit mailing list