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

+ improved tile support

git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@78 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-10-05 21:16:11 +00:00
parent 03bfcdf46d
commit 9e682f4bfe
16 changed files with 111 additions and 40 deletions

View file

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PySol 0.0.1\n"
"POT-Creation-Date: Thu Sep 21 15:57:22 2006\n"
"PO-Revision-Date: 2006-09-26 15:53+0400\n"
"PO-Revision-Date: 2006-10-05 16:31+0400\n"
"Last-Translator: Скоморох <skomoroh@gmail.com>\n"
"Language-Team: Russian <ru@li.org>\n"
"MIME-Version: 1.0\n"
@ -3016,7 +3016,7 @@ msgstr "Выкладывание на сброс"
#: pysollib/tk/soundoptionsdialog.py:80
msgid "Turn waste"
msgstr "Переворачивание сброса"
msgstr "Перелистывание сброса"
#: pysollib/tk/soundoptionsdialog.py:81
msgid "Start drag"
@ -3024,11 +3024,11 @@ msgstr "Начало перемещения"
#: pysollib/tk/soundoptionsdialog.py:83
msgid "Drop"
msgstr "Сбрасывание карты"
msgstr "Сброс карты"
#: pysollib/tk/soundoptionsdialog.py:84
msgid "Drop pair"
msgstr "Сбрасывание двух карт"
msgstr "Сброс двух карт"
#: pysollib/tk/soundoptionsdialog.py:85
msgid "Auto drop"

View file

@ -88,6 +88,7 @@ def parse_option(argv):
"fg=", "foreground=",
"bg=", "background=",
"fn=", "font=",
"tile-theme=",
"french-only",
"noplugins",
"nosound",
@ -104,6 +105,7 @@ def parse_option(argv):
"fg": None,
"bg": None,
"fn": None,
"tile-theme": None,
"french-only": False,
"noplugins": False,
"nosound": False,
@ -123,6 +125,8 @@ def parse_option(argv):
opts["bg"] = i[1]
elif i[0] in ("--fn", "--font"):
opts["fn"] = i[1]
elif i[0] == "--tile-theme":
opts["tile-theme"] = i[1]
elif i[0] == "--french-only":
opts["french-only"] = True
elif i[0] == "--noplugins":
@ -209,6 +213,9 @@ def pysol_init(app, args):
app.debug = int(opts['debug'])
except:
print >> sys.stderr, 'invalid argument for debug'
if opts['tile-theme']:
import settings
settings.TILE_THEME = opts['tile-theme']
# init games database
import games
@ -323,14 +330,6 @@ def pysol_init(app, args):
app.top_palette[0] = fg
#
if USE_TILE: # for tile
top.option_add('*Toolbar.relief', 'groove')
top.option_add('*Toolbar.borderWidth', 2)
top.option_add('*Toolbar.Button.Pad', 2)
top.option_add('*Toolbar.Button.default', 'disabled')
top.option_add('*Toolbar*takeFocus', 1)
top.option_add('*Tree.background', 'red')
if os.name == "posix": # Unix/X11
top.option_add('*Entry.background', 'white', 60)
top.option_add('*Entry.foreground', 'black', 60)
@ -370,6 +369,24 @@ def pysol_init(app, args):
else:
app.opt.fonts["default"] = None
if USE_TILE: # for tile
##top.option_add('*Toolbar.relief', 'groove')
##top.option_add('*Toolbar.relief', 'raised')
top.option_add('*Toolbar.borderWidth', 1)
top.option_add('*Toolbar.Button.Pad', 2)
top.option_add('*Toolbar.Button.default', 'disabled')
top.option_add('*Toolbar*takeFocus', 0)
#
from settings import TILE_THEME
if TILE_THEME:
if font:
top.tk.call('style', 'configure', '.', '-font', font)
else:
font = top.tk.call('style', 'lookup', TILE_THEME, '-font')
top.option_add('*font', font)
bg = top.tk.call('style', 'lookup', TILE_THEME, '-background')
top.tk_setPalette(bg)
# check games
if len(app.gdb.getGamesIdSortedByName()) == 0:
app.wm_withdraw()

