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

* cleanup code

* bugfixes


git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@171 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2007-05-26 21:17:19 +00:00
parent b643693619
commit 8a2616449e
12 changed files with 27 additions and 98 deletions

View file

@ -297,17 +297,18 @@ class Options:
self.default_tile_theme = 'default'
elif WIN_SYSTEM == 'aqua':
self.tile_theme = self.default_tile_theme = 'aqua'
# cardsets
#
sw, sh, sd = 0, 0, 8
if top:
sw, sh, sd = (top.winfo_screenwidth(),
top.winfo_screenheight(),
top.winfo_screendepth())
# bg
if sd > 8:
self.tabletile_name = "Nostalgy.gif" # basename
else:
self.tabletile_name = None
#
# cardsets
c = "Standard"
if sw < 800 or sh < 600:
c = "2000"
@ -390,12 +391,15 @@ class Options:
# games_geometry
for key, val in self.games_geometry.items():
val = ' '.join(val)
val = ' '.join([str(i) for i in val])
config.set('games_geometry', str(key), val)
config.write(file(filename, 'w'))
#config.write(sys.stdout)
def printOptError(self, key):
pass
def _getOption(self, section, key, t):
config = self._config
try:
@ -410,6 +414,7 @@ class Options:
except ConfigParser.NoOptionError:
val = None
except:
print >> sys.stderr, 'Load option error:', key
traceback.print_exc()
val = None
return val
@ -1038,7 +1043,7 @@ class Application:
self.menubar.updateRecentGamesMenu(self.opt.recent_gameid)
self.menubar.updateFavoriteGamesMenu()
# hide/show "Shuffle" button
self.toolbar.config('shuffle', self.game.canShuffle())
##self.toolbar.config('shuffle', self.game.canShuffle() and self.opt.toolbar_vars['shuffle'])
# delete intro progress bar
if self.intro.progress:
self.intro.progress.destroy()
@ -1453,6 +1458,14 @@ Please select a %s type %s.
def loadOptions(self):
self.opt.setDefaults(self.top)
if os.path.exists(self.fn.opt):
# for backwards compatibility
opt = unpickle(self.fn.opt)
if opt:
self.opt.__dict__.update(opt.__dict__)
os.remove(self.fn.opt)
if not os.path.exists(self.fn.opt_cfg):
return
self.opt.load(self.fn.opt_cfg)

View file

@ -42,7 +42,7 @@ from settings import TOOLKIT
from mfxutil import Image, ImageTk
# Toolkit imports
from pysoltk import tkversion, loadImage, copyImage, createImage, shadowImage
from pysoltk import loadImage, copyImage, createImage, shadowImage
# /***********************************************************************
@ -408,10 +408,8 @@ class SubsampledImages(Images):
#
CW, CH = self.CARDW, self.CARDH
for im in images._shade:
if im is None or tkversion < (8, 3, 0, 0):
self._shade.append(None)
else:
self._shade.append(copyImage(im, 0, 0, CW, CH))
##self._shade.append(None)
self._shade.append(copyImage(im, 0, 0, CW, CH))
def getShadow(self, ncards):
return None

View file

