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

* fixed scrolling in MfxScrolledCanvas

* added clickable url to About dialog
* many other improvements and bugfixes


git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@173 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2007-06-09 21:59:16 +00:00
parent 67bd2b8cd8
commit 9eaeadce61
72 changed files with 1780 additions and 1899 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

After

Width:  |  Height:  |  Size: 770 B

View file

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PySol 0.0.1\n"
"POT-Creation-Date: Sat May 19 16:39:10 2007\n"
"POT-Creation-Date: Tue Jun 5 04:28:06 2007\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PySol 0.0.1\n"
"POT-Creation-Date: Sat May 19 16:39:10 2007\n"
"POT-Creation-Date: Tue Jun 5 04:28:06 2007\n"
"PO-Revision-Date: 2007-05-11 17:25+0400\n"
"Last-Translator: Скоморох <skomoroh@gmail.com>\n"
"Language-Team: Russian <ru@li.org>\n"

File diff suppressed because it is too large Load diff

View file

@ -212,13 +212,13 @@ class PysolMenubarActions:
self.setMenuState(ms.undo, "edit.undo")
self.setMenuState(ms.redo, "edit.redo")
self.setMenuState(ms.redo, "edit.redoall")
self.setMenuState(ms.shuffle, "edit.shuffletiles")
self.updateBookmarkMenuState()
self.setMenuState(ms.restart, "edit.restart")
self.setMenuState(ms.custom_game, "edit.editcurrentgame")
# Game menu
self.setMenuState(ms.deal, "game.dealcards")
self.setMenuState(ms.autodrop, "game.autodrop")
self.setMenuState(ms.shuffle, "game.shuffletiles")
self.setMenuState(ms.pause, "game.pause")
# Assist menu
self.setMenuState(ms.hint, "assist.hint")

View file

@ -929,7 +929,7 @@ class Application:
self.helpbar = HelpStatusbar(self.top)
self.helpbar.show(self.opt.helpbar)
# create the canvas
self.scrolled_canvas = MfxScrolledCanvas(self.top)
self.scrolled_canvas = MfxScrolledCanvas(self.top, propagate=True)
self.canvas = self.scrolled_canvas.canvas
padx, pady = TkSettings.canvas_padding
self.scrolled_canvas.grid(row=1, column=1, sticky='nsew',
@ -1045,7 +1045,9 @@ class Application:
self.menubar.updateRecentGamesMenu(self.opt.recent_gameid)
self.menubar.updateFavoriteGamesMenu()
# hide/show "Shuffle" button
##self.toolbar.config('shuffle', self.game.canShuffle() and self.opt.toolbar_vars['shuffle'])
self.toolbar.config(
'shuffle',
self.opt.toolbar_vars['shuffle'] and self.game.canShuffle())
# delete intro progress bar
if self.intro.progress:
self.intro.progress.destroy()

View file

@ -25,7 +25,6 @@ from stack import *
from game import Game
from layout import Layout
from hint import AbstractHint, DefaultHint, CautiousDefaultHint, Yukon_Hint
#from pysoltk import MfxCanvasText
from wizardutil import WizardWidgets
@ -238,7 +237,7 @@ class CustomGame(Game):
def startGame(self):
min_cards = max(len(self.s.rows), 8)
s = get_settings(self.SETTINGS)
anim_frames = -1
def deal(rows, flip, frames, max_cards):
@ -253,14 +252,17 @@ class CustomGame(Game):
frames=frames)
return frames, max_cards
frames = 0
s = get_settings(self.SETTINGS)
if isinstance(self.s.talon, InitialDealTalonStack):
max_cards = 52 * s['decks']
else:
max_cards = s['deal_max_cards']
min_cards = max(len(self.s.rows), 8)
max_rows = s['deal_face_down'] + s['deal_face_up'] + s['deal_to_reserves']
if max_rows <= 1:
min_cards = max_cards
# deal to foundations
if s['deal_found']:
frames, max_cards = deal(self.s.foundations,

View file

@ -101,7 +101,8 @@ class StreetsAndAlleys(Game):
tx, ty, ta, tf = l.getTextAttr(None, "ss")
tx, ty = x+tx, y-l.YS+ty
font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font)
self.texts.info = MfxCanvasText(self.canvas, tx, ty,
anchor=ta, font=font)
for x in (x0, x2):
y = l.YM+l.YS*int(reserves!=0)
for i in range(4):

View file

@ -213,7 +213,8 @@ class Dover(Bristol):
tx, ty, ta, tf = l.getTextAttr(None, "ss")
tx, ty = x+tx+l.XM, y+ty
font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font)
self.texts.info = MfxCanvasText(self.canvas, tx, ty,
anchor=ta, font=font)
x, y = 2*l.XM+(max_rows-rows)*l.XS, l.YM+l.YS
if text:

View file

@ -145,7 +145,8 @@ class Canfield(Game):
tx, ty, ta, tf = l.getTextAttr(None, "ss")
tx, ty = x + tx, y + ty
font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font)
self.texts.info = MfxCanvasText(self.canvas, tx, ty,
anchor=ta, font=font)
x, y = l.XM, l.YM + l.YS + l.TEXT_HEIGHT
s.reserves.append(self.ReserveStack_Class(x, y, self))
s.reserves[0].CARD_YOFFSET = yoffset

View file

@ -526,14 +526,9 @@ class OceanTowers(TripleFreecell):
# // KingCell
# ************************************************************************/
class KingCell_RowStack(RK_RowStack):
def canMoveCards(self, cards):
max_move = getNumberOfFreeStacks(self.game.s.reserves) + 1
return len(cards) <= max_move and RK_RowStack.canMoveCards(self, cards)
class KingCell(FreeCell):
Solver_Class = FreeCellSolverWrapper(esf='kings')
RowStack_Class = StackWrapper(KingCell_RowStack, base_rank=KING)
Solver_Class = FreeCellSolverWrapper(sbb='rank', esf='kings')
RowStack_Class = StackWrapper(SuperMoveRK_RowStack, base_rank=KING)
shallHighlightMatch = Game._shallHighlightMatch_RK

View file

@ -122,7 +122,8 @@ class Glenwood(Game):
tx, ty, ta, tf = l.getTextAttr(None, "ss")
tx, ty = x - l.XS + tx, y + ty
font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font)
self.texts.info = MfxCanvasText(self.canvas, tx, ty,
anchor=ta, font=font)
for i in range(4):
x = 2*l.XM + (i+2)*l.XS

View file

@ -32,7 +32,6 @@ from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.pysoltk import MfxCanvasText
# /***********************************************************************

View file

@ -32,7 +32,6 @@ from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.pysoltk import MfxCanvasText
# /***********************************************************************

View file

@ -39,10 +39,10 @@ from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.settings import TOOLKIT, DEBUG
from pysollib.pysoltk import MfxCanvasText, MfxCanvasImage
from pysollib.pysoltk import bind, EVENT_HANDLED, ANCHOR_NW
from pysollib.pysoltk import MfxMessageDialog
from pysollib.settings import TOOLKIT, DEBUG
def factorial(x):

View file

@ -236,7 +236,8 @@ class DerFreieNapoleon(DerKleineNapoleon):
if texts:
tx, ty, ta, tf = l.getTextAttr(s.foundations[-1], "se")
font = self.app.getFont("canvas_default")
self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta, font=font)
self.texts.info = MfxCanvasText(self.canvas, tx, ty, anchor=ta,
font=font)
# talon
x, y = l.XM, self.height - l.YS
s.talon = InitialDealTalonStack(x, y, self)

View file

@ -42,7 +42,6 @@ from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.pysoltk import MfxCanvasText
from pysollib.mfxutil import kwdefault

View file

@ -30,7 +30,6 @@ from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.pysoltk import MfxCanvasText
# /***********************************************************************
# //

View file

@ -37,7 +37,7 @@ from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.pysoltk import MfxCanvasText, MfxCanvasImage, bind, ANCHOR_NW
from pysollib.pysoltk import MfxCanvasText
from golf import Golf_Waste, Golf_Hint

View file

@ -56,7 +56,6 @@ from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.pysoltk import MfxCanvasText
# /***********************************************************************

View file

@ -35,7 +35,6 @@ from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.pysoltk import MfxCanvasText
from pysollib.games.larasgame import LarasGame_Talon, LarasGame, LarasGame_Reserve

View file

@ -38,7 +38,7 @@ from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
from pysollib.hint import AbstractHint, DefaultHint, CautiousDefaultHint
from pysollib.pysoltk import MfxCanvasText, MfxCanvasImage, bind, ANCHOR_NW
from pysollib.pysoltk import bind
# /***********************************************************************

View file

@ -36,7 +36,6 @@ from pysollib.mfxutil import kwdefault
from pysollib.stack import *
from pysollib.game import Game
from pysollib.layout import Layout
#from pysollib.pysoltk import MfxCanvasText
from pysollib.games.special.tarock import AbstractTarockGame, Grasshopper
from pysollib.games.threepeaks import ThreePeaksNoScore

View file

@ -40,6 +40,7 @@
from settings import PACKAGE, PACKAGE_URL, TOOLKIT, FC_VERSION
from pysoltk import make_help_toplevel
from pysoltk import MfxMessageDialog
from pysoltk import PysolAboutDialog
from pysoltk import HTMLViewer
@ -47,12 +48,6 @@ from pysoltk import HTMLViewer
# //
# ************************************************************************/
class AboutDialog(MfxMessageDialog):
def createFrames(self, kw):
top_frame, bottom_frame = MfxMessageDialog.createFrames(self, kw)
return top_frame, bottom_frame
def help_about(app, timeout=0, sound=1):
if sound:
app.audio.playSample("about")
@ -62,25 +57,26 @@ def help_about(app, timeout=0, sound=1):
strings=(_("&Nice"), _("&Credits..."))
if timeout:
strings=(_("&Enjoy"),)
##version = _("Version %s (%s)\n\n") % (FC_VERSION, VERSION)
version = _("Version %s\n\n") % FC_VERSION
d = AboutDialog(app.top, title=_("About ") + PACKAGE, timeout=timeout,
text=_('''PySol Fan Club edition
version = _("Version %s") % FC_VERSION
d = PysolAboutDialog(app, app.top, title=_("About ") + PACKAGE,
timeout=timeout,
text=_('''PySol Fan Club edition
%s%s
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
Markus F.X.J. Oberhumer
Copyright (C) 2003 Mt. Hood Playing Card Co.
Copyright (C) 2005 Skomoroh (Fan Club edition)
Copyright (C) 2005 Skomoroh
All Rights Reserved.
PySol is free software distributed under the terms
of the GNU General Public License.
For more information about this application visit
%s''') % (t, version, PACKAGE_URL),
image=app.gimages.logos[2],
strings=strings, default=0,
separatorwidth=2)
For more information about this application visit''') % (t, version),
url=PACKAGE_URL,
image=app.gimages.logos[2],
strings=strings, default=0,
separatorwidth=2)
if d.status == 0 and d.button == 1:
help_credits(app, sound=sound)
return d.status

View file

@ -1,56 +0,0 @@
## vim:ts=4:et:nowrap
##
##---------------------------------------------------------------------------##
##
## PySol -- a Python Solitaire game
##
## Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
## Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
## Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.
## If not, write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
## Markus F.X.J. Oberhumer
## <markus.oberhumer@jk.uni-linz.ac.at>
## http://wildsau.idv.uni-linz.ac.at/mfx/pysol.html
##
##---------------------------------------------------------------------------##
# imports
import os, sys
from gtk import *
# PySol imports
from mfxutil import destruct, kwdefault, KwStruct, Struct
# Toolkit imports
from tkwidget import MfxDialog
# /***********************************************************************
# //
# ************************************************************************/
class DemoOptionsDialog(MfxDialog):
def __init__(self, parent, title, app, **kw):
pass
class HintOptionsDialog(MfxDialog):
def __init__(self, parent, title, app, **kw):
pass

View file

