예제 #1
0
파일: catalog.py 프로젝트: rkrug/grass-ci
    def __init__(self, parent, giface=None, id=wx.ID_ANY,
                 title=_("Data catalog"), name='catalog', **kwargs):
        """Panel constructor  """
        self.showNotification = Signal('DataCatalog.showNotification')
        self.changeMapset = Signal('DataCatalog.changeMapset')
        self.changeLocation = Signal('DataCatalog.changeLocation')
        self.parent = parent
        self.baseTitle = title
        wx.Panel.__init__(self, parent=parent, id=id, **kwargs)
        self.SetName("DataCatalog")

        Debug.msg(1, "DataCatalog.__init__()")

        # toolbar
        self.toolbar = DataCatalogToolbar(parent=self)

        # tree with layers
        self.tree = DataCatalogTree(self, giface=giface)
        self.thread = gThread()
        self._loaded = False
        self.tree.showNotification.connect(self.showNotification)
        self.tree.changeMapset.connect(self.changeMapset)
        self.tree.changeLocation.connect(self.changeLocation)

        # some layout
        self._layout()
예제 #2
0
    def __init__(self, giface, mapWindow):
        wx.EvtHandler.__init__(self)
        self._giface = giface
        self._mapWindow = mapWindow

        self._thread = gThread()
        self._editedRaster = None
        self._backgroundRaster = None
        self._backupRasterName = None
        self._areas = None
        self._lines = None
        self._points = None
        self._all = []
        self._drawing = False
        self._running = False
        self._drawColor = wx.GREEN
        self._drawTransparency = 100
        self._graphicsType = 'area'
        self._currentCellValue = None
        self._currentWidthValue = None

        self._oldMouseUse = None
        self._oldCursor = None

        self.newRasterCreated = Signal('RDigitController:newRasterCreated')
        self.newFeatureCreated = Signal('RDigitController:newFeatureCreated')
        self.uploadMapCategories = Signal('RDigitController:uploadMapCategories')
        self.quitDigitizer = Signal('RDigitController:quitDigitizer')
        self.showNotification = Signal('RDigitController:showNotification')
예제 #3
0
    def __init__(self,
                 parent,
                 giface=None,
                 id=wx.ID_ANY,
                 title=_("Data catalog"),
                 name='catalog',
                 **kwargs):
        """Panel constructor  """
        self.showNotification = Signal('DataCatalog.showNotification')
        self.changeMapset = Signal('DataCatalog.changeMapset')
        self.changeLocation = Signal('DataCatalog.changeLocation')
        self.parent = parent
        self.baseTitle = title
        wx.Panel.__init__(self, parent=parent, id=id, **kwargs)
        self.SetName("DataCatalog")

        Debug.msg(1, "DataCatalog.__init__()")

        # toolbar
        self.toolbar = DataCatalogToolbar(parent=self)

        # tree with layers
        self.tree = DataCatalogTree(self, giface=giface)
        self.thread = gThread()
        self._loaded = False
        self.tree.showNotification.connect(self.showNotification)
        self.tree.changeMapset.connect(self.changeMapset)
        self.tree.changeLocation.connect(self.changeLocation)

        # some layout
        self._layout()
예제 #4
0
파일: ws.py 프로젝트: rkanavath/grass-ci
    def __init__(self, layer, env):
        if not haveGdal:
            sys.stderr.write(
                _("Unable to load GDAL Python bindings.\n"
                  "WMS layers can not be displayed without the bindings.\n"))

        self.layer = layer

        wx.EvtHandler.__init__(self)

        # thread for d.wms commands
        self.thread = gThread()

        self._startTime = None
        self.downloading = False
        self.renderedRegion = None
        self.updateMap = True
        self.fetched_data_cmd = None

        self.tempMap = grass.tempfile()
        self.dstSize = {}

        self.dataFetched = Signal('RenderWMSMgr.dataFetched')
        self.updateProgress = Signal('RenderWMSMgr.updateProgress')
        self.renderingFailed = Signal('RenderWMSMgr.renderingFailed')
