本文整理汇总了Python中pychess.System.glock.release函数的典型用法代码示例。如果您正苦于以下问题:Python release函数的具体用法?Python release怎么用?Python release使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了release函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _set_rotation
def _set_rotation (self, radians):
if not conf.get("fullAnimation", True):
glock.acquire()
try:
self._rotation = radians
self.nextRotation = radians
self.matrix = cairo.Matrix.init_rotate(radians)
self.redraw_canvas()
finally:
glock.release()
else:
if hasattr(self, "nextRotation") and \
self.nextRotation != self.rotation:
return
self.nextRotation = radians
oldr = self.rotation
start = time()
def callback ():
glock.acquire()
try:
amount = (time()-start)/ANIMATION_TIME
if amount > 1:
amount = 1
next = False
else: next = True
self._rotation = new = oldr + amount*(radians-oldr)
self.matrix = cairo.Matrix.init_rotate(new)
self.redraw_canvas()
finally:
glock.release()
return next
repeat(callback)
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:32,代码来源:BoardView.py
示例2: __init__
def __init__(self, gamemodel):
gobject.GObject.__init__(self)
self.gamemodel = gamemodel
tabcontent = self.initTabcontents()
boardvbox, board, messageSock = self.initBoardAndClock(gamemodel)
statusbar, stat_hbox = self.initStatusbar(board)
self.tabcontent = tabcontent
self.board = board
self.statusbar = statusbar
self.messageSock = messageSock
self.notebookKey = gtk.Label()
self.notebookKey.set_size_request(0, 0)
self.boardvbox = boardvbox
self.stat_hbox = stat_hbox
# Some stuff in the sidepanels .load functions might change UI, so we
# need glock
# TODO: Really?
glock.acquire()
try:
self.panels = [panel.Sidepanel().load(self) for panel in sidePanels]
finally:
glock.release()
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:26,代码来源:gamewidget.py
示例3: setLocked
def setLocked (self, locked):
do_animation = False
glock.acquire()
self.stateLock.acquire()
try:
if locked and self.isLastPlayed(self.getBoard()) and \
self.view.model.status == RUNNING:
if self.view.model.status != RUNNING:
self.view.selected = None
self.view.active = None
self.view.hover = None
self.view.draggedPiece = None
do_animation = True
if self.currentState == self.selectedState:
self.currentState = self.lockedSelectedState
elif self.currentState == self.activeState:
self.currentState = self.lockedActiveState
else:
self.currentState = self.lockedNormalState
else:
if self.currentState == self.lockedSelectedState:
self.currentState = self.selectedState
elif self.currentState == self.lockedActiveState:
self.currentState = self.activeState
else:
self.currentState = self.normalState
finally:
self.stateLock.release()
glock.release()
if do_animation:
self.view.startAnimation()
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:34,代码来源:BoardControl.py
示例4: game_ended
def game_ended (gamemodel, reason, gmwidg):
nameDic = {"white": gamemodel.players[WHITE],
"black": gamemodel.players[BLACK],
"mover": gamemodel.curplayer}
if gamemodel.status == WHITEWON:
nameDic["winner"] = gamemodel.players[WHITE]
nameDic["loser"] = gamemodel.players[BLACK]
elif gamemodel.status == BLACKWON:
nameDic["winner"] = gamemodel.players[BLACK]
nameDic["loser"] = gamemodel.players[WHITE]
m1 = reprResult_long[gamemodel.status] % nameDic
m2 = reprReason_long[reason] % nameDic
md = gtk.MessageDialog()
md.set_markup("<b><big>%s</big></b>" % m1)
md.format_secondary_markup(m2)
if gamemodel.players[0].__type__ == LOCAL or gamemodel.players[1].__type__ == LOCAL:
if gamemodel.players[0].__type__ == REMOTE or gamemodel.players[1].__type__ == REMOTE:
md.add_button(_("Offer Rematch"), 0)
else:
md.add_button(_("Play Rematch"), 1)
if gamemodel.ply > 1:
md.add_button(_("Undo two moves"), 2)
elif gamemodel.ply == 1:
md.add_button(_("Undo one move"), 2)
def cb (messageDialog, responseId):
if responseId == 0:
if gamemodel.players[0].__type__ == REMOTE:
gamemodel.players[0].offerRematch()
else:
gamemodel.players[1].offerRematch()
elif responseId == 1:
from pychess.widgets.newGameDialog import createRematch
createRematch(gamemodel)
elif responseId == 2:
if gamemodel.curplayer.__type__ == LOCAL and gamemodel.ply > 1:
offer = Offer(TAKEBACK_OFFER, gamemodel.ply-2)
else:
offer = Offer(TAKEBACK_OFFER, gamemodel.ply-1)
if gamemodel.players[0].__type__ == LOCAL:
gamemodel.players[0].emit("offer", offer)
else: gamemodel.players[1].emit("offer", offer)
md.connect("response", cb)
glock.acquire()
try:
gmwidg.showMessage(md)
gmwidg.status("%s %s." % (m1,m2[0].lower()+m2[1:]))
if reason == WHITE_ENGINE_DIED:
engineDead(gamemodel.players[0], gmwidg)
elif reason == BLACK_ENGINE_DIED:
engineDead(gamemodel.players[1], gmwidg)
finally:
glock.release()
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:60,代码来源:gamenanny.py
示例5: analyse_moves
def analyse_moves():
move_time = int(conf.get("max_analysis_spin", 3))
thresold = int(conf.get("variation_thresold_spin", 50))
for board in gamemodel.boards:
if stop_event.is_set():
break
glock.acquire()
try:
gmwidg.board.view.setShownBoard(board)
finally:
glock.release()
analyzer.setBoard(board)
time.sleep(move_time + 0.1)
ply = board.ply
if ply - 1 in gamemodel.scores:
color = (ply - 1) % 2
oldmoves, oldscore, olddepth = gamemodel.scores[ply - 1]
oldscore = oldscore * -1 if color == BLACK else oldscore
moves, score, depth = gamemodel.scores[ply]
score = score * -1 if color == WHITE else score
diff = score - oldscore
if (diff > thresold and color == BLACK) or (diff < -1 * thresold and color == WHITE):
gamemodel.add_variation(gamemodel.boards[ply - 1], oldmoves)
widgets["analyze_game"].hide()
widgets["analyze_ok_button"].set_sensitive(True)
conf.set("analyzer_check", old_check_value)
开发者ID:fowode,项目名称:pychess,代码行数:28,代码来源:analyzegameDialog.py
示例6: __stopSearching
def __stopSearching(self):
lsearch.searching = False
if self.worker:
self.worker.cancel()
glock.acquire()
self.worker.get()
glock.release()
self.worker = None
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:8,代码来源:PyChess.py
示例7: status
def status(self, message):
glock.acquire()
try:
self.statusbar.pop(0)
if message:
self.statusbar.push(0, message)
finally:
glock.release()
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:8,代码来源:gamewidget.py
示例8: game_unended
def game_unended (gamemodel, gmwidg):
glock.acquire()
try:
print "sending hideMessage"
gmwidg.hideMessage()
gmwidg.status("")
finally:
glock.release()
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:8,代码来源:gamenanny.py
示例9: on_gmwidg_closed
def on_gmwidg_closed (gmwidg):
glock.acquire()
try:
if len(key2gmwidg) == 1:
getWidgets()['window1'].set_title('%s - PyChess' % _('Welcome'))
finally:
glock.release()
return False
开发者ID:fowode,项目名称:pychess,代码行数:8,代码来源:gamenanny.py
示例10: game_unended
def game_unended (gamemodel, gmwidg):
log.debug("gamenanny.game_unended: %s" % gamemodel.boards[-1])
glock.acquire()
try:
gmwidg.clearMessages()
finally:
glock.release()
_set_statusbar(gmwidg, "")
return False
开发者ID:fowode,项目名称:pychess,代码行数:9,代码来源:gamenanny.py
示例11: status
def status (self, message):
glock.acquire()
try:
self.statusbar.pop(0)
if message:
#print "Setting statusbar to \"%s\"" % str(message)
self.statusbar.push(0, message)
finally:
glock.release()
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:9,代码来源:gamewidget.py
示例12: _set_widget
def _set_widget (self, prop, value):
if not self.gamewidget.isInFront(): return
if gamewidget.getWidgets()[self.name].get_property(prop) != value:
#print "setting %s property %s to %s.." % (self.name, prop, str(value)),
glock.acquire()
try:
gamewidget.getWidgets()[self.name].set_property(prop, value)
finally:
glock.release()
开发者ID:btrent,项目名称:knave,代码行数:9,代码来源:MenuItemsDict.py
示例13: getPromotion
def getPromotion(self):
color = self.view.model.boards[-1].color
variant = self.view.model.boards[-1].variant
promotion = None
glock.acquire()
try:
promotion = self.promotionDialog.runAndHide(color, variant)
finally:
glock.release()
return promotion
开发者ID:Alex-Linhares,项目名称:pychess,代码行数:10,代码来源:BoardControl.py
示例14: game_loaded
def game_loaded (gamemodel, uri, gmwidg):
if type(uri) in (str, unicode):
s = "%s: %s" % (_("Loaded game"), str(uri))
else: s = _("Loaded game")
glock.acquire()
try:
gmwidg.status(s)
finally:
glock.release()
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:10,代码来源:gamenanny.py
示例15: on_gmwidg_title_changed
def on_gmwidg_title_changed (gmwidg, new_title):
log.debug("gamenanny.on_gmwidg_title_changed: starting %s" % repr(gmwidg))
glock.acquire()
try:
if gmwidg.isInFront():
getWidgets()['window1'].set_title('%s - PyChess' % new_title)
finally:
glock.release()
log.debug("gamenanny.on_gmwidg_title_changed: returning")
return False
开发者ID:fowode,项目名称:pychess,代码行数:10,代码来源:gamenanny.py
示例16: __init__
def __init__(self, gamemodel):
GObject.GObject.__init__(self)
self.gamemodel = gamemodel
self.cids = {}
tabcontent, white_label, black_label, game_info_label = self.initTabcontents()
boardvbox, board, infobar, clock = self.initBoardAndClock(gamemodel)
statusbar, stat_hbox = self.initStatusbar(board)
self.tabcontent = tabcontent
self.player_name_labels = (white_label, black_label)
self.game_info_label = game_info_label
self.board = board
self.statusbar = statusbar
self.infobar = infobar
infobar.connect("hide", self.infobar_hidden)
self.game_ended_message = None
self.clock = clock
self.notebookKey = Gtk.Label()
self.notebookKey.set_size_request(0, 0)
self.boardvbox = boardvbox
self.stat_hbox = stat_hbox
self.menuitems = MenuItemsDict(self)
gamemodel.connect("game_started", self.game_started)
gamemodel.connect("game_ended", self.game_ended)
gamemodel.connect("game_changed", self.game_changed)
gamemodel.connect("game_paused", self.game_paused)
gamemodel.connect("game_resumed", self.game_resumed)
gamemodel.connect("moves_undone", self.moves_undone)
gamemodel.connect("game_unended", self.game_unended)
gamemodel.connect("game_saved", self.game_saved)
gamemodel.connect("players_changed", self.players_changed)
gamemodel.connect("analyzer_added", self.analyzer_added)
gamemodel.connect("analyzer_removed", self.analyzer_removed)
gamemodel.connect("analyzer_resumed", self.analyzer_resumed)
gamemodel.connect("analyzer_paused", self.analyzer_paused)
self.players_changed(gamemodel)
if self.gamemodel.display_text:
self.game_info_label.set_text(" " + self.gamemodel.display_text)
if gamemodel.timed:
gamemodel.timemodel.connect("zero_reached", self.zero_reached)
if isinstance(gamemodel, ICGameModel):
gamemodel.connection.bm.connect("player_lagged", self.player_lagged)
gamemodel.connection.bm.connect("opp_not_out_of_time", self.opp_not_out_of_time)
board.view.connect("shown_changed", self.shown_changed)
# Some stuff in the sidepanels .load functions might change UI, so we
# need glock
# TODO: Really?
glock.acquire()
try:
self.panels = [panel.Sidepanel().load(self) for panel in sidePanels]
finally:
glock.release()
开发者ID:fowode,项目名称:pychess,代码行数:55,代码来源:gamewidget.py
示例17: addMessage
def addMessage (self, sender, text):
glock.acquire()
try:
tb = self.readView.get_buffer()
iter = tb.get_end_iter()
# Messages have linebreak before the text. This is opposite to log
# messages
if tb.props.text: tb.insert(iter, "\n")
self.__addMessage(iter, strftime("%H:%M:%S"), sender, text)
finally:
glock.release()
开发者ID:btrent,项目名称:knave,代码行数:11,代码来源:ChatView.py
示例18: redraw_canvas
def redraw_canvas(self):
if self.window:
glock.acquire()
try:
if self.window:
a = self.get_allocation()
rect = gdk.Rectangle(0, 0, a.width, a.height)
self.window.invalidate_rect(rect, True)
self.window.process_updates(True)
finally:
glock.release()
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:11,代码来源:ChessClock.py
示例19: offer_callback
def offer_callback (player, offer, gamemodel, gmwidg):
if offer.type == DRAW_OFFER:
if gamemodel.status != RUNNING:
return # If the offer has already been handled by
# Gamemodel and the game was drawn, we need
# to do nothing
glock.acquire()
try:
gmwidg.status(_("You sent a draw offer"))
finally:
glock.release()
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:11,代码来源:gamenanny.py
示例20: onSizeAllocate
def onSizeAllocate(self, widget, requisition):
if self.window:
glock.acquire()
try:
a = self.get_allocation()
rect = gdk.Rectangle(a.x, a.y, a.width, a.height)
unionrect = self.lastRectangle.union(rect) if self.lastRectangle != None else rect
self.window.invalidate_rect(unionrect, True)
self.window.process_updates(True)
self.lastRectangle = rect
finally:
glock.release()
开发者ID:jskurka,项目名称:PyChess-Learning-Module,代码行数:12,代码来源:ChainVBox.py
注:本文中的pychess.System.glock.release函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论