1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

+ added SELECT_GAME_MENU setting

* misc. improvements and bugs fixes


git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@131 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-12-27 22:16:00 +00:00
parent 0b258a674a
commit c3f3fe3638
14 changed files with 65 additions and 66 deletions

View file

@ -41,6 +41,7 @@ from cStringIO import StringIO
# PySol imports
from mfxutil import Pickler, Unpickler, UnpicklingError
from mfxutil import Image, ImageTk
from mfxutil import destruct, Struct, SubclassResponsibility
from mfxutil import uclock, usleep
from mfxutil import format_time
@ -1035,9 +1036,7 @@ class Game:
return False
if not stack.cards:
return False
try:
import ImageTk # use PIL
except ImportError:
if not Image:
return False
if self.moves.state == self.S_INIT:
# don't use flip animation for initial dealing
@ -1095,8 +1094,6 @@ class Game:
def doWinAnimation(self):
# based on code from pygtk-demo
import Image, ImageTk
FRAME_DELAY = 40
CYCLE_LEN = 60
images = self.win_animation.images
@ -1173,13 +1170,13 @@ class Game:
def winAnimation(self, perfect=0):
### if not self.app.opt.win_animation:
### return
if self.preview:
return
if not self.app.opt.animations:
return
if TOOLKIT == 'gtk':
return
try:
import Image
except ImportError:
if not Image:
return
self.canvas.hideAllItems()
# select some random cards
@ -1199,6 +1196,8 @@ class Game:
return
def redealAnimation(self):
if self.preview:
return
if not self.app.opt.animations or not self.app.opt.redeal_animation:
return
self.setCursor(cursor=CURSOR_WATCH)

View file

@ -50,7 +50,7 @@ def init():
locale_dir = d
##if locale_dir: locale_dir = os.path.normpath(locale_dir)
gettext.install('pysol', locale_dir, unicode=True)
# debug
if 'PYSOL_CHECK_GAMES' in os.environ or \
'PYSOL_DEBUG' in os.environ:
settings.CHECK_GAMES = True
@ -97,4 +97,8 @@ def init():
# "can't invoke event <<ThemeChanged>>: application has been destroyed"
#root.destroy()
Tkinter._default_root = None
#
if '--no-games-menu' in sys.argv:
sys.argv.remove('--no-games-menu')
settings.SELECT_GAME_MENU = False

View file

@ -47,6 +47,24 @@ try:
except:
thread = None
from settings import TOOLKIT
Image = ImageTk = ImageOps = None
if TOOLKIT == 'tk':
try: # PIL
import Image
except ImportError:
pass
else:
import ImageTk
import ImageOps
# for py2exe
import GifImagePlugin
import PngImagePlugin
import JpegImagePlugin
import BmpImagePlugin
import PpmImagePlugin
Image._initialized=2
if os.name == "mac":
# macfs module is deprecated, consider using Carbon.File or Carbon.Folder
import macfs, MACFS

View file

@ -66,6 +66,9 @@ if os.name == 'mac':
TOP_SIZE = 10
TOP_TITLE = n_('Top 10')
# use menu for select game
SELECT_GAME_MENU = True
# debug
DEBUG = 0 # must be integer
CHECK_GAMES = False # check duplicated names and classes

View file

@ -95,6 +95,7 @@ import types
# PySol imports
from mfxutil import Struct, kwdefault, SubclassResponsibility
from mfxutil import Image, ImageTk, ImageOps
from util import ACE, KING
from util import ANY_SUIT, ANY_COLOR, ANY_RANK, NO_RANK
from pysoltk import EVENT_HANDLED, EVENT_PROPAGATE
@ -1289,13 +1290,6 @@ class Stack:
xx0, yy0 = x0, y0
w, h = x1-x0, y1-y0
#
Image = None
if TOOLKIT == 'tk':
try:
import Image, ImageTk
except ImportError:
pass
##Image = None
if TOOLKIT == 'gtk' or not Image:
color = self.game.app.opt.colors['cards_1']
r = MfxCanvasRectangle(self.canvas, xx0, yy0, xx0+w, yy0+h,

View file

@ -46,6 +46,7 @@ from pysollib.mfxutil import destruct, Struct, kwdefault
from pysollib.util import CARDSET
from pysollib.settings import PACKAGE, WIN_SYSTEM
from pysollib.settings import TOP_TITLE
from pysollib.settings import SELECT_GAME_MENU
from pysollib.gamedb import GI
from pysollib.actions import PysolMenubarActions
@ -630,6 +631,8 @@ class PysolMenubar(PysolMenubarActions):
command=self.mSelectGameDialog)
menu.add_command(label=n_("Playable pre&view..."), accelerator="V",
command=self.mSelectGameDialogWithPreview)
if not SELECT_GAME_MENU:
return
menu.add_separator()
self._addSelectPopularGameSubMenu(games, menu, self.mSelectGame,
self.tkopt.gameid)