예제 #5
0
    def __init__(self, giface, mapWindow):
        """Constructs controller

        :param giface: grass interface object
        :param mapWindow: instance of BufferedMapWindow
        """
        wx.EvtHandler.__init__(self)
        self._giface = giface
        self._mapWindow = mapWindow

        # thread for running rasterization process
        self._thread = gThread()
        # name of raster map which is edited (also new one)
        self._editedRaster = None
        # name of optional background raster
        self._backgroundRaster = None
        # name of temporary raster used to backup original state
        self._backupRasterName = None
        # if we edit an old raster or a new one (important for setting color
        # table)
        self._editOldRaster = False
        # type of output raster map (CELL, FCELL, DCELL)
        self._mapType = None
        # GraphicsSet for drawing areas, lines, points
        self._areas = None
        self._lines = None
        self._points = None
        # list of all GraphicsItems in the order of drawing
        self._all = []
        # if in state of drawing lin or area
        self._drawing = False
        # if running digitizing process in thread (to block drawing)
        self._running = False
        # color used to draw (should be moved to settings)
        self._drawColor = wx.GREEN
        # transparency used to draw (should be moved to settings)
        self._drawTransparency = 100
        # current selected drawing method
        self._graphicsType = 'area'
        # last edited cell value
        self._currentCellValue = None
        # last edited buffer value
        self._currentWidthValue = None
        # digit env
        self._env = os.environ.copy()

        self._oldMouseUse = None
        self._oldCursor = None

        # signal to add new raster to toolbar items
        self.newRasterCreated = Signal('RDigitController:newRasterCreated')
        # signal to add just used cell value in toolbar combo
        self.newFeatureCreated = Signal('RDigitController:newFeatureCreated')
        # signal to upload unique categories of background map into toolbar
        # combo
        self.uploadMapCategories = Signal(
            'RDigitController:uploadMapCategories')
        self.quitDigitizer = Signal('RDigitController:quitDigitizer')
        self.showNotification = Signal('RDigitController:showNotification')
예제 #6
0
    def __init__(self, giface, mapWindow):
        """Constructs controller

        :param giface: grass interface object
        :param mapWindow: instance of BufferedMapWindow
        """
        wx.EvtHandler.__init__(self)
        self._giface = giface
        self._mapWindow = mapWindow

        # thread for running rasterization process
        self._thread = gThread()
        # name of raster map which is edited (also new one)
        self._editedRaster = None
        # name of optional background raster
        self._backgroundRaster = None
        # name of temporary raster used to backup original state
        self._backupRasterName = None
        # if we edit an old raster or a new one (important for setting color
        # table)
        self._editOldRaster = False
        # type of output raster map (CELL, FCELL, DCELL)
        self._mapType = None
        # GraphicsSet for drawing areas, lines, points
        self._areas = None
        self._lines = None
        self._points = None
        # list of all GraphicsItems in the order of drawing
        self._all = []
        # if in state of drawing lin or area
        self._drawing = False
        # if running digitizing process in thread (to block drawing)
        self._running = False
        # color used to draw (should be moved to settings)
        self._drawColor = wx.GREEN
        # transparency used to draw (should be moved to settings)
        self._drawTransparency = 100
        # current selected drawing method
        self._graphicsType = 'area'
        # last edited cell value
        self._currentCellValue = None
        # last edited buffer value
        self._currentWidthValue = None

        self._oldMouseUse = None
        self._oldCursor = None

        # signal to add new raster to toolbar items
        self.newRasterCreated = Signal('RDigitController:newRasterCreated')
        # signal to add just used cell value in toolbar combo
        self.newFeatureCreated = Signal('RDigitController:newFeatureCreated')
        # signal to upload unique categories of background map into toolbar
        # combo
        self.uploadMapCategories = Signal(
            'RDigitController:uploadMapCategories')
        self.quitDigitizer = Signal('RDigitController:quitDigitizer')
        self.showNotification = Signal('RDigitController:showNotification')
예제 #7
0
        def terminate_download_callback(event):
            # Clean up after urllib urlretrieve which is used internally
            # in grass.utils.
            from urllib import request  # pylint: disable=import-outside-toplevel

            self._download_in_progress = False
            request.urlcleanup()
            sys.stdout.write("Download aborted")
            self.thread = gThread()
            self._change_download_btn_label()
    def startProcess(self, evt=None):
        profilePath = os.path.join(self.workPath, "logs")
        if not os.path.exists(profilePath):
            os.mkdir(profilePath)
        self.initFileLogger(
            os.path.join(profilePath, "%s.log" % self.settings['workSchema']))
        print("file logger initialized")

        self.thread = gThread()
        self.thread.Run(callable=self.runComp, ondone=self.onFinish)
        self.computeBtt.Enable()
        self.exportDataBtt.Enable()