@ -42,17 +42,12 @@ from gtk import ANCHOR_NW, ANCHOR_SW, ANCHOR_NE, ANCHOR_SE
# // constants
# ************************************************************************/
# (major version, minor version, micro version, patchlevel)
tkversion = (0, 0, 0, 0)
EVENT_HANDLED = 1
EVENT_PROPAGATE = 0
CURSOR_DRAG = gdk.HAND1
CURSOR_WATCH = gdk.WATCH
CURSOR_DOWN_ARROW = gdk.SB_DOWN_ARROW
CURSOR_CAN_MOVE = gdk.HAND2
CURSOR_NO_MOVE = gdk.DOT
TOOLBAR_BUTTONS = (
"new",

View file

@ -112,7 +112,7 @@ from mfxutil import Image, ImageTk
from util import ACE, KING
from util import ANY_SUIT, ANY_COLOR, ANY_RANK, NO_RANK
from pysoltk import EVENT_HANDLED, EVENT_PROPAGATE
from pysoltk import CURSOR_DRAG, CURSOR_DOWN_ARROW, CURSOR_CAN_MOVE, CURSOR_NO_MOVE
from pysoltk import CURSOR_DRAG, CURSOR_DOWN_ARROW
from pysoltk import ANCHOR_NW, ANCHOR_SE
from pysoltk import bind, unbind_destroy
from pysoltk import after, after_idle, after_cancel
@ -1089,8 +1089,6 @@ class Stack:
return self.__defaultClickEventHandler(event, self.shiftrightclickHandler)
def __motionEventHandler(self, event):
##if not self.game.drag.stack:
## self._setMotionCursor(event)
if not self.game.drag.stack or self is not self.game.drag.stack:
return EVENT_PROPAGATE
if self.game.demo:
@ -1436,20 +1434,6 @@ class Stack:
group=self.group)
drag.shadows.append(im)
## def _setMotionCursor(self, event):
## if not event:
## return
## self.cursor_changed = True
## i = self._findCard(event)
## if i < 0 or not self.canMoveCards(self.cards[i:]):
## if self.current_cursor != CURSOR_NO_MOVE:
## self.game.canvas.config(cursor=CURSOR_NO_MOVE)
## self.current_cursor = CURSOR_NO_MOVE
## else:
## if self.current_cursor != CURSOR_CAN_MOVE:
## self.game.canvas.config(cursor=CURSOR_CAN_MOVE)
## self.current_cursor = CURSOR_CAN_MOVE
def _stopDrag(self):
drag = self.game.drag
after_cancel(drag.timer)

View file

@ -41,7 +41,6 @@ __all__ = ['Card']
from pysollib.acard import AbstractCard
# Toolkit imports
from tkconst import TK_DASH_PATCH
from tkcanvas import MfxCanvasGroup, MfxCanvasImage
@ -190,18 +189,12 @@ class _TwoImageCard(_HideableCard):
def showFace(self, unhide=1):
if not self.face_up:
if TK_DASH_PATCH:
self.__back.config(state="hidden")
self.__face.config(state="normal")
self.__face.tkraise()
self.tkraise(unhide)
self.face_up = 1
def showBack(self, unhide=1):
if self.face_up:
if TK_DASH_PATCH:
self.__face.config(state="hidden")
self.__back.config(state="normal")
self.__back.tkraise()
self.tkraise(unhide)
self.face_up = 0

View file

@ -175,7 +175,7 @@ class SoundOptionsDialog(MfxDialog):
def mDone(self, button):
if button == 0 or button == 1:
self.app.opt.sound = self.sound.get()
self.app.opt.sound_mode = self.sound_mode.get()
self.app.opt.sound_mode = int(self.sound_mode.get())
self.app.opt.sound_sample_volume = self.sample_volume.get()
self.app.opt.sound_music_volume = self.music_volume.get()
for n, t, v in self.samples:

View file