View file

@ -44,16 +44,9 @@ __all__ = ['MfxCanvasGroup',
import os, sys, types
import Tile as Tkinter
import Canvas
try:
# PIL (Python Image Library)
import Image
except ImportError:
Image = None
else:
import ImageTk
# for py2exe
import GifImagePlugin, PngImagePlugin, JpegImagePlugin, BmpImagePlugin, PpmImagePlugin
Image._initialized=2
# PySol imports
from pysollib.mfxutil import Image, ImageTk, ImageOps
# Toolkit imports
from tkutil import bind, unbind_destroy, loadImage

View file

@ -60,13 +60,9 @@ import sys, os, re
import traceback
import Tile as Tkinter
from tkFont import Font
try:
# PIL
import Image
import ImageTk
import ImageOps
except ImportError:
Image = None
# PySol imports
from pysollib.mfxutil import Image, ImageTk, ImageOps
# Toolkit imports
from tkconst import tkversion

View file

@ -38,14 +38,10 @@ __all__ = ['PysolToolbar'] #, 'TOOLBAR_BUTTONS']
# imports
import os
import Tile as Tkinter
try:
# PIL
import Image, ImageTk
except ImportError:
Image = None
# PySol imports
from pysollib.mfxutil import destruct
from pysollib.mfxutil import Image, ImageTk, ImageOps
from pysollib.util import IMAGE_EXTENSIONS
from pysollib.settings import PACKAGE
from pysollib.actions import PysolToolbarActions

View file

@ -38,13 +38,14 @@ __all__ = ['PysolMenubar']
# imports
import math, os, sys, re
import Tkinter, tkColorChooser, tkFileDialog
import Tkinter, tkFileDialog
# PySol imports
from pysollib.mfxutil import destruct, Struct, kwdefault
from pysollib.util import CARDSET
from pysollib.settings import PACKAGE, WIN_SYSTEM
from pysollib.settings import TOP_TITLE
from pysollib.settings import SELECT_GAME_MENU
from pysollib.gamedb import GI
from pysollib.actions import PysolMenubarActions
@ -626,6 +627,8 @@ class PysolMenubar(PysolMenubarActions):
command=self.mSelectGameDialog)
menu.add_command(label=n_("Playable pre&view..."), accelerator="V",
command=self.mSelectGameDialogWithPreview)
if not SELECT_GAME_MENU:
return
menu.add_separator()
self._addSelectPopularGameSubMenu(games, menu, self.mSelectGame,
self.tkopt.gameid)

View file

@ -43,16 +43,9 @@ __all__ = ['MfxCanvasGroup',
# imports
import os, sys, types
import Tkinter, Canvas
try:
# PIL (Python Image Library)
import Image
except ImportError:
Image = None
else:
import ImageTk
# for py2exe
import GifImagePlugin, PngImagePlugin, JpegImagePlugin, BmpImagePlugin, PpmImagePlugin
Image._initialized=2
# PySol imports
from pysollib.mfxutil import Image, ImageTk
# Toolkit imports
from tkutil import bind, unbind_destroy, loadImage

View file

@ -60,13 +60,9 @@ import sys, os, re
import traceback
import Tkinter
from tkFont import Font
try:
# PIL
import Image
import ImageTk
import ImageOps
except ImportError:
Image = None
# PySol imports
from pysollib.mfxutil import Image, ImageTk, ImageOps
# Toolkit imports
from tkconst import tkversion

View file

@ -38,14 +38,10 @@ __all__ = ['PysolToolbar'] #, 'TOOLBAR_BUTTONS']
# imports
import os, sys, types, Tkinter
import traceback
try:
# PIL
import Image, ImageTk
except ImportError:
Image = None
# PySol imports
from pysollib.mfxutil import destruct
from pysollib.mfxutil import Image, ImageTk
from pysollib.util import IMAGE_EXTENSIONS
from pysollib.settings import PACKAGE
from pysollib.actions import PysolToolbarActions

View file

@ -62,8 +62,16 @@ __all__ = ['SUITS',
# imports
import sys, os, re, time
try:
import Image, ImageTk, ImageOps
except ImportError:
Image = ImageTk = ImageOps = None
# PySol imports
from settings import DATA_DIRS
from mfxutil import Image
# /***********************************************************************
# // constants
@ -102,11 +110,8 @@ IMAGE_EXTENSIONS = (".gif", ".ppm",)
if 1 and os.name == "nt":
IMAGE_EXTENSIONS = (".png", ".gif", ".ppm", ".jpg",)
pass
try:
import Image
except ImportError:
pass
else:
if Image:
IMAGE_EXTENSIONS = (".png", ".gif", ".jpg", ".ppm", ".bmp")