예제 #9
0
    def __init__(self, guiparent, giface, iclass_mapwin=None):
        self.giface = giface
        self.mapDisp = giface.GetMapDisplay()

        if iclass_mapwin:
            self.mapWin = iclass_mapwin
        else:
            self.mapWin = giface.GetMapWindow()

        self.guiparent = guiparent

        self.show_add_scatt_plot = False

        self.core = Core()

        self.cats_mgr = CategoriesManager(self, self.core)
        self.render_mgr = PlotsRenderingManager(scatt_mgr=self,
                                                cats_mgr=self.cats_mgr,
                                                core=self.core)

        self.thread = gThread()

        self.plots = {}

        self.plot_mode = None
        self.pol_sel_mode = [False, None]

        self.data_set = False

        self.cursorPlotMove = Signal("ScattsManager.cursorPlotMove")

        self.renderingStarted = self.render_mgr.renderingStarted
        self.renderingFinished = self.render_mgr.renderingFinished

        self.computingStarted = Signal("ScattsManager.computingStarted")

        if iclass_mapwin:
            self.digit_conn = IClassDigitConnection(self,
                                                    self.mapWin,
                                                    self.core.CatRastUpdater())
            self.iclass_conn = IClassConnection(self,
                                                iclass_mapwin.parent,
                                                self.cats_mgr)
        else:
            self.digit_conn = IMapWinDigitConnection()
            self.iclass_conn = IMapDispConnection(scatt_mgr=self,
                                                  cats_mgr=self.cats_mgr,
                                                  giface=self.giface)

        self._initSettings()

        self.modeSet = Signal("ScattsManager.mondeSet")
예제 #10
0
    def __init__(self, guiparent, giface, iclass_mapwin=None):
        self.giface = giface
        self.mapDisp = giface.GetMapDisplay()

        if iclass_mapwin:
            self.mapWin = iclass_mapwin
        else:
            self.mapWin = giface.GetMapWindow()

        self.guiparent = guiparent

        self.show_add_scatt_plot = False

        self.core = Core()

        self.cats_mgr = CategoriesManager(self, self.core)
        self.render_mgr = PlotsRenderingManager(scatt_mgr=self,
                                                cats_mgr=self.cats_mgr,
                                                core=self.core)

        self.thread = gThread()

        self.plots = {}

        self.plot_mode = None
        self.pol_sel_mode = [False, None]

        self.data_set = False

        self.cursorPlotMove = Signal("ScattsManager.cursorPlotMove")

        self.renderingStarted = self.render_mgr.renderingStarted
        self.renderingFinished = self.render_mgr.renderingFinished

        self.computingStarted = Signal("ScattsManager.computingStarted")

        if iclass_mapwin:
            self.digit_conn = IClassDigitConnection(self,
                                                    self.mapWin,
                                                    self.core.CatRastUpdater())
            self.iclass_conn = IClassConnection(self,
                                                iclass_mapwin.parent,
                                                self.cats_mgr)
        else:
            self.digit_conn = IMapWinDigitConnection()
            self.iclass_conn = IMapDispConnection(scatt_mgr=self,
                                                  cats_mgr=self.cats_mgr,
                                                  giface=self.giface)

        self._initSettings()

        self.modeSet = Signal("ScattsManager.mondeSet")
예제 #11
0
    def __init__(self, parent, database, locations=LOCATIONS):
        """

        :param database: directory with G database to download to
        :param locations: list of dictionaries with label and url
        """
        wx.Panel.__init__(self, parent=parent)

        self._last_downloaded_location_name = None
        self._download_in_progress = False
        self.database = database
        self.locations = locations

        self.label = wx.StaticText(
            parent=self,
            label=_("Select sample location to download:"))

        choices = []
        for item in self.locations:
            choices.append(item['label'])
        self.choice = wx.Choice(parent=self, choices=choices)

        self.choice.Bind(wx.EVT_CHOICE, self.OnChangeChoice)

        self.download_button = Button(parent=self, id=wx.ID_ANY,
                                      label=_("Do&wnload"))
        self.download_button.SetToolTip(_("Download selected location"))
        self.download_button.Bind(wx.EVT_BUTTON, self.OnDownload)
        # TODO: add button for a link to an associated website?
        # TODO: add thumbnail for each location?

        # TODO: messages copied from gis_set.py, need this as API?
        self.message = wx.StaticText(parent=self, size=(-1, 50))
        sys.stdout = RedirectText(self.message)

        # It is not clear if all wx versions supports color, so try-except.
        # The color itself may not be correct for all platforms/system settings
        # but in http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.SystemSettings.html
        # there is no 'warning' color.
        try:
            self.message.SetForegroundColour(wx.Colour(255, 0, 0))
        except AttributeError:
            pass

        self._layout()

        default = 0
        self.choice.SetSelection(default)
        self.CheckItem(self.locations[default])

        self.thread = gThread()
