当前位置: 首页>>代码示例>>Python>>正文


Python prefix.addDataPrefix函数代码示例

本文整理汇总了Python中pychess.System.prefix.addDataPrefix函数的典型用法代码示例。如果您正苦于以下问题:Python addDataPrefix函数的具体用法?Python addDataPrefix怎么用?Python addDataPrefix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了addDataPrefix函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__ (self):
     #GObject.GObject.__init__(self,0,0,0,0)
     GObject.GObject.__init__(self)       
     self.widgets = widgets = uistuff.GladeWidgets("taskers.glade")       
     tasker = widgets["newGameTasker"]
     tasker.unparent()
     self.add(tasker)
     
     combo = ToggleComboBox()      
     combo.addItem(_("White"), GdkPixbuf.Pixbuf.new_from_file(addDataPrefix("glade/white.png")))
     combo.addItem(_("Black"), GdkPixbuf.Pixbuf.new_from_file(addDataPrefix("glade/black.png")))
     combo.addItem(_("Random"), GdkPixbuf.Pixbuf.new_from_file(addDataPrefix("glade/random.png")))
     combo.setMarkup("<b>", "</b>")
     widgets["colorDock"].add(combo)
     uistuff.keep(combo, "newgametasker_colorcombo")
     widgets['yourColorLabel'].set_mnemonic_widget(combo)
     
     # We need to wait until after engines have been discovered, to init the
     # playerCombos. We use connect_after to make sure, that newGameDialog
     # has also had time to init the constants we share with them.
     self.playerCombo = ToggleComboBox()
     widgets["opponentDock"].add(self.playerCombo)
     glock_connect_after(discoverer, "all_engines_discovered",
                         self.__initPlayerCombo, widgets)
     widgets['opponentLabel'].set_mnemonic_widget(self.playerCombo)
     
     def on_skill_changed (scale):
         pix = newGameDialog.skillToIconLarge[int(scale.get_value())]
         widgets["skillImage"].set_from_pixbuf(pix)
     widgets["skillSlider"].connect("value-changed", on_skill_changed)
     on_skill_changed(widgets["skillSlider"])
     
     widgets["startButton"].connect("clicked", self.startClicked)
     self.widgets["opendialog1"].connect("clicked", self.openDialogClicked)
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:34,代码来源:TaskerManager.py

示例2: onClicked

 def onClicked (self, button):
     if self._active is False:
         self.image.set_from_file(addDataPrefix("glade/stock-vchain-24.png"))
         self._active = True
     else:
         self.image.set_from_file(addDataPrefix("glade/stock-vchain-broken-24.png"))
         self._active = False
开发者ID:btrent,项目名称:knave,代码行数:7,代码来源:ChainVBox.py

示例3: setActive

 def setActive (self, active):
     assert isinstance(active, bool)
     self._active = active
     if self._active is True:
         self.image.set_from_file(addDataPrefix("glade/stock-vchain-24.png"))
     else:
         self.image.set_from_file(addDataPrefix("glade/stock-vchain-broken-24.png"))
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:7,代码来源:ChainVBox.py

示例4: createPlayerUIGlobals

def createPlayerUIGlobals(discoverer):
    global playerItems
    global analyzerItems
    global allEngineItems

    playerItems = []
    analyzerItems = []
    allEngineItems = []

    for variantClass in variants.values():
        playerItems += [[(ipeople, _("Human Being"))]]
    for engine in discoverer.getEngines():
        name = engine["name"]
        c = discoverer.getCountry(engine)
        path = addDataPrefix("flags/%s.png" % c)

        if c and os.path.isfile(path):
            flag_icon = get_pixbuf(path)
        else:
            path = addDataPrefix("flags/unknown.png")
            flag_icon = get_pixbuf(path)

        allEngineItems.append((flag_icon, name))

        for variant in discoverer.getEngineVariants(engine):
            playerItems[variant] += [(flag_icon, name)]

        if discoverer.is_analyzer(engine):
            analyzerItems.append((flag_icon, name))
开发者ID:leogregianin,项目名称:pychess,代码行数:29,代码来源:newGameDialog.py