@ -57,6 +57,7 @@ TOOLBAR_BUTTONS = (
"undo",
"redo",
"autodrop",
"shuffle",
"pause",
"statistics",
"rules",

View file

@ -285,6 +285,7 @@ class HTMLViewer:
parent.set_default_size(600, 440)
parent.show_all()
gobject.idle_add(gtk.main)
def motion_notify_event(self, widget, event):

View file

@ -48,7 +48,7 @@ class StatsFormatter(PysolStatsFormatter):
for result in self.getStatResults(player, sort_by):
iter = self.store.append(None)
self.store.set(iter,
0, _(result[0]),
0, result[0],
1, result[1],
2, result[2],
3, result[3],

View file

@ -34,14 +34,14 @@
import os, sys
import gtk
from gtk import gdk
gdk = gtk.gdk
# PySol imports
# Toolkit imports
from tkutil import makeToplevel, setTransient, wm_withdraw
from pysollib.mfxutil import kwdefault, KwStruct
from pysollib.mfxutil import kwdefault, KwStruct, openURL
# /***********************************************************************
@ -78,7 +78,8 @@ class MfxDialog(_MyDialog):
bitmap=None, bitmap_side='left',
bitmap_padx=20, bitmap_pady=20,
image=None, image_side='left',
image_padx=10, image_pady=20):
image_padx=10, image_pady=20,
**kw):
_MyDialog.__init__(self)
self.status = 1
self.button = -1
@ -215,6 +216,55 @@ class MfxMessageDialog(MfxDialog):
return MfxDialog.initKw(self, kw)
# /***********************************************************************
# //
# ************************************************************************/
class PysolAboutDialog(MfxDialog):
def __init__(self, app, parent, title, **kw):
self._url = kw['url']
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, **kw)
top_box, bottom_box = self.createBox()
self.createBitmaps(top_box, kw)
box = gtk.VBox()
box.set_property('border-width', 20)
top_box.pack_start(box)
label = gtk.Label(kw['text'])
label.set_justify(gtk.JUSTIFY_CENTER)
box.pack_start(label)
url_label = gtk.Label()
url_label.set_justify(gtk.JUSTIFY_CENTER)
url_label.set_markup(
'<span foreground="blue" underline="single">%s</span>' % kw['url'])
event_box = gtk.EventBox()
box.pack_start(event_box)
event_box.connect('button-press-event', self._urlClicked)
event_box.add(url_label)
self.createButtons(bottom_box, kw)
self.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
##self.set_position(gtk.WIN_POS_CENTER)
self.show_all()
event_box.window.set_cursor(gdk.Cursor(gdk.HAND2))
gtk.main()
def initKw(self, kw):
#if kw.has_key('bitmap'):
# kwdefault(kw, width=250, height=150)
return MfxDialog.initKw(self, kw)
def _urlClicked(self, *args):
openURL(self._url)
# /***********************************************************************
# //
# ************************************************************************/
@ -234,19 +284,6 @@ class MfxExceptionDialog(MfxDialog):
MfxDialog.__init__(self, parent, title, **kw.__dict__)
# /***********************************************************************
# //
# ************************************************************************/
class MfxSimpleSlider(_MyDialog):
def __init__(self, parent, title,
label, value, from_, to, resolution,
resizable=0):
self.button = 0
self.status = 1
self.value = value
# /***********************************************************************
# //
# ************************************************************************/

View file

@ -73,18 +73,21 @@ class PysolStatsFormatter:
g = sort_func(player=player)
twon, tlost, tgames, ttime, tmoves = 0, 0, 0, 0, 0
for id in g:
name = app.getGameTitleName(id)
#won, lost = app.stats.getStats(player, id)
won, lost, time, moves = app.stats.getFullStats(player, id)
twon, tlost = twon + won, tlost + lost
ttime, tmoves = ttime+time, tmoves+moves
if won + lost > 0: perc = "%.1f" % (100.0 * won / (won + lost))
else: perc = "0.0"
if won > 0 or lost > 0 or id == app.game.id:
# yield only played games
name = app.getGameTitleName(id)
twon, tlost = twon + won, tlost + lost
ttime, tmoves = ttime+time, tmoves+moves
if won + lost > 0:
perc = "%.1f" % (100.0 * won / (won + lost))
else:
perc = "0.0"
t = format_time(time)
m = str(round(moves, 1))
yield [name, won+lost, won, lost, t, m, perc, id]
tgames = tgames + 1
tgames += 1
# summary
won, lost = twon, tlost
if won + lost > 0:
if won > 0:
@ -94,7 +97,8 @@ class PysolStatsFormatter:
time = format_time(0)
moves = 0
perc = "%.1f" % (100.0*won/(won+lost))
else: perc = "0.0"
else:
perc = "0.0"
self.total_games = len(g)
self.played_games = tgames
self.won_games = won

View file

@ -59,8 +59,8 @@ class EditTextDialog(MfxDialog):
#
self.text_w = Tkinter.Text(top_frame, bd=1, relief="sunken",
wrap="word", width=64, height=16)
self.text_w.pack(side='left', fill="both", expand=1)
###self.text_w.pack(side=Tkinter.TOP, padx=kw.padx, pady=kw.pady)
self.text_w.pack(side='left', fill="both", expand=True)
###self.text_w.pack(side='top', padx=kw.padx, pady=kw.pady)
vbar = Tkinter.Scrollbar(top_frame)
vbar.pack(side='right', fill='y')
self.text_w["yscrollcommand"] = vbar.set

View file

@ -139,6 +139,7 @@ class FindCardDialog(Tkinter.Toplevel):
def enterEvent(self, suit, rank, rect, group):
##print 'enterEvent', suit, rank, self.busy
if self.busy: return
if self.game.demo: return
self.busy = True
self.highlight_items = self.game.highlightCard(suit, rank)
if not self.highlight_items:

View file