예제 #12
0
    def __init__(self, layer, env):
        """Render layer into image

        :param layer: Layer to be rendered
        """
        self.layer = layer
         
        wx.EvtHandler.__init__(self)
        self.thread = gThread()
        
        self.updateProgress = Signal('RenderLayerMgr.updateProgress')
        
        self._startTime = None
        self._render_env = env
예제 #13
0
    def __init__(self, layer, env):
        """Render layer into image

        :param layer: Layer to be rendered
        """
        self.layer = layer

        wx.EvtHandler.__init__(self)
        self.thread = gThread()

        self.updateProgress = Signal('RenderLayerMgr.updateProgress')

        self._startTime = None
        self._render_env = env
예제 #14
0
파일: ws.py 프로젝트: rkrug/grass-ci
    def __init__(self, layer, env):
        if not haveGdal:
            sys.stderr.write(_("Unable to load GDAL Python bindings.\n"
                               "WMS layers can not be displayed without the bindings.\n"))

        self.layer = layer

        wx.EvtHandler.__init__(self)

        # thread for d.wms commands
        self.thread = gThread()

        self._startTime = None
        self.downloading = False
        self.renderedRegion = None
        self.updateMap = True
        self.fetched_data_cmd = None

        self.tempMap = grass.tempfile()
        self.dstSize = {}

        self.dataFetched = Signal('RenderWMSMgr.dataFetched')
        self.updateProgress = Signal('RenderWMSMgr.updateProgress')
예제 #15
0
파일: controller.py 프로젝트: neteler/grass
    def _export(self, exportInfo, decorations):
        size = self.frame.animationPanel.GetSize()
        if self.temporalMode == TemporalMode.TEMPORAL:
            timeLabels, mapNamesDict = self.temporalManager.GetLabelsAndMaps()
            frameCount = len(timeLabels)
        else:
            frameCount = self.animationData[
                0].mapCount  # should be the same for all

        animWinSize = []
        animWinPos = []
        animWinIndex = []
        legends = [anim.legendCmd for anim in self.animationData]
        # determine position and sizes of bitmaps
        for i, (win, anim) in enumerate(zip(self.mapwindows, self.animations)):
            if anim.IsActive():
                pos = win.GetPosition()
                animWinPos.append(pos)
                animWinSize.append(win.GetSize())
                animWinIndex.append(i)

        images = []
        busy = wx.BusyInfo(_("Preparing export, please wait..."),
                           parent=self.frame)
        wx.GetApp().Yield()
        lastBitmaps = {}
        fgcolor = UserSettings.Get(group="animation",
                                   key="font",
                                   subkey="fgcolor")
        bgcolor = UserSettings.Get(group="animation",
                                   key="font",
                                   subkey="bgcolor")
        for frameIndex in range(frameCount):
            image = EmptyImage(*size)
            image.Replace(0, 0, 0, 255, 255, 255)
            # collect bitmaps of all windows and paste them into the one
            for i in animWinIndex:
                frameId = self.animations[i].GetFrame(frameIndex)
                if not UserSettings.Get(group="animation",
                                        key="temporal",
                                        subkey=["nodata", "enable"]):
                    if frameId is not None:
                        bitmap = self.bitmapProvider.GetBitmap(frameId)
                        lastBitmaps[i] = bitmap
                    else:
                        if i not in lastBitmaps:
                            lastBitmaps[i] = wx.NullBitmap()
                else:
                    bitmap = self.bitmapProvider.GetBitmap(frameId)
                    lastBitmaps[i] = bitmap

                im = ImageFromBitmap(lastBitmaps[i])

                # add legend if used
                legend = legends[i]
                if legend:
                    legendBitmap = self.bitmapProvider.LoadOverlay(legend)
                    x, y = self.mapwindows[i].GetOverlayPos()
                    legImage = ImageFromBitmap(legendBitmap)
                    # not so nice result, can we handle the transparency
                    # otherwise?
                    legImage.ConvertAlphaToMask()
                    im.Paste(legImage, x, y)

                if im.GetSize() != animWinSize[i]:
                    im.Rescale(*animWinSize[i])
                image.Paste(im, *animWinPos[i])
            # paste decorations
            for decoration in decorations:
                # add image
                x = decoration["pos"][0] / 100.0 * size[0]
                y = decoration["pos"][1] / 100.0 * size[1]
                if decoration["name"] == "image":
                    decImage = wx.Image(decoration["file"])
                elif decoration["name"] == "time":
                    timeLabel = timeLabels[frameIndex]
                    if timeLabel[1]:  # interval
                        text = _("%(from)s %(dash)s %(to)s") % {
                            "from": timeLabel[0],
                            "dash": "\u2013",
                            "to": timeLabel[1],
                        }
                    else:
                        if (self.temporalManager.GetTemporalType() ==
                                TemporalType.ABSOLUTE):
                            text = timeLabel[0]
                        else:
                            text = _("%(start)s %(unit)s") % {
                                "start": timeLabel[0],
                                "unit": timeLabel[2],
                            }

                    decImage = RenderText(text, decoration["font"], bgcolor,
                                          fgcolor).ConvertToImage()
                elif decoration["name"] == "text":
                    text = decoration["text"]
                    decImage = RenderText(text, decoration["font"], bgcolor,
                                          fgcolor).ConvertToImage()

                image.Paste(decImage, x, y)

            images.append(image)
        del busy

        # export
        pilImages = [WxImageToPil(image) for image in images]
        self.busy = wx.BusyInfo(_("Exporting animation, please wait..."),
                                parent=self.frame)
        wx.GetApp().Yield()
        try:

            def export_avi_callback(event):
                error = event.ret
                del self.busy
                if error:
                    GError(parent=self.frame, message=error)
                    return

            if exportInfo["method"] == "sequence":
                filename = os.path.join(
                    exportInfo["directory"],
                    exportInfo["prefix"] + "." + exportInfo["format"].lower(),
                )
                writeIms(filename=filename, images=pilImages)
            elif exportInfo["method"] == "gif":
                writeGif(
                    filename=exportInfo["file"],
                    images=pilImages,
                    duration=self.timeTick / float(1000),
                    repeat=True,
                )
            elif exportInfo["method"] == "swf":
                writeSwf(
                    filename=exportInfo["file"],
                    images=pilImages,
                    duration=self.timeTick / float(1000),
                    repeat=True,
                )
            elif exportInfo["method"] == "avi":
                thread = gThread()
                thread.Run(
                    callable=writeAvi,
                    filename=exportInfo["file"],
                    images=pilImages,
                    duration=self.timeTick / float(1000),
                    encoding=exportInfo["encoding"],
                    inputOptions=exportInfo["options"],
                    bg_task=True,
                    ondone=export_avi_callback,
                )
        except Exception as e:
            del self.busy
            GError(parent=self.frame, message=str(e))
            return
        if exportInfo["method"] in ("sequence", "gif", "swf"):
            del self.busy
