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


Python conf.hasKey函数代码示例

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


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

示例1: loadPosition

 def loadPosition (window):
     #log.debug("keepWindowSize.loadPosition: %s" % window.title)
     width, height = window.get_size_request()
     
     if conf.hasKey(key+"_width") and conf.hasKey(key+"_height"):
         width = conf.getStrict(key+"_width")
         height = conf.getStrict(key+"_height")
         log.debug("Resizing window to width=%s height=%s" % (width, height))
         window.resize(width, height)
     
     elif defaultSize:
         width, height = defaultSize
         log.debug("Resizing window to width=%s height=%s" % (width, height))
         window.resize(width, height)
     
     if conf.hasKey(key+"_x") and conf.hasKey(key+"_y"):
         log.debug("Moving window to x=%s y=%s" % (conf.getStrict(key+"_x"),
                                                   conf.getStrict(key+"_y")))
         window.move(conf.getStrict(key+"_x"),
                     conf.getStrict(key+"_y"))
     
     elif defaultPosition in (POSITION_CENTER, POSITION_GOLDEN):
         monitor_x, monitor_y, monitor_width, monitor_height = getMonitorBounds()
         x = int(monitor_width/2-width/2) + monitor_x
         if defaultPosition == POSITION_CENTER:
             y = int(monitor_height/2-height/2) + monitor_y
         else:
             # Place the window on the upper golden ratio line
             y = int(monitor_height/2.618-height/2) + monitor_y
         log.debug("Moving window to x=%s y=%s" % (x, y))
         window.move(x, y)
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:31,代码来源:uistuff.py

示例2: loadPosition

 def loadPosition (window):
     width, height = window.get_size_request()
     
     if conf.hasKey(key+"_width") and conf.hasKey(key+"_height"):
         width = conf.getStrict(key+"_width")
         height = conf.getStrict(key+"_height")
         window.resize(width, height)
     
     elif defaultSize:
         width, height = defaultSize
         window.resize(width, height)
     
     if conf.hasKey(key+"_x") and conf.hasKey(key+"_y"):
         window.move(conf.getStrict(key+"_x"),
                     conf.getStrict(key+"_y"))
     
     elif defaultPosition in (POSITION_CENTER, POSITION_GOLDEN):
         monitor_x, monitor_y, monitor_width, monitor_height = getMonitorBounds()
         x = int(monitor_width/2-width/2) + monitor_x
         if defaultPosition == POSITION_CENTER:
             y = int(monitor_height/2-height/2) + monitor_y
         else:
             # Place the window on the upper golden ratio line
             y = int(monitor_height/2.618-height/2) + monitor_y
         window.move(x, y)
开发者ID:btrent,项目名称:knave,代码行数:25,代码来源:uistuff.py

示例3: loadPosition

    def loadPosition(window):
        # log.debug("keepWindowSize.loadPosition: %s" % window.title)
        # Just to make sphinx happy...
        try:
            width, height = window.get_size_request()
        except TypeError:
            pass

        if conf.hasKey(key + "_width") and conf.hasKey(key + "_height"):
            width = conf.get(key + "_width")
            height = conf.get(key + "_height")
            log.debug("Resizing window to width=%s height=%s" %
                      (width, height))
            window.resize(width, height)

        elif defaultSize:
            width, height = defaultSize
            log.debug("Resizing window to width=%s height=%s" %
                      (width, height))
            window.resize(width, height)

        elif key == "mainwindow":
            monitor_x, monitor_y, monitor_width, monitor_height = getMonitorBounds()
            width = int(monitor_width / 2)
            height = int(monitor_height / 4) * 3
            log.debug("Resizing window to width=%s height=%s" %
                      (width, height))
            window.resize(width, height)

        elif key == "preferencesdialogwindow":
            monitor_x, monitor_y, monitor_width, monitor_height = getMonitorBounds()
            width = int(monitor_width / 2)
            height = int(monitor_height / 4) * 3
            window.resize(1, 1)
        else:
            monitor_x, monitor_y, monitor_width, monitor_height = getMonitorBounds()
            width = int(monitor_width / 2)
            height = int(monitor_height / 4) * 3

        if conf.hasKey(key + "_x") and conf.hasKey(key + "_y"):
            x = max(0, conf.get(key + "_x"))
            y = max(0, conf.get(key + "_y"))
            log.debug("Moving window to x=%s y=%s" % (x, y))
            window.move(x, y)

        elif defaultPosition in (POSITION_CENTER, POSITION_GOLDEN):
            monitor_x, monitor_y, monitor_width, monitor_height = getMonitorBounds()
            x_loc = int(monitor_width / 2 - width / 2) + monitor_x
            if defaultPosition == POSITION_CENTER:
                y_loc = int(monitor_height / 2 - height / 2) + monitor_y
            else:
                # Place the window on the upper golden ratio line
                y_loc = int(monitor_height / 2.618 - height / 2) + monitor_y
            log.debug("Moving window to x=%s y=%s" % (x_loc, y_loc))
            window.move(x_loc, y_loc)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:55,代码来源:uistuff.py

示例4: keep