@ -33,15 +33,11 @@
##
##---------------------------------------------------------------------------##
__all__ = ['tkversion',
'TK_DASH_PATCH',
'EVENT_HANDLED',
__all__ = ['EVENT_HANDLED',
'EVENT_PROPAGATE',
'CURSOR_DRAG',
'CURSOR_WATCH',
'CURSOR_DOWN_ARROW',
'CURSOR_CAN_MOVE',
'CURSOR_NO_MOVE',
'ANCHOR_CENTER',
'ANCHOR_N',
'ANCHOR_NW',
@ -64,30 +60,12 @@ import Tkinter
# // constants
# ************************************************************************/
# (major version, minor version, micro version, patchlevel)
tkversion = (8, 0, 0, 0)
try:
m = str(Tkinter._tkinter.TK_VERSION).split(".")
if m:
m = map(int, m) + 4*[0]
tkversion = tuple(m[:4])
del m
except:
traceback.print_exc()
pass
# experimental
TK_DASH_PATCH = 0
EVENT_HANDLED = "break"
EVENT_PROPAGATE = None
CURSOR_DRAG = "hand1"
CURSOR_WATCH = "watch"
CURSOR_DOWN_ARROW = 'sb_down_arrow'
CURSOR_CAN_MOVE = 'hand2'
CURSOR_NO_MOVE = 'dot'
ANCHOR_CENTER = Tkinter.CENTER
ANCHOR_N = Tkinter.N
@ -117,6 +95,7 @@ TOOLBAR_BUTTONS = (
"undo",
"redo",
"autodrop",
"shuffle",
"pause",
"statistics",
"rules",

View file

@ -65,9 +65,6 @@ from tkFont import Font
from pysollib.mfxutil import Image, ImageTk, ImageOps
from pysollib.settings import PACKAGE, WIN_SYSTEM
# Toolkit imports
from tkconst import tkversion
# /***********************************************************************
# // window manager util

View file

@ -41,7 +41,6 @@ __all__ = ['Card']
from pysollib.acard import AbstractCard
# Toolkit imports
from tkconst import TK_DASH_PATCH
from tkcanvas import MfxCanvasGroup, MfxCanvasImage
@ -190,18 +189,12 @@ class _TwoImageCard(_HideableCard):
def showFace(self, unhide=1):
if not self.face_up:
if TK_DASH_PATCH:
self.__back.config(state="hidden")
self.__face.config(state="normal")
self.__face.tkraise()
self.tkraise(unhide)
self.face_up = 1
def showBack(self, unhide=1):
if self.face_up:
if TK_DASH_PATCH:
self.__face.config(state="hidden")
self.__back.config(state="normal")
self.__back.tkraise()
self.tkraise(unhide)
self.face_up = 0

View file

@ -180,7 +180,7 @@ class SoundOptionsDialog(MfxDialog):
def mDone(self, button):
if button == 0 or button == 1:
self.app.opt.sound = self.sound.get()
self.app.opt.sound_mode = self.sound_mode.get()
self.app.opt.sound_mode = int(self.sound_mode.get())
self.app.opt.sound_sample_volume = self.sample_volume.get()
self.app.opt.sound_music_volume = self.music_volume.get()
for n, t, v in self.samples:

View file

@ -33,15 +33,11 @@
##
##---------------------------------------------------------------------------##
__all__ = ['tkversion',
'TK_DASH_PATCH',
'EVENT_HANDLED',
__all__ = ['EVENT_HANDLED',
'EVENT_PROPAGATE',
'CURSOR_DRAG',
'CURSOR_WATCH',
'CURSOR_DOWN_ARROW',
'CURSOR_CAN_MOVE',
'CURSOR_NO_MOVE',
'ANCHOR_CENTER',
'ANCHOR_N',
'ANCHOR_NW',
@ -63,29 +59,12 @@ import Tkinter
# // constants
# ************************************************************************/
# (major version, minor version, micro version, patchlevel)
tkversion = (8, 0, 0, 0)
try:
m = str(Tkinter._tkinter.TK_VERSION).split(".")
if m:
m = map(int, m) + 4*[0]
tkversion = tuple(m[:4])
del m
except:
pass
# experimental
TK_DASH_PATCH = 0
EVENT_HANDLED = "break"
EVENT_PROPAGATE = None
CURSOR_DRAG = "hand1"
CURSOR_WATCH = "watch"
CURSOR_DOWN_ARROW = 'sb_down_arrow'
CURSOR_CAN_MOVE = 'hand2'
CURSOR_NO_MOVE = 'dot'
ANCHOR_CENTER = Tkinter.CENTER
ANCHOR_N = Tkinter.N
@ -115,6 +94,7 @@ TOOLBAR_BUTTONS = (
"undo",
"redo",
"autodrop",
"shuffle",
"pause",
"statistics",
"rules",

View file

@ -65,9 +65,6 @@ from tkFont import Font
from pysollib.mfxutil import Image, ImageTk, ImageOps
from pysollib.settings import PACKAGE, WIN_SYSTEM
# Toolkit imports
from tkconst import tkversion
# /***********************************************************************
# // window manager util