예제 #16
0
    def __init__(
            self,
            parent,
            giface,
            id=wx.ID_ANY,
            title=_("Fetch & install extension from GRASS Addons"),
            **kwargs,
    ):
        self.parent = parent
        self._giface = giface
        self.options = dict()  # list of options

        wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs)
        self.SetIcon(
            wx.Icon(os.path.join(globalvar.ICONDIR, "grass.ico"),
                    wx.BITMAP_TYPE_ICO))

        self.panel = wx.Panel(parent=self, id=wx.ID_ANY)

        # self.repoBox = StaticBox(
        #     parent=self.panel, id=wx.ID_ANY, label=" %s " %
        #     _("Repository (leave empty to use the official one)"))
        self.treeBox = StaticBox(
            parent=self.panel,
            id=wx.ID_ANY,
            label=" %s " % _("List of extensions - double-click to install"),
        )

        # self.repo = TextCtrl(parent=self.panel, id=wx.ID_ANY)

        # modelBuilder loads data into tree model
        self.modelBuilder = ExtensionTreeModelBuilder()
        # tree view displays model data
        self.tree = CTreeView(parent=self.panel,
                              model=self.modelBuilder.GetModel())

        self.search = SearchCtrl(self.panel)
        self.search.SetDescriptiveText(_("Search"))
        self.search.ShowCancelButton(True)
        # load data in different thread
        self.thread = gThread()

        self.optionBox = StaticBox(parent=self.panel,
                                   id=wx.ID_ANY,
                                   label=" %s " % _("Options"))
        task = gtask.parse_interface("g.extension")
        ignoreFlags = ["l", "c", "g", "a", "f", "t", "help", "quiet"]
        if sys.platform == "win32":
            ignoreFlags.append("d")
            ignoreFlags.append("i")

        for f in task.get_options()["flags"]:
            name = f.get("name", "")
            desc = f.get("label", "")
            if not desc:
                desc = f.get("description", "")
            if not name and not desc:
                continue
            if name in ignoreFlags:
                continue
            self.options[name] = wx.CheckBox(parent=self.panel,
                                             id=wx.ID_ANY,
                                             label=desc)
        # defaultUrl = ''  # default/official one will be used when option empty
        # self.repo.SetValue(
        #     task.get_param(
        #         value='url').get(
        #         'default',
        #         defaultUrl))

        self.statusbar = self.CreateStatusBar(number=1)

        # self.btnFetch = Button(parent=self.panel, id=wx.ID_ANY,
        #                        label=_("&Fetch"))
        # self.btnFetch.SetToolTip(_("Fetch list of available modules "
        #                            "from GRASS Addons repository"))
        self.btnClose = Button(parent=self.panel, id=wx.ID_CLOSE)
        self.btnInstall = Button(parent=self.panel,
                                 id=wx.ID_ANY,
                                 label=_("&Install"))
        self.btnInstall.SetToolTip(_("Install selected add-ons GRASS module"))
        self.btnInstall.Enable(False)
        self.btnHelp = Button(parent=self.panel, id=wx.ID_HELP)
        self.btnHelp.SetToolTip(_("Show g.extension manual page"))

        self.btnClose.Bind(wx.EVT_BUTTON, lambda evt: self.Close())
        # self.btnFetch.Bind(wx.EVT_BUTTON, self.OnFetch)
        self.btnInstall.Bind(wx.EVT_BUTTON, self.OnInstall)
        self.btnHelp.Bind(wx.EVT_BUTTON, self.OnHelp)
        self.search.Bind(wx.EVT_TEXT, lambda evt: self.Filter(evt.GetString()))
        self.search.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN,
                         lambda evt: self.Filter(""))
        self.tree.selectionChanged.connect(self.OnItemSelected)
        self.tree.itemActivated.connect(self.OnItemActivated)
        self.tree.contextMenu.connect(self.OnContextMenu)

        wx.CallAfter(self._fetch)

        self._layout()
