本文整理汇总了Python中solver.Solver.displayClues方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.displayClues方法的具体用法?Python Solver.displayClues怎么用?Python Solver.displayClues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solver.Solver
的用法示例。
在下文中一共展示了Solver.displayClues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Kakuro
# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import displayClues [as 别名]
#.........这里部分代码省略.........
self.winDim.destroy()
rows = int(self.rowVar.get())
cols = int(self.colVar.get())
self.drawNew(rows, cols, 'Solver')
self.timer.pause(reset=True)
def drawNew(self, rows, cols, mode):
self.menu.file.entryconfigure('Save', state = DISABLED)
if mode == 'Solver':
self.solver.drawNew(rows, cols)
self.enableSolver()
else:
self.player.drawNew(rows, cols)
self.enablePlayer()
def openFile(self):
# Mainly for development, to avoid having to enter puzzles
# over and over
fname = askopenfile( filetypes = [('Kakuro Files', '.kro')],
title = 'Open Puzzle File',
defaultextension = 'kro',
initialdir = self.fileOpenDir)
if not fname:
return
self.timer.pause(reset = True)
self.fileOpenDir = os.path.dirname(fname.name)
text = fname.read()
dimPattern = re.compile(r'(\d+) by (\d+)')
rows, cols = dimPattern.search(text).groups()
self.drawNew(int(rows), int(cols), 'Solver')
cluePattern = re.compile(r'\d+ +\d+ +\d+ +\d+.*\n')
clues = cluePattern.findall(text)
self.solver.displayClues(clues)
def savePuzzleKro(self):
# Save puzzle in .kro format
# Menu item is enabled if and only if the puzzle has been solved
# and has exactly one solution.
# If there are more rows than columns, the puzzle is transposed to
# better fit a computer screen.
board = self.solver
rows = board.rows
cols = board.cols
fname = asksaveasfilename( filetypes = [('Kakuro Files', '.kro')],
title = 'Save Puzzle',
defaultextension = 'kro',
initialdir = self.fileSaveDir)
if not fname: return
# Force a .kro extension in linux
if not fname.endswith('.kro'):
fname = fname[:-3] + '.kro'
self.fileSaveDir = os.path.split(fname[0])
fout = file(fname, 'w')
fout.write('# %s\n' % os.path.split(fname)[1])
fout.write('# %s\n' % time.strftime("%A, %d %B %Y %H:%M:%S"))
if rows <= cols:
fout.write('dim %d by %d\n' % (rows-1, cols-1))
else:
fout.write('#Transposed from data entry.\n')
fout.write('dim %d by %d\n' % (cols-1, rows-1))
fout.write('\nBlack Squares\n')
fout.write('Row Col Acr Dwn\n\n')
blacks = board.getClues()