[GRASS-SVN] r47831 -
grass-addons/grass7/gui/wxpython/wx.stream/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Aug 22 12:48:31 EDT 2011
Author: madi
Date: 2011-08-22 09:48:31 -0700 (Mon, 22 Aug 2011)
New Revision: 47831
Added:
grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_ImageViewer.py
Modified:
grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_panelOne.py
Log:
Image viewer for preview added
Added: grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_ImageViewer.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_ImageViewer.py (rev 0)
+++ grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_ImageViewer.py 2011-08-22 16:48:31 UTC (rev 47831)
@@ -0,0 +1,127 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+"""!
+ at package rstream.py
+
+ at brief GUI for r.stream.* modules
+
+See http://grass.osgeo.org/wiki/Wx.stream_GSoC_2011
+
+Classes:
+ - ImgFrame
+ - ListImg
+ - ImgPanel
+
+(C) 2011 by Margherita Di Leo, and the GRASS Development Team
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
+
+ at author Margherita Di Leo (GSoC student 2011)
+"""
+
+
+import wx
+import glob
+import os, sys
+
+from debug import Debug as Debug
+from preferences import globalSettings as UserSettings
+
+import grass.script as grass
+import gselect
+import gcmd
+import dbm
+import globalvar
+import utils
+import menuform
+
+
+class ImgPanel(wx.Panel):
+ """!Display selected image in the main window
+ """
+
+ def __init__(self, parent, img):
+ """"""
+ wx.Panel.__init__(self, parent)
+ self.sizer = wx.BoxSizer(wx.HORIZONTAL)
+ self.staticBitmap = wx.StaticBitmap(self, -1, img)
+ self.PhotoMaxSize = 240
+ self.sizer.Add(self.staticBitmap, 1, wx.EXPAND)
+ self.SetSizer(self.sizer)
+ self.sizer.Layout()
+
+
+
+class ListImg(wx.Listbook):
+ """!Load png files *from current folder* and convert to bitmap"""
+
+ def __init__(self, parent):
+ """"""
+ wx.Listbook.__init__(self, parent, style=wx.BK_BOTTOM)
+ self.pages = []
+ pathname = "*.png"
+ self.ImL = wx.ImageList(32, 32)
+ for imID, filename in enumerate(glob.glob(pathname)):
+ bmp = wx.Bitmap(filename, wx.BITMAP_TYPE_PNG)
+ img = bmp.ConvertToImage()
+ img.Rescale(32, 32)
+ bmp_scaled = img.ConvertToBitmap()
+ self.ImL.Add(bmp_scaled)
+ self.pages.append(ImgPanel(self, bmp))
+ self.AddPage(self.pages[-1], "", imageId=imID)
+ self.AssignImageList(self.ImL)
+
+ # Binders
+ self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGED, self.OnPageChanged)
+ self.Bind(wx.EVT_LISTBOOK_PAGE_CHANGING, self.OnPageChanging)
+
+
+ def OnPageChanged(self, event):
+ old = event.GetOldSelection()
+ new = event.GetSelection()
+ sel = self.GetSelection()
+ print 'OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)
+ event.Skip()
+
+
+ def OnPageChanging(self, event):
+ old = event.GetOldSelection()
+ new = event.GetSelection()
+ sel = self.GetSelection()
+ print 'OnPageChanging, old:%d, new:%d, sel:%d\n' % (old, new, sel)
+ event.Skip()
+
+
+class ImgFrame(wx.Frame):
+ """!Main frame
+ """
+
+ def __init__(self, pat):
+ """"""
+
+ wx.Frame.__init__(self, None, wx.ID_ANY,
+ "Image Viewer",
+ size=(800,600)
+ )
+
+ directory = pat
+ panel = wx.Panel(self)
+
+ os.chdir(directory)
+ previews = ListImg(panel)
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ sizer.Add(previews, 1, wx.ALL | wx.EXPAND, 5)
+ panel.SetSizer(sizer)
+ self.Layout()
+
+ self.Show()
+
+
+#if __name__ == "__main__":
+ #app = wx.PySimpleApp()
+ #frame = ImgFrame()
+ #app.MainLoop()
+
+
+
Modified: grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_panelOne.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_panelOne.py 2011-08-22 16:44:32 UTC (rev 47830)
+++ grass-addons/grass7/gui/wxpython/wx.stream/gui_modules/rstream_panelOne.py 2011-08-22 16:48:31 UTC (rev 47831)
@@ -38,10 +38,11 @@
import utils
import menuform
+import rstream_ImageViewer
+from rstream_ImageViewer import ImgFrame
-
#-------------------------------------------------------------
class CoorWindow(wx.Dialog):
@@ -227,8 +228,9 @@
grass.run_command( 'd.vect', map = self.v_net)
print "Exported in file " + img_tmp
+ directory = os.path.dirname(img_tmp)
+ print directory
-
# set region to original region
grass.run_command('g.region',
@@ -237,12 +239,14 @@
s = original_s,
w = original_w,
e = original_e)
+
+ os.chdir(directory)
+ # Call ImageViewer
+ ImgVvr = wx.PySimpleApp()
+ frame = ImgFrame(directory)
+ ImgVvr.MainLoop()
-
-
-
-
-
+
def OnButtonCoor(self, event):
More information about the grass-commit
mailing list