예제 #17
0
    def __init__(self,
                 parent,
                 giface,
                 id=wx.ID_ANY,
                 title=_("Fetch & install extension from GRASS Addons"),
                 **kwargs):
        self.parent = parent
        self._giface = giface
        self.options = dict()  # list of options

        wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs)
        self.SetIcon(
            wx.Icon(os.path.join(globalvar.ICONDIR, 'grass.ico'),
                    wx.BITMAP_TYPE_ICO))

        self.panel = wx.Panel(parent=self, id=wx.ID_ANY)

        self.repoBox = wx.StaticBox(
            parent=self.panel,
            id=wx.ID_ANY,
            label=" %s " %
            _("Repository (leave empty to use the official one)"))
        self.treeBox = wx.StaticBox(
            parent=self.panel,
            id=wx.ID_ANY,
            label=" %s " % _("List of extensions - double-click to install"))

        self.repo = wx.TextCtrl(parent=self.panel, id=wx.ID_ANY)

        # modelBuilder loads data into tree model
        self.modelBuilder = ExtensionTreeModelBuilder()
        # tree view displays model data
        self.tree = CTreeView(parent=self.panel,
                              model=self.modelBuilder.GetModel())

        self.search = SearchModuleWidget(parent=self.panel,
                                         model=self.modelBuilder.GetModel(),
                                         showChoice=False)
        self.search.showSearchResult.connect(
            lambda result: self.tree.Select(result))
        # show text in statusbar when notification appears
        self.search.showNotification.connect(
            lambda message: self.SetStatusText(message))
        # load data in different thread
        self.thread = gThread()

        self.optionBox = wx.StaticBox(parent=self.panel,
                                      id=wx.ID_ANY,
                                      label=" %s " % _("Options"))
        task = gtask.parse_interface('g.extension')
        ignoreFlags = ['l', 'c', 'g', 'a', 'f', 't', 'help', 'quiet']
        if sys.platform == 'win32':
            ignoreFlags.append('d')
            ignoreFlags.append('i')

        for f in task.get_options()['flags']:
            name = f.get('name', '')
            desc = f.get('label', '')
            if not desc:
                desc = f.get('description', '')
            if not name and not desc:
                continue
            if name in ignoreFlags:
                continue
            self.options[name] = wx.CheckBox(parent=self.panel,
                                             id=wx.ID_ANY,
                                             label=desc)
        defaultUrl = ''  # default/official one will be used when option empty
        self.repo.SetValue(
            task.get_param(value='url').get('default', defaultUrl))

        self.statusbar = self.CreateStatusBar(number=1)

        self.btnFetch = wx.Button(parent=self.panel,
                                  id=wx.ID_ANY,
                                  label=_("&Fetch"))
        self.btnFetch.SetToolTipString(
            _("Fetch list of available modules "
              "from GRASS Addons SVN repository"))
        self.btnClose = wx.Button(parent=self.panel, id=wx.ID_CLOSE)
        self.btnInstall = wx.Button(parent=self.panel,
                                    id=wx.ID_ANY,
                                    label=_("&Install"))
        self.btnInstall.SetToolTipString(
            _("Install selected add-ons GRASS module"))
        self.btnInstall.Enable(False)
        self.btnHelp = wx.Button(parent=self.panel, id=wx.ID_HELP)
        self.btnHelp.SetToolTipString(_("Show g.extension manual page"))

        self.btnClose.Bind(wx.EVT_BUTTON, lambda evt: self.Close())
        self.btnFetch.Bind(wx.EVT_BUTTON, self.OnFetch)
        self.btnInstall.Bind(wx.EVT_BUTTON, self.OnInstall)
        self.btnHelp.Bind(wx.EVT_BUTTON, self.OnHelp)
        self.tree.selectionChanged.connect(self.OnItemSelected)
        self.tree.itemActivated.connect(self.OnItemActivated)
        self.tree.contextMenu.connect(self.OnContextMenu)

        wx.CallAfter(self._fetch)

        self._layout()
