Beispiel #1
0
 def UpdateDialog(self, layer):
     """Updates dialog layout for given layer"""
     DbMgrBase.UpdateDialog(self, layer=layer)
     # set current page selection
     self.notebook.SetSelectionByName('layers')
Beispiel #2
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title=None,
                 vectorName=None,
                 item=None,
                 log=None,
                 selection=None,
                 **kwargs):
        """GRASS Attribute Table Manager window

        :param parent: parent window
        :param id: window id
        :param title: window title or None for default title
        :param vectorName: name of vector map
        :param item: item from Layer Tree
        :param log: log window
        :param selection: name of page to be selected
        :param kwagrs: other wx.Frame's arguments
        """
        self.parent = parent
        try:
            mapdisplay = self.parent.GetMapDisplay()
        except:
            mapdisplay = None

        DbMgrBase.__init__(self,
                           id=id,
                           mapdisplay=mapdisplay,
                           vectorName=vectorName,
                           item=item,
                           log=log,
                           statusbar=self,
                           **kwargs)

        wx.Frame.__init__(self, parent, id, *kwargs)

        # title
        if not title:
            title = "%s" % _("GRASS GIS Attribute Table Manager - ")
            if not self.dbMgrData['editable']:
                title += _("READONLY - ")
            title += "<%s>" % (self.dbMgrData['vectName'])

        self.SetTitle(title)

        # icon
        self.SetIcon(
            wx.Icon(os.path.join(globalvar.ICONDIR, 'grass_sql.ico'),
                    wx.BITMAP_TYPE_ICO))

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

        if len(self.dbMgrData['mapDBInfo'].layers.keys()) == 0:
            GMessage(parent=self.parent,
                     message=_("Database connection for vector map <%s> "
                               "is not defined in DB file. "
                               "You can define new connection in "
                               "'Manage layers' tab.") %
                     self.dbMgrData['vectName'])

        busy = wx.BusyInfo(_("Please wait, loading attribute data..."),
                           parent=self.parent)
        wx.SafeYield()
        self.CreateStatusBar(number=1)

        self.notebook = GNotebook(self.panel, style=globalvar.FNPageDStyle)

        self.CreateDbMgrPage(parent=self, pageName='browse')

        self.notebook.AddPage(page=self.pages['browse'],
                              text=_("Browse data"),
                              name='browse')
        self.pages['browse'].SetTabAreaColour(globalvar.FNPageColor)

        self.CreateDbMgrPage(parent=self, pageName='manageTable')

        self.notebook.AddPage(page=self.pages['manageTable'],
                              text=_("Manage tables"),
                              name='table')
        self.pages['manageTable'].SetTabAreaColour(globalvar.FNPageColor)

        self.CreateDbMgrPage(parent=self, pageName='manageLayer')
        self.notebook.AddPage(page=self.pages['manageLayer'],
                              text=_("Manage layers"),
                              name='layers')
        del busy

        if selection:
            wx.CallAfter(self.notebook.SetSelectionByName, selection)
        else:
            wx.CallAfter(self.notebook.SetSelection, 0)  # select browse tab

        # buttons
        self.btnClose = CloseButton(parent=self.panel)
        self.btnClose.SetToolTip(_("Close Attribute Table Manager"))
        self.btnReload = Button(parent=self.panel, id=wx.ID_REFRESH)
        self.btnReload.SetToolTip(
            _("Reload currently selected attribute data"))
        self.btnReset = ClearButton(parent=self.panel)
        self.btnReset.SetToolTip(
            _("Reload all attribute data (drop current selection)"))

        # bind closing to ESC
        self.Bind(wx.EVT_MENU, self.OnCloseWindow, id=wx.ID_CANCEL)
        accelTableList = [(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, wx.ID_CANCEL)]
        accelTable = wx.AcceleratorTable(accelTableList)
        self.SetAcceleratorTable(accelTable)

        # events
        self.btnClose.Bind(wx.EVT_BUTTON, self.OnCloseWindow)
        self.btnReload.Bind(wx.EVT_BUTTON, self.OnReloadData)
        self.btnReset.Bind(wx.EVT_BUTTON, self.OnReloadDataAll)
        self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED,
                           self.OnPageChanged)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        # do layout
        self._layout()

        # self.SetMinSize(self.GetBestSize())
        self.SetSize((700, 550))  # FIXME hard-coded size
        self.SetMinSize(self.GetSize())
