コード例 #1
0
ファイル: species.py プロジェクト: RoDuth/bauble.classic
    def __init__(self):
        '''
        the constructor
        '''
        super(SpeciesInfoPage, self).__init__()
        filename = os.path.join(paths.lib_dir(), 'plugins', 'plants',
                                'infoboxes.glade')
        # load the widgets directly instead of using load_widgets()
        # because the caching that load_widgets() does can mess up
        # displaying the SpeciesInfoBox sometimes if you try to show
        # the infobox while having a vernacular names selected in
        # the search results and then a species name
        self.widgets = utils.BuilderWidgets(filename)
        self.general = GeneralSpeciesExpander(self.widgets)
        self.add_expander(self.general)
        self.vernacular = VernacularExpander(self.widgets)
        self.add_expander(self.vernacular)
        self.synonyms = SynonymsExpander(self.widgets)
        self.add_expander(self.synonyms)
        self.links = LinksExpander()
        self.add_expander(self.links)
        self.props = PropertiesExpander()
        self.add_expander(self.props)
        self.label = _('General')

        if 'GardenPlugin' not in pluginmgr.plugins:
            self.widgets.remove_parent('sp_nacc_label')
            self.widgets.remove_parent('sp_nacc_data')
            self.widgets.remove_parent('sp_nplants_label')
            self.widgets.remove_parent('sp_nplants_data')
コード例 #2
0
 def __init__(self, parent=None, fake=False):
     logger.debug("entering PicturesView.__init__(parent=%s, fake=%s)" %
                  (parent, fake))
     super(PicturesView, self).__init__()
     if fake:
         self.fake = True
         return
     self.fake = False
     import os
     from bauble import paths
     glade_file = os.path.join(paths.lib_dir(), 'pictures_view.glade')
     self.widgets = utils.BuilderWidgets(glade_file)
     self.widgets.remove_parent(self.widgets.scrolledwindow2)
     parent.add(self.widgets.scrolledwindow2)
     parent.show_all()
     self.widgets.scrolledwindow2.show()
コード例 #3
0
 def add_page_to_bottom_notebook(self, bottom_info):
     '''add notebook page for a plugin class
     '''
     glade_name = bottom_info['glade_name']
     builder = utils.BuilderLoader.load(glade_name)
     widgets = utils.BuilderWidgets(builder)
     page = getattr(widgets, bottom_info['page_widget'])
     # 2: detach it from parent (its container)
     widgets.remove_parent(page)
     # 3: create the label object
     label = gtk.Label(bottom_info['name'])
     # 4: add the page, non sensitive
     self.view.widget_append_page('bottom_notebook', page, label)
     # 5: store the values for later use
     bottom_info['tree'] = page.get_children()[0]
     bottom_info['label'] = label
コード例 #4
0
    def create_gui(self):
        if self.working_dbtypes is None or len(self.working_dbtypes) == 0:
            msg = _("No Python database connectors installed.\n"
                    "Please consult the documentation for the "
                    "prerequesites for installing Bauble.")
            utils.message_dialog(msg, gtk.MESSAGE_ERROR)
            raise Exception(msg)

        glade_path = os.path.join(paths.lib_dir(), "connmgr.glade")
        self.widgets = utils.BuilderWidgets(glade_path)
        self.builder = self.widgets._builder_

        self.dialog = self.widgets.main_dialog
        title = '%s %s' % ('Bauble', bauble.version)
        self.dialog.set_title(title)
        try:
            pixbuf = gtk.gdk.pixbuf_new_from_file(bauble.default_icon)
            self.dialog.set_icon(pixbuf)
        except Exception:
            logger.warning(
                _('Could not load icon from %s' % bauble.default_icon))
            logger.warning(traceback.format_exc())

        if bauble.gui is not None and bauble.gui.window is not None:
            self.dialog.set_transient_for(bauble.gui.window)
            if not bauble.gui.window.get_property('visible'):
                self.dialog.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
                self.dialog.set_property('skip-taskbar-hint', False)

        self.builder.connect_signals(self)

        # set the logo image manually, it's hard to depend on glade to
        # get this right since the image paths may change
        logo = self.widgets.logo_image
        logo_path = os.path.join(paths.lib_dir(), "images", "bauble_logo.png")
        logo.set_from_file(logo_path)

        self.params_box = None
        self.expander_box = self.widgets.expander_box

        # setup the type combo
        self.type_combo = self.widgets.type_combo

        def type_combo_cell_data_func(combo, renderer, model, iter, data=None):
            """
            if the database type is not in self.working_dbtypes then
            make it not sensitive
            """
            dbtype = model[iter][0]
            sensitive = dbtype in self.working_dbtypes
            renderer.set_property('sensitive', sensitive)
            renderer.set_property('text', dbtype)

        utils.setup_text_combobox(self.type_combo, self._dbtypes,
                                  type_combo_cell_data_func)
        self.type_combo.connect("changed", self.on_changed_type_combo)

        # setup the name combo
        self.name_combo = self.widgets.name_combo
        utils.setup_text_combobox(self.name_combo)
        self.name_combo.connect("changed", self.on_changed_name_combo)

        self.dialog.set_focus(self.widgets.connect_button)