예제 #18
0
    def __init__(self, parent, giface, id=wx.ID_ANY, title=_(
            "Fetch & install extension from GRASS Addons"), **kwargs):
        self.parent = parent
        self._giface = giface
        self.options = dict()  # list of options

        wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs)
        self.SetIcon(
            wx.Icon(
                os.path.join(
                    globalvar.ICONDIR,
                    'grass.ico'),
                wx.BITMAP_TYPE_ICO))

        self.panel = wx.Panel(parent=self, id=wx.ID_ANY)

        self.repoBox = wx.StaticBox(
            parent=self.panel, id=wx.ID_ANY, label=" %s " %
            _("Repository (leave empty to use the official one)"))
        self.treeBox = wx.StaticBox(
            parent=self.panel, id=wx.ID_ANY, label=" %s " %
            _("List of extensions - double-click to install"))

        self.repo = wx.TextCtrl(parent=self.panel, id=wx.ID_ANY)

        # modelBuilder loads data into tree model
        self.modelBuilder = ExtensionTreeModelBuilder()
        # tree view displays model data
        self.tree = CTreeView(
            parent=self.panel,
            model=self.modelBuilder.GetModel())

        self.search = SearchModuleWidget(
            parent=self.panel,
            model=self.modelBuilder.GetModel(),
            showChoice=False)
        self.search.showSearchResult.connect(
            lambda result: self.tree.Select(result))
        # show text in statusbar when notification appears
        self.search.showNotification.connect(
            lambda message: self.SetStatusText(message))
        # load data in different thread
        self.thread = gThread()

        self.optionBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY,
                                      label=" %s " % _("Options"))
        task = gtask.parse_interface('g.extension')
        ignoreFlags = ['l', 'c', 'g', 'a', 'f', 't', 'help', 'quiet']
        if sys.platform == 'win32':
            ignoreFlags.append('d')
            ignoreFlags.append('i')

        for f in task.get_options()['flags']:
            name = f.get('name', '')
            desc = f.get('label', '')
            if not desc:
                desc = f.get('description', '')
            if not name and not desc:
                continue
            if name in ignoreFlags:
                continue
            self.options[name] = wx.CheckBox(parent=self.panel, id=wx.ID_ANY,
                                             label=desc)
        defaultUrl = ''  # default/official one will be used when option empty
        self.repo.SetValue(
            task.get_param(
                value='url').get(
                'default',
                defaultUrl))

        self.statusbar = self.CreateStatusBar(number=1)

        self.btnFetch = wx.Button(parent=self.panel, id=wx.ID_ANY,
                                  label=_("&Fetch"))
        self.btnFetch.SetToolTipString(_("Fetch list of available modules "
                                         "from GRASS Addons SVN repository"))
        self.btnClose = wx.Button(parent=self.panel, id=wx.ID_CLOSE)
        self.btnInstall = wx.Button(parent=self.panel, id=wx.ID_ANY,
                                    label=_("&Install"))
        self.btnInstall.SetToolTipString(
            _("Install selected add-ons GRASS module"))
        self.btnInstall.Enable(False)
        self.btnHelp = wx.Button(parent=self.panel, id=wx.ID_HELP)
        self.btnHelp.SetToolTipString(_("Show g.extension manual page"))

        self.btnClose.Bind(wx.EVT_BUTTON, lambda evt: self.Close())
        self.btnFetch.Bind(wx.EVT_BUTTON, self.OnFetch)
        self.btnInstall.Bind(wx.EVT_BUTTON, self.OnInstall)
        self.btnHelp.Bind(wx.EVT_BUTTON, self.OnHelp)
        self.tree.selectionChanged.connect(self.OnItemSelected)
        self.tree.itemActivated.connect(self.OnItemActivated)
        self.tree.contextMenu.connect(self.OnContextMenu)

        wx.CallAfter(self._fetch)

        self._layout()