示例5: _init

    def _init (cls):
        def callback (widget, allocation):
            cls.widgets["enterGameNotationFrame"].set_size_request(
                    223, allocation.height-4)
        cls.widgets["enterGameNotationSidePanel"].connect_after("size-allocate", callback)

        flags = []
        if isInstalled():
            path = gettext.find("pychess")
        else:
            path = gettext.find("pychess", localedir=addDataPrefix("lang"))
        if path:
            loc = locale.getdefaultlocale()[0][-2:].lower()
            flags.append(addDataPrefix("flags/%s.png" % loc))

        flags.append(addDataPrefix("flags/us.png"))

        cls.ib = ImageButton(flags)
        cls.widgets["imageButtonDock"].add(cls.ib)
        cls.ib.show()

        cls.sourcebuffer = GtkSource.Buffer()
        sourceview = GtkSource.View.new_with_buffer(cls.sourcebuffer)
        sourceview.set_tooltip_text(
            _("Type or paste PGN game or FEN positions here"))
        cls.widgets["scrolledwindow6"].add(sourceview)
        sourceview.show()

        # Pgn format does not allow tabulator
        sourceview.set_insert_spaces_instead_of_tabs(True)
        sourceview.set_wrap_mode(Gtk.WrapMode.WORD)

        man = GtkSource.LanguageManager()
        # Init new version
        if hasattr(man.props, 'search_path'):
            try:
                path = os.path.join(getDataPrefix(),"gtksourceview-1.0/language-specs")
                man.props.search_path = man.props.search_path + [path]
                if 'pgn' in man.get_language_ids():
                    lang = man.get_language('pgn')
                    cls.sourcebuffer.set_language(lang)
                else:
                    log.warning("Unable to load pgn syntax-highlighting.")
                cls.sourcebuffer.set_highlight_syntax(True)
            except NotImplementedError:
                # Python 2.7.3 in Ubuntu 12.04
                log.warning("Unable to load pgn syntax-highlighting.")
        # Init old version
        else:
            os.environ["XDG_DATA_DIRS"] = getDataPrefix()+":/usr/share/"
            man = LanguageManager()
            for lang in man.get_available_languages():
                if lang.get_name() == "PGN":
                    cls.sourcebuffer.set_language(lang)
                    break
            else:
                log.warning("Unable to load pgn syntax-highlighting.")
            cls.sourcebuffer.set_highlight(True)
开发者ID:jcoffee,项目名称:pychess,代码行数:58,代码来源:newGameDialog.py

示例6: run

def run(widgets):
    global firstRun, engine_dialog
    if firstRun:
        # Display of the countries
        items = []
        for iso in ISO3166_LIST:
            path = addDataPrefix("flags/%s.png" % iso.iso2)
            if not(iso.iso2 and os.path.isfile(path)):
                path = addDataPrefix("flags/unknown.png")
            items.append((get_pixbuf(path), iso.country))
        uistuff.createCombo(widgets["engine_country_combo"], name="engine_country_combo",
                            ellipsize_mode=Pango.EllipsizeMode.END)
        data = [(item[0], item[1]) for item in items]
        uistuff.updateCombo(widgets["engine_country_combo"], data)

        engine_dialog = EnginesDialog(widgets)

        def cancel_event(widget, with_confirmation, *args):
            # Confirm if the changes need to be saved
            modified = discoverer.hasChanged()
            if modified and with_confirmation:
                dialog = Gtk.MessageDialog(mainwindow(), type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.YES_NO)
                dialog.set_markup(_("You have unsaved changes. Do you want to save before leaving?"))
                response = dialog.run()
                dialog.destroy()
                # if response == Gtk.ResponseType.CANCEL:
                #    return False
                if response == Gtk.ResponseType.NO:
                    discoverer.restore()
                if response == Gtk.ResponseType.YES:
                    discoverer.save()

            # Close the window
            widgets["manage_engines_dialog"].hide()
            return True

        def save_event(widget, *args):
            discoverer.save()
            widgets["manage_engines_dialog"].hide()
            return True

        widgets["manage_engines_dialog"].connect("delete-event", cancel_event, True)
        widgets["engine_cancel_button"].connect("clicked", cancel_event, False)
        widgets["engine_save_button"].connect("clicked", save_event)
        widgets["manage_engines_dialog"].connect(
            "key-press-event",
            lambda w, e: cancel_event(w, True) if e.keyval == Gdk.KEY_Escape else None)

    discoverer.backup()
    engine_dialog.widgets["enginebook"].set_current_page(0)
    widgets["manage_engines_dialog"].show()
    if not firstRun:
        engine_dialog.update_store()
    firstRun = False