@ -62,7 +62,6 @@ from selectcardset import SelectCardsetDialogWithPreview
from selecttile import SelectTileDialogWithPreview
from findcarddialog import connect_game_find_card_dialog, destroy_find_card_dialog
from solverdialog import connect_game_solver_dialog
from tkwrap import MfxRadioMenuItem, MfxCheckMenuItem, StringVar
from tkwidget import MfxMessageDialog
#from toolbar import TOOLBAR_BUTTONS
@ -74,16 +73,16 @@ from tkconst import TOOLBAR_BUTTONS
# ************************************************************************/
def createToolbarMenu(menubar, menu):
data_dir = os.path.join(menubar.app.dataloader.dir, 'images', 'toolbar')
tearoff = menu.cget('tearoff')
submenu = MfxMenu(menu, label=n_('Style'), tearoff=tearoff)
for f in os.listdir(data_dir):
d = os.path.join(data_dir, f)
if os.path.isdir(d) and os.path.exists(os.path.join(d, 'small')):
name = f.replace('_', ' ').capitalize()
submenu.add_radiobutton(label=name,
variable=menubar.tkopt.toolbar_style,
value=f, command=menubar.mOptToolbarStyle)
## data_dir = os.path.join(menubar.app.dataloader.dir, 'images', 'toolbar')
## submenu = MfxMenu(menu, label=n_('Style'), tearoff=tearoff)
## for f in os.listdir(data_dir):
## d = os.path.join(data_dir, f)
## if os.path.isdir(d) and os.path.exists(os.path.join(d, 'small')):
## name = f.replace('_', ' ').capitalize()
## submenu.add_radiobutton(label=name,
## variable=menubar.tkopt.toolbar_style,
## value=f, command=menubar.mOptToolbarStyle)
submenu = MfxMenu(menu, label=n_('Compound'), tearoff=tearoff)
for comp, label in COMPOUNDS:
submenu.add_radiobutton(
@ -105,15 +104,13 @@ def createToolbarMenu(menubar, menu):
menu.add_radiobutton(label=n_("Right"),
variable=menubar.tkopt.toolbar, value=4,
command=menubar.mOptToolbar)
menu.add_separator()
menu.add_radiobutton(label=n_("Small icons"),
variable=menubar.tkopt.toolbar_size, value=0,
command=menubar.mOptToolbarSize)
menu.add_radiobutton(label=n_("Large icons"),
variable=menubar.tkopt.toolbar_size, value=1,
command=menubar.mOptToolbarSize)
#
#return
## menu.add_separator()
## menu.add_radiobutton(label=n_("Small icons"),
## variable=menubar.tkopt.toolbar_size, value=0,
## command=menubar.mOptToolbarSize)
## menu.add_radiobutton(label=n_("Large icons"),
## variable=menubar.tkopt.toolbar_size, value=1,
## command=menubar.mOptToolbarSize)
menu.add_separator()
submenu = MfxMenu(menu, label=n_('Visible buttons'), tearoff=tearoff)
for w in TOOLBAR_BUTTONS:
@ -210,52 +207,52 @@ class PysolMenubar(PysolMenubarActions):
def _createTkOpt(self):
# structure to convert menu-options to Toolkit variables
self.tkopt = Struct(
gameid = MfxRadioMenuItem(self),
gameid_popular = MfxRadioMenuItem(self),
comment = MfxCheckMenuItem(self),
autofaceup = MfxCheckMenuItem(self),
autodrop = MfxCheckMenuItem(self),
autodeal = MfxCheckMenuItem(self),
quickplay = MfxCheckMenuItem(self),
undo = MfxCheckMenuItem(self),
bookmarks = MfxCheckMenuItem(self),
hint = MfxCheckMenuItem(self),
highlight_piles = MfxCheckMenuItem(self),
highlight_cards = MfxCheckMenuItem(self),
highlight_samerank = MfxCheckMenuItem(self),
highlight_not_matching = MfxCheckMenuItem(self),
mahjongg_show_removed = MfxCheckMenuItem(self),
shisen_show_hint = MfxCheckMenuItem(self),
sound = MfxCheckMenuItem(self),
cardback = MfxRadioMenuItem(self),
tabletile = MfxRadioMenuItem(self),
animations = MfxRadioMenuItem(self),
redeal_animation = MfxCheckMenuItem(self),
win_animation = MfxCheckMenuItem(self),
shadow = MfxCheckMenuItem(self),
shade = MfxCheckMenuItem(self),
shade_filled_stacks = MfxCheckMenuItem(self),
shrink_face_down = MfxCheckMenuItem(self),
toolbar = MfxRadioMenuItem(self),
toolbar_style = StringVar(),
toolbar_relief = StringVar(),
toolbar_compound = StringVar(),
toolbar_size = MfxRadioMenuItem(self),
statusbar = MfxCheckMenuItem(self),
num_cards = MfxCheckMenuItem(self),
helpbar = MfxCheckMenuItem(self),
save_games_geometry = MfxCheckMenuItem(self),
splashscreen = MfxCheckMenuItem(self),
demo_logo = MfxCheckMenuItem(self),
mouse_type = StringVar(),
mouse_undo = MfxCheckMenuItem(self),
negative_bottom = MfxCheckMenuItem(self),
pause = MfxCheckMenuItem(self),
theme = StringVar(),
gameid = Tkinter.IntVar(),
gameid_popular = Tkinter.IntVar(),
comment = Tkinter.BooleanVar(),
autofaceup = Tkinter.BooleanVar(),
autodrop = Tkinter.BooleanVar(),
autodeal = Tkinter.BooleanVar(),
quickplay = Tkinter.BooleanVar(),
undo = Tkinter.BooleanVar(),
bookmarks = Tkinter.BooleanVar(),
hint = Tkinter.BooleanVar(),
highlight_piles = Tkinter.BooleanVar(),
highlight_cards = Tkinter.BooleanVar(),
highlight_samerank = Tkinter.BooleanVar(),
highlight_not_matching = Tkinter.BooleanVar(),
mahjongg_show_removed = Tkinter.BooleanVar(),
shisen_show_hint = Tkinter.BooleanVar(),
sound = Tkinter.BooleanVar(),
cardback = Tkinter.IntVar(),
tabletile = Tkinter.IntVar(),
animations = Tkinter.IntVar(),
redeal_animation = Tkinter.BooleanVar(),
win_animation = Tkinter.BooleanVar(),
shadow = Tkinter.BooleanVar(),
shade = Tkinter.BooleanVar(),
shade_filled_stacks = Tkinter.BooleanVar(),
shrink_face_down = Tkinter.BooleanVar(),
toolbar = Tkinter.IntVar(),
toolbar_style = Tkinter.StringVar(),
toolbar_relief = Tkinter.StringVar(),
toolbar_compound = Tkinter.StringVar(),
toolbar_size = Tkinter.IntVar(),
statusbar = Tkinter.BooleanVar(),
num_cards = Tkinter.BooleanVar(),
helpbar = Tkinter.BooleanVar(),
save_games_geometry = Tkinter.BooleanVar(),
splashscreen = Tkinter.BooleanVar(),
demo_logo = Tkinter.BooleanVar(),
mouse_type = Tkinter.StringVar(),
mouse_undo = Tkinter.BooleanVar(),
negative_bottom = Tkinter.BooleanVar(),
pause = Tkinter.BooleanVar(),
theme = Tkinter.StringVar(),
toolbar_vars = {},
)
for w in TOOLBAR_BUTTONS:
self.tkopt.toolbar_vars[w] = MfxCheckMenuItem(self)
self.tkopt.toolbar_vars[w] = Tkinter.BooleanVar()
def _setOptions(self):
tkopt, opt = self.tkopt, self.app.opt
@ -300,7 +297,7 @@ class PysolMenubar(PysolMenubarActions):
tkopt.negative_bottom.set(opt.negative_bottom)
tkopt.theme.set(opt.tile_theme)
for w in TOOLBAR_BUTTONS:
tkopt.toolbar_vars[w].set(opt.toolbar_vars[w])
tkopt.toolbar_vars[w].set(opt.toolbar_vars.get(w, False))
def connectGame(self, game):
self.game = game
@ -386,7 +383,6 @@ class PysolMenubar(PysolMenubarActions):
menu.add_command(label=n_("&Undo"), command=self.mUndo, accelerator="Z")
menu.add_command(label=n_("&Redo"), command=self.mRedo, accelerator="R")
menu.add_command(label=n_("Redo &all"), command=self.mRedoAll)
menu.add_command(label=n_("Shu&ffle tiles"), command=self.mShuffle, accelerator="F")
menu.add_separator()
submenu = MfxMenu(menu, label=n_("&Set bookmark"))
@ -410,6 +406,7 @@ class PysolMenubar(PysolMenubarActions):
menu = MfxMenu(self.__menubar, label=n_("&Game"))
menu.add_command(label=n_("&Deal cards"), command=self.mDeal, accelerator="D")
menu.add_command(label=n_("&Auto drop"), command=self.mDrop, accelerator="A")
menu.add_command(label=n_("Shu&ffle tiles"), command=self.mShuffle, accelerator="F")
menu.add_checkbutton(label=n_("&Pause"), variable=self.tkopt.pause, command=self.mPause, accelerator="P")
#menu.add_command(label=n_("&Pause"), command=self.mPause, accelerator="P")
menu.add_separator()
@ -431,7 +428,7 @@ class PysolMenubar(PysolMenubarActions):
if USE_FREECELL_SOLVER:
menu.add_command(label=n_("&Solver (experimental)"), command=self.mSolver)
else:
menu.add_command(label=n_("&Solver (experimental)"), command=self.mSolver, state=Tkinter.DISABLED)
menu.add_command(label=n_("&Solver (experimental)"), command=self.mSolver, state='disabled')
menu.add_separator()
menu.add_command(label=n_("&Piles description"), command=self.mStackDesk, accelerator="F2")
@ -459,7 +456,7 @@ class PysolMenubar(PysolMenubarActions):
menu.add_separator()
label = n_("&Sound...")
if not self.app.audio.CAN_PLAY_SOUND:
menu.add_checkbutton(label=label, variable=self.tkopt.sound, command=self.mOptSoundDialog, state=Tkinter.DISABLED)
menu.add_checkbutton(label=label, variable=self.tkopt.sound, command=self.mOptSoundDialog, state='disabled')
else:
menu.add_checkbutton(label=label, variable=self.tkopt.sound, command=self.mOptSoundDialog)
# cardsets

View file

@ -68,7 +68,7 @@ class PlayerOptionsDialog(MfxDialog):
self.win_animation_var.set(app.opt.win_animation != 0)
#
frame = Tkinter.Frame(top_frame)
frame.pack(expand=1, fill='both', padx=5, pady=10)
frame.pack(expand=True, fill='both', padx=5, pady=10)
widget = Tkinter.Label(frame, text=_("\nPlease enter your name"),
takefocus=0)
widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
@ -87,7 +87,7 @@ class PlayerOptionsDialog(MfxDialog):
widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
### widget = Tkinter.Checkbutton(frame, variable=self.win_animation_var,
### text="Win animation")
### widget.pack(side=Tkinter.TOP, padx=kw.padx, pady=kw.pady)
### widget.pack(side='top', padx=kw.padx, pady=kw.pady)
frame.columnconfigure(0, weight=1)
#
self.player = self.player_var.get()

View file

@ -66,12 +66,12 @@ class PysolProgressBar:
if images:
self.f1 = Tkinter.Label(self.frame, image=images[0])
self.f1.pack(side='left', ipadx=8, ipady=4)
self.progress.pack(side='left', expand='yes', fill='x')
self.progress.pack(side='left', expand=True, fill='x')
self.f2 = Tkinter.Label(self.frame, image=images[1])
self.f2.pack(side='left', ipadx=8, ipady=4)
else:
self.progress.pack(expand='yes', fill='x')
self.frame.pack(expand='yes', fill='both')
self.progress.pack(expand=True, fill='x')
self.frame.pack(expand=True, fill='both')
if 1:
setTransient(self.top, None, relx=0.5, rely=0.5)
else:

View file

@ -201,7 +201,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
else:
w1, w2 = 200, 300
paned_window = Tkinter.PanedWindow(top_frame)
paned_window.pack(expand=1, fill='both')
paned_window.pack(expand=True, fill='both')
left_frame = Tkinter.Frame(paned_window)
right_frame = Tkinter.Frame(paned_window)
paned_window.add(left_frame)
@ -210,10 +210,10 @@ class SelectCardsetDialogWithPreview(MfxDialog):
self.tree = self.Tree_Class(self, left_frame, key=key,
default=kw.default,
font=font, width=w1)
self.tree.frame.pack(fill='both', expand=1, padx=padx, pady=pady)
self.tree.frame.pack(fill='both', expand=True, padx=padx, pady=pady)
self.preview = MfxScrolledCanvas(right_frame, width=w2)
self.preview.setTile(app, app.tabletile_index, force=True)
self.preview.pack(fill='both', expand=1, padx=padx, pady=pady)
self.preview.pack(fill='both', expand=True, padx=padx, pady=pady)
self.preview.canvas.preview = 1
# create a preview of the current state
self.preview_key = -1
@ -283,11 +283,12 @@ class SelectCardsetDialogWithPreview(MfxDialog):
x, y = 10, y + dy
else:
x = x + dx
canvas.config(scrollregion=(0, 0, sx+dx, sy+dy))
canvas.config(width=sx+dx, height=sy+dy)
## canvas.config(scrollregion=(0, 0, sx+dx, sy+dy))
## canvas.config(width=sx+dx, height=sy+dy)
canvas.config(scrollregion=(0, 0, sx+dx, sy+dy),
width=sx+dx, height=sy+dy)
#canvas.config(xscrollincrement=dx, yscrollincrement=dy)
## self.preview.showHbar()
## self.preview.showVbar()
canvas.event_generate('<Configure>') # update bg image
self.preview_key = key

View file

@ -288,9 +288,8 @@ class SelectGameDialog(MfxDialog):
self.top.wm_minsize(200, 200)
font = app.getFont("default")
self.tree = self.Tree_Class(self, top_frame, key=gameid,
font=font,
default=kw.default)
self.tree.frame.pack(fill=Tkinter.BOTH, expand=1,
font=font, default=kw.default)
self.tree.frame.pack(fill='both', expand=True,
padx=kw.padx, pady=kw.pady)
#
focus = self.createButtons(bottom_frame, kw)
@ -363,7 +362,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
padx, pady = 4, 4
# PanedWindow
paned_window = Tkinter.PanedWindow(top_frame)
paned_window.pack(expand=1, fill='both', padx=8, pady=8)
paned_window.pack(expand=True, fill='both', padx=8, pady=8)
left_frame = Tkinter.Frame(paned_window)
right_frame = Tkinter.Frame(paned_window)
paned_window.add(left_frame)
@ -372,7 +371,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
font = app.getFont("default")
self.tree = self.Tree_Class(self, left_frame, key=gameid,
default=kw.default, font=font, width=w1)
self.tree.frame.pack(padx=padx, pady=pady, expand=1, fill='both')
self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')
# LabelFrame
info_frame = Tkinter.LabelFrame(right_frame, text=_('About game'))
info_frame.grid(row=0, column=0, padx=padx, pady=pady,

View file

@ -134,11 +134,10 @@ class SelectTileDialogWithPreview(MfxDialog):
font = app.getFont("default")
self.tree = self.Tree_Class(self, top_frame, key=key,
default=kw.default,
font=font,
width=w1)
self.tree.frame.pack(side="left", fill=Tkinter.BOTH, expand=0, padx=kw.padx, pady=kw.pady)
font=font, width=w1)
self.tree.frame.pack(side="left", fill='both', expand=False, padx=kw.padx, pady=kw.pady)
self.preview = MfxScrolledCanvas(top_frame, width=w2, hbar=0, vbar=0)
self.preview.pack(side="right", fill=Tkinter.BOTH, expand=1,
self.preview.pack(side="right", fill='both', expand=True,
padx=kw.padx, pady=kw.pady)
self.preview.canvas.preview = 1
# create a preview of the current state
@ -173,15 +172,19 @@ class SelectTileDialogWithPreview(MfxDialog):
self.key = self.tree.selection_key
self.tree.n_expansions = 1 # save xyview in any case
if button == 10: # "Solid color..."
c = tkColorChooser.askcolor(master=self.top,
initialcolor=self.table_color,
title=_("Select table color"))
if c and c[1]:
color = str(c[1])
self.key = color.lower()
self.table_color = self.key
self.tree.updateSelection(self.key)
self.updatePreview(self.key)
try:
c = tkColorChooser.askcolor(master=self.top,
initialcolor=self.table_color,
title=_("Select table color"))
except Tkinter.TclError:
pass
else:
if c and c[1]:
color = str(c[1])
self.key = color.lower()
self.table_color = self.key
self.tree.updateSelection(self.key)
self.updatePreview(self.key)
return
MfxDialog.mDone(self, button)

View file

@ -39,7 +39,7 @@ from pysollib.settings import PACKAGE
# Toolkit imports
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
from tkwidget import MfxDialog
from tkwidget import PysolScale
from tkwidget import PysolScale, PysolCombo
from tkutil import bind, unbind_destroy
@ -85,10 +85,10 @@ class SolverDialog(MfxDialog):
self.games[name] = id
gamenames.sort()
self.gamenames = gamenames
cb = Tkinter.Combobox(frame, values=tuple(gamenames),
state='readonly', width=40)
cb = PysolCombo(frame, values=tuple(gamenames),
selectcommand=self.gameSelected,
state='readonly', width=40)
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
bind(cb, '<<ComboboxSelected>>', self.gameSelected)
self.games_var = cb
#
@ -103,7 +103,7 @@ class SolverDialog(MfxDialog):
'A randomized DFS',
##'"Soft" DFS'
]
cb = Tkinter.Combobox(frame, values=tuple(sm), state='readonly')
cb = PysolCombo(frame, values=tuple(sm), state='readonly')
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
cb.current(sm.index('Depth-First Search'))
self.solving_method_var = cb
@ -125,7 +125,7 @@ class SolverDialog(MfxDialog):
'yellow-brick-road',
]
self.presets = presets
cb = Tkinter.Combobox(frame, values=tuple(presets), state='readonly')
cb = PysolCombo(frame, values=tuple(presets), state='readonly')
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
cb.current(0)
self.preset_var = cb
@ -191,14 +191,11 @@ class SolverDialog(MfxDialog):
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout, transient=False)
self.start_button = self.buttons[0]
self.play_button = self.buttons[1]
#
self._reset()
self.connectGame(self.app.game)
self.mainloop(focus, kw.timeout, transient=False)
def initKw(self, kw):
strings=[_('&Start'), _('&Play'), _('&New'), 'sep', _('&Close'),]
@ -256,6 +253,8 @@ class SolverDialog(MfxDialog):
self.play_button.config(state='disabled')
def startSolving(self):
from gettext import ungettext
self._reset()
game = self.app.game
solver = game.Solver_Class(game, self) # create solver instance
@ -271,7 +270,10 @@ class SolverDialog(MfxDialog):
solver.computeHints()
hints_len = len(solver.hints)-1
if hints_len > 0:
self.result_label['text'] = _('This game is solveable in %s moves.') % hints_len
t = ungettext('This game is solveable in %d move.',
'This game is solveable in %d moves.',
hints_len) % hints_len
self.result_label['text'] = t
self.play_button.config(state='normal')
else:
self.result_label['text'] = _('I could not solve this game.')
@ -279,9 +281,13 @@ class SolverDialog(MfxDialog):
def startPlay(self):
self.play_button.config(state='disabled')
self.start_button.focus()
if self.app.game.pause:
self.app.menubar.mPause()
self.app.top.tkraise()
self.app.top.update_idletasks()
self.app.top.update()
self.app.top.after(200)
self.app.game.startDemo(level=3)
def setText(self, **kw):

