當前位置: 首頁>>代碼示例>>Python>>正文


Python Database.load_game方法代碼示例

本文整理匯總了Python中model.database.Database.load_game方法的典型用法代碼示例。如果您正苦於以下問題:Python Database.load_game方法的具體用法?Python Database.load_game怎麽用?Python Database.load_game使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在model.database.Database的用法示例。


在下文中一共展示了Database.load_game方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: open_database

# 需要導入模塊: from model.database import Database [as 別名]
# 或者: from model.database.Database import load_game [as 別名]
 def open_database(self):
     dialog = QFileDialog()
     if self.model.gamestate.last_open_dir != None:
         dialog.setDirectory(self.model.gamestate.last_open_dir)
     filename = dialog.getOpenFileName(
         self.mainAppWindow.chessboard_view,
         self.mainAppWindow.trUtf8("Open PGN"),
         None,
         "PGN (*.pgn)",
         QFileDialog.DontUseNativeDialog,
     )
     if filename:
         db = Database(filename)
         db.init_from_pgn(self.mainAppWindow, self.mainAppWindow.trUtf8("Scanning PGN File..."))
         self.model.database = db
         self.model.user_settings.active_database = db.filename
         selectedGame = 0
         if db.no_of_games() > 1:
             dlg = DialogBrowsePgn(db)
             if dlg.exec_() == QDialog.Accepted:
                 items = dlg.table.selectedItems()
                 selectedGame = int(items[0].text()) - 1
             else:
                 selectedGame = None
         if not selectedGame == None and db.no_of_games() > 0:
             loaded_game = db.load_game(selectedGame)
             self.model.gamestate.current = loaded_game
             self.mainAppWindow.chessboard_view.update()
             self.mainAppWindow.chessboard_view.emit(SIGNAL("statechanged()"))
             self.mainAppWindow.save.setEnabled(False)
             self.mainAppWindow.setLabels()
             self.mainAppWindow.moves_edit_view.setFocus()
             self.model.gamestate.last_open_dir = QFileInfo(filename).dir().absolutePath()
             self.model.gamestate.init_game_tree(self.mainAppWindow)
     self.mainAppWindow.moves_edit_view.setFocus()
開發者ID:jasiegel4,項目名稱:jerry,代碼行數:37,代碼來源:file_mnu_ctr.py


注:本文中的model.database.Database.load_game方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。