Merged revisions 85820,85823,85825,85840,85843-85845,85849-85851,85855,85867,85875,85907-85908,85911,85914 via svnmerge from

svn+ssh://svn.python.org/python/branches/py3k

........
  r85820 | georg.brandl | 2010-10-24 16:20:22 +0200 (So, 24 Okt 2010) | 1 line

  Remove usage of exception indexing.
........
  r85823 | georg.brandl | 2010-10-24 16:32:45 +0200 (So, 24 Okt 2010) | 1 line

  Fix style.
........
  r85825 | georg.brandl | 2010-10-24 17:16:02 +0200 (So, 24 Okt 2010) | 1 line

  Add documentation about the default warnings filters.
........
  r85840 | georg.brandl | 2010-10-25 19:50:20 +0200 (Mo, 25 Okt 2010) | 1 line

  #3018: tkinter demo fixes for py3k.
........
  r85843 | georg.brandl | 2010-10-26 08:59:23 +0200 (Di, 26 Okt 2010) | 1 line

  Markup fix.
........
  r85844 | georg.brandl | 2010-10-26 12:39:14 +0200 (Di, 26 Okt 2010) | 1 line

  Work a bit more on tkinter demos.
........
  r85845 | georg.brandl | 2010-10-26 12:42:16 +0200 (Di, 26 Okt 2010) | 1 line

  faqwiz is removed.
........
  r85849 | georg.brandl | 2010-10-26 21:31:06 +0200 (Di, 26 Okt 2010) | 1 line

  #10200: typo.
........
  r85850 | georg.brandl | 2010-10-26 21:58:11 +0200 (Di, 26 Okt 2010) | 1 line

  #10200: typo.
........
  r85851 | georg.brandl | 2010-10-26 22:12:37 +0200 (Di, 26 Okt 2010) | 1 line

  Fix import.
........
  r85855 | georg.brandl | 2010-10-27 09:21:54 +0200 (Mi, 27 Okt 2010) | 1 line

  Encoding fix.
........
  r85867 | georg.brandl | 2010-10-27 22:01:51 +0200 (Mi, 27 Okt 2010) | 1 line

  Add David.
........
  r85875 | georg.brandl | 2010-10-28 10:38:30 +0200 (Do, 28 Okt 2010) | 1 line

  Fix bytes/str issues in get-remote-certificate.py.
........
  r85907 | georg.brandl | 2010-10-29 06:54:13 +0200 (Fr, 29 Okt 2010) | 1 line

  #10222: fix for overzealous AIX compiler.
........
  r85908 | georg.brandl | 2010-10-29 07:22:17 +0200 (Fr, 29 Okt 2010) | 1 line

  send_bytes obviously needs bytes...
........
  r85911 | georg.brandl | 2010-10-29 07:36:28 +0200 (Fr, 29 Okt 2010) | 1 line

  Fix markup error and update false positive entries from "make suspicious".
........
  r85914 | georg.brandl | 2010-10-29 08:17:38 +0200 (Fr, 29 Okt 2010) | 1 line

  (?:...) is a non-capturing, but still grouping construct.
........
This commit is contained in:
Georg Brandl 2010-11-26 08:59:40 +00:00
parent d62ecbf0ba
commit f55aa80b37
34 changed files with 315 additions and 269 deletions

View file

@ -22,20 +22,10 @@ know!
# Imports
import math
import random
from tkinter import *
from Canvas import Rectangle, CanvasText, Group, Window
# Fix a bug in Canvas.Group as distributed in Python 1.4. The
# distributed bind() method is broken. Rather than asking you to fix
# the source, we fix it here by deriving a subclass:
class Group(Group):
def bind(self, sequence=None, command=None):
return self.canvas.tag_bind(self.id, sequence, command)
from canvasevents import Group
# Constants determining the size and lay-out of cards and stacks. We
@ -165,20 +155,22 @@ class Card:
self.face_shown = 0
self.x = self.y = 0
self.canvas = canvas
self.group = Group(canvas)
text = "%s %s" % (VALNAMES[value], suit)
self.__text = CanvasText(canvas, CARDWIDTH//2, 0,
anchor=N, fill=self.color, text=text)
self.__text = canvas.create_text(CARDWIDTH // 2, 0, anchor=N,
fill=self.color, text=text)
self.group.addtag_withtag(self.__text)
self.__rect = Rectangle(canvas, 0, 0, CARDWIDTH, CARDHEIGHT,
outline='black', fill='white')
self.__rect = canvas.create_rectangle(0, 0, CARDWIDTH, CARDHEIGHT,
outline='black', fill='white')
self.group.addtag_withtag(self.__rect)
self.__back = Rectangle(canvas, MARGIN, MARGIN,
CARDWIDTH-MARGIN, CARDHEIGHT-MARGIN,
outline='black', fill='blue')
self.__back = canvas.create_rectangle(MARGIN, MARGIN,
CARDWIDTH - MARGIN,
CARDHEIGHT - MARGIN,
outline='black', fill='blue')
self.group.addtag_withtag(self.__back)
def __repr__(self):
@ -202,15 +194,15 @@ class Card:
def showface(self):
"""Turn the card's face up."""
self.tkraise()
self.__rect.tkraise()
self.__text.tkraise()
self.canvas.tag_raise(self.__rect)
self.canvas.tag_raise(self.__text)
self.face_shown = 1
def showback(self):
"""Turn the card's face down."""
self.tkraise()
self.__rect.tkraise()
self.__back.tkraise()
self.canvas.tag_raise(self.__rect)
self.canvas.tag_raise(self.__back)
self.face_shown = 0
@ -400,10 +392,9 @@ class Deck(Stack):
"""
def makebottom(self):
bottom = Rectangle(self.game.canvas,
self.x, self.y,
self.x+CARDWIDTH, self.y+CARDHEIGHT,
outline='black', fill=BACKGROUND)
bottom = self.game.canvas.create_rectangle(self.x, self.y,
self.x + CARDWIDTH, self.y + CARDHEIGHT, outline='black',
fill=BACKGROUND)
self.group.addtag_withtag(bottom)
def fill(self):
@ -435,7 +426,7 @@ class Deck(Stack):
def randperm(n):
"""Function returning a random permutation of range(n)."""
r = range(n)
r = list(range(n))
x = []
while r:
i = random.choice(r)
@ -478,10 +469,8 @@ class OpenStack(Stack):
class SuitStack(OpenStack):
def makebottom(self):
bottom = Rectangle(self.game.canvas,
self.x, self.y,
self.x+CARDWIDTH, self.y+CARDHEIGHT,
outline='black', fill='')
bottom = self.game.canvas.create_rectangle(self.x, self.y,
self.x + CARDWIDTH, self.y + CARDHEIGHT, outline='black', fill='')
def userclickhandler(self):
pass
@ -540,8 +529,8 @@ class Solitaire:
background=BACKGROUND,
activebackground="green",
command=self.deal)
Window(self.canvas, MARGIN, 3*YSPACING + 20,
window=self.dealbutton, anchor=SW)
self.canvas.create_window(MARGIN, 3 * YSPACING + 20,
window=self.dealbutton, anchor=SW)
x = MARGIN
y = MARGIN