View file

@ -143,7 +143,7 @@ class SoundOptionsDialog(MfxDialog):
kw.strings[1] = None
#
frame = Tkinter.LabelFrame(top_frame, text=_('Enable samples'))
frame.pack(expand=1, fill='both', padx=5, pady=5)
frame.pack(expand=True, fill='both', padx=5, pady=5)
frame.columnconfigure(0, weight=1)
frame.columnconfigure(1, weight=1)
#

View file

@ -75,9 +75,8 @@ class MfxStatusbar:
self.frame.pack(side='left', expand=True, fill='both', padx=0, pady=1)
# util
def _createLabel(self, name, side='left',
fill='none', expand=0, width=0,
tooltip=None):
def _createLabel(self, name, side='left', fill='none',
expand=False, width=0, tooltip=None):
frame = Tkinter.Frame(self.frame, borderwidth=1, relief=self.label_relief)
frame.pack(side=side, fill=fill, padx=self.padx, expand=expand)
label = Tkinter.Label(frame, width=width)
@ -154,7 +153,7 @@ class PysolStatusbar(MfxStatusbar):
):
self._createLabel(n, tooltip=t, width=w)
#
l = self._createLabel("info", fill='both', expand=1)
l = self._createLabel("info", fill='both', expand=True)
##l.config(text="", justify="left", anchor='w')
l.config(padding=(8, 0))
self._createSizegrip()
@ -163,14 +162,14 @@ class PysolStatusbar(MfxStatusbar):
class HelpStatusbar(MfxStatusbar):
def __init__(self, top):
MfxStatusbar.__init__(self, top, row=3, column=0, columnspan=3)
l = self._createLabel("info", fill='both', expand=1)
l = self._createLabel("info", fill='both', expand=True)
l.config(justify="left", anchor='w', padding=(8, 0))
class HtmlStatusbar(MfxStatusbar):
def __init__(self, top, row, column, columnspan):
MfxStatusbar.__init__(self, top, row=row, column=column, columnspan=columnspan)
l = self._createLabel("url", fill='both', expand=1)
l = self._createLabel("url", fill='both', expand=True)
l.config(justify="left", anchor='w', padding=(8, 0))
self._createSizegrip()

View file

@ -142,10 +142,10 @@ class MfxCanvas(Tkinter.Canvas):
#
self.xmargin, self.ymargin = 10, 10
# resize bg image
self.bind('<Configure>', lambda e: self.set_bg_image())
self.bind('<Configure>', self.setBackgroundImage)
def set_bg_image(self):
##print 'set_bg_image', self._bg_img
def setBackgroundImage(self, event=None):
##print 'setBackgroundImage', self._bg_img
if not hasattr(self, '_bg_img'):
return
if not self._bg_img: # solid color
@ -306,7 +306,7 @@ class MfxCanvas(Tkinter.Canvas):
except:
return 0
self._stretch_bg_image = stretch
self.set_bg_image()
self.setBackgroundImage()
else:
for id in self.__tiles:
self.delete(id)

View file

@ -247,8 +247,9 @@ class HTMLViewer:
##self.defcursor = 'xterm'
self.handcursor = "hand2"
frame = Tkinter.Frame(parent)
frame = Tkinter.Frame(parent, width=640, height=440)
frame.pack(expand=True, fill='both')
frame.grid_propagate(False)
# create buttons
button_width = 8
@ -274,13 +275,13 @@ class HTMLViewer:
text_frame.grid(row=1, column=0, columnspan=4,
sticky='nsew', padx=1, pady=1)
vbar = Tkinter.Scrollbar(text_frame)
vbar.pack(side=Tkinter.RIGHT, fill=Tkinter.Y)
vbar.pack(side='right', fill='y')
self.text = Tkinter.Text(text_frame,
fg='black', bg='white',
bd=1, relief='sunken',
cursor=self.defcursor,
wrap='word', padx=10)
self.text.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
self.text.pack(side='left', fill='both', expand=True)
self.text["yscrollcommand"] = vbar.set
vbar["command"] = self.text.yview

View file

@ -374,7 +374,6 @@ class TreeFormatter(PysolStatsFormatter):
for result in self.getStatResults(player, sort_by):
# result == [name, won+lost, won, lost, time, moves, perc, id]
t1, t2, t3, t4, t5, t6, t7, t8 = result
t1 = _(t1) # game name
id = self.tree.insert(None, "end", text=t1,
values=(t2, t3, t4, t5, t6, t7))
self.parent_window.tree_items.append(id)
@ -486,7 +485,6 @@ class AllGamesFrame(Tkinter.Frame):
def fillTreeview(self, player):
if self.tree_items:
#return
self.tree.delete(tuple(self.tree_items))
self.tree_items = []
self.formatter.writeStats(player, sort_by=self.sort_by)
@ -667,7 +665,7 @@ class _TopDialog(MfxDialog):
'padding': (4, 1),
}
frame = Tkinter.Frame(**cnf)
frame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH, padx=10, pady=10)
frame.pack(expand=True, fill='both', padx=10, pady=10)
frame.columnconfigure(0, weight=1)
cnf['master'] = frame
cnf['text'] = _('N')

View file

@ -258,7 +258,7 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
bind(self.canvas, "<ButtonPress-1>", self.singleClick)
bind(self.canvas, "<Double-Button-1>", self.doubleClick)
##bind(self.canvas, "<ButtonRelease-1>", xxx)
self.pack(fill=Tkinter.BOTH, expand=1)
self.pack(fill='both', expand=True)
def destroy(self):
for node in self.keys.get(self.selection_key, []):
@ -266,7 +266,7 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
MfxScrolledCanvas.destroy(self)
def findNode(self, event=None):
id = self.canvas.find_withtag(Tkinter.CURRENT)
id = self.canvas.find_withtag('current')
if id:
return self.nodes.get(id[0])
return None

View file