예제 #19
0
 def terminate_download_callback(event):
     self._download_in_progress = False
     request.urlcleanup()
     sys.stdout.write("Download aborted")
     self.thread = gThread()
     self._change_download_btn_label()
예제 #20
0
파일: extensions.py 프로젝트: caomw/grass
    def __init__(self, parent, giface, id=wx.ID_ANY, title=_("Fetch & install extension from GRASS Addons"), **kwargs):
        self.parent = parent
        self._giface = giface
        self.options = dict()  # list of options

        wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs)
        self.SetIcon(wx.Icon(os.path.join(globalvar.ICONDIR, "grass.ico"), wx.BITMAP_TYPE_ICO))

        self.panel = wx.Panel(parent=self, id=wx.ID_ANY)

        self.repoBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Repository"))
        self.treeBox = wx.StaticBox(
            parent=self.panel, id=wx.ID_ANY, label=" %s " % _("List of extensions - double-click to install")
        )

        self.repo = wx.TextCtrl(parent=self.panel, id=wx.ID_ANY)

        # modelBuilder loads data into tree model
        self.modelBuilder = ExtensionTreeModelBuilder()
        # tree view displays model data
        self.tree = CTreeView(parent=self.panel, model=self.modelBuilder.GetModel())

        self.search = SearchModuleWidget(parent=self.panel, model=self.modelBuilder.GetModel(), showChoice=False)
        self.search.showSearchResult.connect(lambda result: self.tree.Select(result))
        # show text in statusbar when notification appears
        self.search.showNotification.connect(lambda message: self.SetStatusText(message))
        # load data in different thread
        self.thread = gThread()

        self.optionBox = wx.StaticBox(parent=self.panel, id=wx.ID_ANY, label=" %s " % _("Options"))
        task = gtask.parse_interface("g.extension")
        ignoreFlags = ["l", "c", "g", "a", "f", "t", "help", "quiet"]
        if sys.platform == "win32":
            ignoreFlags.append("d")
            ignoreFlags.append("i")

        for f in task.get_options()["flags"]:
            name = f.get("name", "")
            desc = f.get("label", "")
            if not desc:
                desc = f.get("description", "")
            if not name and not desc:
                continue
            if name in ignoreFlags:
                continue
            self.options[name] = wx.CheckBox(parent=self.panel, id=wx.ID_ANY, label=desc)
        defaultUrl = "http://svn.osgeo.org/grass/grass-addons/grass7"
        self.repo.SetValue(task.get_param(value="svnurl").get("default", defaultUrl))

        self.statusbar = self.CreateStatusBar(number=1)

        self.btnFetch = wx.Button(parent=self.panel, id=wx.ID_ANY, label=_("&Fetch"))
        self.btnFetch.SetToolTipString(_("Fetch list of available modules " "from GRASS Addons SVN repository"))
        self.btnClose = wx.Button(parent=self.panel, id=wx.ID_CLOSE)
        self.btnInstall = wx.Button(parent=self.panel, id=wx.ID_ANY, label=_("&Install"))
        self.btnInstall.SetToolTipString(_("Install selected add-ons GRASS module"))
        self.btnInstall.Enable(False)
        self.btnHelp = wx.Button(parent=self.panel, id=wx.ID_HELP)
        self.btnHelp.SetToolTipString(_("Show g.extension manual page"))

        self.btnClose.Bind(wx.EVT_BUTTON, lambda evt: self.Close())
        self.btnFetch.Bind(wx.EVT_BUTTON, self.OnFetch)
        self.btnInstall.Bind(wx.EVT_BUTTON, self.OnInstall)
        self.btnHelp.Bind(wx.EVT_BUTTON, self.OnHelp)
        self.tree.selectionChanged.connect(self.OnItemSelected)
        self.tree.itemActivated.connect(self.OnItemActivated)
        self.tree.contextMenu.connect(self.OnContextMenu)

        wx.CallAfter(self._fetch)

        self._layout()