开发者ID:leogregianin,项目名称:pychess,代码行数:54,代码来源:enginesDialog.py

示例7: discover_themes

    def discover_themes(self):
        themes = ['Pychess']

        pieces = addDataPrefix("pieces")
        themes += [d.capitalize() for d in listdir(pieces) if isdir(os.path.join(pieces,d)) and d != 'ttf']

        ttf = addDataPrefix("pieces/ttf")
        themes += ["ttf-" + splitext(d)[0].capitalize() for d in listdir(ttf) if splitext(d)[1] == '.ttf']
        themes.sort()

        return themes
开发者ID:sally0813,项目名称:pychess,代码行数:11,代码来源:preferencesDialog.py

示例8: get_svg_pieces

def get_svg_pieces(svgdir):
    """Load figurines from .svg files"""

    if all_in_one:
        rsvg_handles = Rsvg.Handle.new_from_file(addDataPrefix("pieces/%s/%s.svg" % (svgdir, svgdir)))
    else:
        rsvg_handles = [[None]*7, [None]*7]
        for c, color in ((WHITE, 'white'), (BLACK, 'black')):
            for p in pieces:
                rsvg_handles[c][p] = Rsvg.Handle.new_from_file(addDataPrefix("pieces/%s/%s%s.svg" % (svgdir, color[0], reprSign[p].lower())))
    return rsvg_handles
开发者ID:ZeepXanflorp,项目名称:pychess,代码行数:11,代码来源:Pieces.py

示例9: onColorRadioChanged

 def onColorRadioChanged(self, radio):
     if self.widgets["nocolorRadio"].get_active():
         self.widgets["colorImage"].set_from_file(addDataPrefix(
             "glade/piece-unknown.png"))
         self.widgets["colorImage"].set_sensitive(False)
     elif self.widgets["whitecolorRadio"].get_active():
         self.widgets["colorImage"].set_from_file(addDataPrefix(
             "glade/piece-white.png"))
         self.widgets["colorImage"].set_sensitive(True)
     elif self.widgets["blackcolorRadio"].get_active():
         self.widgets["colorImage"].set_from_file(addDataPrefix(
             "glade/piece-black.png"))
         self.widgets["colorImage"].set_sensitive(True)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:13,代码来源:SeekChallenge.py

示例10: __init__

 def __init__ (self, id):
     TopDock.__init__(self, id)
     self.set_no_show_all(True)
     
     self.highlightArea = HighlightArea(self)
     
     self.buttons = (ArrowButton(self, addDataPrefix("glade/dock_top.svg"), NORTH),
                     ArrowButton(self, addDataPrefix("glade/dock_right.svg"), EAST),
                     ArrowButton(self, addDataPrefix("glade/dock_bottom.svg"), SOUTH),
                     ArrowButton(self, addDataPrefix("glade/dock_left.svg"), WEST))
     
     for button in self.buttons:
         button.connect("dropped", self.__onDrop)
         button.connect("hovered", self.__onHover)
         button.connect("left", self.__onLeave)
开发者ID:fowode,项目名称:pychess,代码行数:15,代码来源:PyDockTop.py

示例11: on_opening_file_entry_changed

 def on_opening_file_entry_changed(none):
     default_path = os.path.join(addDataPrefix("pychess_book.bin"))
     path = conf.get("opening_file_entry", default_path) 
     if os.path.isfile(path):
         for advisor in self.advisors:
             if advisor.mode == OPENING:
                 advisor.shown_changed(self.boardview, self.boardview.shown)