@ -37,6 +37,7 @@ __all__ = ['MfxDialog',
'MfxMessageDialog',
'MfxExceptionDialog',
'MfxSimpleEntry',
'PysolAboutDialog',
'MfxTooltip',
'MfxScrolledCanvas',
'StackDesc',
@ -46,10 +47,11 @@ __all__ = ['MfxDialog',
import os, sys, time, locale
import Tkinter as Tk
import Tile as Tkinter
import tkFont
import traceback
# PySol imports
from pysollib.mfxutil import destruct, kwdefault, KwStruct
from pysollib.mfxutil import destruct, kwdefault, KwStruct, openURL
from pysollib.settings import WIN_SYSTEM
# Toolkit imports
@ -167,7 +169,7 @@ class MfxDialog: # ex. _ToplevelDialog
def createFrames(self, kw):
bottom_frame = Tkinter.Frame(self._frame, relief='flat', borderwidth=4)
bottom_frame.pack(side='bottom', fill='both', expand=0)
bottom_frame.pack(side='bottom', fill='both', expand=False)
if kw.separatorwidth > 0:
separator = Tkinter.Separator(self._frame)
separator.pack(side='bottom', fill='x')
@ -275,7 +277,7 @@ class MfxMessageDialog(MfxDialog):
self.button = kw.default
msg = Tkinter.Label(top_frame, text=kw.text, justify=kw.justify,
width=kw.width)
msg.pack(fill=Tkinter.BOTH, expand=1, padx=kw.padx, pady=kw.pady)
msg.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
@ -300,6 +302,39 @@ class MfxExceptionDialog(MfxMessageDialog):
MfxMessageDialog.__init__(self, parent, title, **kw.getKw())
# /***********************************************************************
# //
# ************************************************************************/
class PysolAboutDialog(MfxMessageDialog):
def __init__(self, app, parent, title, **kw):
self._url = kw['url']
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
#
self.button = kw.default
frame = Tkinter.Frame(top_frame)
frame.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
msg = Tkinter.Label(frame, text=kw.text, justify=kw.justify,
width=kw.width)
msg.pack(fill='both', expand=True)
font = tkFont.Font(parent, app.getFont('default'))
font.configure(underline=True)
url_label = Tkinter.Label(frame, text=kw.url, font=font,
foreground='blue', cursor='hand2')
url_label.pack()
url_label.bind('<1>', self._urlClicked)
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
def _urlClicked(self, event):
openURL(self._url)
# /***********************************************************************
# //
# ************************************************************************/
@ -318,7 +353,7 @@ class MfxSimpleEntry(MfxDialog):
w = kw.get("e_width", 0) # width in characters
self.var = Tkinter.Entry(top_frame, exportselection=1, width=w)
self.var.insert(0, value)
self.var.pack(side=Tkinter.TOP, padx=kw.padx, pady=kw.pady)
self.var.pack(side='top', padx=kw.padx, pady=kw.pady)
#
focus = self.createButtons(bottom_frame, kw)
focus = self.var
@ -408,7 +443,7 @@ class MfxTooltip:
if self.tooltip or not self.text:
return
## if isinstance(self.widget, (Tkinter.Button, Tkinter.Checkbutton)):
## if self.widget["state"] == Tkinter.DISABLED:
## if self.widget["state"] == 'disabled':
## return
import Tkinter # not Tile
##x = self.widget.winfo_rootx()
@ -435,30 +470,24 @@ class MfxTooltip:
# ************************************************************************/
class MfxScrolledCanvas:
def __init__(self, parent, hbar=2, vbar=2, **kw):
def __init__(self, parent, hbar=True, vbar=True, propagate=0, **kw):
kwdefault(kw, highlightthickness=0, bd=1, relief='sunken')
self.parent = parent
self.createFrame(kw)
self.canvas = None
self.hbar = None
self.hbar_mode = hbar
self.vbar = None
self.vbar_mode = vbar
self.hbar_show = 0
self.vbar_show = 0
self.resize_pending = 0
self.timer = None
self.hbar_show = False
self.vbar_show = False
self.createCanvas(kw)
self.frame.grid_rowconfigure(0, weight=1)
self.frame.grid_columnconfigure(0, weight=1)
self.frame.grid_propagate(propagate)
if hbar:
self.createHbar()
if not vbar:
bind(self.hbar, "<Map>", self._mapBar)
self.bindHbar()
if vbar:
self.createVbar()
bind(self.vbar, "<Map>", self._mapBar)
self.bindVbar()
###self.canvas.focus_set()
@ -467,8 +496,6 @@ class MfxScrolledCanvas:
#
def destroy(self):
after_cancel(self.timer)
self.timer = None
self.unbind_all()
self.canvas.destroy()
self.frame.destroy()
@ -534,14 +561,18 @@ class MfxScrolledCanvas:
self.canvas = MfxCanvas(self.frame, **kw)
self.canvas.grid(row=0, column=0, sticky="news")
def createHbar(self):
self.hbar = Tkinter.Scrollbar(self.frame, name="hbar",
takefocus=0, orient="horizontal")
self.hbar = Tkinter.Scrollbar(self.frame, takefocus=0,
orient="horizontal")
self.canvas["xscrollcommand"] = self._setHbar
self.hbar["command"] = self.canvas.xview
self.hbar.grid(row=1, column=0, sticky="we")
self.hbar.grid_remove()
def createVbar(self):
self.vbar = Tkinter.Scrollbar(self.frame, name="vbar", takefocus=0)
self.vbar = Tkinter.Scrollbar(self.frame, takefocus=0)
self.canvas["yscrollcommand"] = self._setVbar
self.vbar["command"] = self.canvas.yview
self.vbar.grid(row=0, column=1, sticky="ns")
self.vbar.grid_remove()
def bindHbar(self, w=None):
if w is None:
w = self.canvas
@ -567,66 +598,30 @@ class MfxScrolledCanvas:
def mouse_wheel(self, *args):
print 'MfxScrolledCanvas.mouse_wheel', args
def _mapBar(self, event):
# see: autoscroll.tcl, http://mini.net/cgi-bin/wikit/950.html
top = event.widget.winfo_toplevel()
g = top.wm_geometry()
if self.resize_pending:
self.resize_pending = 0
self.canvas.update()
self.canvas.update_idletasks()
top.wm_geometry(g)
def _setHbar(self, *args):
self.canvas.update()
self.hbar.set(*self.canvas.xview())
self.showHbar()
##self.hbar.update_idletasks()
def _setVbar(self, *args):
self.canvas.update()
self.vbar.set(*self.canvas.yview())
self.showVbar()
##self.vbar.update_idletasks()
def showHbar(self, show=-1):
if not self.hbar:
return 0
if show < 0:
show = self.hbar_mode
if show > 1:
if not self.canvas.winfo_ismapped():
return 0
##self.canvas.update()
view = self.canvas.xview()
show = abs(view[0]) > 0.0001 or abs(view[1] - 1.0) > 0.0001
if show == self.hbar_show:
return 0
if show:
self.hbar.grid(row=1, column=0, sticky="we")
def _setHbar(self, first, last):
sb = self.hbar
if not self.canvas.winfo_ismapped():
sb.set(first, last)
return
if float(first) <= 0 and float(last) >= 1:
sb.grid_remove()
self.hbar_show = False
else:
self.hbar.grid_forget()
self.hbar_show = show
return 1
def showVbar(self, show=-1):
if not self.vbar:
return 0
if show < 0:
show = self.vbar_mode
if show > 1:
if not self.canvas.winfo_ismapped():
return 0
##self.canvas.update()
view = self.canvas.yview()
show = abs(view[0]) > 0.0001 or abs(view[1] - 1.0) > 0.0001
if show == self.vbar_show:
return 0
if show:
self.vbar.grid(row=0, column=1, sticky="ns")
sb.grid()
self.hbar_show = True
sb.set(first, last)
def _setVbar(self, first, last):
sb = self.vbar
if not self.canvas.winfo_ismapped():
sb.set(first, last)
return
if float(first) <= 0and float(last) >= 1:
sb.grid_remove()
self.vbar_show = False
else:
self.vbar.grid_forget()
self.vbar_show = show
return 1
sb.grid()
self.vbar_show = True
sb.set(first, last)
def _xview(self, *args):
if self.hbar_show: self.canvas.xview(*args)
@ -805,3 +800,30 @@ class TkinterScale(Tk.Scale):
PysolScale = MyPysolScale
#PysolScale = TkinterScale
# /***********************************************************************
# // Tile.Combobox workaround (clear selection)
# ************************************************************************/
class PysolCombo(Tkinter.Combobox):
def __init__(self, master=None, **kw):
self._command = None
if 'selectcommand' in kw:
self._command = kw['selectcommand']
del kw['selectcommand']
Tkinter.Combobox.__init__(self, master, **kw)
self.bind('<<ComboboxSelected>>', self._callback)
def _callback(self, *args):
##self.selection_clear()
self.selection_range(0,0)
if self._command is not None:
return self._command(*args)
return None

View file

@ -34,9 +34,6 @@
##---------------------------------------------------------------------------##
__all__ = ['TclError',
'MfxCheckMenuItem',
'MfxRadioMenuItem',
'StringVar',
'MfxRoot']
# imports
@ -52,31 +49,6 @@ from pysollib.macosx.appSupport import setupApp
from tkutil import after_idle
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
# /***********************************************************************
# // menubar
# ************************************************************************/
class MfxCheckMenuItem(Tkinter.BooleanVar):
def __init__(self, menubar, path=None):
Tkinter.BooleanVar.__init__(self)
def set(self, value):
if not value or value == "false": value = 0
##print value, type(value)
Tkinter.BooleanVar.set(self, value)
class MfxRadioMenuItem(Tkinter.IntVar):
def __init__(self, menubar, path=None):
Tkinter.IntVar.__init__(self)
def set(self, value):
Tkinter.IntVar.set(self, value)
## BooleanVar = Tkinter.BooleanVar
## IntVar = Tkinter.IntVar
StringVar = Tkinter.StringVar
# /***********************************************************************
# // Wrapper class for Tk.

View file

@ -164,8 +164,7 @@ class ToolbarLabel(Tkinter.Message):
class PysolToolbar(PysolToolbarActions):
def __init__(self, top, dir, size=0, relief=Tkinter.FLAT,
compound=Tkinter.NONE):
def __init__(self, top, dir, size=0, relief='flat', compound='none'):
PysolToolbarActions.__init__(self)
@ -364,7 +363,7 @@ class PysolToolbar(PysolToolbarActions):
padx, pady = TkSettings.vertical_toolbar_padding
pack_func(row=1, column=2, sticky='ns', padx=padx, pady=pady)
# set orient
orient = side in (1, 2) and Tkinter.HORIZONTAL or Tkinter.VERTICAL
orient = side in (1, 2) and 'horizontal' or 'vertical'
self._setOrient(orient)
self.side = side
return 1
@ -467,6 +466,6 @@ class PysolToolbar(PysolToolbarActions):
if self.compound == 'text':
return 0
size = self.size
comp = int(self.compound in (Tkinter.TOP, Tkinter.BOTTOM))
comp = int(self.compound in ('top', 'bottom'))
return int((size+comp) != 0)

View file

@ -32,7 +32,7 @@ from pysollib.wizardpresets import presets
# Toolkit imports
from tkwidget import MfxDialog
from tkwidget import PysolScale
from tkwidget import PysolScale, PysolCombo
# /***********************************************************************
@ -71,12 +71,13 @@ class WizardDialog(MfxDialog):
values.remove(default)
values.sort()
values.insert(0, default)
cb = Combobox(frame, values=tuple(values),
textvariable=w.variable,
state='readonly', width=32)
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
callback = lambda e, w=w: self.presetSelected(e, w)
cb.bind('<<ComboboxSelected>>', callback)
cb = PysolCombo(frame, values=tuple(values),
textvariable=w.variable,
exportselection=False,
selectcommand=callback,
state='readonly', width=32)
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
elif w.widget == 'entry':
if w.variable is None:
w.variable = StringVar()
@ -86,9 +87,10 @@ class WizardDialog(MfxDialog):
if w.variable is None:
w.variable = StringVar()
values = [_(v) for v in w.values]
cb = Combobox(frame, values=tuple(values),
textvariable=w.variable,
state='readonly', width=32)
cb = PysolCombo(frame, values=tuple(values),
textvariable=w.variable,
exportselection=False,
state='readonly', width=32)
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
elif w.widget == 'spin':
if w.variable is None:

View file

@ -58,8 +58,8 @@ class EditTextDialog(MfxDialog):
#
self.text_w = Tkinter.Text(top_frame, bd=1, relief="sunken",
wrap="word", width=64, height=16)
self.text_w.pack(side='left', fill="both", expand=1)
###self.text_w.pack(side=Tkinter.TOP, padx=kw.padx, pady=kw.pady)
self.text_w.pack(side='left', fill="both", expand=True)
###self.text_w.pack(side='top', padx=kw.padx, pady=kw.pady)
vbar = Tkinter.Scrollbar(top_frame)
vbar.pack(side='right', fill='y')
self.text_w["yscrollcommand"] = vbar.set

View file

@ -139,6 +139,7 @@ class FindCardDialog(Tkinter.Toplevel):
def enterEvent(self, suit, rank, rect, group):
##print 'enterEvent', suit, rank, self.busy
if self.busy: return
if self.game.demo: return
self.busy = True
self.highlight_items = self.game.highlightCard(suit, rank)
if not self.highlight_items:

View file

@ -61,9 +61,7 @@ from selectcardset import SelectCardsetDialogWithPreview
from selecttile import SelectTileDialogWithPreview
from findcarddialog import connect_game_find_card_dialog, destroy_find_card_dialog
from solverdialog import connect_game_solver_dialog
from tkwrap import MfxRadioMenuItem, MfxCheckMenuItem, StringVar
#from toolbar import TOOLBAR_BUTTONS
from tkconst import TOOLBAR_BUTTONS
@ -72,16 +70,16 @@ from tkconst import TOOLBAR_BUTTONS
# ************************************************************************/
def createToolbarMenu(menubar, menu):
data_dir = os.path.join(menubar.app.dataloader.dir, 'images', 'toolbar')
tearoff = menu.cget('tearoff')
submenu = MfxMenu(menu, label=n_('Style'), tearoff=tearoff)
for f in os.listdir(data_dir):
d = os.path.join(data_dir, f)
if os.path.isdir(d) and os.path.exists(os.path.join(d, 'small')):
name = f.replace('_', ' ').capitalize()
submenu.add_radiobutton(label=name,
variable=menubar.tkopt.toolbar_style,
value=f, command=menubar.mOptToolbarStyle)
## data_dir = os.path.join(menubar.app.dataloader.dir, 'images', 'toolbar')
## submenu = MfxMenu(menu, label=n_('Style'), tearoff=tearoff)
## for f in os.listdir(data_dir):
## d = os.path.join(data_dir, f)
## if os.path.isdir(d) and os.path.exists(os.path.join(d, 'small')):
## name = f.replace('_', ' ').capitalize()
## submenu.add_radiobutton(label=name,
## variable=menubar.tkopt.toolbar_style,
## value=f, command=menubar.mOptToolbarStyle)
if Tkinter.TkVersion >= 8.4:
submenu = MfxMenu(menu, label=n_('Compound'), tearoff=tearoff)
for comp, label in COMPOUNDS:
@ -104,15 +102,13 @@ def createToolbarMenu(menubar, menu):
menu.add_radiobutton(label=n_("Right"),
variable=menubar.tkopt.toolbar, value=4,
command=menubar.mOptToolbar)
menu.add_separator()
menu.add_radiobutton(label=n_("Small icons"),
variable=menubar.tkopt.toolbar_size, value=0,
command=menubar.mOptToolbarSize)
menu.add_radiobutton(label=n_("Large icons"),
variable=menubar.tkopt.toolbar_size, value=1,
command=menubar.mOptToolbarSize)
#
#return
## menu.add_separator()
## menu.add_radiobutton(label=n_("Small icons"),
## variable=menubar.tkopt.toolbar_size, value=0,
## command=menubar.mOptToolbarSize)
## menu.add_radiobutton(label=n_("Large icons"),
## variable=menubar.tkopt.toolbar_size, value=1,
## command=menubar.mOptToolbarSize)
menu.add_separator()
submenu = MfxMenu(menu, label=n_('Visible buttons'), tearoff=tearoff)
for w in TOOLBAR_BUTTONS:
@ -209,51 +205,51 @@ class PysolMenubar(PysolMenubarActions):
def _createTkOpt(self):
# structure to convert menu-options to Toolkit variables
self.tkopt = Struct(
gameid = MfxRadioMenuItem(self),
gameid_popular = MfxRadioMenuItem(self),
comment = MfxCheckMenuItem(self),
autofaceup = MfxCheckMenuItem(self),
autodrop = MfxCheckMenuItem(self),
autodeal = MfxCheckMenuItem(self),
quickplay = MfxCheckMenuItem(self),
undo = MfxCheckMenuItem(self),
bookmarks = MfxCheckMenuItem(self),
hint = MfxCheckMenuItem(self),
highlight_piles = MfxCheckMenuItem(self),
highlight_cards = MfxCheckMenuItem(self),
highlight_samerank = MfxCheckMenuItem(self),
highlight_not_matching = MfxCheckMenuItem(self),
mahjongg_show_removed = MfxCheckMenuItem(self),
shisen_show_hint = MfxCheckMenuItem(self),
sound = MfxCheckMenuItem(self),
cardback = MfxRadioMenuItem(self),
tabletile = MfxRadioMenuItem(self),
animations = MfxRadioMenuItem(self),
redeal_animation = MfxCheckMenuItem(self),
win_animation = MfxCheckMenuItem(self),
shadow = MfxCheckMenuItem(self),
shade = MfxCheckMenuItem(self),
shade_filled_stacks = MfxCheckMenuItem(self),
shrink_face_down = MfxCheckMenuItem(self),
toolbar = MfxRadioMenuItem(self),
toolbar_style = StringVar(),
toolbar_relief = StringVar(),
toolbar_compound = StringVar(),
toolbar_size = MfxRadioMenuItem(self),
statusbar = MfxCheckMenuItem(self),
num_cards = MfxCheckMenuItem(self),
helpbar = MfxCheckMenuItem(self),
save_games_geometry = MfxCheckMenuItem(self),
splashscreen = MfxCheckMenuItem(self),
demo_logo = MfxCheckMenuItem(self),
mouse_type = StringVar(),
mouse_undo = MfxCheckMenuItem(self),
negative_bottom = MfxCheckMenuItem(self),
pause = MfxCheckMenuItem(self),
gameid = Tkinter.IntVar(),
gameid_popular = Tkinter.IntVar(),
comment = Tkinter.BooleanVar(),
autofaceup = Tkinter.BooleanVar(),
autodrop = Tkinter.BooleanVar(),
autodeal = Tkinter.BooleanVar(),
quickplay = Tkinter.BooleanVar(),
undo = Tkinter.BooleanVar(),
bookmarks = Tkinter.BooleanVar(),
hint = Tkinter.BooleanVar(),
highlight_piles = Tkinter.BooleanVar(),
highlight_cards = Tkinter.BooleanVar(),
highlight_samerank = Tkinter.BooleanVar(),
highlight_not_matching = Tkinter.BooleanVar(),
mahjongg_show_removed = Tkinter.BooleanVar(),
shisen_show_hint = Tkinter.BooleanVar(),
sound = Tkinter.BooleanVar(),
cardback = Tkinter.IntVar(),
tabletile = Tkinter.IntVar(),
animations = Tkinter.IntVar(),
redeal_animation = Tkinter.BooleanVar(),
win_animation = Tkinter.BooleanVar(),
shadow = Tkinter.BooleanVar(),
shade = Tkinter.BooleanVar(),
shade_filled_stacks = Tkinter.BooleanVar(),
shrink_face_down = Tkinter.BooleanVar(),
toolbar = Tkinter.IntVar(),
toolbar_style = Tkinter.StringVar(),
toolbar_relief = Tkinter.StringVar(),
toolbar_compound = Tkinter.StringVar(),
toolbar_size = Tkinter.IntVar(),
statusbar = Tkinter.BooleanVar(),
num_cards = Tkinter.BooleanVar(),
helpbar = Tkinter.BooleanVar(),
save_games_geometry = Tkinter.BooleanVar(),
splashscreen = Tkinter.BooleanVar(),
demo_logo = Tkinter.BooleanVar(),
mouse_type = Tkinter.StringVar(),
mouse_undo = Tkinter.BooleanVar(),
negative_bottom = Tkinter.BooleanVar(),
pause = Tkinter.BooleanVar(),
toolbar_vars = {},
)
for w in TOOLBAR_BUTTONS:
self.tkopt.toolbar_vars[w] = MfxCheckMenuItem(self)
self.tkopt.toolbar_vars[w] = Tkinter.BooleanVar()
def _setOptions(self):
tkopt, opt = self.tkopt, self.app.opt
@ -297,7 +293,7 @@ class PysolMenubar(PysolMenubarActions):
tkopt.mouse_undo.set(opt.mouse_undo)
tkopt.negative_bottom.set(opt.negative_bottom)
for w in TOOLBAR_BUTTONS:
tkopt.toolbar_vars[w].set(opt.toolbar_vars[w])
tkopt.toolbar_vars[w].set(opt.toolbar_vars.get(w, False))
def connectGame(self, game):
self.game = game
@ -383,7 +379,6 @@ class PysolMenubar(PysolMenubarActions):
menu.add_command(label=n_("&Undo"), command=self.mUndo, accelerator="Z")
menu.add_command(label=n_("&Redo"), command=self.mRedo, accelerator="R")
menu.add_command(label=n_("Redo &all"), command=self.mRedoAll)
menu.add_command(label=n_("Shu&ffle tiles"), command=self.mShuffle, accelerator="F")
menu.add_separator()
submenu = MfxMenu(menu, label=n_("&Set bookmark"))
@ -407,6 +402,7 @@ class PysolMenubar(PysolMenubarActions):
menu = MfxMenu(self.__menubar, label=n_("&Game"))
menu.add_command(label=n_("&Deal cards"), command=self.mDeal, accelerator="D")
menu.add_command(label=n_("&Auto drop"), command=self.mDrop, accelerator="A")
menu.add_command(label=n_("Shu&ffle tiles"), command=self.mShuffle, accelerator="F")
menu.add_checkbutton(label=n_("&Pause"), variable=self.tkopt.pause, command=self.mPause, accelerator="P")
#menu.add_command(label=n_("&Pause"), command=self.mPause, accelerator="P")
menu.add_separator()
@ -436,7 +432,7 @@ class PysolMenubar(PysolMenubarActions):
if USE_FREECELL_SOLVER:
menu.add_command(label=n_("&Solver (experimental)"), command=self.mSolver)
else:
menu.add_command(label=n_("&Solver (experimental)"), command=self.mSolver, state=Tkinter.DISABLED)
menu.add_command(label=n_("&Solver (experimental)"), command=self.mSolver, state='disabled')
menu.add_separator()
menu.add_command(label=n_("&Piles description"), command=self.mStackDesk, accelerator="F2")
@ -464,7 +460,7 @@ class PysolMenubar(PysolMenubarActions):
menu.add_separator()
label = n_("&Sound...")
if not self.app.audio.CAN_PLAY_SOUND:
menu.add_checkbutton(label=label, variable=self.tkopt.sound, command=self.mOptSoundDialog, state=Tkinter.DISABLED)
menu.add_checkbutton(label=label, variable=self.tkopt.sound, command=self.mOptSoundDialog, state='disabled')
else:
menu.add_checkbutton(label=label, variable=self.tkopt.sound, command=self.mOptSoundDialog)
# cardsets

View file

@ -59,7 +59,7 @@ class SelectUserNameDialog(MfxDialog):
self.createBitmaps(top_frame, kw)
#
listbox = Tkinter.Listbox(top_frame)
listbox.pack(side='left', fill='both', expand=1)
listbox.pack(side='left', fill='both', expand=True)
scrollbar = Tkinter.Scrollbar(top_frame)
scrollbar.pack(side='right', fill='y')
listbox.configure(yscrollcommand=scrollbar.set)
@ -108,7 +108,7 @@ class PlayerOptionsDialog(MfxDialog):
self.win_animation_var.set(app.opt.win_animation != 0)
#
frame = Tkinter.Frame(top_frame)
frame.pack(expand=1, fill='both', padx=5, pady=10)
frame.pack(expand=True, fill='both', padx=5, pady=10)
widget = Tkinter.Label(frame, text=_("\nPlease enter your name"),
#justify='left', anchor='w',
takefocus=0)
@ -129,7 +129,7 @@ class PlayerOptionsDialog(MfxDialog):
widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
### widget = Tkinter.Checkbutton(frame, variable=self.win_animation_var,
### text="Win animation")
### widget.pack(side=Tkinter.TOP, padx=kw.padx, pady=kw.pady)
### widget.pack(side='top', padx=kw.padx, pady=kw.pady)
frame.columnconfigure(0, weight=1)
#
self.player = self.player_var.get()

View file

@ -56,9 +56,9 @@ class PysolProgressBar:
self.top.wm_protocol("WM_DELETE_WINDOW", self.wmDeleteWindow)
self.top.wm_group(parent)
self.top.wm_resizable(0, 0)
self.frame = Tkinter.Frame(self.top, relief=Tkinter.FLAT, bd=0,
self.frame = Tkinter.Frame(self.top, relief='flat', bd=0,
takefocus=0)
self.cframe = Tkinter.Frame(self.frame, relief=Tkinter.SUNKEN, bd=1,
self.cframe = Tkinter.Frame(self.frame, relief='sunken', bd=1,
takefocus=0)
self.canvas = Tkinter.Canvas(self.cframe, width=width, height=height,
takefocus=0, bd=0, highlightthickness=0)
@ -95,7 +95,7 @@ class PysolProgressBar:
self.top = None
def pack(self, **kw):
self.canvas.pack(fill=Tkinter.X, expand=0)
self.canvas.pack(fill=Tkinter.X, expand=False)
self.frame.pack(**kw)
def reset(self, percent=0):

View file

@ -201,7 +201,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
w1, w2 = 200, 300
if Tkinter.TkVersion >= 8.4:
paned_window = Tkinter.PanedWindow(top_frame)
paned_window.pack(expand=1, fill='both')
paned_window.pack(expand=True, fill='both')
left_frame = Tkinter.Frame(paned_window)
right_frame = Tkinter.Frame(paned_window)
paned_window.add(left_frame)
@ -209,16 +209,16 @@ class SelectCardsetDialogWithPreview(MfxDialog):
else:
left_frame = Tkinter.Frame(top_frame)
right_frame = Tkinter.Frame(top_frame)
left_frame.pack(side='left', expand=0, fill='both')
right_frame.pack(side='right', expand=1, fill='both')
left_frame.pack(side='left', expand=False, fill='both')
right_frame.pack(side='right', expand=True, fill='both')
font = app.getFont("default")
self.tree = self.Tree_Class(self, left_frame, key=key,
default=kw.default,
font=font, width=w1)
self.tree.frame.pack(fill='both', expand=1, padx=padx, pady=pady)
self.tree.frame.pack(fill='both', expand=True, padx=padx, pady=pady)
self.preview = MfxScrolledCanvas(right_frame, width=w2)
self.preview.setTile(app, app.tabletile_index, force=True)
self.preview.pack(fill='both', expand=1, padx=padx, pady=pady)
self.preview.pack(fill='both', expand=True, padx=padx, pady=pady)
self.preview.canvas.preview = 1
# create a preview of the current state
self.preview_key = -1
@ -289,11 +289,10 @@ class SelectCardsetDialogWithPreview(MfxDialog):
x, y = 10, y + dy
else:
x = x + dx
canvas.config(scrollregion=(0, 0, sx+dx, sy+dy))
canvas.config(width=sx+dx, height=sy+dy)
canvas.config(scrollregion=(0, 0, sx+dx, sy+dy),
width=sx+dx, height=sy+dy)
canvas.event_generate('<Configure>') # update bg image
#canvas.config(xscrollincrement=dx, yscrollincrement=dy)
## self.preview.showHbar()
## self.preview.showVbar()
self.preview_key = key

View file

@ -289,9 +289,8 @@ class SelectGameDialog(MfxDialog):
self.top.wm_minsize(200, 200)
font = app.getFont("default")
self.tree = self.Tree_Class(self, top_frame, key=gameid,
font=font,
default=kw.default)
self.tree.frame.pack(fill=Tkinter.BOTH, expand=1,
font=font, default=kw.default)
self.tree.frame.pack(fill='both', expand=True,
padx=kw.padx, pady=kw.pady)
#
focus = self.createButtons(bottom_frame, kw)
@ -366,7 +365,7 @@ class SelectGameDialogWithPreview(SelectGameDialog):
# PanedWindow
if Tkinter.TkVersion >= 8.4:
paned_window = Tkinter.PanedWindow(top_frame)
paned_window.pack(expand=1, fill='both')
paned_window.pack(expand=True, fill='both')
left_frame = Tkinter.Frame(paned_window)
right_frame = Tkinter.Frame(paned_window)
paned_window.add(left_frame)
@ -374,13 +373,13 @@ class SelectGameDialogWithPreview(SelectGameDialog):
else:
left_frame = Tkinter.Frame(top_frame)
right_frame = Tkinter.Frame(top_frame)
left_frame.pack(side='left', expand=1, fill='both')
right_frame.pack(side='right', expand=1, fill='both')
left_frame.pack(side='left', expand=True, fill='both')
right_frame.pack(side='right', expand=True, fill='both')
# Tree
font = app.getFont("default")
self.tree = self.Tree_Class(self, left_frame, key=gameid,
default=kw.default, font=font, width=w1)
self.tree.frame.pack(padx=padx, pady=pady, expand=1, fill='both')
self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')
# LabelFrame
if Tkinter.TkVersion >= 8.4:
info_frame = Tkinter.LabelFrame(right_frame, text=_('About game'))

View file

@ -133,11 +133,11 @@ class SelectTileDialogWithPreview(MfxDialog):
font = app.getFont("default")
self.tree = self.Tree_Class(self, top_frame, key=key,
default=kw.default,
font=font,
width=w1)
self.tree.frame.pack(side="left", fill=Tkinter.BOTH, expand=0, padx=kw.padx, pady=kw.pady)
font=font, width=w1)
self.tree.frame.pack(side="left", fill='both', expand=False,
padx=kw.padx, pady=kw.pady)
self.preview = MfxScrolledCanvas(top_frame, width=w2, hbar=0, vbar=0)
self.preview.pack(side="right", fill=Tkinter.BOTH, expand=1,
self.preview.pack(side="right", fill='both', expand=True,
padx=kw.padx, pady=kw.pady)
self.preview.canvas.preview = 1
# create a preview of the current state
@ -173,15 +173,19 @@ class SelectTileDialogWithPreview(MfxDialog):
self.key = self.tree.selection_key
self.tree.n_expansions = 1 # save xyview in any case
if button == 1: # "Solid color..."
c = tkColorChooser.askcolor(master=self.top,
initialcolor=self.table_color,
title=_("Select table color"))
if c and c[1]:
color = str(c[1])
self.key = color.lower()
self.table_color = self.key
self.tree.updateSelection(self.key)
self.updatePreview(self.key)
try:
c = tkColorChooser.askcolor(master=self.top,
initialcolor=self.table_color,
title=_("Select table color"))
except Tkinter.TclError:
pass
else:
if c and c[1]:
color = str(c[1])
self.key = color.lower()
self.table_color = self.key
self.tree.updateSelection(self.key)
self.updatePreview(self.key)
return
MfxDialog.mDone(self, button)

View file

@ -194,14 +194,11 @@ class SolverDialog(MfxDialog):
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout, transient=False)
self.start_button = self.buttons[0]
self.play_button = self.buttons[1]
#
self._reset()
self.connectGame(self.app.game)
self.mainloop(focus, kw.timeout, transient=False)
def initKw(self, kw):
strings=[_('&Start'), _('&Play'), _('&New'), _('&Close'),]
@ -259,6 +256,8 @@ class SolverDialog(MfxDialog):
self.play_button.config(state='disabled')
def startSolving(self):
from gettext import ungettext
self._reset()
game = self.app.game
solver = game.Solver_Class(game, self) # create solver instance
@ -274,7 +273,10 @@ class SolverDialog(MfxDialog):
solver.computeHints()
hints_len = len(solver.hints)-1
if hints_len > 0:
self.result_label['text'] = _('This game is solveable in %s moves.') % hints_len
t = ungettext('This game is solveable in %d move.',
'This game is solveable in %d moves.',
hints_len) % hints_len
self.result_label['text'] = t
self.play_button.config(state='normal')
else:
self.result_label['text'] = _('I could not solve this game.')
@ -282,9 +284,13 @@ class SolverDialog(MfxDialog):
def startPlay(self):
self.play_button.config(state='disabled')
self.start_button.focus()
if self.app.game.pause:
self.app.menubar.mPause()
self.app.top.tkraise()
self.app.top.update_idletasks()
self.app.top.update()
self.app.top.after(200)
self.app.game.startDemo(level=3)
def setText(self, **kw):

View file

@ -145,7 +145,7 @@ class SoundOptionsDialog(MfxDialog):
padx=5, pady=5)
else:
frame = Tkinter.Frame(top_frame, bd=2, relief='groove')
frame.pack(expand=1, fill='both', padx=5, pady=5)
frame.pack(expand=True, fill='both', padx=5, pady=5)
frame.columnconfigure(0, weight=1)
frame.columnconfigure(1, weight=1)
#

View file

@ -82,9 +82,8 @@ class MfxStatusbar:
self.padx = 0
# util
def _createLabel(self, name, side='left',
fill='none', expand=0, width=0,
tooltip=None):
def _createLabel(self, name, side='left', fill='none',
expand=False, width=0, tooltip=None):
if 0:
frame = Tkinter.Frame(self.frame, bd=1, relief=self.label_relief,
highlightbackground='#9e9a9e',
@ -163,7 +162,7 @@ class PysolStatusbar(MfxStatusbar):
):
self._createLabel(n, tooltip=t, width=w)
#
l = self._createLabel("info", fill='both', expand=1)
l = self._createLabel("info", fill='both', expand=True)
##l.config(text="", justify="left", anchor='w')
l.config(padx=8)
@ -171,14 +170,14 @@ class PysolStatusbar(MfxStatusbar):
class HelpStatusbar(MfxStatusbar):
def __init__(self, top):
MfxStatusbar.__init__(self, top, row=4, column=0, columnspan=3)
l = self._createLabel("info", fill='both', expand=1)
l = self._createLabel("info", fill='both', expand=True)
l.config(justify="left", anchor='w', padx=8)
class HtmlStatusbar(MfxStatusbar):
def __init__(self, top, row, column, columnspan):
MfxStatusbar.__init__(self, top, row=row, column=column, columnspan=columnspan)
l = self._createLabel("url", fill='both', expand=1)
l = self._createLabel("url", fill='both', expand=True)
l.config(justify="left", anchor='w', padx=8)

View file

@ -19,7 +19,7 @@ class PageTab(Frame):
"""
def __init__(self,parent):
Frame.__init__(self, parent, borderwidth=2, relief=MYRIDGE)
self.button=Radiobutton(self, padx=5, pady=5, takefocus=FALSE,
self.button=Radiobutton(self, padx=5, pady=5, takefocus=0,
indicatoron=FALSE, highlightthickness=0,
borderwidth=0, selectcolor=self.cget('bg'))
self.button.pack()

View file

@ -141,10 +141,10 @@ class MfxCanvas(Tkinter.Canvas):
#
self.xmargin, self.ymargin = 10, 10
# resize bg image
self.bind('<Configure>', lambda e: self.set_bg_image())
self.bind('<Configure>', self.setBackgroundImage)
def set_bg_image(self):
##print 'set_bg_image', self._bg_img
def setBackgroundImage(self, event=None):
##print 'setBackgroundImage', self._bg_img
if not hasattr(self, '_bg_img'):
return
if not self._bg_img: # solid color
@ -305,7 +305,7 @@ class MfxCanvas(Tkinter.Canvas):
except:
return 0
self._stretch_bg_image = stretch
self.set_bg_image()
self.setBackgroundImage()
else:
for id in self.__tiles:
self.delete(id)

View file

@ -269,14 +269,15 @@ class HTMLViewer:
# create text widget
text_frame = Tkinter.Frame(parent)
text_frame.grid(row=1, column=0, columnspan=4, sticky='nsew')
text_frame.grid_propagate(False)
vbar = Tkinter.Scrollbar(text_frame)
vbar.pack(side=Tkinter.RIGHT, fill=Tkinter.Y)
vbar.pack(side='right', fill='y')
self.text = Tkinter.Text(text_frame,
fg='black', bg='white',
bd=1, relief='sunken',
cursor=self.defcursor,
wrap='word', padx=10)
self.text.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
self.text.pack(side='left', fill='both', expand=True)
self.text["yscrollcommand"] = vbar.set
vbar["command"] = self.text.yview

View file

@ -143,7 +143,7 @@ class SingleGame_StatsDialog(MfxDialog):
def _createChartInit(self, text):
w, h = self.tab_x[-1]+20, self.tab_y[-1]+20
c = Tkinter.Canvas(self.top_frame, width=w, height=h)
c.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=0, padx=20, pady=10)
c.pack(side='top', fill='both', expand=False, padx=20, pady=10)
self.canvas = c
##self.fg = c.cget("insertbackground")
self.fg = c.option_get('foreground', '') or c.cget("insertbackground")
@ -411,7 +411,6 @@ class CanvasFormatter(PysolStatsFormatter):
y += 2*self.h
for result in self.getStatResults(player, sort_by):
gameid = result.pop()
result[0] = _(result[0]) # game name
self.pstats(y, result, gameid)
y += self.h
#
@ -489,7 +488,7 @@ class AllGames_StatsDialog(MfxDialog):
#
self.sc = AllGames_StatsDialogScrolledCanvas(top_frame,
width=kw.width, height=kw.height)
self.sc.pack(fill=Tkinter.BOTH, expand=1, padx=kw.padx, pady=kw.pady)
self.sc.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
#
self.nodes = {}
self.canvas = self.sc.canvas
@ -532,7 +531,7 @@ class AllGames_StatsDialog(MfxDialog):
self.fillCanvas(self.player, self.title)
def singleClick(self, event=None):
id = self.canvas.find_withtag(Tkinter.CURRENT)
id = self.canvas.find_withtag('current')
if not id:
return
##print 'singleClick:', id, self.nodes.get(id[0])
@ -657,7 +656,7 @@ class _TopDialog(MfxDialog):
'highlightbackground': 'black',
}
frame = Tkinter.Frame(**cnf)
frame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH, padx=10, pady=10)
frame.pack(expand=True, fill='both', padx=10, pady=10)
frame.columnconfigure(0, weight=1)
cnf['master'] = frame
cnf['text'] = _('N')
@ -718,7 +717,7 @@ class Top_StatsDialog(MfxDialog):
self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame)
frame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH, padx=10, pady=10)
frame.pack(expand=True, fill='both', padx=10, pady=10)
frame.columnconfigure(0, weight=1)
if (player in app.stats.games_stats and

View file

@ -258,7 +258,7 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
bind(self.canvas, "<ButtonPress-1>", self.singleClick)
bind(self.canvas, "<Double-Button-1>", self.doubleClick)
##bind(self.canvas, "<ButtonRelease-1>", xxx)
self.pack(fill=Tkinter.BOTH, expand=1)
self.pack(fill='both', expand=True)
def destroy(self):
for node in self.keys.get(self.selection_key, []):
@ -266,7 +266,7 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
MfxScrolledCanvas.destroy(self)
def findNode(self, event=None):
id = self.canvas.find_withtag(Tkinter.CURRENT)
id = self.canvas.find_withtag('current')
if id:
return self.nodes.get(id[0])
return None

View file

@ -37,6 +37,7 @@ __all__ = ['MfxDialog',
'MfxMessageDialog',
'MfxExceptionDialog',
'MfxSimpleEntry',
'PysolAboutDialog',
'MfxTooltip',
'MfxScrolledCanvas',
'StackDesc',
@ -45,10 +46,11 @@ __all__ = ['MfxDialog',
# imports
import os, sys, time, types
import Tkinter
import tkFont
import traceback
# PySol imports
from pysollib.mfxutil import destruct, kwdefault, KwStruct
from pysollib.mfxutil import destruct, kwdefault, KwStruct, openURL
from pysollib.settings import WIN_SYSTEM
# Toolkit imports
@ -173,14 +175,15 @@ class MfxDialog: # ex. _ToplevelDialog
def createFrames(self, kw):
bottom_frame = Tkinter.Frame(self.top)
bottom_frame.pack(side='bottom', fill='both', expand=0, ipadx=3, ipady=3)
bottom_frame.pack(side='bottom', fill='both', expand=False,
ipadx=3, ipady=3)
if kw.separatorwidth > 0:
separator = Tkinter.Frame(self.top, relief="sunken",
height=kw.separatorwidth, width=kw.separatorwidth,
borderwidth=kw.separatorwidth / 2)
separator.pack(side='bottom', fill='x')
top_frame = Tkinter.Frame(self.top)
top_frame.pack(side='top', fill='both', expand=1)
top_frame.pack(side='top', fill='both', expand=True)
return top_frame, bottom_frame
def createBitmaps(self, frame, kw):
@ -270,7 +273,7 @@ class MfxMessageDialog(MfxDialog):
self.button = kw.default
msg = Tkinter.Label(top_frame, text=kw.text, justify=kw.justify,
width=kw.width)
msg.pack(fill=Tkinter.BOTH, expand=1, padx=kw.padx, pady=kw.pady)
msg.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
@ -295,6 +298,39 @@ class MfxExceptionDialog(MfxMessageDialog):
MfxMessageDialog.__init__(self, parent, title, **kw.getKw())
# /***********************************************************************
# //
# ************************************************************************/
class PysolAboutDialog(MfxMessageDialog):
def __init__(self, app, parent, title, **kw):
self._url = kw['url']
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw)
#
self.button = kw.default
frame = Tkinter.Frame(top_frame)
frame.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
msg = Tkinter.Label(frame, text=kw.text, justify=kw.justify,
width=kw.width)
msg.pack(fill='both', expand=True)
font = tkFont.Font(parent, app.getFont('default'))
font.configure(underline=True)
url_label = Tkinter.Label(frame, text=kw.url, font=font,
foreground='blue', cursor='hand2')
url_label.pack()
url_label.bind('<1>', self._urlClicked)
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
def _urlClicked(self, event):
openURL(self._url)
# /***********************************************************************
# //
# ************************************************************************/
@ -313,7 +349,7 @@ class MfxSimpleEntry(MfxDialog):
w = kw.get("e_width", 0) # width in characters
self.var = Tkinter.Entry(top_frame, exportselection=1, width=w)
self.var.insert(0, value)
self.var.pack(side=Tkinter.TOP, padx=kw.padx, pady=kw.pady)
self.var.pack(side='top', padx=kw.padx, pady=kw.pady)
#
focus = self.createButtons(bottom_frame, kw)
focus = self.var
@ -355,8 +391,8 @@ class MfxTooltip:
self.timeout = 800 # milliseconds
self.cancel_timeout = 5000
self.leave_timeout = 400
self.relief = Tkinter.SOLID
self.justify = Tkinter.LEFT
self.relief = 'solid'
self.justify = 'left'
self.fg = "#000000"
self.bg = "#ffffe0"
self.xoffset = 0
@ -403,7 +439,7 @@ class MfxTooltip:
if self.tooltip or not self.text:
return
## if isinstance(self.widget, (Tkinter.Button, Tkinter.Checkbutton)):
## if self.widget["state"] == Tkinter.DISABLED:
## if self.widget["state"] == 'disabled':
## return
##x = self.widget.winfo_rootx()
x = self.widget.winfo_pointerx()
@ -429,36 +465,24 @@ class MfxTooltip:
# ************************************************************************/
class MfxScrolledCanvas:
def __init__(self, parent, hbar=2, vbar=2, **kw):
def __init__(self, parent, hbar=True, vbar=True, propagate=False, **kw):
kwdefault(kw, highlightthickness=0, bd=1, relief='sunken')
self.parent = parent
self.createFrame(kw)
self.canvas = None
self.hbar = None
self.hbar_mode = hbar
self.vbar = None
self.vbar_mode = vbar
self.hbar_show = 0
self.vbar_show = 0
self.resize_pending = 0
self.timer = None
self.hbar_show = False
self.vbar_show = False
self.createCanvas(kw)
self.frame.grid_rowconfigure(0, weight=1)
self.frame.grid_columnconfigure(0, weight=1)
self.frame.grid_propagate(propagate)
if hbar:
if hbar == 3:
w = 21
self.frame.grid_rowconfigure(1, minsize=w)
self.createHbar()
if not vbar:
bind(self.hbar, "<Map>", self._mapBar)
self.bindHbar()
if vbar:
if vbar == 3:
w = 21
self.frame.grid_columnconfigure(1, minsize=w)
self.createVbar()
bind(self.vbar, "<Map>", self._mapBar)
self.bindVbar()
###self.canvas.focus_set()
@ -467,8 +491,6 @@ class MfxScrolledCanvas:
#
def destroy(self):
after_cancel(self.timer)
self.timer = None
self.unbind_all()
self.canvas.destroy()
self.frame.destroy()
@ -534,14 +556,18 @@ class MfxScrolledCanvas:
self.canvas = MfxCanvas(self.frame, **kw)
self.canvas.grid(row=0, column=0, sticky="news")
def createHbar(self):
self.hbar = Tkinter.Scrollbar(self.frame, name="hbar",
takefocus=0, orient="horizontal")
self.hbar = Tkinter.Scrollbar(self.frame, takefocus=0,
orient="horizontal")
self.canvas["xscrollcommand"] = self._setHbar
self.hbar["command"] = self.canvas.xview
self.hbar.grid(row=1, column=0, sticky="we")
self.hbar.grid_remove()
def createVbar(self):
self.vbar = Tkinter.Scrollbar(self.frame, name="vbar", takefocus=0)
self.vbar = Tkinter.Scrollbar(self.frame, takefocus=0)
self.canvas["yscrollcommand"] = self._setVbar
self.vbar["command"] = self.canvas.yview
self.vbar.grid(row=0, column=1, sticky="ns")
self.vbar.grid_remove()
def bindHbar(self, w=None):
if w is None:
w = self.canvas
@ -564,70 +590,33 @@ class MfxScrolledCanvas:
# don't work on Linux
#bind(w, '<MouseWheel>', self.mouse_wheel)
def mouse_wheel(self, *args):
print 'MfxScrolledCanvas.mouse_wheel', args
def _mapBar(self, event):
# see: autoscroll.tcl, http://mini.net/cgi-bin/wikit/950.html
top = event.widget.winfo_toplevel()
g = top.wm_geometry()
if self.resize_pending:
self.resize_pending = 0
self.canvas.update()
self.canvas.update_idletasks()
top.wm_geometry(g)
def _setHbar(self, *args):
self.canvas.update()
self.hbar.set(*self.canvas.xview())
self.showHbar()
##self.hbar.update_idletasks()
def _setVbar(self, *args):
self.canvas.update()
self.vbar.set(*self.canvas.yview())
self.showVbar()
##self.vbar.update_idletasks()
def showHbar(self, show=-1):
if not self.hbar:
return 0
if show < 0:
show = self.hbar_mode
if show > 1:
if not self.canvas.winfo_ismapped():
return 0
##self.canvas.update()
view = self.canvas.xview()
show = abs(view[0]) > 0.0001 or abs(view[1] - 1.0) > 0.0001
if show == self.hbar_show:
return 0
if show:
self.hbar.grid(row=1, column=0, sticky="we")
def _setHbar(self, first, last):
sb = self.hbar
if not self.canvas.winfo_ismapped():
sb.set(first, last)
return
if float(first) <= 0 and float(last) >= 1:
sb.grid_remove()
self.hbar_show = False
else:
self.hbar.grid_forget()
self.hbar_show = show
return 1
def showVbar(self, show=-1):
if not self.vbar:
return 0
if show < 0:
show = self.vbar_mode
if show > 1:
if not self.canvas.winfo_ismapped():
return 0
##self.canvas.update()
view = self.canvas.yview()
show = abs(view[0]) > 0.0001 or abs(view[1] - 1.0) > 0.0001
if show == self.vbar_show:
return 0
if show:
self.vbar.grid(row=0, column=1, sticky="ns")
sb.grid()
self.hbar_show = True
sb.set(first, last)
def _setVbar(self, first, last):
sb = self.vbar
if not self.canvas.winfo_ismapped():
sb.set(first, last)
return
if float(first) <= 0 and float(last) >= 1:
sb.grid_remove()
self.vbar_show = False
else:
self.vbar.grid_forget()
self.vbar_show = show
return 1
sb.grid()
self.vbar_show = True
sb.set(first, last)
def _xview(self, *args):
if self.hbar_show: self.canvas.xview(*args)

View file

@ -34,9 +34,6 @@
##---------------------------------------------------------------------------##
__all__ = ['TclError',
'MfxCheckMenuItem',
'MfxRadioMenuItem',
'StringVar',
'MfxRoot']
# imports
@ -53,32 +50,6 @@ from tkutil import after_idle
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
# /***********************************************************************
# // menubar
# ************************************************************************/
class MfxCheckMenuItem(Tkinter.BooleanVar):
def __init__(self, menubar, path=None):
Tkinter.BooleanVar.__init__(self)
def set(self, value):
if not value or value == "false": value = 0
##print value, type(value)
Tkinter.BooleanVar.set(self, value)
class MfxRadioMenuItem(Tkinter.IntVar):
def __init__(self, menubar, path=None):
Tkinter.IntVar.__init__(self)
def set(self, value):
Tkinter.IntVar.set(self, value)
## BooleanVar = Tkinter.BooleanVar
## IntVar = Tkinter.IntVar
StringVar = Tkinter.StringVar
# /***********************************************************************
# // Wrapper class for Tk.
# // Required so that a Game will get properly destroyed.

View file

@ -69,7 +69,7 @@ class AbstractToolbarButton:
return
self.visible = True
padx, pady = 2, 2
if orient == Tkinter.HORIZONTAL:
if orient == 'horizontal':
self.grid(row=0,
column=self.position,
ipadx=padx, ipady=pady,
@ -112,7 +112,7 @@ class ToolbarSeparator(Tkinter.Frame):
height = 4
padx = 6
pady = 6
if orient == Tkinter.HORIZONTAL:
if orient == 'horizontal':
self.config(width=width, height=height)
self.grid(row=0,
column=self.position,
@ -144,7 +144,7 @@ class ToolbarLabel(Tkinter.Message):
return
self.visible = True
padx, pady = TkSettings.toolbar_label_padding
if orient == Tkinter.HORIZONTAL:
if orient == 'horizontal':
self.grid(row=0,
column=self.position,
padx=padx, pady=pady,
@ -166,8 +166,7 @@ class ToolbarLabel(Tkinter.Message):
class PysolToolbar(PysolToolbarActions):
def __init__(self, top, dir, size=0, relief=Tkinter.FLAT,
compound=Tkinter.NONE):
def __init__(self, top, dir, size=0, relief='flat', compound='none'):
PysolToolbarActions.__init__(self)
@ -179,7 +178,7 @@ class PysolToolbar(PysolToolbarActions):
self.dir = dir
self.size = size
self.compound = compound
self.orient=Tkinter.HORIZONTAL
self.orient = 'horizontal'
self.button_pad = 2
#
self.frame = Tkinter.Frame(top, relief=TkSettings.toolbar_relief,
@ -401,7 +400,7 @@ class PysolToolbar(PysolToolbarActions):
# right
pack_func(row=1, column=2, sticky='ns')
# set orient
orient = side in (1, 2) and Tkinter.HORIZONTAL or Tkinter.VERTICAL
orient = side in (1, 2) and 'horizontal' or 'vertical'
self._setOrient(orient)
self.side = side
return 1
@ -516,6 +515,6 @@ class PysolToolbar(PysolToolbarActions):
if self.compound == 'text':
return 0
size = self.size
comp = int(self.compound in (Tkinter.TOP, Tkinter.BOTTOM))
comp = int(self.compound in ('top', 'bottom'))
return int((size+comp) != 0)

View file

@ -53,9 +53,16 @@ class initRootWindow(baseInitRootWindow):
color = style.lookup('.', 'background')
if color:
root.tk_setPalette(color)
root.option_add('*Menu.borderWidth', 1, 60)
root.option_add('*Menu.activeBorderWidth', 1, 60)
color = style.lookup('.', 'background', 'active')
if color:
root.option_add('*Menu.activeBackground', color)
root.option_add('*Menu.activeBackground', color, 60)
root.option_add('*Listbox.background', 'white', 60)
root.option_add('*Listbox.foreground', 'black', 60)
font = root.option_get('font', PACKAGE)
if font:
# use font from xrdb
@ -75,10 +82,10 @@ class initRootWindow(baseInitRootWindow):
if fn:
root.option_add('*font', font)
app.opt.fonts['default'] = fn
root.option_add('*Menu.borderWidth', 1, 60)
root.option_add('*Menu.activeBorderWidth', 1, 60)
if app.opt.tile_theme == 'clam':
if app.opt.tile_theme in ('clam', 'clearlooks'):
root.wm_minsize(550, 360)
style.configure('TLabelframe', labeloutside=False,
labelmargins=(8, 0, 8, 0))
#
else:
root.option_add('*Entry.background', 'white', 60)

View file

@ -168,13 +168,6 @@ FoundDir = WizSetting(
label = _('Direction:'),
var_name = 'found_dir',
)
FoundWrap = WizSetting(
values_map = (0, 1),
default = 0,
label = _('Wrapping:'),
var_name = 'found_wrap',
widget = 'check',
)
FoundMaxMove = WizSetting(
values_map = ((n_('None'), 0,), (n_('Top card'), 1)),
default = n_('Top card'),
@ -328,7 +321,6 @@ WizardWidgets = (
FoundType,
FoundBaseCard,
FoundDir,
##FoundWrap,
FoundMaxMove,
FoundEqual,
_('Tableau'),

View file

@ -44,8 +44,10 @@ if os.name == 'posix':
for l in ('ru', 'ru_RU'):
data_files.append(('share/locale/%s/LC_MESSAGES' % l,
['locale/%s/LC_MESSAGES/pysol.mo' % l]))
data_files.append((data_dir, ['data/pysolfc.glade']))
##from pprint import pprint; pprint(data_files)
##import sys; sys.exit()
long_description = '''\
PySol is a solitaire card game. Its features include support for many