def keep(widget, key, get_value_=None, set_value_=None, first_value=None):
    if widget is None:
        raise AttributeError("key '%s' isn't in widgets" % key)

    for class_, methods_ in METHODS:
        # Use try-except just to make spinx happy...
        try:
            if isinstance(widget, class_):
                getter, setter, signal = methods_
                break
        except TypeError:
            getter, setter, signal = methods_
            break
    else:
        raise AttributeError("I don't have any knowledge of type: '%s'" %
                             widget)

    if get_value_:
        def get_value():
            return get_value_(widget)
    else:
        get_value = getattr(widget, getter)

    if set_value_:
        def set_value(v):
            return set_value_(widget, v)
    else:
        set_value = getattr(widget, setter)

    def setFromConf():
        try:
            v = conf.get(key)
        except TypeError:
            log.warning("uistuff.keep.setFromConf: Key '%s' from conf had the wrong type '%s', ignored" %
                        (key, type(conf.get(key))))
            if first_value is not None:
                conf.set(key, first_value)
            else:
                conf.set(key, get_value())
        else:
            set_value(v)

    def callback(*args):
        if not conf.hasKey(key) or conf.get(key) != get_value():
            conf.set(key, get_value())

    widget.connect(signal, callback)
    conf.notify_add(key, lambda *args: setFromConf())

    if conf.hasKey(key):
        setFromConf()
    elif first_value is not None:
        conf.set(key, first_value)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:53,代码来源:uistuff.py

示例5: loadDialogWidget

def loadDialogWidget(widget,
                     widget_name,
                     config_number,
                     get_value_=None,
                     set_value_=None,
                     first_value=None):
    key = widget_name + "-" + str(config_number)

    if widget is None:
        raise AttributeError("key '%s' isn't in widgets" % widget_name)

    for class_, methods_ in METHODS:
        if isinstance(widget, class_):
            getter, setter, signal = methods_
            break
    else:
        if set_value_ is None:
            raise AttributeError("I don't have any knowledge of type: '%s'" %
                                 widget)

    if get_value_:
        def get_value():
            return get_value_(widget)
    else:
        get_value = getattr(widget, getter)

    if set_value_:
        def set_value(v):
            return set_value_(widget, v)
    else:
        set_value = getattr(widget, setter)

    if conf.hasKey(key):
        try:
            v = conf.get(key)
        except TypeError:
            log.warning("uistuff.loadDialogWidget: Key '%s' from conf had the wrong type '%s', ignored" %
                        (key, type(conf.get(key))))
            if first_value is not None:
                conf.set(key, first_value)
            else:
                conf.set(key, get_value())
        else:
            set_value(v)
    elif first_value is not None:
        conf.set(key, first_value)
        set_value(conf.get(key))
    else:
        log.warning("Didn't load widget \"%s\": no conf value and no first_value arg" % widget_name)
开发者ID:teacoffee2017,项目名称:pychess,代码行数:49,代码来源:uistuff.py

示例6: saveDialogWidget

def saveDialogWidget (widget, widget_name, config_number, get_value_=None):
    key = widget_name + "-" + str(config_number)
    
    if widget == None:
        raise AttributeError("key '%s' isn't in widgets" % widget_name)
    
    for class_, methods_ in METHODS:
        if isinstance(widget, class_):
            getter, setter, signal = methods_
            break
    else:
        if get_value_ == None:
            raise AttributeError("I don't have any knowledge of type: '%s'" % widget)
    
    if get_value_:
        get_value = lambda: get_value_(widget)
    else:
        get_value = getattr(widget, getter)

    if not conf.hasKey(key) or conf.getStrict(key) != get_value():
        conf.set(key, get_value())
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:21,代码来源:uistuff.py

示例7: anal_combo_set_value

            self.widgets["ana_combobox"], "ana_combobox", anal_combo_get_value,
            lambda combobox, value: anal_combo_set_value(combobox, value, "hint_mode", "analyzer_check", HINT))
        uistuff.keep(
            self.widgets["inv_ana_combobox"], "inv_ana_combobox",
            anal_combo_get_value,
            lambda combobox, value: anal_combo_set_value(combobox, value, "spy_mode", "inv_analyzer_check", SPY))

        uistuff.keep(self.widgets["max_analysis_spin"], "max_analysis_spin", first_value=3)

# Sound initing

# Setup default sounds
EXT = "wav" if sys.platform == "win32" else "ogg"

for i in range(11):
    if not conf.hasKey("soundcombo%d" % i):
        conf.set("soundcombo%d" % i, SOUND_URI)
if not conf.hasKey("sounduri0"):
    conf.set("sounduri0",
             "file:" + pathname2url(addDataPrefix("sounds/move1.%s" % EXT)))
if not conf.hasKey("sounduri1"):
    conf.set("sounduri1",
             "file:" + pathname2url(addDataPrefix("sounds/check1.%s" % EXT)))
if not conf.hasKey("sounduri2"):
    conf.set("sounduri2",
             "file:" + pathname2url(addDataPrefix("sounds/capture1.%s" % EXT)))
if not conf.hasKey("sounduri3"):
    conf.set("sounduri3",
             "file:" + pathname2url(addDataPrefix("sounds/start1.%s" % EXT)))
if not conf.hasKey("sounduri4"):
    conf.set("sounduri4",
开发者ID:bboutkov,项目名称:pychess,代码行数:31,代码来源:preferencesDialog.py

示例8: callback

 def callback(*args):
     if not conf.hasKey(key) or conf.get(key) != get_value():
         conf.set(key, get_value())
开发者ID:teacoffee2017,项目名称:pychess,代码行数:3,代码来源:uistuff.py


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