开发者ID:ZeepXanflorp,项目名称:pychess,代码行数:7,代码来源:bookPanel.py

示例12: load

    def load (self, gmwidg):
        
        self.gamemodel = gmwidg.board.view.model
        self.gmhandlers = [
            glock_connect(self.gamemodel, "game_changed", self.game_changed),
            glock_connect(self.gamemodel, "game_started", self.game_started),
            glock_connect(self.gamemodel, "moves_undoing", self.moves_undoing)
        ]

        widgets = Gtk.Builder()
        widgets.add_from_file(addDataPrefix("sidepanel/book.glade"))
        self.tv = widgets.get_object("treeview")
        scrollwin = widgets.get_object("scrolledwindow")
        scrollwin.unparent()

        self.store = Gtk.ListStore(str)
        self.tv.set_model(self.store)
        self.tv.get_selection().set_mode(Gtk.SelectionMode.BROWSE)
        uistuff.appendAutowrapColumn(self.tv, "Comment", text=0)

        self.tv.get_selection().connect_after('changed', self.select_cursor_row)
        self.boardview = gmwidg.board.view
        self.boardview.connect("shown_changed", self.shown_changed)

        self.frozen = Switch()

        return scrollwin
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:27,代码来源:commentPanel.py

示例13: load

 def load (self, gmwidg):
     widgets = gtk.glade.XML(addDataPrefix("sidepanel/book.glade"))
     self.tv = widgets.get_widget("treeview")
     self.sw = widgets.get_widget("scrolledwindow")
     self.sw.unparent()
     
     self.store = gtk.ListStore(str, str, gobject.TYPE_PYOBJECT)
     self.tv.set_model(self.store)
     
     self.tv.append_column(gtk.TreeViewColumn(
             "Move", gtk.CellRendererText(), text=0))
     r = gtk.CellRendererText()
     r.set_property("xalign", 1)
     self.tv.append_column(gtk.TreeViewColumn("Games", r, text=1))
     self.tv.append_column(gtk.TreeViewColumn(
             "Win/Draw/Loss", BookCellRenderer(), data=2))
     
     self.boardcontrol = gmwidg.board
     self.board = self.boardcontrol.view
     self.board.connect("shown_changed", self.shown_changed)
     self.tv.connect("cursor_changed", self.selection_changed)
     self.tv.connect("select_cursor_row", self.selection_changed)
     self.tv.connect("row-activated", self.row_activated)
     self.tv.connect("query-tooltip", self.query_tooltip)
     
     self.tv.props.has_tooltip = True
     
     self.shown_changed(self.board, 0)
     
     return self.sw
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:30,代码来源:bookPanel.py

示例14: get_pixbuf

def get_pixbuf(path, size=None):
    file = Gio.File.new_for_path(addDataPrefix(path))
    if size is None:
        return GdkPixbuf.Pixbuf.new_from_stream(file.read(None), None)
    else:
        return GdkPixbuf.Pixbuf.new_from_stream_at_scale(
            file.read(None), size, size, True, None)
开发者ID:CarbonFixer,项目名称:pychess,代码行数:7,代码来源:IconLoader.py

示例15: __init__

 def __init__(self, filename):
     # TODO: remove this when upstream fixes translations with Python3+Windows
     if sys.platform == "win32" and not no_gettext:
         tree = ET.parse(addDataPrefix("glade/%s" % filename))
         for node in tree.iter():
             if 'translatable' in node.attrib:
                 node.text = _(node.text)
                 del node.attrib['translatable']
             if node.get('name') in ('pixbuf', 'logo'):
                 node.text = addDataPrefix("glade/%s" % node.text)
         xml_text = ET.tostring(tree.getroot(), encoding='unicode', method='xml')
         self.builder = Gtk.Builder.new_from_string(xml_text, -1)
     else:
         self.builder = Gtk.Builder()
         if not no_gettext:
             self.builder.set_translation_domain("pychess")
         self.builder.add_from_file(addDataPrefix("glade/%s" % filename))
开发者ID:teacoffee2017,项目名称:pychess,代码行数:17,代码来源:uistuff.py


注:本文中的pychess.System.prefix.addDataPrefix函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。