Beispiel #3
0
    def __init__(self, parent, id = wx.ID_ANY,
                 title = None, vectorName = None, item = None, log = None,
                 selection = None, **kwargs):
        """GRASS Attribute Table Manager window

        :param parent: parent window
        :param id: window id
        :param title: window title or None for default title
        :param vectorName: name of vector map
        :param item: item from Layer Tree
        :param log: log window
        :param selection: name of page to be selected
        :param kwagrs: other wx.Frame's arguments
        """
        self.parent = parent
        try:
            mapdisplay = self.parent.GetMapDisplay()
        except:
            mapdisplay = None
        
        DbMgrBase.__init__(self, id = id, mapdisplay = mapdisplay,
                           vectorName = vectorName, item = item, 
                           log = log, statusbar = self, 
                           **kwargs)
        
        wx.Frame.__init__(self, parent, id, *kwargs)

        # title
        if not title:
            title = "%s" % _("GRASS GIS Attribute Table Manager - ")
            if not self.dbMgrData['editable']:
                title += _("READONLY - ")
            title += "<%s>" % (self.dbMgrData['vectName'])


        self.SetTitle(title)
        
        # icon
        self.SetIcon(wx.Icon(os.path.join(globalvar.ICONDIR, 'grass_sql.ico'), wx.BITMAP_TYPE_ICO))

        self.panel = wx.Panel(parent = self, id = wx.ID_ANY)
             
        if len(self.dbMgrData['mapDBInfo'].layers.keys()) == 0:
            GMessage(parent = self.parent,
                     message = _("Database connection for vector map <%s> "
                                 "is not defined in DB file. "
                                 "You can define new connection in "
                                 "'Manage layers' tab.") % self.dbMgrData['vectName'])
        
        busy = wx.BusyInfo(message=_("Please wait, loading attribute data..."),
                           parent=self.parent)
        wx.SafeYield()
        self.CreateStatusBar(number = 1)

        self.notebook = GNotebook(self.panel, style = globalvar.FNPageDStyle)
                
        self.CreateDbMgrPage(parent = self, pageName = 'browse')

        self.notebook.AddPage(page = self.pages['browse'], text = _("Browse data"),
                              name = 'browse')
        self.pages['browse'].SetTabAreaColour(globalvar.FNPageColor)

        self.CreateDbMgrPage(parent = self, pageName = 'manageTable')

        self.notebook.AddPage(page = self.pages['manageTable'], text = _("Manage tables"),
                              name = 'table')
        self.pages['manageTable'].SetTabAreaColour(globalvar.FNPageColor)

        self.CreateDbMgrPage(parent = self, pageName = 'manageLayer')
        self.notebook.AddPage(page = self.pages['manageLayer'], text = _("Manage layers"),
                              name = 'layers')
        del busy

        if selection:
            wx.CallAfter(self.notebook.SetSelectionByName, selection)
        else:
            wx.CallAfter(self.notebook.SetSelection, 0) # select browse tab
        
        # buttons
        self.btnClose   = wx.Button(parent = self.panel, id = wx.ID_CLOSE)
        self.btnClose.SetToolTipString(_("Close Attribute Table Manager"))
        self.btnReload = wx.Button(parent = self.panel, id = wx.ID_REFRESH)
        self.btnReload.SetToolTipString(_("Reload currently selected attribute data"))
        self.btnReset = wx.Button(parent = self.panel, id = wx.ID_CLEAR)
        self.btnReset.SetToolTipString(_("Reload all attribute data (drop current selection)"))
        
        # events
        self.btnClose.Bind(wx.EVT_BUTTON,   self.OnCloseWindow)
        self.btnReload.Bind(wx.EVT_BUTTON,  self.OnReloadData)
        self.btnReset.Bind(wx.EVT_BUTTON,   self.OnReloadDataAll)
        self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        # do layout
        self._layout()

        # self.SetMinSize(self.GetBestSize())
        self.SetSize((700, 550)) # FIXME hard-coded size
        self.SetMinSize(self.GetSize())