View file

@ -34,7 +34,7 @@ VERSION_TUPLE = (4, 82)
TOOLKIT = 'tk' # or 'gtk'
USE_TILE = False
TILE_THEME = 'clam' #'default' # name of tile's theme
TILE_THEME = 'default' # name of tile's theme
# data dirs
DATA_DIRS = []

View file

@ -177,7 +177,7 @@ class Label(Widget, Tkinter.Label):
class Frame(Widget, Tkinter.Frame):
def __init__(self, master=None, cnf={}, **kw):
for opt in ('bd', 'highlightthickness',):
for opt in ('bd', 'highlightbackground', 'highlightthickness',):
if kw.has_key(opt):
del kw[opt]
Widget.__init__(self, master, "ttk::frame", cnf, kw)
@ -185,6 +185,9 @@ class Frame(Widget, Tkinter.Frame):
class LabelFrame(Widget, Tkinter.Frame):
def __init__(self, master=None, cnf={}, **kw):
for opt in ('padx', 'pady',):
if kw.has_key(opt):
del kw[opt]
Widget.__init__(self, master, "ttk::labelframe", cnf, kw)

View file

@ -34,6 +34,8 @@ from pysollib.mfxutil import destruct, kwdefault, KwStruct, Struct
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
from tkwidget import MfxDialog
from tkutil import bind
from tkwidget import PysolScale
# /***********************************************************************
# //
@ -73,9 +75,12 @@ class FontChooserDialog(MfxDialog):
#self.family_var = Tkinter.StringVar()
self.weight_var = Tkinter.BooleanVar()
self.weight_var.set(self.font_weight == 'bold')
self.slant_var = Tkinter.BooleanVar()
self.slant_var.set(self.font_slant == 'italic')
self.size_var = Tkinter.IntVar()
self.size_var.set(self.font_size)
#
frame = Tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1)
@ -100,15 +105,12 @@ class FontChooserDialog(MfxDialog):
variable=self.slant_var)
cb2.grid(row=3, column=0, columnspan=2, sticky='we')
sc = Tkinter.Scale(frame, from_=6, to=40, resolution=1,
sc = PysolScale(frame, from_=6, to=40, resolution=1,
#label='Size',
orient='horizontal',
command=self.fontupdate, variable=self.size_var)
sc.grid(row=4, column=0, columnspan=2, sticky='news')
#
self.size_var.set(self.font_size)
self.weight_var.set(self.font_weight == 'bold')
self.slant_var.set(self.font_slant == 'italic')
font_families = list(tkFont.families())
font_families.sort()
selected = -1

View file

@ -56,14 +56,12 @@ class PysolProgressBar:
self.top = makeToplevel(parent, title=title)
self.top.wm_protocol("WM_DELETE_WINDOW", self.wmDeleteWindow)
self.top.wm_group(parent)
self.top.wm_geometry('400x120')
self.top.wm_minsize(400, 120)
self.top.wm_resizable(0, 0)
self.top.config(cursor="watch")
#
self.frame = Tkinter.Frame(self.top, relief=Tkinter.FLAT, bd=0,
takefocus=0)
self.progress = Tkinter.Progressbar(self.frame, maximum=100)
self.progress = Tkinter.Progressbar(self.frame, maximum=100, length=250)
##style = Tkinter.Style(self.progress)
##style.configure('TProgressbar', background=color)
if images:
@ -73,7 +71,7 @@ class PysolProgressBar:
self.f2 = Tkinter.Label(self.frame, image=images[1])
self.f2.pack(side='left', ipadx=8, ipady=4)
else:
self.progress.grid(expand='yes', fill='x')
self.progress.pack(expand='yes', fill='x')
self.frame.pack(expand='yes', fill='both')
if app:
try:

View file

@ -48,6 +48,8 @@ from pysollib.pysolaudio import pysolsoundserver
# Toolkit imports
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
from tkwidget import MfxDialog, MfxMessageDialog
from tkwidget import PysolScale
# /***********************************************************************
# //
@ -121,16 +123,16 @@ class SoundOptionsDialog(MfxDialog):
if app.audio.CAN_PLAY_MUSIC: # and app.startup_opt.sound_mode > 0:
row += 1
w = Tkinter.Label(frame, text=_('Sample volume:'))
w.grid(row=row, column=0, sticky='w')
w = Tkinter.Scale(frame, from_=0, to=128, resolution=1,
w.grid(row=row, column=0, sticky='ew')
w = PysolScale(frame, from_=0, to=128, resolution=1,
orient='horizontal', takefocus=0,
length="3i", #label=_('Sample volume'),
variable=self.sample_volume)
w.grid(row=row, column=1, sticky='w', padx=5)
row += 1
w = Tkinter.Label(frame, text=_('Music volume:'))
w.grid(row=row, column=0, sticky='w', padx=5)
w = Tkinter.Scale(frame, from_=0, to=128, resolution=1,
w.grid(row=row, column=0, sticky='ew', padx=5)
w = PysolScale(frame, from_=0, to=128, resolution=1,
orient='horizontal', takefocus=0,
length="3i", #label=_('Music volume'),
variable=self.music_volume)

View file

@ -31,6 +31,8 @@ from pysollib.mfxutil import destruct, kwdefault, KwStruct, Struct
# Toolkit imports
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
from tkwidget import MfxDialog
from tkwidget import PysolScale
# /***********************************************************************
# //
@ -71,7 +73,7 @@ class TimeoutsDialog(MfxDialog):
):
Tkinter.Label(frame, text=title, anchor='w'
).grid(row=row, column=0, sticky='we')
widget = Tkinter.Scale(frame, from_=0.2, to=9.9,
widget = PysolScale(frame, from_=0.2, to=9.9, value=var.get(),
resolution=0.1, orient='horizontal',
length="3i", variable=var, takefocus=0)
widget.grid(row=row, column=1)

View file

@ -275,7 +275,7 @@ class HTMLViewer:
fg='black', bg='white',
bd=1, relief='sunken',
cursor=self.defcursor,
wrap='word', padx=20, pady=20)
wrap='word', padx=10)
self.text.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
self.text["yscrollcommand"] = vbar.set
vbar["command"] = self.text.yview

View file

@ -255,8 +255,8 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
#
self.style = self.Style()
##self.style.text_normal_fg = self.canvas.cget("insertbackground")
self.style.text_normal_fg = self.canvas.option_get('foreground', '') or self.canvas.cget("insertbackground")
self.style.text_normal_bg = self.canvas.option_get('background', self.canvas.cget("background"))
#self.style.text_normal_fg = self.canvas.option_get('foreground', '') or self.canvas.cget("insertbackground")
#self.style.text_normal_bg = self.canvas.option_get('background', self.canvas.cget("background"))
#
bind(self.canvas, "<ButtonPress-1>", self.singleClick)
bind(self.canvas, "<Double-Button-1>", self.doubleClick)

View file

@ -69,7 +69,6 @@ except ImportError:
# Toolkit imports
from tkconst import tkversion
from pysollib.settings import PACKAGE
from pysollib.settings import TILE_THEME
# /***********************************************************************
@ -176,10 +175,13 @@ def make_help_toplevel(app, title=None):
parent = app.top
window = Tkinter.Tk(className=PACKAGE)
window.tk.call('package', 'require', 'tile')
from pysollib.settings import TILE_THEME
if TILE_THEME:
##window.tk.call('style', 'theme', 'use', TILE_THEME)
style = Tkinter.Style(window)
style.theme_use(TILE_THEME)
bg = window.tk.call('style', 'lookup', TILE_THEME, '-background')
window.tk_setPalette(bg)
font = parent.option_get('font', '')
if font:
window.option_add('*font', font)
@ -202,11 +204,10 @@ def make_help_toplevel(app, title=None):
def __getWidgetXY(widget, parent, relx=None, rely=None,
w_width=None, w_height=None):
min_width, min_height = widget.wm_minsize()
if w_width is None:
w_width = max(min_width, widget.winfo_reqwidth())
w_width = widget.winfo_reqwidth()
if w_height is None:
w_height = max(min_height, widget.winfo_reqheight())
w_height = widget.winfo_reqheight()
s_width = widget.winfo_screenwidth()
s_height = widget.winfo_screenheight()
m_x = m_y = 0

View file

@ -720,3 +720,49 @@ class StackDesc:
for b in self.bindings:
self.label.unbind('<ButtonPress>', b)
# /***********************************************************************
# //
# ************************************************************************/
class PysolScale:
def __init__(self, parent, **kw):
if kw.has_key('resolution'):
self.resolution = kw['resolution']
else:
self.resolution = 1
if kw.has_key('command'):
self.command = kw['command']
else:
self.command = None
self.frame = Tkinter.Frame(parent)
self.label = Tkinter.Label(self.frame)
self.label.pack()
kw['command'] = self._scale_command
self.scale = Tkinter.Scale(self.frame, **kw)
self.scale.pack(expand=True, fill='both')
if kw.has_key('value'):
self.label.configure(text=self._round(kw['value']))
elif kw.has_key('variable'):
self.label.configure(text=self._round(kw['variable'].get()))
def _round(self, value):
return int(float(value)/self.resolution)*self.resolution
def _scale_command(self, value):
self.label.configure(text=self._round(value))
if self.command:
self.command(value)
def pack(self, **kw):
self.frame.pack(**kw)
def grid(self, **kw):
self.frame.grid(**kw)
def configure(self, **kw):
self.scale.configure(**kw)
config = configure

View file

@ -46,7 +46,6 @@ import Tile as Tkinter
# PySol imports
from pysollib.mfxutil import destruct, Struct
from pysollib.settings import TILE_THEME
from tkutil import after_idle
from tkconst import EVENT_HANDLED, EVENT_PROPAGATE
@ -87,6 +86,7 @@ class MfxRoot(Tkinter.Tk):
def __init__(self, **kw):
apply(Tkinter.Tk.__init__, (self,), kw)
self.tk.call("package", "require", "tile")
from pysollib.settings import TILE_THEME
if TILE_THEME:
##self.tk.call('style', 'theme', 'use', TILE_THEME)
style = Tkinter.Style(self)

View file

@ -223,7 +223,7 @@ class PysolToolbar(PysolToolbarActions):
self.label_pady = 4
self.button_pad = 2
#
self.frame = Tkinter.Frame(top) #, class_='Toolbar')
self.frame = Tkinter.Frame(top, class_='Toolbar')
#
for l, f, t in (
(n_("New"), self.mNewGame, _("New game")),

View file

@ -121,12 +121,12 @@ class SoundOptionsDialog(MfxDialog):
if app.audio.CAN_PLAY_MUSIC: # and app.startup_opt.sound_mode > 0:
row += 1
w = Tkinter.Label(frame, text=_('Sample volume:'))
w.grid(row=row, column=0, sticky='w')
w.grid(row=row, column=0, sticky='ew')
w = Tkinter.Scale(frame, from_=0, to=128, resolution=1,
orient='horizontal', takefocus=0,
length="3i", #label=_('Sample volume'),
variable=self.sample_volume)
w.grid(row=row, column=1, sticky='w', padx=5)
w.grid(row=row, column=1, sticky='ew', padx=5)
row += 1
w = Tkinter.Label(frame, text=_('Music volume:'))
w.grid(row=row, column=0, sticky='w', padx=5)

View file

@ -275,7 +275,7 @@ class HTMLViewer:
fg='black', bg='white',
bd=1, relief='sunken',
cursor=self.defcursor,
wrap='word', padx=20, pady=20)
wrap='word', padx=10)
self.text.pack(side=Tkinter.LEFT, fill=Tkinter.BOTH, expand=1)
self.text["yscrollcommand"] = vbar.set
vbar["command"] = self.text.yview