コード例 #5
0
    def __init__(self):
        '''
        the constructor
        '''
        button_defs = [
            {
                'name': 'GoogleButton',
                '_base_uri': "http://www.google.com/search?q=%s",
                '_space': '+',
                'title': "Search Google",
                'tooltip': None,
            },
            {
                'name':
                'GBIFButton',
                '_base_uri':
                "http://www.gbif.org/species/search?q=%s",
                '_space':
                '+',
                'title':
                _("Search GBIF"),
                'tooltip':
                _("Search the Global Biodiversity Information Facility"),
            },
            {
                'name':
                'ITISButton',
                '_base_uri':
                "http://www.itis.gov/servlet/SingleRpt/SingleRpt?search_topic=Scientific_Name&search_value=%s&search_kingdom=Plant&search_span=containing&categories=All&source=html&search_credRating=All",
                '_space':
                '%20',
                'title':
                _("Search ITIS"),
                'tooltip':
                _("Search the Intergrated Taxonomic Information System"),
            },
            {
                'name': 'GRINButton',
                '_base_uri':
                "http://www.ars-grin.gov/cgi-bin/npgs/swish/accboth?query=%s&submit=Submit+Text+Query&si=0",
                '_space': '+',
                'title': _("Search NPGS/GRIN"),
                'tooltip': _('Search National Plant Germplasm System'),
            },
            {
                'name': 'ALAButton',
                '_base_uri': "http://bie.ala.org.au/search?q=%s",
                '_space': '+',
                'title': _("Search ALA"),
                'tooltip': _("Search the Atlas of Living Australia"),
            },
            {
                'name': 'WikipediaButton',
                '_base_uri':
                "http://en.wikipedia.org/wiki/%(genus.epithet)s_%(sp)s",
                '_space': '+',
                'title': _("Search Wikipedia"),
                'tooltip': _("open the wikipedia page about this species"),
            },
            {
                'name': 'IPNIButton',
                '_base_uri':
                "http://www.ipni.org/ipni/advPlantNameSearch.do?find_genus=%(genus.epithet)s&find_species=%(sp)s&find_isAPNIRecord=on& find_isGCIRecord=on&find_isIKRecord=on&output_format=normal",
                '_space': ' ',
                'title': _("Search IPNI"),
                'tooltip': _("Search the International Plant Names Index"),
            },
            {
                'name': 'BGCIButton',
                '_base_uri':
                "http://www.bgci.org/plant_search.php?action=Find&ftrGenus=%(genus.epithet)s&ftrRedList=&ftrSpecies=%(sp)s&ftrRedList1997=&ftrEpithet=&ftrCWR=&x=0&y=0#results",
                '_space': ' ',
                'title': _("Search BGCI"),
                'tooltip':
                _("Search Botanic Gardens Conservation International"),
            },
            {
                'name': 'TPLButton',
                '_base_uri':
                "http://www.theplantlist.org/tpl1.1/search?q=%(genus.epithet)s+%(sp)s",
                '_space': '+',
                'title': _("Search TPL"),
                'tooltip': _("Search The Plant List online database"),
            },
            {
                'name': 'TropicosButton',
                '_base_uri':
                "http://tropicos.org/NameSearch.aspx?name=%(genus.epithet)s+%(sp)s",
                '_space': '+',
                'title': _("Search Tropicos"),
                'tooltip': _("Search Tropicos (MissouriBG) online database"),
            },
        ]
        super(SpeciesInfoPage, self).__init__()
        filename = os.path.join(paths.lib_dir(), 'plugins', 'plants',
                                'infoboxes.glade')
        # load the widgets directly instead of using load_widgets()
        # because the caching that load_widgets() does can mess up
        # displaying the SpeciesInfoBox sometimes if you try to show
        # the infobox while having a vernacular names selected in
        # the search results and then a species name
        self.widgets = utils.BuilderWidgets(filename)
        self.general = GeneralSpeciesExpander(self.widgets)
        self.add_expander(self.general)
        self.vernacular = VernacularExpander(self.widgets)
        self.add_expander(self.vernacular)
        self.synonyms = SynonymsExpander(self.widgets)
        self.add_expander(self.synonyms)
        self.links = view.LinksExpander('notes', links=button_defs)
        self.add_expander(self.links)
        self.props = PropertiesExpander()
        self.add_expander(self.props)
        self.label = _('General')

        if 'GardenPlugin' not in pluginmgr.plugins:
            self.widgets.remove_parent('sp_nacc_label')
            self.widgets.remove_parent('sp_nacc_data')
            self.widgets.remove_parent('sp_nplants_label')
            self.widgets.remove_parent('sp_nplants_data')