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

git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@227 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2008-06-10 07:23:08 +00:00
parent a0cd63eac6
commit 890fa91e54
28 changed files with 1793 additions and 936 deletions

2
README
View file

@ -14,7 +14,7 @@ Requirements.
- PyGame: http://www.pygame.org/ (mp3, ogg, wav, midi, tracker music) - PyGame: http://www.pygame.org/ (mp3, ogg, wav, midi, tracker music)
** other packages (optional) ** ** other packages (optional) **
- Tile: http://tktable.sourceforge.net/tile/ (0.7.8 or later) - Tile (ttk): http://tktable.sourceforge.net/tile/ (0.8.0 or later)
- PIL (Python Imaging Library): http://www.pythonware.com/products/pil - PIL (Python Imaging Library): http://www.pythonware.com/products/pil
- Freecell Solver: http://vipe.technion.ac.il/~shlomif/freecell-solver/ - Freecell Solver: http://vipe.technion.ac.il/~shlomif/freecell-solver/

View file

@ -418,7 +418,7 @@ class OSSAudioClient(AbstractAudioClient):
class PyGameAudioClient(AbstractAudioClient): class PyGameAudioClient(AbstractAudioClient):
EXTENSIONS = r'\.((ogg)|(mp3)|(wav)|(it)|(mod)|(s3m)|(xm)|(mid))$' EXTENSIONS = r'\.((ogg)|(mp3)|(wav)|(it)|(mod)|(s3m)|(xm)|(mid)|(midi))$'
CAN_PLAY_SOUND = True CAN_PLAY_SOUND = True
CAN_PLAY_MUSIC = True CAN_PLAY_MUSIC = True
@ -492,18 +492,22 @@ class PyGameAudioClient(AbstractAudioClient):
self.music.set_volume(vol) self.music.set_volume(vol)
self.music.play() self.music.play()
while self.music and self.music.get_busy(): while self.music and self.music.get_busy():
self.time.wait(200) self._wait(200)
if self.time: self._wait(300)
self.time.wait(300)
except: except:
##if traceback: traceback.print_exc() ##if traceback: traceback.print_exc()
self.time.wait(1000) self._wait(1000)
def _destroy(self): def _destroy(self):
self.mixer.stop() self.mixer.stop()
self.mixer.quit() self.mixer.quit()
self.music = None self.music = None
def _wait(self, s):
# sometime time or time.wait is None (threading)
if self.time and self.time.wait:
self.time.wait(s)
def playContinuousMusic(self, music_list): def playContinuousMusic(self, music_list):
##print 'playContinuousMusic' ##print 'playContinuousMusic'
self.music_list = music_list self.music_list = music_list

View file

@ -1,618 +0,0 @@
# http://tkinter.unpythonic.net/wiki/TileWrapper
import Tkinter
TileVersion = None
_tile_prefix = '' # XXX
def initialize(root=None):
global TileVersion, _tile_prefix
if root is None:
root = Tkinter._default_root
TileVersion = root.tk.call("package", "require", "tile", "0.7.8")
if TileVersion >= '0.8':
_tile_prefix = 'ttk::' # XXX
def availableThemes(root=None):
if root is None:
root = Tkinter._default_root
if TileVersion >= '0.8':
return root.tk.call("ttk::themes")
return root.tk.call("tile::availableThemes")
def setTheme(root=None, theme=None):
if root is None:
root = Tkinter._default_root
if TileVersion >= '0.8':
return root.tk.call("ttk::setTheme", theme)
return root.tk.call("tile::setTheme", theme)
class Style(Tkinter.Misc):
def __init__(self, master=None):
if master is None:
master = Tkinter._default_root
self.tk = master.tk
def default(self, style, **kw):
"""Sets the default value of the specified option(s) in style"""
assert TileVersion < '0.8' # removed in Tile-0.8.0
opts = self._options(kw)
return self.tk.call(_tile_prefix+"style", "default", style, *opts)
def map_style(self, **kw):
"""Sets dynamic values of the specified option(s) in style. See
"STATE MAPS", below.
"""
raise NotImplementedError()
def layout(self, style, layoutSpec):
"""Define the widget layout for style style. See "LAYOUTS" below
for the format of layoutSpec. If layoutSpec is omitted, return the
layout specification for style style.
"""
raise NotImplementedError()
def element_create(self, name, type, *args):
"""Creates a new element in the current theme of type type. The
only built-in element type is image (see image(n)), although
themes may define other element types (see
Ttk_RegisterElementFactory).
"""
raise NotImplementedError()
def element_names(self):
"""Returns a list of all elements defined in the current theme."""
return self.tk.call(_tile_prefix+"style", "elements", "names")
def theme_create(self, name, parent=None, basedon=None):
"""Creates a new theme. It is an error if themeName already exists.
If -parent is specified, the new theme will inherit styles, elements,
and layouts from the parent theme basedon. If -settings is present,
script is evaluated in the context of the new theme as per style theme
settings.
"""
raise NotImplementedError()
def theme_settings(self, name, script):
"""Temporarily sets the current theme to themeName, evaluate script,
then restore the previous theme. Typically script simply defines
styles and elements, though arbitrary Tcl code may appear.
"""
raise NotImplementedError()
def theme_names(self):
"""Returns a list of the available themes."""
return self.tk.call(_tile_prefix+"style", "theme", "names")
def theme_use(self, theme):
"""Sets the current theme to themeName, and refreshes all widgets."""
return self.tk.call(_tile_prefix+"style", "theme", "use", theme)
def configure(self, style, cnf={}, **kw):
"""Sets the default value of the specified option(s)
in style."""
opts = self._options(cnf, kw)
return self.tk.call(_tile_prefix+"style", "configure", style, *opts)
config = configure
def lookup(self, style, option, state=None, default=None):
"""Returns the value specified for -option in style
style in state state, using the standard lookup
rules for element options. state is a list of
state names; if omitted, it defaults to all bits
off (the ``normal'' state). If the default argu-
ment is present, it is used as a fallback value in
case no specification for -option is found."""
opts = []
if state:
opts = [state]
if default:
opts.append(default)
return self.tk.call(_tile_prefix+"style", "lookup", style,
"-"+option, *opts)
class Widget(Tkinter.Widget, Style):
def __init__(self, master, widgetName=None, cnf={}, kw={}, extra=()):
if not widgetName:
## why you would ever want to create a Tile Widget is behond me!
widgetName="ttk::widget"
Tkinter.Widget.__init__(self, master, widgetName, cnf, kw)
def instate(self, spec=None, script=None):
"""Test the widget's state. If script is not specified, returns 1
if the widget state matches statespec and 0 otherwise. If script
is specified, equivalent to if {[pathName instate stateSpec]}
script.
"""
return self.tk.call(self._w, "instate", spec, script)
def state(self, spec=None):
"""Modify or inquire widget state. If stateSpec is present, sets
the widget state: for each flag in stateSpec, sets the corresponding
flag or clears it if prefixed by an exclamation point. Returns a new
state spec indicating which flags were changed: ''set changes
[pathName state spec] ; pathName state $changes'' will restore
pathName to the original state. If stateSpec is not specified,
returns a list of the currently-enabled state flags.
"""
return self.tk.call(self._w, "state", spec)
class Button(Widget, Tkinter.Button):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::button", cnf, kw)
class Checkbutton(Widget, Tkinter.Checkbutton):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::checkbutton", cnf, kw)
class Combobox(Widget, Tkinter.Entry):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::combobox", cnf, kw)
def current(self, index=None):
"""If index is supplied, sets the combobox value to the element
at position newIndex in the list of -values. Otherwise, returns
the index of the current value in the list of -values or -1 if
the current value does not appear in the list.
"""
return self.tk.call(self._w, "current", index)
class Entry(Widget, Tkinter.Entry):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::entry", cnf, kw)
def validate(self):
"""Force revalidation, independent of the conditions specified by
the -validate option. Returns 0 if the -validatecommand returns a
false value, or 1 if it returns a true value or is not specified.
"""
return self.tk.call(self._w, "validate")
class Label(Widget, Tkinter.Label):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::label", cnf, kw)
class Frame(Widget, Tkinter.Frame):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::frame", cnf, kw)
class Sizegrip(Widget):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::sizegrip", cnf, kw)
class LabelFrame(Widget, Tkinter.LabelFrame):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::labelframe", cnf, kw)
class Menubutton(Widget, Tkinter.Menubutton):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::menubutton", cnf, kw)
class Scale(Widget, Tkinter.Scale):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::scale", cnf, kw)
class Notebook(Widget):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::notebook", cnf, kw)
def add(self, child, cnf=(), **kw):
"""Adds a new tab to the notebook. When the tab is selected, the
child window will be displayed. child must be a direct child of
the notebook window. See TAB OPTIONS for the list of available
options.
"""
return self.tk.call((self._w, "add", child) + self._options(cnf, kw))
def forget(self, index):
"""Removes the tab specified by index, unmaps and unmanages the
associated child window.
"""
return self.tk.call(self._w, "forget", index)
def index(self, index):
"""Returns the numeric index of the tab specified by index, or
the total number of tabs if index is the string "end".
"""
return self.tk.call(self._w, "index")
def select(self, index=None):
"""Selects the specified tab. The associated child pane will be
displayed, and the previously-selected pane (if different) is
unmapped. If tabid is omitted, returns the widget name of the
currently selected pane.
"""
return self.tk.call(self._w, "select", index)
def tab(self, index, **kw):
"""Query or modify the options of the specific tab. If no
-option is specified, returns a dictionary of the tab option
values. If one -option is specified, returns the value of tha
t option. Otherwise, sets the -options to the corresponding
values. See TAB OPTIONS for the available options.
"""
return self.tk.call((self._w, "tab", index) + self._options(kw))
def tabs(self):
"""Returns a list of all pane windows managed by the widget."""
return self.tk.call(self._w, "tabs")
def enableTraversal(self):
"""To enable keyboard traversal for a toplevel window containing a
notebook widget $nb, call:
ttk::notebook::enableTraversal $nb
This will extend the bindings for the toplevel widget containing the
notebook as follows:
* Control-Tab selects the tab following the currently selected one.
* Shift-Control-Tab selects the tab preceding the currently selected
one.
* Alt-K, where K is the mnemonic (underlined) character of any tab,
will select that tab.
Multiple notebooks in a single toplevel may be enabled for traversal,
including nested notebooks. However, notebook traversal only works
properly if all panes are direct children of the notebook."""
return self.tk.call("ttk::notebook::enableTraversal", self._w)
class Paned(Widget):
"""
WIDGET OPTIONS
Name Database name Database class
-orient orient Orient
Specifies the orientation of the window. If vertical, subpanes
are stacked top-to-bottom; if horizontal, subpanes are stacked
left-to-right.
PANE OPTIONS
The following options may be specified for each pane:
Name Database name Database class
-weight weight Weight
An integer specifying the relative stretchability of the pane.
When the paned window is resized, the extra space is added or
subracted to each pane proportionally to its -weight
"""
def __init__(self, master=None, cnf={}, **kw):
if 'orient' not in kw:
kw['orient'] = 'horizontal'
##Widget.__init__(self, master, "ttk::paned", cnf, kw)
Widget.__init__(self, master, "ttk::panedwindow", cnf, kw)
def add(self, subwindow, **kw):
"""Adds a new pane to the window. subwindow must be a direct child of
the paned window pathname. See PANE OPTIONS for the list of available
options.
"""
return self.tk.call((self._w, "add", subwindow) + self._options(kw))
def forget(self, pane):
"""Removes the specified subpane from the widget. pane is either an
integer index or the name of a managed subwindow.
"""
self.tk.call(self._w, "forget", pane)
def insert(self, pos, subwindow, **kw):
"""Inserts a pane at the specified position. pos is either the string
end, an integer index, or the name of a managed subwindow. If
subwindow is already managed by the paned window, moves it to the
specified position. See PANE OPTIONS for the list of available
options.
"""
return self.tk.call((self._w, "insert", pos, subwindow) + self._options(kw))
def pane(self, pane, **kw):
"""Query or modify the options of the specified pane, where pane is
either an integer index or the name of a managed subwindow. If no
-option is specified, returns a dictionary of the pane option values.
If one -option is specified, returns the value of that option.
Otherwise, sets the -options to the corresponding values.
"""
return self.tk.call((self._w, "pane", pane) + self._options(kw))
PanedWindow = Paned
class Progressbar(Widget):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::progressbar", cnf, kw)
def step(self, amount=1.0):
"""Increments the -value by amount. amount defaults to 1.0
if omitted.
"""
return self.tk.call(self._w, "step", amount)
def start(self, interval=None):
"""Begin autoincrement mode: schedules a recurring timer event that
calls step every interval milliseconds. If omitted, interval defaults
to 50 milliseconds (20 steps/second).
"""
self.tk.call("ttk::progressbar::start", self._w, interval)
def stop(self):
"""Stop autoincrement mode: cancels any recurring timer event
initiated by pathName start.
"""
self.tk.call("ttk::progressbar::stop", self._w)
class Radiobutton(Widget, Tkinter.Radiobutton):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::radiobutton", cnf, kw)
class Scrollbar(Widget, Tkinter.Scrollbar):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::scrollbar", cnf, kw)
class Separator(Widget):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, "ttk::separator", cnf, kw)
class Treeview(Widget, Tkinter.Listbox):
def __init__(self, master=None, cnf={}, **kw):
Widget.__init__(self, master, 'ttk::treeview', cnf, kw)
def children(self, item, newchildren=None):
"""If newchildren is not specified, returns the list of
children belonging to item.
If newchildren is specified, replaces item's child list
with newchildren. Items in the old child list not present
in the new child list are detached from the tree. None of
the items in newchildren may be an ancestor of item.
"""
return self.tk.call(self._w, "children", item, newchildren)
# Workaround: `children' overwrite in Tkinter.BaseWidget.__init__
child = children
tree_children = children
def column(self, column, **kw):
"""Query or modify the options for the specified column.
If no options are specified, returns a dictionary of
option/value pairs. If a single option is specified,
returns the value of that option. Otherwise, the options
are updated with the specified values. The following
options may be set on each column:
-id name
The column name. This is a read-only option. For example,
[$pathname column #n -id] returns the data column
associated with data column #n.
-anchor
Specifies how the text in this column should be aligned
with respect to the cell. One of n, ne, e, se, s, sw, w,
nw, or center.
-width w
The width of the column in pixels. Default is something
reasonable, probably 200 or so.
"""
return self.tk.call((self._w, 'column', column) + self._options(kw))
def delete(self, items):
"""Deletes each of the items and all of their descendants.
The root item may not be deleted. See also: detach.
"""
return self.tk.call(self._w, "delete", items)
def detach(self, items):
"""Unlinks all of the specified items from the tree. The
items and all of their descendants are still present and
may be reinserted at another point in the tree but will
not be displayed. The root item may not be detached. See
also: delete.
"""
return self.tk.call(self._w, "detach", items)
def exists(self, item):
"""Returns 1 if the specified item is present in the
tree, 0 otherwise.
"""
return self.tk.call(self._w, "exists", item)
def focus(self, item=None):
"""If item is specified, sets the focus item to item.
Otherwise, returns the current focus item, or {} if there
is none.
"""
return self.tk.call(self._w, "focus", item)
def heading(self, column, **kw):
"""Query or modify the heading options for the specified
column. Valid options are:
-text text
The text to display in the column heading.
-image imageName
Specifies an image to display to the right of the column heading.
-command script
A script to evaluate when the heading label is pressed.
"""
return self.tk.call((self._w, 'heading', column) + self._options(kw))
def identify(self, component, x, y):
"""Returns a description of the specified component under the point
given by x and y, or the empty string if no such component is
present at that position. The following subcommands are
supported:
pathname identify row x y
Returns the item ID of the item at position y.
pathname identify column x y
Returns the data column identifier of the cell at position x.
The tree column has ID #0.
See COLUMN IDENTIFIERS for a discussion of display columns and data
columns.
"""
return self.tk.call(self._w, "identify", component, x, y)
def identify_row(self, x, y):
return self.identify('row', x, y)
def identify_column(self, x, y):
return self.identify('column', x, y)
def index(self, item):
"""Returns the integer index of item within its parent's list of
children.
"""
return self.tk.call(self._w, "index", item)
def insert(self, parent, index, id=None, **kw):
"""Creates a new item. parent is the item ID of the parent item, or
the empty string {} to create a new top-level item. index is an
integer, or the value end, specifying where in the list of parent's
children to insert the new item. If index is less than or equal to
zero, the new node is inserted at the beginning; if index is greater
than or equal to the current number of children, it is inserted at the
end. If -id is specified, it is used as the item identifier; id must
not already exist in the tree. Otherwise, a new unique identifier is
generated.
returns the item identifier of the newly created item. See ITEM
OPTIONS for the list of available options.
"""
if not parent: parent = ''
args = (self._w, 'insert', parent, index)
if id: args = args + ('-id', id)
return self.tk.call(args + self._options(kw))
def item(self, item, **kw):
"""Query or modify the options for the specified item. If no -option
is specified, returns a dictionary of option/value pairs. If a single
-option is specified, returns the value of that option. Otherwise, the
item's options are updated with the specified values. See ITEM OPTIONS
for the list of available options.
"""
return self.tk.call((self._w, 'item') + self._options(kw))
def move(self, item, parent, index):
"""Moves item to position index in parent's list of children. It is
illegal to move an item under one of its descendants.
If index is less than or equal to zero, item is moved to the
beginning; if greater than or equal to the number of children, it's
moved to the end.
"""
return self.tk.call(self._w, 'move', item, parent, index)
def next(self, item):
"""Returns the identifier of item's next sibling, or {} if item is the
last child of its parent.
"""
return self.tk.call(self._w, 'next', item)
def parent(self, item):
"""Returns the ID of the parent of item, or {} if item is at the top
level of the hierarchy.
"""
return self.tk.call(self._w, 'parent', item)
def prev(self, item):
"""Returns the identifier of item's previous sibling, or {} if item is
the first child of its parent.
"""
return self.tk.call(self._w, 'prev', item)
def selection(self):
"""Returns the list of selected items."""
return self.tk.call(self._w, "selection")
def selection_set(self, items):
"""items becomes the new selection."""
return self.tk.call(self._w, "selection", "set", items)
def selection_add(self, items):
"""Add items to the selection."""
return self.tk.call(self._w, "selection", "add", items)
def selection_remove(self, items):
"""Remove items from the selection."""
return self.tk.call(self._w, "selection", "remove", items)
def selection_toggle(self, items):
"""Toggle the selection state of each item in items."""
return self.tk.call(self._w, "selection", "toggle", items)
def set(self, item, column, value=None):
"""If value is specified, sets the value of column column in item
item, otherwise returns the current value. See COLUMN IDENTIFIERS.
"""
raise NotImplementedError()
def test():
import sys
root = Tkinter.Tk()
initialize()
root.option_add('*Toolbar.relief', 'groove')
root.option_add('*Toolbar.borderWidth', 2)
root.option_add('*Toolbar.Button.Pad', 2)
base = Frame(root)
base.pack(expand=True, fill='both')
tb_frame = Frame(base, class_='Toolbar')
tb_frame.pack(side='top', expand=False, fill='x')
b = Button(tb_frame, text='Open', style='Toolbutton')
b.grid(row=0, column=0, sticky='news')
b = Button(tb_frame, text='Save', style='Toolbutton')
b.grid(row=0, column=1, sticky='news')
b = Checkbutton(tb_frame, text='Bold', style='Toolbutton')
b.grid(row=0, column=2, sticky='news')
b = Checkbutton(tb_frame, text='Italic', style='Toolbutton')
b.grid(row=0, column=3, sticky='news')
tb_frame.grid_columnconfigure(4, weight=1)
theme_frame = LabelFrame(base, text='Theme')
theme_frame.pack(side='left', expand=False, fill='y', padx=4, pady=4)
theme_var = Tkinter.StringVar()
theme_var.set('default')
for theme in availableThemes():
command = lambda theme=theme: setTheme(theme=theme)
b = Radiobutton(theme_frame, text=theme, variable=theme_var,
value=theme, command=command)
b.pack(side='top', expand=False, fill='x', padx=4)
right_frame = Frame(base)
right_frame.pack(side='right', expand=True, fill='both')
b = Checkbutton(right_frame, text='Checkbutton')
b.pack(expand=False, fill='x')
b = Button(right_frame, text='Button')
b.pack(expand=False, fill='x')
text_frame = Frame(right_frame)
text_frame.pack(expand=True, fill='both')
text = Tkinter.Text(text_frame, width=40, height=20,
fg='black', bg='white', wrap='none')
hsb = Scrollbar(text_frame, orient='horizontal', command=text.xview)
vsb = Scrollbar(text_frame, orient='vertical', command=text.yview)
text.grid(row=0, column=0, sticky='nwse')
hsb.grid(row=1, column=0, sticky='we')
vsb.grid(row=0, column=1, sticky='ns')
text.configure(xscrollcommand=hsb.set)
text.configure(yscrollcommand=vsb.set)
text.insert('end', open(sys.argv[0]).read())
grip = Sizegrip(text_frame)
grip.grid(row=1, column=1, sticky='se')
text_frame.grid_columnconfigure(0, weight=1)
text_frame.grid_rowconfigure(0, weight=1)
root.mainloop()
if __name__ == '__main__':
test()

View file

@ -23,7 +23,7 @@ __all__ = ['ColorsDialog']
# imports # imports
import Tkinter import Tkinter
import Tile import ttk
from tkColorChooser import askcolor from tkColorChooser import askcolor
# PySol imports # PySol imports
@ -43,7 +43,7 @@ class ColorsDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -75,13 +75,13 @@ class ColorsDialog(MfxDialog):
(_('Hint arrow:'), self.hintarrow_var), (_('Hint arrow:'), self.hintarrow_var),
(_('Highlight not matching:'), self.not_matching_var), (_('Highlight not matching:'), self.not_matching_var),
): ):
Tile.Label(frame, text=title, anchor='w', ttk.Label(frame, text=title, anchor='w',
).grid(row=row, column=0, sticky='we') ).grid(row=row, column=0, sticky='we')
l = Tkinter.Label(frame, width=10, height=2, l = Tkinter.Label(frame, width=10, height=2,
bg=var.get(), textvariable=var) bg=var.get(), textvariable=var)
l.grid(row=row, column=1, padx=5) l.grid(row=row, column=1, padx=5)
b = Tile.Button(frame, text=_('Change...'), width=10, b = ttk.Button(frame, text=_('Change...'), width=10,
command=lambda l=l: self.selectColor(l)) command=lambda l=l: self.selectColor(l))
b.grid(row=row, column=2) b.grid(row=row, column=2)
row += 1 row += 1
# #

View file

@ -37,7 +37,7 @@ __all__ = ['EditTextDialog']
# imports # imports
import Tkinter import Tkinter
import Tile import ttk
# PySol imports # PySol imports
from pysollib.mfxutil import KwStruct from pysollib.mfxutil import KwStruct
@ -61,7 +61,7 @@ class EditTextDialog(MfxDialog):
wrap="word", width=64, height=16) wrap="word", width=64, height=16)
self.text_w.pack(side='left', fill="both", expand=True) self.text_w.pack(side='left', fill="both", expand=True)
###self.text_w.pack(side='top', padx=kw.padx, pady=kw.pady) ###self.text_w.pack(side='top', padx=kw.padx, pady=kw.pady)
vbar = Tile.Scrollbar(top_frame) vbar = ttk.Scrollbar(top_frame)
vbar.pack(side='right', fill='y') vbar.pack(side='right', fill='y')
self.text_w["yscrollcommand"] = vbar.set self.text_w["yscrollcommand"] = vbar.set
vbar["command"] = self.text_w.yview vbar["command"] = self.text_w.yview

View file

@ -23,7 +23,7 @@ __all__ = ['FontsDialog']
# imports # imports
import Tkinter import Tkinter
import Tile import ttk
import tkFont import tkFont
# PySol imports # PySol imports
@ -79,28 +79,28 @@ class FontChooserDialog(MfxDialog):
self.size_var = Tkinter.IntVar() self.size_var = Tkinter.IntVar()
self.size_var.set(self.font_size) self.size_var.set(self.font_size)
# #
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
#frame.rowconfigure(1, weight=1) #frame.rowconfigure(1, weight=1)
self.entry = Tile.Entry(frame) self.entry = ttk.Entry(frame)
self.entry.grid(row=0, column=0, columnspan=2, sticky='news') self.entry.grid(row=0, column=0, columnspan=2, sticky='news')
self.entry.insert('end', _('abcdefghABCDEFGH')) self.entry.insert('end', _('abcdefghABCDEFGH'))
self.list_box = Tkinter.Listbox(frame, width=36, exportselection=False) self.list_box = Tkinter.Listbox(frame, width=36, exportselection=False)
sb = Tile.Scrollbar(frame) sb = ttk.Scrollbar(frame)
self.list_box.configure(yscrollcommand=sb.set) self.list_box.configure(yscrollcommand=sb.set)
sb.configure(command=self.list_box.yview) sb.configure(command=self.list_box.yview)
self.list_box.grid(row=1, column=0, sticky='news') # rowspan=4 self.list_box.grid(row=1, column=0, sticky='news') # rowspan=4
sb.grid(row=1, column=1, sticky='ns') sb.grid(row=1, column=1, sticky='ns')
bind(self.list_box, '<<ListboxSelect>>', self.fontupdate) bind(self.list_box, '<<ListboxSelect>>', self.fontupdate)
##self.list_box.focus() ##self.list_box.focus()
cb1 = Tile.Checkbutton(frame, text=_('Bold'), cb1 = ttk.Checkbutton(frame, text=_('Bold'),
command=self.fontupdate, command=self.fontupdate,
variable=self.weight_var) variable=self.weight_var)
cb1.grid(row=2, column=0, columnspan=2, sticky='we') cb1.grid(row=2, column=0, columnspan=2, sticky='we')
cb2 = Tile.Checkbutton(frame, text=_('Italic'), cb2 = ttk.Checkbutton(frame, text=_('Italic'),
command=self.fontupdate, command=self.fontupdate,
variable=self.slant_var) variable=self.slant_var)
cb2.grid(row=3, column=0, columnspan=2, sticky='we') cb2.grid(row=3, column=0, columnspan=2, sticky='we')
sc = PysolScale(frame, from_=6, to=40, resolution=1, sc = PysolScale(frame, from_=6, to=40, resolution=1,
@ -155,7 +155,7 @@ class FontsDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -172,16 +172,16 @@ class FontsDialog(MfxDialog):
): ):
font = app.opt.fonts[fn] font = app.opt.fonts[fn]
self.fonts[fn] = font self.fonts[fn] = font
Tile.Label(frame, text=title, anchor='w' ttk.Label(frame, text=title, anchor='w'
).grid(row=row, column=0, sticky='we') ).grid(row=row, column=0, sticky='we')
if font: if font:
title = ' '.join([str(i) for i in font if i not in ('roman', 'normal')]) title = ' '.join([str(i) for i in font if i not in ('roman', 'normal')])
elif font is None: elif font is None:
title = 'Default' title = 'Default'
l = Tile.Label(frame, font=font, text=title) l = ttk.Label(frame, font=font, text=title)
l.grid(row=row, column=1, padx=8) l.grid(row=row, column=1, padx=8)
b = Tile.Button(frame, text=_('Change...'), width=10, b = ttk.Button(frame, text=_('Change...'), width=10,
command=lambda l=l, fn=fn: self.selectFont(l, fn)) command=lambda l=l, fn=fn: self.selectFont(l, fn))
b.grid(row=row, column=2) b.grid(row=row, column=2)
row += 1 row += 1
# #

View file

@ -23,7 +23,7 @@
__all__ = ['GameInfoDialog'] __all__ = ['GameInfoDialog']
# imports # imports
import Tile import ttk
# PySol imports # PySol imports
from pysollib.mfxutil import KwStruct from pysollib.mfxutil import KwStruct
@ -43,7 +43,7 @@ class GameInfoDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -107,10 +107,10 @@ class GameInfoDialog(MfxDialog):
('Hint:', hint), ('Hint:', hint),
): ):
if t: if t:
Tile.Label(frame, text=n, anchor='w' ttk.Label(frame, text=n, anchor='w'
).grid(row=row, column=0, sticky='nw') ).grid(row=row, column=0, sticky='nw')
Tile.Label(frame, text=t, anchor='w', justify='left' ttk.Label(frame, text=t, anchor='w', justify='left'
).grid(row=row, column=1, sticky='nw') ).grid(row=row, column=1, sticky='nw')
row += 1 row += 1
if game.s.talon: if game.s.talon:
@ -133,8 +133,8 @@ class GameInfoDialog(MfxDialog):
self.mainloop(focus, kw.timeout) self.mainloop(focus, kw.timeout)
def showStacks(self, frame, row, title, stacks): def showStacks(self, frame, row, title, stacks):
Tile.Label(frame, text=title, anchor='w' ttk.Label(frame, text=title, anchor='w'
).grid(row=row, column=0, sticky='nw') ).grid(row=row, column=0, sticky='nw')
if isinstance(stacks, (list, tuple)): if isinstance(stacks, (list, tuple)):
fs = {} fs = {}
for f in stacks: for f in stacks:
@ -146,8 +146,8 @@ class GameInfoDialog(MfxDialog):
t = '\n'.join(['%s (%d)' % (i[0], i[1]) for i in fs.items()]) t = '\n'.join(['%s (%d)' % (i[0], i[1]) for i in fs.items()])
else: else:
t = stacks.__class__.__name__ t = stacks.__class__.__name__
Tile.Label(frame, text=t, anchor='w', justify='left' ttk.Label(frame, text=t, anchor='w', justify='left'
).grid(row=row, column=1, sticky='nw') ).grid(row=row, column=1, sticky='nw')
def initKw(self, kw): def initKw(self, kw):
kw = KwStruct(kw, kw = KwStruct(kw,

View file

@ -38,8 +38,8 @@ __all__ = ['PysolMenubarTk']
# imports # imports
import math, os, sys, re, traceback import math, os, sys, re, traceback
import Tile
import Tkinter import Tkinter
import ttk
import tkFileDialog import tkFileDialog
# PySol imports # PySol imports
@ -1351,7 +1351,7 @@ the next time you restart """)+TITLE,
def createThemesMenu(self, menu): def createThemesMenu(self, menu):
submenu = MfxMenu(menu, label=n_("Set t&heme")) submenu = MfxMenu(menu, label=n_("Set t&heme"))
all_themes = list(Tile.availableThemes()) all_themes = list(ttk.Style(self.top).theme_names())
all_themes.sort() all_themes.sort()
# #
tn = { tn = {

View file

@ -37,7 +37,7 @@ __all__ = ['PlayerOptionsDialog']
# imports # imports
import Tkinter import Tkinter
import Tile import ttk
# PySol imports # PySol imports
from pysollib.mfxutil import KwStruct from pysollib.mfxutil import KwStruct
@ -65,25 +65,25 @@ class PlayerOptionsDialog(MfxDialog):
self.win_animation_var = Tkinter.BooleanVar() self.win_animation_var = Tkinter.BooleanVar()
self.win_animation_var.set(app.opt.win_animation != 0) self.win_animation_var.set(app.opt.win_animation != 0)
# #
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
widget = Tile.Label(frame, text=_("\nPlease enter your name"), widget = ttk.Label(frame, text=_("\nPlease enter your name"),
takefocus=0) takefocus=0)
widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5) widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
# #
w = kw.get("e_width", 30) # width in characters w = kw.get("e_width", 30) # width in characters
names = self.app.getAllUserNames() names = self.app.getAllUserNames()
self.player_var = Tile.Combobox(frame, width=w, values=tuple(names)) self.player_var = ttk.Combobox(frame, width=w, values=tuple(names))
self.player_var.current(names.index(app.opt.player)) self.player_var.current(names.index(app.opt.player))
self.player_var.grid(row=1, column=0, sticky='ew', padx=0, pady=5) self.player_var.grid(row=1, column=0, sticky='ew', padx=0, pady=5)
# #
widget = Tile.Checkbutton(frame, variable=self.confirm_var, widget = ttk.Checkbutton(frame, variable=self.confirm_var,
text=_("Confirm quit")) text=_("Confirm quit"))
widget.grid(row=2, column=0, columnspan=2, sticky='ew', padx=0, pady=5) widget.grid(row=2, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
widget = Tile.Checkbutton(frame, variable=self.update_stats_var, widget = ttk.Checkbutton(frame, variable=self.update_stats_var,
text=_("Update statistics and logs")) text=_("Update statistics and logs"))
widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5) widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
### widget = Tile.Checkbutton(frame, variable=self.win_animation_var, ### widget = ttk.Checkbutton(frame, variable=self.win_animation_var,
### text="Win animation") ### text="Win animation")
### widget.pack(side='top', padx=kw.padx, pady=kw.pady) ### widget.pack(side='top', padx=kw.padx, pady=kw.pady)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)

View file

@ -37,7 +37,7 @@ __all__ = ['PysolProgressBar']
# imports # imports
import Tkinter import Tkinter
import Tile import ttk
# Toolkit imports # Toolkit imports
from tkconst import EVENT_HANDLED from tkconst import EVENT_HANDLED
@ -59,15 +59,15 @@ class PysolProgressBar:
self.top.wm_resizable(False, False) self.top.wm_resizable(False, False)
self.top.config(cursor="watch") self.top.config(cursor="watch")
# #
self.frame = Tile.Frame(self.top, relief='flat', borderwidth=0) self.frame = ttk.Frame(self.top, relief='flat', borderwidth=0)
self.progress = Tile.Progressbar(self.frame, maximum=100, length=250) self.progress = ttk.Progressbar(self.frame, maximum=100, length=250)
##style = Tile.Style(self.progress) ##style = ttk.Style(self.progress)
##style.configure('TProgressbar', background=color) ##style.configure('TProgressbar', background=color)
if images: if images:
self.f1 = Tile.Label(self.frame, image=images[0]) self.f1 = ttk.Label(self.frame, image=images[0])
self.f1.pack(side='left', ipadx=8, ipady=4) self.f1.pack(side='left', ipadx=8, ipady=4)
self.progress.pack(side='left', expand=True, fill='x') self.progress.pack(side='left', expand=True, fill='x')
self.f2 = Tile.Label(self.frame, image=images[1]) self.f2 = ttk.Label(self.frame, image=images[1])
self.f2.pack(side='left', ipadx=8, ipady=4) self.f2.pack(side='left', ipadx=8, ipady=4)
else: else:
self.progress.pack(expand=True, fill='x') self.progress.pack(expand=True, fill='x')

View file

@ -38,7 +38,7 @@ __all__ = ['SelectCardsetDialogWithPreview']
# imports # imports
import os import os
import Tkinter import Tkinter
import Tile import ttk
# PySol imports # PySol imports
from pysollib.mfxutil import KwStruct from pysollib.mfxutil import KwStruct
@ -201,10 +201,10 @@ class SelectCardsetDialogWithPreview(MfxDialog):
w1, w2 = 216, 400 w1, w2 = 216, 400
else: else:
w1, w2 = 200, 300 w1, w2 = 200, 300
paned_window = Tile.PanedWindow(top_frame) paned_window = ttk.PanedWindow(top_frame, orient='horizontal')
paned_window.pack(expand=True, fill='both') paned_window.pack(expand=True, fill='both')
left_frame = Tile.Frame(paned_window) left_frame = ttk.Frame(paned_window)
right_frame = Tile.Frame(paned_window) right_frame = ttk.Frame(paned_window)
paned_window.add(left_frame) paned_window.add(left_frame)
paned_window.add(right_frame) paned_window.add(right_frame)
font = app.getFont("default") font = app.getFont("default")
@ -308,11 +308,11 @@ class CardsetInfoDialog(MfxDialog):
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default) MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(fill="both", expand=True, padx=5, pady=10) frame.pack(fill="both", expand=True, padx=5, pady=10)
# #
# #
info_frame = Tile.LabelFrame(frame, text=_('About cardset')) info_frame = ttk.LabelFrame(frame, text=_('About cardset'))
info_frame.grid(row=0, column=0, columnspan=2, sticky='ew', info_frame.grid(row=0, column=0, columnspan=2, sticky='ew',
padx=0, pady=5, ipadx=5, ipady=5) padx=0, pady=5, ipadx=5, ipady=5)
styles = nationalities = year = None styles = nationalities = year = None
@ -334,11 +334,11 @@ class CardsetInfoDialog(MfxDialog):
(_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)), (_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)),
): ):
if t is not None: if t is not None:
l = Tile.Label(info_frame, text=n, l = ttk.Label(info_frame, text=n,
anchor='w', justify='left') anchor='w', justify='left')
l.grid(row=row, column=0, sticky='nw', padx=4) l.grid(row=row, column=0, sticky='nw', padx=4)
l = Tile.Label(info_frame, text=t, l = ttk.Label(info_frame, text=t,
anchor='w', justify='left') anchor='w', justify='left')
l.grid(row=row, column=1, sticky='nw', padx=4) l.grid(row=row, column=1, sticky='nw', padx=4)
row += 1 row += 1
if images: if images:
@ -347,10 +347,10 @@ class CardsetInfoDialog(MfxDialog):
im = choice(images) im = choice(images)
f = os.path.join(cardset.dir, cardset.backname) f = os.path.join(cardset.dir, cardset.backname)
self.back_image = loadImage(file=f) # store the image self.back_image = loadImage(file=f) # store the image
l = Tile.Label(info_frame, image=im, padding=5) l = ttk.Label(info_frame, image=im, padding=5)
l.grid(row=0, column=2, rowspan=row+1, sticky='ne') l.grid(row=0, column=2, rowspan=row+1, sticky='ne')
l = Tile.Label(info_frame, image=self.back_image, l = ttk.Label(info_frame, image=self.back_image,
padding=(0,5,5,5)) # left margin = 0 padding=(0,5,5,5)) # left margin = 0
l.grid(row=0, column=3, rowspan=row+1, sticky='ne') l.grid(row=0, column=3, rowspan=row+1, sticky='ne')
info_frame.columnconfigure(2, weight=1) info_frame.columnconfigure(2, weight=1)
@ -362,7 +362,7 @@ class CardsetInfoDialog(MfxDialog):
text_w = Tkinter.Text(frame, bd=1, relief="sunken", wrap="word", text_w = Tkinter.Text(frame, bd=1, relief="sunken", wrap="word",
padx=4, width=64, height=16, bg=bg) padx=4, width=64, height=16, bg=bg)
text_w.grid(row=1, column=0, sticky='nsew') text_w.grid(row=1, column=0, sticky='nsew')
sb = Tile.Scrollbar(frame) sb = ttk.Scrollbar(frame)
sb.grid(row=1, column=1, sticky='ns') sb.grid(row=1, column=1, sticky='ns')
text_w.configure(yscrollcommand=sb.set) text_w.configure(yscrollcommand=sb.set)
sb.configure(command=text_w.yview) sb.configure(command=text_w.yview)

View file

@ -36,7 +36,7 @@
# imports # imports
import os import os
import Tile import ttk
from UserList import UserList from UserList import UserList
# PySol imports # PySol imports
@ -363,10 +363,10 @@ class SelectGameDialogWithPreview(SelectGameDialog):
#padx, pady = kw.padx/2, kw.pady/2 #padx, pady = kw.padx/2, kw.pady/2
padx, pady = 4, 4 padx, pady = 4, 4
# PanedWindow # PanedWindow
paned_window = Tile.PanedWindow(top_frame) paned_window = ttk.PanedWindow(top_frame, orient='horizontal')
paned_window.pack(expand=True, fill='both', padx=8, pady=8) paned_window.pack(expand=True, fill='both', padx=8, pady=8)
left_frame = Tile.Frame(paned_window) left_frame = ttk.Frame(paned_window)
right_frame = Tile.Frame(paned_window) right_frame = ttk.Frame(paned_window)
paned_window.add(left_frame) paned_window.add(left_frame)
paned_window.add(right_frame) paned_window.add(right_frame)
# Tree # Tree
@ -375,10 +375,10 @@ class SelectGameDialogWithPreview(SelectGameDialog):
default=kw.default, font=font, width=w1) default=kw.default, font=font, width=w1)
self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both') self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')
# LabelFrame # LabelFrame
info_frame = Tile.LabelFrame(right_frame, text=_('About game')) info_frame = ttk.LabelFrame(right_frame, text=_('About game'))
info_frame.grid(row=0, column=0, padx=padx, pady=pady, info_frame.grid(row=0, column=0, padx=padx, pady=pady,
ipadx=4, ipady=4, sticky='nws') ipadx=4, ipady=4, sticky='nws')
stats_frame = Tile.LabelFrame(right_frame, text=_('Statistics')) stats_frame = ttk.LabelFrame(right_frame, text=_('Statistics'))
stats_frame.grid(row=0, column=1, padx=padx, pady=pady, stats_frame.grid(row=0, column=1, padx=padx, pady=pady,
ipadx=4, ipady=4, sticky='nws') ipadx=4, ipady=4, sticky='nws')
# Info # Info
@ -400,9 +400,9 @@ class SelectGameDialogWithPreview(SelectGameDialog):
('moves', _('Moves:'), stats_frame, 4), ('moves', _('Moves:'), stats_frame, 4),
('percent', _('% won:'), stats_frame, 5), ('percent', _('% won:'), stats_frame, 5),
): ):
title_label = Tile.Label(f, text=t, justify='left', anchor='w') title_label = ttk.Label(f, text=t, justify='left', anchor='w')
title_label.grid(row=row, column=0, sticky='nw', padx=4) title_label.grid(row=row, column=0, sticky='nw', padx=4)
text_label = Tile.Label(f, justify='left', anchor='w') text_label = ttk.Label(f, justify='left', anchor='w')
text_label.grid(row=row, column=1, sticky='nw', padx=4) text_label.grid(row=row, column=1, sticky='nw', padx=4)
self.info_labels[n] = (title_label, text_label) self.info_labels[n] = (title_label, text_label)
##info_frame.columnconfigure(1, weight=1) ##info_frame.columnconfigure(1, weight=1)

View file

@ -36,7 +36,7 @@
# imports # imports
import Tkinter import Tkinter
import Tile import ttk
import tkColorChooser import tkColorChooser
# PySol imports # PySol imports
@ -131,7 +131,7 @@ class SelectTileDialogWithPreview(MfxDialog):
w1, w2 = 200, 300 w1, w2 = 200, 300
font = app.getFont("default") font = app.getFont("default")
padx, pady = 4, 4 padx, pady = 4, 4
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(fill='both', expand=True, frame.pack(fill='both', expand=True,
padx=kw.padx-padx, pady=kw.pady-pady) padx=kw.padx-padx, pady=kw.pady-pady)
self.tree = self.Tree_Class(self, frame, key=key, default=kw.default, self.tree = self.Tree_Class(self, frame, key=key, default=kw.default,

View file

@ -29,7 +29,7 @@ __all__ = [
# imports # imports
import Tkinter import Tkinter
import Tile import ttk
# PySol imports # PySol imports
from pysollib.settings import TITLE from pysollib.settings import TITLE
@ -66,14 +66,14 @@ class SolverDialog(MfxDialog):
self.games = {} # key: gamename; value: gameid self.games = {} # key: gamename; value: gameid
# #
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=4, pady=4) frame.pack(expand=True, fill='both', padx=4, pady=4)
frame.columnconfigure(1, weight=1) frame.columnconfigure(1, weight=1)
# #
row = 0 row = 0
Tile.Label(frame, text=_('Game:'), anchor='w' ttk.Label(frame, text=_('Game:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2) ).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
games = app.getGamesForSolver() games = app.getGamesForSolver()
gamenames = [''] gamenames = ['']
for id in games: for id in games:
@ -90,8 +90,8 @@ class SolverDialog(MfxDialog):
# #
row += 1 row += 1
Tile.Label(frame, text=_('Solving method:'), anchor='w' ttk.Label(frame, text=_('Solving method:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2) ).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
##sm = self.solving_methods.values() ##sm = self.solving_methods.values()
##sm.sort() ##sm.sort()
sm = ['A*', sm = ['A*',
@ -107,8 +107,8 @@ class SolverDialog(MfxDialog):
# #
row += 1 row += 1
Tile.Label(frame, text=_('Preset:'), anchor='w' ttk.Label(frame, text=_('Preset:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2) ).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
presets = [ presets = [
'none', 'none',
'abra-kadabra', 'abra-kadabra',
@ -131,8 +131,8 @@ class SolverDialog(MfxDialog):
row += 1 row += 1
self.max_iters_var = Tkinter.IntVar() self.max_iters_var = Tkinter.IntVar()
self.max_iters_var.set(10e4) self.max_iters_var.set(10e4)
Tile.Label(frame, text=_('Max iterations:'), anchor='w' ttk.Label(frame, text=_('Max iterations:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2) ).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
spin = Tkinter.Spinbox(frame, bg='white', from_=1000, to=10e6, spin = Tkinter.Spinbox(frame, bg='white', from_=1000, to=10e6,
increment=1000, textvariable=self.max_iters_var) increment=1000, textvariable=self.max_iters_var)
spin.grid(row=row, column=1, sticky='w', padx=2, pady=2) spin.grid(row=row, column=1, sticky='w', padx=2, pady=2)
@ -141,8 +141,8 @@ class SolverDialog(MfxDialog):
row += 1 row += 1
self.max_depth_var = Tkinter.IntVar() self.max_depth_var = Tkinter.IntVar()
self.max_depth_var.set(1000) self.max_depth_var.set(1000)
Tile.Label(frame, text=_('Max depth:'), anchor='w' ttk.Label(frame, text=_('Max depth:'), anchor='w'
).grid(row=row, column=0, sticky='ew', padx=2, pady=2) ).grid(row=row, column=0, sticky='ew', padx=2, pady=2)
spin = Tkinter.Spinbox(frame, bg='white', from_=100, to=10000, spin = Tkinter.Spinbox(frame, bg='white', from_=100, to=10000,
increment=100, textvariable=self.max_depth_var) increment=100, textvariable=self.max_depth_var)
spin.grid(row=row, column=1, sticky='w', padx=2, pady=2) spin.grid(row=row, column=1, sticky='w', padx=2, pady=2)
@ -151,38 +151,38 @@ class SolverDialog(MfxDialog):
row += 1 row += 1
self.progress_var = Tkinter.BooleanVar() self.progress_var = Tkinter.BooleanVar()
self.progress_var.set(True) self.progress_var.set(True)
w = Tile.Checkbutton(frame, variable=self.progress_var, w = ttk.Checkbutton(frame, variable=self.progress_var,
text=_('Show progress')) text=_('Show progress'))
w.grid(row=row, column=0, columnspan=2, sticky='ew', padx=2, pady=2) w.grid(row=row, column=0, columnspan=2, sticky='ew', padx=2, pady=2)
# #
label_frame = Tile.LabelFrame(top_frame, text=_('Progress')) label_frame = ttk.LabelFrame(top_frame, text=_('Progress'))
label_frame.pack(expand=True, fill='both', padx=6, pady=2) label_frame.pack(expand=True, fill='both', padx=6, pady=2)
#label_frame.columnconfigure(0, weight=1) #label_frame.columnconfigure(0, weight=1)
label_frame.columnconfigure(1, weight=1) label_frame.columnconfigure(1, weight=1)
# #
frow = 0 frow = 0
Tile.Label(label_frame, text=_('Iteration:'), anchor='w' ttk.Label(label_frame, text=_('Iteration:'), anchor='w'
).grid(row=frow, column=0, sticky='ew', padx=4, pady=2) ).grid(row=frow, column=0, sticky='ew', padx=4, pady=2)
lb = Tile.Label(label_frame, anchor='w') lb = ttk.Label(label_frame, anchor='w')
lb.grid(row=frow, column=1, sticky='ew', padx=4, pady=2) lb.grid(row=frow, column=1, sticky='ew', padx=4, pady=2)
self.iter_label = lb self.iter_label = lb
frow += 1 frow += 1
Tile.Label(label_frame, text=_('Depth:'), anchor='w' ttk.Label(label_frame, text=_('Depth:'), anchor='w'
).grid(row=frow, column=0, sticky='ew', padx=4, pady=2) ).grid(row=frow, column=0, sticky='ew', padx=4, pady=2)
lb = Tile.Label(label_frame, anchor='w') lb = ttk.Label(label_frame, anchor='w')
lb.grid(row=frow, column=1, sticky='ew', padx=4, pady=2) lb.grid(row=frow, column=1, sticky='ew', padx=4, pady=2)
self.depth_label = lb self.depth_label = lb
frow += 1 frow += 1
Tile.Label(label_frame, text=_('Stored-States:'), anchor='w' ttk.Label(label_frame, text=_('Stored-States:'), anchor='w'
).grid(row=frow, column=0, sticky='ew', padx=4, pady=2) ).grid(row=frow, column=0, sticky='ew', padx=4, pady=2)
lb = Tile.Label(label_frame, anchor='w') lb = ttk.Label(label_frame, anchor='w')
lb.grid(row=frow, column=1, sticky='ew', padx=4, pady=2) lb.grid(row=frow, column=1, sticky='ew', padx=4, pady=2)
self.states_label = lb self.states_label = lb
# #
lb = Tile.Label(top_frame, anchor='w') lb = ttk.Label(top_frame, anchor='w')
lb.pack(expand=True, fill='x', padx=6, pady=4) lb.pack(expand=True, fill='x', padx=6, pady=4)
self.result_label = lb self.result_label = lb

View file

@ -38,7 +38,7 @@ __all__ = ['SoundOptionsDialog']
# imports # imports
import os import os
import Tkinter import Tkinter
import Tile import ttk
# PySol imports # PySol imports
from pysollib.mfxutil import KwStruct from pysollib.mfxutil import KwStruct
@ -104,34 +104,34 @@ class SoundOptionsDialog(MfxDialog):
] ]
# #
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=5) frame.pack(expand=True, fill='both', padx=5, pady=5)
frame.columnconfigure(1, weight=1) frame.columnconfigure(1, weight=1)
# #
row = 0 row = 0
w = Tile.Checkbutton(frame, variable=self.sound, w = ttk.Checkbutton(frame, variable=self.sound,
text=_("Sound enabled")) text=_("Sound enabled"))
w.grid(row=row, column=0, columnspan=2, sticky='ew') w.grid(row=row, column=0, columnspan=2, sticky='ew')
# #
if os.name == "nt" and pysolsoundserver: if os.name == "nt" and pysolsoundserver:
row += 1 row += 1
w = Tile.Checkbutton(frame, variable=self.sound_mode, w = ttk.Checkbutton(frame, variable=self.sound_mode,
text=_("Use DirectX for sound playing"), text=_("Use DirectX for sound playing"),
command=self.mOptSoundDirectX) command=self.mOptSoundDirectX)
w.grid(row=row, column=0, columnspan=2, sticky='ew') w.grid(row=row, column=0, columnspan=2, sticky='ew')
# #
if app.audio.CAN_PLAY_MUSIC: # and app.startup_opt.sound_mode > 0: if app.audio.CAN_PLAY_MUSIC: # and app.startup_opt.sound_mode > 0:
row += 1 row += 1
Tile.Label(frame, text=_('Sample volume:'), anchor='w' ttk.Label(frame, text=_('Sample volume:'), anchor='w'
).grid(row=row, column=0, sticky='ew') ).grid(row=row, column=0, sticky='ew')
w = PysolScale(frame, from_=0, to=128, resolution=1, w = PysolScale(frame, from_=0, to=128, resolution=1,
orient='horizontal', takefocus=0, orient='horizontal', takefocus=0,
length="3i", #label=_('Sample volume'), length="3i", #label=_('Sample volume'),
variable=self.sample_volume) variable=self.sample_volume)
w.grid(row=row, column=1, sticky='w', padx=5) w.grid(row=row, column=1, sticky='w', padx=5)
row += 1 row += 1
Tile.Label(frame, text=_('Music volume:'), anchor='w' ttk.Label(frame, text=_('Music volume:'), anchor='w'
).grid(row=row, column=0, sticky='ew') ).grid(row=row, column=0, sticky='ew')
w = PysolScale(frame, from_=0, to=128, resolution=1, w = PysolScale(frame, from_=0, to=128, resolution=1,
orient='horizontal', takefocus=0, orient='horizontal', takefocus=0,
length="3i", #label=_('Music volume'), length="3i", #label=_('Music volume'),
@ -142,7 +142,7 @@ class SoundOptionsDialog(MfxDialog):
# remove "Apply" button # remove "Apply" button
kw.strings[1] = None kw.strings[1] = None
# #
frame = Tile.LabelFrame(top_frame, text=_('Enable samples')) frame = ttk.LabelFrame(top_frame, text=_('Enable samples'))
frame.pack(expand=True, fill='both', padx=5, pady=5) frame.pack(expand=True, fill='both', padx=5, pady=5)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
frame.columnconfigure(1, weight=1) frame.columnconfigure(1, weight=1)
@ -151,7 +151,7 @@ class SoundOptionsDialog(MfxDialog):
col = 0 col = 0
for n, t, v in self.samples: for n, t, v in self.samples:
v.set(app.opt.sound_samples[n]) v.set(app.opt.sound_samples[n])
w = Tile.Checkbutton(frame, text=t, variable=v) w = ttk.Checkbutton(frame, text=t, variable=v)
w.grid(row=row, column=col, sticky='ew', padx=3, pady=1) w.grid(row=row, column=col, sticky='ew', padx=3, pady=1)
if col == 1: if col == 1:
col = 0 col = 0

View file

@ -39,7 +39,7 @@ __all__ = ['PysolStatusbar',
# imports # imports
import os, sys import os, sys
import Tkinter import Tkinter
import Tile import ttk
if __name__ == '__main__': if __name__ == '__main__':
d = os.path.abspath(os.path.join(sys.path[0], os.pardir, os.pardir)) d = os.path.abspath(os.path.join(sys.path[0], os.pardir, os.pardir))
@ -70,15 +70,15 @@ class MfxStatusbar:
# #
self.padx = 1 self.padx = 1
self.label_relief = 'sunken' self.label_relief = 'sunken'
self.top_frame = Tile.Frame(self.top) self.top_frame = ttk.Frame(self.top)
self.top_frame.grid(row=self._row, column=self._column, self.top_frame.grid(row=self._row, column=self._column,
columnspan=self._columnspan, sticky='ew') columnspan=self._columnspan, sticky='ew')
self.frame = Tile.Frame(self.top_frame) self.frame = ttk.Frame(self.top_frame)
self.frame.pack(side='left', expand=True, fill='both', padx=0, pady=1) self.frame.pack(side='left', expand=True, fill='both', padx=0, pady=1)
# util # util
def _createLabel(self, name, expand=False, width=0, tooltip=None): def _createLabel(self, name, expand=False, width=0, tooltip=None):
frame = Tile.Frame(self.frame, borderwidth=1, relief=self.label_relief) frame = ttk.Frame(self.frame, borderwidth=1, relief=self.label_relief)
frame.grid(row=0, column=self._label_column, frame.grid(row=0, column=self._label_column,
sticky='nsew', padx=self.padx) sticky='nsew', padx=self.padx)
if expand: if expand:
@ -87,7 +87,7 @@ class MfxStatusbar:
self._label_column += 1 self._label_column += 1
setattr(self, name + '_frame', frame) setattr(self, name + '_frame', frame)
self._widgets.append(frame) self._widgets.append(frame)
label = Tile.Label(frame, width=width, anchor='center') label = ttk.Label(frame, width=width, anchor='center')
label.pack(expand=True, fill='both') label.pack(expand=True, fill='both')
setattr(self, name + '_label', label) setattr(self, name + '_label', label)
self._widgets.append(label) self._widgets.append(label)
@ -98,7 +98,7 @@ class MfxStatusbar:
return label return label
def _createSizegrip(self): def _createSizegrip(self):
sg = Tile.Sizegrip(self.top_frame) sg = ttk.Sizegrip(self.top_frame)
sg.pack(side='right', anchor='se') sg.pack(side='right', anchor='se')

View file

@ -23,7 +23,7 @@ __all__ = ['TimeoutsDialog']
# imports # imports
import Tkinter import Tkinter
import Tile import ttk
# PySol imports # PySol imports
from pysollib.mfxutil import KwStruct from pysollib.mfxutil import KwStruct
@ -43,7 +43,7 @@ class TimeoutsDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
#self.createBitmaps(top_frame, kw) #self.createBitmaps(top_frame, kw)
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -60,7 +60,7 @@ class TimeoutsDialog(MfxDialog):
self.highlight_samerank_sleep_var = Tkinter.DoubleVar() self.highlight_samerank_sleep_var = Tkinter.DoubleVar()
self.highlight_samerank_sleep_var.set(app.opt.timeouts['highlight_samerank']) self.highlight_samerank_sleep_var.set(app.opt.timeouts['highlight_samerank'])
# #
lframe = Tile.LabelFrame(frame, text=_('Set delays in seconds'), lframe = ttk.LabelFrame(frame, text=_('Set delays in seconds'),
padding=(10, 5)) padding=(10, 5))
lframe.pack(expand=True, fill='both', padx=4) lframe.pack(expand=True, fill='both', padx=4)
row = 0 row = 0
@ -72,7 +72,7 @@ class TimeoutsDialog(MfxDialog):
(_('Highlight cards:'), self.highlight_cards_sleep_var), (_('Highlight cards:'), self.highlight_cards_sleep_var),
(_('Highlight same rank:'), self.highlight_samerank_sleep_var), (_('Highlight same rank:'), self.highlight_samerank_sleep_var),
): ):
Tile.Label(lframe, text=title, anchor='w' ttk.Label(lframe, text=title, anchor='w'
).grid(row=row, column=0, sticky='we') ).grid(row=row, column=0, sticky='we')
widget = PysolScale(lframe, from_=0.2, to=9.9, value=var.get(), widget = PysolScale(lframe, from_=0.2, to=9.9, value=var.get(),
resolution=0.1, orient='horizontal', resolution=0.1, orient='horizontal',

View file

@ -39,7 +39,7 @@ __all__ = ['HTMLViewer']
import os, sys import os, sys
import htmllib, formatter import htmllib, formatter
import Tkinter import Tkinter
import Tile import ttk
if __name__ == '__main__': if __name__ == '__main__':
d = os.path.abspath(os.path.join(sys.path[0], '..', '..')) d = os.path.abspath(os.path.join(sys.path[0], '..', '..'))
@ -248,34 +248,34 @@ class HTMLViewer:
##self.defcursor = 'xterm' ##self.defcursor = 'xterm'
self.handcursor = "hand2" self.handcursor = "hand2"
frame = Tile.Frame(parent, width=640, height=440) frame = ttk.Frame(parent, width=640, height=440)
frame.pack(expand=True, fill='both') frame.pack(expand=True, fill='both')
frame.grid_propagate(False) frame.grid_propagate(False)
# create buttons # create buttons
button_width = 8 button_width = 8
self.homeButton = Tile.Button(frame, text=_("Index"), self.homeButton = ttk.Button(frame, text=_("Index"),
width=button_width, width=button_width,
command=self.goHome) command=self.goHome)
self.homeButton.grid(row=0, column=0, sticky='w') self.homeButton.grid(row=0, column=0, sticky='w')
self.backButton = Tile.Button(frame, text=_("Back"), self.backButton = ttk.Button(frame, text=_("Back"),
width=button_width, width=button_width,
command=self.goBack) command=self.goBack)
self.backButton.grid(row=0, column=1, sticky='w') self.backButton.grid(row=0, column=1, sticky='w')
self.forwardButton = Tile.Button(frame, text=_("Forward"), self.forwardButton = ttk.Button(frame, text=_("Forward"),
width=button_width, width=button_width,
command=self.goForward) command=self.goForward)
self.forwardButton.grid(row=0, column=2, sticky='w') self.forwardButton.grid(row=0, column=2, sticky='w')
self.closeButton = Tile.Button(frame, text=_("Close"), self.closeButton = ttk.Button(frame, text=_("Close"),
width=button_width, width=button_width,
command=self.destroy) command=self.destroy)
self.closeButton.grid(row=0, column=3, sticky='e') self.closeButton.grid(row=0, column=3, sticky='e')
# create text widget # create text widget
text_frame = Tile.Frame(frame) text_frame = ttk.Frame(frame)
text_frame.grid(row=1, column=0, columnspan=4, text_frame.grid(row=1, column=0, columnspan=4,
sticky='nsew', padx=1, pady=1) sticky='nsew', padx=1, pady=1)
vbar = Tile.Scrollbar(text_frame) vbar = ttk.Scrollbar(text_frame)
vbar.pack(side='right', fill='y') vbar.pack(side='right', fill='y')
self.text = Tkinter.Text(text_frame, self.text = Tkinter.Text(text_frame,
fg='black', bg='white', fg='black', bg='white',

View file

@ -46,7 +46,7 @@ __all__ = ['SingleGame_StatsDialog',
import os import os
import time import time
import Tkinter import Tkinter
import Tile import ttk
import tkFont import tkFont
# PySol imports # PySol imports
@ -77,14 +77,14 @@ class StatsDialog(MfxDialog):
self.font = app.getFont('default') self.font = app.getFont('default')
self.tkfont = tkFont.Font(parent, self.font) self.tkfont = tkFont.Font(parent, self.font)
self.font_metrics = self.tkfont.metrics() self.font_metrics = self.tkfont.metrics()
style = Tile.Style() style = ttk.Style(parent)
heading_font = style.lookup('Heading', 'font') # treeview heading heading_font = style.lookup('Heading', 'font') # treeview heading
self.heading_tkfont = tkFont.Font(parent, heading_font) self.heading_tkfont = tkFont.Font(parent, heading_font)
self.selected_game = None self.selected_game = None
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
notebook = Tile.Notebook(top_frame) notebook = ttk.Notebook(top_frame)
notebook.pack(expand=True, fill='both', padx=10, pady=10) notebook.pack(expand=True, fill='both', padx=10, pady=10)
self.notebook_tabs = [] self.notebook_tabs = []
@ -167,20 +167,21 @@ SingleGame_StatsDialog = AllGames_StatsDialog = Top_StatsDialog = ProgressionDia
# // # //
# ************************************************************************/ # ************************************************************************/
class SingleGameFrame(Tile.Frame): class SingleGameFrame(ttk.Frame):
def __init__(self, dialog, parent, app, player, gameid, **kw): def __init__(self, dialog, parent, app, player, gameid, **kw):
Tile.Frame.__init__(self, parent) ttk.Frame.__init__(self, parent)
self.oval_width = 120 self.oval_width = 120
self.oval_height = 60 self.oval_height = 60
left_label = Tile.Label(self, image=app.gimages.logos[5]) left_label = ttk.Label(self, image=app.gimages.logos[5])
left_label.pack(side='left', expand=True, fill='both') left_label.pack(side='left', expand=True, fill='both')
self.right_frame = Tile.Frame(self) self.right_frame = ttk.Frame(self)
self.right_frame.pack(side='right', expand=True) self.right_frame.pack(side='right', expand=True)
self.dialog = dialog self.dialog = dialog
self.app = app self.app = app
self.parent = parent
self.player = player or _("Demo games") self.player = player or _("Demo games")
# #
self._calc_tabs() self._calc_tabs()
@ -232,9 +233,9 @@ class SingleGameFrame(Tile.Frame):
return pwon, plost return pwon, plost
def _createChartInit(self, text): def _createChartInit(self, text):
frame = Tile.LabelFrame(self.right_frame, text=text) frame = ttk.LabelFrame(self.right_frame, text=text)
frame.pack(side='top', fill='both', expand=False, padx=20, pady=10) frame.pack(side='top', fill='both', expand=False, padx=20, pady=10)
style = Tile.Style(self.right_frame) style = ttk.Style(self.parent)
fg = style.lookup('.', 'foreground') or None # use default if fg == '' fg = style.lookup('.', 'foreground') or None # use default if fg == ''
bg = style.lookup('.', 'background') or None bg = style.lookup('.', 'background') or None
self.fg = fg self.fg = fg
@ -383,14 +384,14 @@ class TreeFormatter(PysolStatsFormatter):
for result in self.getStatResults(player, sort_by): for result in self.getStatResults(player, sort_by):
# result == [name, won+lost, won, lost, time, moves, perc, id] # result == [name, won+lost, won, lost, time, moves, perc, id]
t1, t2, t3, t4, t5, t6, t7, t8 = result t1, t2, t3, t4, t5, t6, t7, t8 = result
id = self.tree.insert(None, "end", text=t1, id = self.tree.insert("", "end", text=t1,
values=(t2, t3, t4, t5, t6, t7)) values=(t2, t3, t4, t5, t6, t7))
self.parent_window.tree_items.append(id) self.parent_window.tree_items.append(id)
self.parent_window.games[id] = t8 self.parent_window.games[id] = t8
total, played, won, lost, time_, moves, perc = self.getStatSummary() total, played, won, lost, time_, moves, perc = self.getStatSummary()
text = _("Total (%d out of %d games)") % (played, total) text = _("Total (%d out of %d games)") % (played, total)
id = self.tree.insert(None, "end", text=text, id = self.tree.insert("", "end", text=text,
values=(won+lost, won, lost, time_, moves, perc)) values=(won+lost, won, lost, time_, moves, perc))
self.parent_window.tree_items.append(id) self.parent_window.tree_items.append(id)
return 1 return 1
@ -401,7 +402,7 @@ class TreeFormatter(PysolStatsFormatter):
num_rows = 0 num_rows = 0
for result in self.getLogResults(player, prev_games): for result in self.getLogResults(player, prev_games):
t1, t2, t3, t4, t5, t6 = result t1, t2, t3, t4, t5, t6 = result
id = self.tree.insert(None, "end", text=t1, values=(t2, t3, t4)) id = self.tree.insert("", "end", text=t1, values=(t2, t3, t4))
self.parent_window.tree_items.append(id) self.parent_window.tree_items.append(id)
num_rows += 1 num_rows += 1
if num_rows > self.MAX_ROWS: if num_rows > self.MAX_ROWS:
@ -421,12 +422,12 @@ class TreeFormatter(PysolStatsFormatter):
# // # //
# ************************************************************************/ # ************************************************************************/
class AllGamesFrame(Tile.Frame): class AllGamesFrame(ttk.Frame):
COLUMNS = ('played', 'won', 'lost', 'time', 'moves', 'percent') COLUMNS = ('played', 'won', 'lost', 'time', 'moves', 'percent')
def __init__(self, dialog, parent, app, player, **kw): def __init__(self, dialog, parent, app, player, **kw):
Tile.Frame.__init__(self, parent) ttk.Frame.__init__(self, parent)
# #
self.dialog = dialog self.dialog = dialog
self.app = app self.app = app
@ -439,22 +440,21 @@ class AllGamesFrame(Tile.Frame):
self.tree_tabs = None self.tree_tabs = None
self.games = {} # tree_itemid: gameid self.games = {} # tree_itemid: gameid
# #
frame = Tile.Frame(self) frame = ttk.Frame(self)
frame.pack(fill='both', expand=True, padx=10, pady=10) frame.pack(fill='both', expand=True, padx=10, pady=10)
vsb = Tile.Scrollbar(frame) vsb = ttk.Scrollbar(frame)
vsb.grid(row=0, column=1, sticky='ns') vsb.grid(row=0, column=1, sticky='ns')
self.tree = Tile.Treeview(frame, columns=self.COLUMNS, self.tree = ttk.Treeview(frame, columns=self.COLUMNS,
selectmode='browse') selectmode='browse')
self.tree.grid(row=0, column=0, sticky='nsew') self.tree.grid(row=0, column=0, sticky='nsew')
self.tree.config(yscrollcommand=vsb.set) self.tree.config(yscrollcommand=vsb.set)
vsb.config(command=self.tree.yview) vsb.config(command=self.tree.yview)
frame.rowconfigure(0, weight=1) frame.rowconfigure(0, weight=1)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
if Tile.TileVersion >= '0.8': hsb = ttk.Scrollbar(frame, orient='horizontal')
hsb = Tile.Scrollbar(frame, orient='horizontal') hsb.grid(row=1, column=0, sticky='ew')
hsb.grid(row=1, column=0, sticky='ew') self.tree.config(xscrollcommand=hsb.set)
self.tree.config(xscrollcommand=hsb.set) hsb.config(command=self.tree.xview)
hsb.config(command=self.tree.xview)
bind(self.tree, '<<TreeviewSelect>>', self.treeviewSelected) bind(self.tree, '<<TreeviewSelect>>', self.treeviewSelected)
# #
self.formatter = TreeFormatter(self.app, self.tree, self, self.formatter = TreeFormatter(self.app, self.tree, self,
@ -519,7 +519,7 @@ class LogDialog(MfxDialog):
self.font = app.getFont('default') self.font = app.getFont('default')
self.tkfont = tkFont.Font(parent, self.font) self.tkfont = tkFont.Font(parent, self.font)
style = Tile.Style() style = ttk.Style(parent)
heading_font = style.lookup('Heading', 'font') # treeview heading heading_font = style.lookup('Heading', 'font') # treeview heading
self.heading_tkfont = tkFont.Font(parent, heading_font) self.heading_tkfont = tkFont.Font(parent, heading_font)
self.font_metrics = self.tkfont.metrics() self.font_metrics = self.tkfont.metrics()
@ -534,7 +534,7 @@ class LogDialog(MfxDialog):
##self.selected_game = None ##self.selected_game = None
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
notebook = Tile.Notebook(top_frame) notebook = ttk.Notebook(top_frame)
notebook.pack(expand=True, fill='both', padx=10, pady=10) notebook.pack(expand=True, fill='both', padx=10, pady=10)
self.notebook_tabs = [] self.notebook_tabs = []
@ -680,48 +680,48 @@ class _TopDialog(MfxDialog):
cnf = {'master': top_frame, cnf = {'master': top_frame,
'padding': (4, 1), 'padding': (4, 1),
} }
frame = Tile.Frame(**cnf) frame = ttk.Frame(**cnf)
frame.pack(expand=True, fill='both', padx=10, pady=10) frame.pack(expand=True, fill='both', padx=10, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
cnf['master'] = frame cnf['master'] = frame
cnf['text'] = _('N') cnf['text'] = _('N')
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=0, column=0, sticky='ew') l.grid(row=0, column=0, sticky='ew')
if gameid == 'all': if gameid == 'all':
cnf['text'] = _('Game') cnf['text'] = _('Game')
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=0, column=1, sticky='ew') l.grid(row=0, column=1, sticky='ew')
cnf['text'] = _('Game number') cnf['text'] = _('Game number')
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=0, column=2, sticky='ew') l.grid(row=0, column=2, sticky='ew')
cnf['text'] = _('Started at') cnf['text'] = _('Started at')
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=0, column=3, sticky='ew') l.grid(row=0, column=3, sticky='ew')
cnf['text'] = _('Result') cnf['text'] = _('Result')
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=0, column=4, sticky='ew') l.grid(row=0, column=4, sticky='ew')
row = 1 row = 1
for i in top: for i in top:
# N # N
cnf['text'] = str(row) cnf['text'] = str(row)
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=row, column=0, sticky='ew') l.grid(row=row, column=0, sticky='ew')
if gameid == 'all': if gameid == 'all':
name = app.getGameTitleName(i.gameid) name = app.getGameTitleName(i.gameid)
if name is None: if name is None:
name = _("** UNKNOWN %d **") % i.gameid name = _("** UNKNOWN %d **") % i.gameid
cnf['text'] = name cnf['text'] = name
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=row, column=1, sticky='ew') l.grid(row=row, column=1, sticky='ew')
# Game number # Game number
cnf['text'] = '#'+str(i.game_number) cnf['text'] = '#'+str(i.game_number)
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=row, column=2, sticky='ew') l.grid(row=row, column=2, sticky='ew')
# Start time # Start time
t = time.strftime('%Y-%m-%d %H:%M', time.localtime(i.game_start_time)) t = time.strftime('%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
cnf['text'] = t cnf['text'] = t
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=row, column=3, sticky='ew') l.grid(row=row, column=3, sticky='ew')
# Result # Result
if isinstance(i.value, float): if isinstance(i.value, float):
@ -731,7 +731,7 @@ class _TopDialog(MfxDialog):
# moves # moves
s = str(i.value) s = str(i.value)
cnf['text'] = s cnf['text'] = s
l = Tile.Label(**cnf) l = ttk.Label(**cnf)
l.grid(row=row, column=4, sticky='ew') l.grid(row=row, column=4, sticky='ew')
row += 1 row += 1
@ -744,31 +744,31 @@ class _TopDialog(MfxDialog):
return MfxDialog.initKw(self, kw) return MfxDialog.initKw(self, kw)
class TopFrame(Tile.Frame): class TopFrame(ttk.Frame):
def __init__(self, dialog, parent, app, player, gameid): def __init__(self, dialog, parent, app, player, gameid):
Tile.Frame.__init__(self, parent) ttk.Frame.__init__(self, parent)
self.app = app self.app = app
self.dialog = dialog self.dialog = dialog
left_label = Tile.Label(self, image=app.gimages.logos[5]) left_label = ttk.Label(self, image=app.gimages.logos[5])
left_label.pack(side='left', expand=True, fill='both') left_label.pack(side='left', expand=True, fill='both')
frame = Tile.LabelFrame(self, text=_('Current game'), frame = ttk.LabelFrame(self, text=_('Current game'),
padding=(10,5,10,10)) padding=(10,5,10,10))
frame.pack(side='top', expand=True, fill='x', padx=10, pady=10) frame.pack(side='top', expand=True, fill='x', padx=10, pady=10)
##frame.columnconfigure(0, weight=1) ##frame.columnconfigure(0, weight=1)
if not self.createTopFrame(frame, player, gameid): if not self.createTopFrame(frame, player, gameid):
Tile.Label(frame, text=_('No TOP for this game') ttk.Label(frame, text=_('No TOP for this game')
).pack(padx=10, pady=10) ).pack(padx=10, pady=10)
frame = Tile.LabelFrame(self, text=_('All games'), frame = ttk.LabelFrame(self, text=_('All games'),
padding=(10,5,10,10)) padding=(10,5,10,10))
frame.pack(side='top', expand=True, fill='x', padx=10, pady=10) frame.pack(side='top', expand=True, fill='x', padx=10, pady=10)
##frame.columnconfigure(0, weight=1) ##frame.columnconfigure(0, weight=1)
if not self.createTopFrame(frame, player, 'all'): if not self.createTopFrame(frame, player, 'all'):
Tile.Label(frame, text=_('No TOP for all games') ttk.Label(frame, text=_('No TOP for all games')
).pack(padx=10, pady=10) ).pack(padx=10, pady=10)
def createTopFrame(self, frame, player, gameid): def createTopFrame(self, frame, player, gameid):
app = self.app app = self.app
@ -778,13 +778,13 @@ class TopFrame(Tile.Frame):
not app.stats.games_stats[player][gameid].time_result.top): not app.stats.games_stats[player][gameid].time_result.top):
return False return False
Tile.Label(frame, text=_('Minimum') ttk.Label(frame, text=_('Minimum')
).grid(row=0, column=1, padx=5, pady=5) ).grid(row=0, column=1, padx=5, pady=5)
Tile.Label(frame, text=_('Maximum') ttk.Label(frame, text=_('Maximum')
).grid(row=0, column=2, padx=5, pady=5) ).grid(row=0, column=2, padx=5, pady=5)
Tile.Label(frame, text=_('Average') ttk.Label(frame, text=_('Average')
).grid(row=0, column=3, padx=5, pady=5) ).grid(row=0, column=3, padx=5, pady=5)
##Tile.Label(frame, text=_('Total')).grid(row=0, column=4) ##ttk.Label(frame, text=_('Total')).grid(row=0, column=4)
s = app.stats.games_stats[player][gameid] s = app.stats.games_stats[player][gameid]
@ -825,19 +825,19 @@ class TopFrame(Tile.Frame):
## s.score_casino_result.max, ## s.score_casino_result.max,
## round(s.score_casino_result.average, 2), )) ## round(s.score_casino_result.average, 2), ))
for l, min, max, avr, tot, top in ll: for l, min, max, avr, tot, top in ll:
Tile.Label(frame, text=l ttk.Label(frame, text=l
).grid(row=row, column=0, padx=5, pady=5) ).grid(row=row, column=0, padx=5, pady=5)
Tile.Label(frame, text=str(min) ttk.Label(frame, text=str(min)
).grid(row=row, column=1, padx=5, pady=5) ).grid(row=row, column=1, padx=5, pady=5)
Tile.Label(frame, text=str(max) ttk.Label(frame, text=str(max)
).grid(row=row, column=2, padx=5, pady=5) ).grid(row=row, column=2, padx=5, pady=5)
Tile.Label(frame, text=str(avr) ttk.Label(frame, text=str(avr)
).grid(row=row, column=3, padx=5, pady=5) ).grid(row=row, column=3, padx=5, pady=5)
##Tile.Label(frame, text=str(tot)).grid(row=row, column=4) ##ttk.Label(frame, text=str(tot)).grid(row=row, column=4)
def command(gameid=gameid, top=top): def command(gameid=gameid, top=top):
self.showTop(gameid, top) self.showTop(gameid, top)
b = Tile.Button(frame, text=TOP_TITLE+' ...', b = ttk.Button(frame, text=TOP_TITLE+' ...',
width=10, command=command) width=10, command=command)
b.grid(row=row, column=5) b.grid(row=row, column=5)
row += 1 row += 1
return True return True
@ -850,10 +850,10 @@ class TopFrame(Tile.Frame):
# // # //
# ************************************************************************/ # ************************************************************************/
class ProgressionFrame(Tile.Frame): class ProgressionFrame(ttk.Frame):
def __init__(self, dialog, parent, app, player, gameid, **kw): def __init__(self, dialog, parent, app, player, gameid, **kw):
Tile.Frame.__init__(self, parent) ttk.Frame.__init__(self, parent)
self.mapped = False self.mapped = False
@ -864,7 +864,7 @@ class ProgressionFrame(Tile.Frame):
self.items = [] self.items = []
self.formatter = ProgressionFormatter(app, player, gameid) self.formatter = ProgressionFormatter(app, player, gameid)
frame = Tile.Frame(self) frame = ttk.Frame(self)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -890,19 +890,19 @@ class ProgressionFrame(Tile.Frame):
canvas.pack(side='left', padx=5) canvas.pack(side='left', padx=5)
# right frame # right frame
right_frame = Tile.Frame(frame) right_frame = ttk.Frame(frame)
right_frame.pack(side='left', fill='x', padx=5) right_frame.pack(side='left', fill='x', padx=5)
self.all_games_variable = var = Tkinter.StringVar() self.all_games_variable = var = Tkinter.StringVar()
var.set('all') var.set('all')
b = Tile.Radiobutton(right_frame, text=_('All games'), b = ttk.Radiobutton(right_frame, text=_('All games'),
variable=var, value='all', variable=var, value='all',
command=self.updateGraph) command=self.updateGraph)
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
b = Tile.Radiobutton(right_frame, text=_('Current game'), b = ttk.Radiobutton(right_frame, text=_('Current game'),
variable=var, value='current', variable=var, value='current',
command=self.updateGraph) command=self.updateGraph)
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
label_frame = Tile.LabelFrame(right_frame, text=_('Statistics for')) label_frame = ttk.LabelFrame(right_frame, text=_('Statistics for'))
label_frame.pack(side='top', fill='x', pady=10) label_frame.pack(side='top', fill='x', pady=10)
self.variable = var = Tkinter.StringVar() self.variable = var = Tkinter.StringVar()
var.set('week') var.set('week')
@ -912,28 +912,28 @@ class ProgressionFrame(Tile.Frame):
('year', _('Last year')), ('year', _('Last year')),
('all', _('All time')), ('all', _('All time')),
): ):
b = Tile.Radiobutton(label_frame, text=t, variable=var, b = ttk.Radiobutton(label_frame, text=t, variable=var,
value=v, command=self.updateGraph) value=v, command=self.updateGraph)
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
label_frame = Tile.LabelFrame(right_frame, text=_('Show graphs')) label_frame = ttk.LabelFrame(right_frame, text=_('Show graphs'))
label_frame.pack(side='top', fill='x') label_frame.pack(side='top', fill='x')
self.played_graph_var = Tkinter.BooleanVar() self.played_graph_var = Tkinter.BooleanVar()
self.played_graph_var.set(True) self.played_graph_var.set(True)
b = Tile.Checkbutton(label_frame, text=_('Played'), b = ttk.Checkbutton(label_frame, text=_('Played'),
command=self.updateGraph, command=self.updateGraph,
variable=self.played_graph_var) variable=self.played_graph_var)
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
self.won_graph_var = Tkinter.BooleanVar() self.won_graph_var = Tkinter.BooleanVar()
self.won_graph_var.set(True) self.won_graph_var.set(True)
b = Tile.Checkbutton(label_frame, text=_('Won'), b = ttk.Checkbutton(label_frame, text=_('Won'),
command=self.updateGraph, command=self.updateGraph,
variable=self.won_graph_var) variable=self.won_graph_var)
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
self.percent_graph_var = Tkinter.BooleanVar() self.percent_graph_var = Tkinter.BooleanVar()
self.percent_graph_var.set(True) self.percent_graph_var.set(True)
b = Tile.Checkbutton(label_frame, text=_('% won'), b = ttk.Checkbutton(label_frame, text=_('% won'),
command=self.updateGraph, command=self.updateGraph,
variable=self.percent_graph_var) variable=self.percent_graph_var)
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
#self.createGraph() #self.createGraph()

View file

@ -46,7 +46,7 @@ __all__ = ['MfxDialog',
# imports # imports
import sys, os, time, locale import sys, os, time, locale
import Tkinter import Tkinter
import Tile import ttk
import tkFont import tkFont
import traceback import traceback
@ -77,7 +77,7 @@ class MfxDialog: # ex. _ToplevelDialog
self.buttons = [] self.buttons = []
self.accel_keys = {} self.accel_keys = {}
self.top = makeToplevel(parent, title=title) self.top = makeToplevel(parent, title=title)
#self._frame = Tile.Frame(self.top) #self._frame = ttk.Frame(self.top)
#self._frame.pack(expand=True, fill='both') #self._frame.pack(expand=True, fill='both')
self._frame = self.top self._frame = self.top
self.top.wm_resizable(resizable, resizable) self.top.wm_resizable(resizable, resizable)
@ -167,23 +167,23 @@ class MfxDialog: # ex. _ToplevelDialog
return kw return kw
def createFrames(self, kw): def createFrames(self, kw):
bottom_frame = Tile.Frame(self._frame, relief='flat', borderwidth=4) bottom_frame = ttk.Frame(self._frame, relief='flat', borderwidth=4)
bottom_frame.pack(side='bottom', fill='both', expand=False) bottom_frame.pack(side='bottom', fill='both', expand=False)
if kw.separator: if kw.separator:
separator = Tile.Separator(self._frame) separator = ttk.Separator(self._frame)
separator.pack(side='bottom', fill='x') separator.pack(side='bottom', fill='x')
top_frame = Tile.Frame(self._frame) top_frame = ttk.Frame(self._frame)
top_frame.pack(side='top', fill='both', expand=1) top_frame.pack(side='top', fill='both', expand=1)
return top_frame, bottom_frame return top_frame, bottom_frame
def createBitmaps(self, frame, kw): def createBitmaps(self, frame, kw):
if kw.bitmap: ## in ("error", "info", "question", "warning") if kw.bitmap: ## in ("error", "info", "question", "warning")
img = self.img.get(kw.bitmap) img = self.img.get(kw.bitmap)
b = Tile.Label(frame, image=img) b = ttk.Label(frame, image=img)
b.pack(side=kw.bitmap_side, b.pack(side=kw.bitmap_side,
padx=kw.bitmap_padx, pady=kw.bitmap_pady) padx=kw.bitmap_padx, pady=kw.bitmap_pady)
elif kw.image: elif kw.image:
b = Tile.Label(frame, image=kw.image) b = ttk.Label(frame, image=kw.image)
b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady) b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady)
def createButtons(self, frame, kw): def createButtons(self, frame, kw):
@ -229,9 +229,9 @@ class MfxDialog: # ex. _ToplevelDialog
button_img = MfxDialog.button_img.get(s) button_img = MfxDialog.button_img.get(s)
s = s.replace('&', '') s = s.replace('&', '')
if button < 0: if button < 0:
widget = Tile.Button(frame, text=s, state="disabled") widget = ttk.Button(frame, text=s, state="disabled")
else: else:
widget = Tile.Button(frame, text=s, default="normal", widget = ttk.Button(frame, text=s, default="normal",
command = lambda self=self, button=button: \ command = lambda self=self, button=button: \
self.mDone(button)) self.mDone(button))
if button == kw.default: if button == kw.default:
@ -274,8 +274,8 @@ class MfxMessageDialog(MfxDialog):
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
# #
self.button = kw.default self.button = kw.default
msg = Tile.Label(top_frame, text=kw.text, justify=kw.justify, msg = ttk.Label(top_frame, text=kw.text, justify=kw.justify,
width=kw.width) width=kw.width)
msg.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady) msg.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
# #
focus = self.createButtons(bottom_frame, kw) focus = self.createButtons(bottom_frame, kw)
@ -314,10 +314,10 @@ class PysolAboutDialog(MfxMessageDialog):
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
# #
self.button = kw.default self.button = kw.default
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady) frame.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
msg = Tile.Label(frame, text=kw.text, justify=kw.justify, msg = ttk.Label(frame, text=kw.text, justify=kw.justify,
width=kw.width) width=kw.width)
msg.pack(fill='both', expand=True) msg.pack(fill='both', expand=True)
if sys.version_info >= (2, 4): if sys.version_info >= (2, 4):
@ -328,8 +328,8 @@ class PysolAboutDialog(MfxMessageDialog):
else: else:
font = tkFont.Font(parent, app.getFont('default')) font = tkFont.Font(parent, app.getFont('default'))
font.configure(underline=True) font.configure(underline=True)
url_label = Tile.Label(frame, text=kw.url, font=font, url_label = ttk.Label(frame, text=kw.url, font=font,
foreground='blue', cursor='hand2') foreground='blue', cursor='hand2')
url_label.pack() url_label.pack()
url_label.bind('<1>', self._urlClicked) url_label.bind('<1>', self._urlClicked)
# #
@ -353,10 +353,10 @@ class MfxSimpleEntry(MfxDialog):
# #
self.value = value self.value = value
if label: if label:
label = Tile.Label(top_frame, text=label, takefocus=0) label = ttk.Label(top_frame, text=label, takefocus=0)
label.pack(pady=5) label.pack(pady=5)
w = kw.get("e_width", 0) # width in characters w = kw.get("e_width", 0) # width in characters
self.var = Tile.Entry(top_frame, exportselection=1, width=w) self.var = ttk.Entry(top_frame, exportselection=1, width=w)
self.var.insert(0, value) self.var.insert(0, value)
self.var.pack(side='top', padx=kw.padx, pady=kw.pady) self.var.pack(side='top', padx=kw.padx, pady=kw.pady)
# #
@ -447,7 +447,7 @@ class MfxTooltip:
self.timer = None self.timer = None
if self.tooltip or not self.text: if self.tooltip or not self.text:
return return
## if isinstance(self.widget, (Tile.Button, Tile.Checkbutton)): ## if isinstance(self.widget, (ttk.Button, ttk.Checkbutton)):
## if self.widget["state"] == 'disabled': ## if self.widget["state"] == 'disabled':
## return ## return
##x = self.widget.winfo_rootx() ##x = self.widget.winfo_rootx()
@ -559,7 +559,7 @@ class MfxScrolledCanvas:
def createFrame(self, kw): def createFrame(self, kw):
width = kw.get("width") width = kw.get("width")
height = kw.get("height") height = kw.get("height")
self.frame = Tile.Frame(self.parent, width=width, height=height) self.frame = ttk.Frame(self.parent, width=width, height=height)
def createCanvas(self, kw): def createCanvas(self, kw):
bd = kw['bd'] bd = kw['bd']
kw['bd'] = 0 kw['bd'] = 0
@ -570,14 +570,14 @@ class MfxScrolledCanvas:
self.canvas = MfxCanvas(frame, **kw) self.canvas = MfxCanvas(frame, **kw)
self.canvas.pack(expand=True, fill='both') self.canvas.pack(expand=True, fill='both')
def createHbar(self): def createHbar(self):
self.hbar = Tile.Scrollbar(self.frame, takefocus=0, self.hbar = ttk.Scrollbar(self.frame, takefocus=0,
orient="horizontal") orient="horizontal")
self.canvas["xscrollcommand"] = self._setHbar self.canvas["xscrollcommand"] = self._setHbar
self.hbar["command"] = self.canvas.xview self.hbar["command"] = self.canvas.xview
self.hbar.grid(row=1, column=0, sticky="we") self.hbar.grid(row=1, column=0, sticky="we")
self.hbar.grid_remove() self.hbar.grid_remove()
def createVbar(self): def createVbar(self):
self.vbar = Tile.Scrollbar(self.frame, takefocus=0) self.vbar = ttk.Scrollbar(self.frame, takefocus=0)
self.canvas["yscrollcommand"] = self._setVbar self.canvas["yscrollcommand"] = self._setVbar
self.vbar["command"] = self.canvas.yview self.vbar["command"] = self.canvas.yview
self.vbar.grid(row=0, column=1, sticky="ns") self.vbar.grid(row=0, column=1, sticky="ns")
@ -713,7 +713,7 @@ class StackDesc:
# /*********************************************************************** # /***********************************************************************
# // Tile.Scale workaround (label and resolution) # // ttk.Scale workaround (label and resolution)
# ************************************************************************/ # ************************************************************************/
class MyPysolScale: class MyPysolScale:
@ -758,11 +758,11 @@ class MyPysolScale:
# create widgets # create widgets
side = 'left' # 'top' side = 'left' # 'top'
self.frame = Tile.Frame(parent) self.frame = ttk.Frame(parent)
self.label = Tile.Label(self.frame, anchor='w', self.label = ttk.Label(self.frame, anchor='w',
width=width, padding=(5,0)) width=width, padding=(5,0))
self.label.pack(side=side, expand=False, fill='x') self.label.pack(side=side, expand=False, fill='x')
self.scale = Tile.Scale(self.frame, **kw) self.scale = ttk.Scale(self.frame, **kw)
self.scale.pack(side=side, expand=True, fill='both', pady=4) self.scale.pack(side=side, expand=True, fill='both', pady=4)
if value is not None: if value is not None:
@ -812,16 +812,16 @@ PysolScale = MyPysolScale
# /*********************************************************************** # /***********************************************************************
# // Tile.Combobox workaround (clear selection) # // ttk.Combobox workaround (clear selection)
# ************************************************************************/ # ************************************************************************/
class PysolCombo(Tile.Combobox): class PysolCombo(ttk.Combobox):
def __init__(self, master=None, **kw): def __init__(self, master=None, **kw):
self._command = None self._command = None
if 'selectcommand' in kw: if 'selectcommand' in kw:
self._command = kw['selectcommand'] self._command = kw['selectcommand']
del kw['selectcommand'] del kw['selectcommand']
Tile.Combobox.__init__(self, master, **kw) ttk.Combobox.__init__(self, master, **kw)
self.bind('<<ComboboxSelected>>', self._callback) self.bind('<<ComboboxSelected>>', self._callback)
def _callback(self, *args): def _callback(self, *args):

View file

@ -39,7 +39,6 @@ __all__ = ['TclError',
# imports # imports
import Tkinter import Tkinter
TclError = Tkinter.TclError TclError = Tkinter.TclError
import Tile
# PySol imports # PySol imports
from tkconst import EVENT_PROPAGATE from tkconst import EVENT_PROPAGATE
@ -53,7 +52,6 @@ from tkconst import EVENT_PROPAGATE
class MfxRoot(Tkinter.Tk): class MfxRoot(Tkinter.Tk):
def __init__(self, **kw): def __init__(self, **kw):
Tkinter.Tk.__init__(self, **kw) Tkinter.Tk.__init__(self, **kw)
Tile.initialize(self)
self.app = None self.app = None
self.wm_protocol('WM_DELETE_WINDOW', self.wmDeleteWindow) self.wm_protocol('WM_DELETE_WINDOW', self.wmDeleteWindow)
# for interruptible sleep # for interruptible sleep

View file

@ -38,7 +38,7 @@ __all__ = ['PysolToolbarTk']
# imports # imports
import os import os
import Tkinter import Tkinter
import Tile import ttk
# PySol imports # PySol imports
from pysollib.mfxutil import destruct from pysollib.mfxutil import destruct
@ -88,25 +88,25 @@ class AbstractToolbarButton:
self.grid_forget() self.grid_forget()
class ToolbarCheckbutton(AbstractToolbarButton, Tile.Checkbutton): class ToolbarCheckbutton(AbstractToolbarButton, ttk.Checkbutton):
def __init__(self, parent, toolbar, toolbar_name, position, **kwargs): def __init__(self, parent, toolbar, toolbar_name, position, **kwargs):
kwargs['style'] = 'Toolbutton' kwargs['style'] = 'Toolbutton'
Tile.Checkbutton.__init__(self, parent, **kwargs) ttk.Checkbutton.__init__(self, parent, **kwargs)
AbstractToolbarButton.__init__(self, parent, toolbar, AbstractToolbarButton.__init__(self, parent, toolbar,
toolbar_name, position) toolbar_name, position)
class ToolbarButton(AbstractToolbarButton, Tile.Button): class ToolbarButton(AbstractToolbarButton, ttk.Button):
def __init__(self, parent, toolbar, toolbar_name, position, **kwargs): def __init__(self, parent, toolbar, toolbar_name, position, **kwargs):
kwargs['style'] = 'Toolbutton' kwargs['style'] = 'Toolbutton'
Tile.Button.__init__(self, parent, **kwargs) ttk.Button.__init__(self, parent, **kwargs)
AbstractToolbarButton.__init__(self, parent, toolbar, AbstractToolbarButton.__init__(self, parent, toolbar,
toolbar_name, position) toolbar_name, position)
class ToolbarSeparator(Tile.Separator): class ToolbarSeparator(ttk.Separator):
def __init__(self, parent, toolbar, position, **kwargs): def __init__(self, parent, toolbar, position, **kwargs):
kwargs['orient'] = 'vertical' kwargs['orient'] = 'vertical'
Tile.Separator.__init__(self, parent, **kwargs) ttk.Separator.__init__(self, parent, **kwargs)
self.toolbar = toolbar self.toolbar = toolbar
self.position = position self.position = position
self.visible = False self.visible = False
@ -179,9 +179,9 @@ class PysolToolbarTk:
self.compound = compound self.compound = compound
self.orient='horizontal' self.orient='horizontal'
# #
self.frame = Tile.Frame(top, class_='Toolbar', self.frame = ttk.Frame(top, class_='Toolbar',
relief=TkSettings.toolbar_relief, relief=TkSettings.toolbar_relief,
borderwidth=TkSettings.toolbar_borderwidth) borderwidth=TkSettings.toolbar_borderwidth)
# #
for l, f, t in ( for l, f, t in (
(n_("New"), self.mNewGame, _("New game")), (n_("New"), self.mNewGame, _("New game")),

1486
pysollib/tile/ttk.py Normal file

File diff suppressed because it is too large Load diff

View file

@ -24,7 +24,7 @@ __all__ = ['WizardDialog']
# imports # imports
import Tkinter import Tkinter
import Tile import ttk
# PySol imports # PySol imports
from pysollib.mfxutil import KwStruct from pysollib.mfxutil import KwStruct
@ -47,22 +47,22 @@ class WizardDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tile.Frame(top_frame) frame = ttk.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=10, pady=10) frame.pack(expand=True, fill='both', padx=10, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
notebook = Tile.Notebook(frame) notebook = ttk.Notebook(frame)
notebook.pack(expand=True, fill='both') notebook.pack(expand=True, fill='both')
for w in WizardWidgets: for w in WizardWidgets:
if isinstance(w, basestring): if isinstance(w, basestring):
frame = Tile.Frame(notebook) frame = ttk.Frame(notebook)
notebook.add(frame, text=w, sticky='nsew', padding=5) notebook.add(frame, text=w, sticky='nsew', padding=5)
frame.columnconfigure(1, weight=1) frame.columnconfigure(1, weight=1)
row = 0 row = 0
continue continue
Tile.Label(frame, text=w.label).grid(row=row, column=0) ttk.Label(frame, text=w.label).grid(row=row, column=0)
if w.widget == 'preset': if w.widget == 'preset':
if w.variable is None: if w.variable is None:
@ -82,7 +82,7 @@ class WizardDialog(MfxDialog):
elif w.widget == 'entry': elif w.widget == 'entry':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.StringVar() w.variable = Tkinter.StringVar()
en = Tile.Entry(frame, textvariable=w.variable) en = ttk.Entry(frame, textvariable=w.variable)
en.grid(row=row, column=1, sticky='ew', padx=2, pady=2) en.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
elif w.widget == 'menu': elif w.widget == 'menu':
if w.variable is None: if w.variable is None:
@ -109,8 +109,8 @@ class WizardDialog(MfxDialog):
elif w.widget == 'check': elif w.widget == 'check':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.BooleanVar() w.variable = Tkinter.BooleanVar()
ch = Tile.Checkbutton(frame, variable=w.variable, ch = ttk.Checkbutton(frame, variable=w.variable,
takefocus=False) takefocus=False)
ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2) ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
if w.current_value is None: if w.current_value is None:

View file

@ -23,7 +23,7 @@ import sys, os
import Tkinter import Tkinter
from pysollib.settings import TOOLKIT, USE_TILE from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.tile import Tile from pysollib.tile import ttk
from pysollib.macosx.appSupport import hideTkConsole from pysollib.macosx.appSupport import hideTkConsole
from common import base_init_root_window, BaseTkSettings from common import base_init_root_window, BaseTkSettings
@ -36,14 +36,14 @@ def init_root_window(root, app):
if TOOLKIT == 'gtk': if TOOLKIT == 'gtk':
pass pass
elif USE_TILE: elif USE_TILE:
style = Tile.Style(root) style = ttk.Style(root)
color = style.lookup('.', 'background') color = style.lookup('.', 'background')
if color: if color:
root.tk_setPalette(color) # for non-Tile widgets root.tk_setPalette(color) # for non-ttk widgets
if app.opt.tile_theme == 'aqua': if app.opt.tile_theme == 'aqua':
# standard Tk scrollbars work on OS X, but Tile ones look weird # standard Tk scrollbars work on OS X, but ttk ones look weird
Tile.Scrollbar = Tkinter.Scrollbar ttk.Scrollbar = Tkinter.Scrollbar
else: # pure Tk else: # pure Tk
#root.option_add(...) #root.option_add(...)

View file

@ -26,11 +26,10 @@ from pysollib.settings import VERSION
from pysollib.settings import TOOLKIT, USE_TILE from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.settings import DEBUG from pysollib.settings import DEBUG
from pysollib.mfxutil import print_err from pysollib.mfxutil import print_err
from pysollib.tile import Tile from pysollib.tile import ttk
def init_tile(app, top): def init_tile(app, top):
Tile.initialize(top)
# load available themes # load available themes
d = os.path.join(app.dataloader.dir, 'themes') d = os.path.join(app.dataloader.dir, 'themes')
if os.path.isdir(d): if os.path.isdir(d):
@ -38,10 +37,7 @@ def init_tile(app, top):
for t in os.listdir(d): for t in os.listdir(d):
if os.path.exists(os.path.join(d, t, 'pkgIndex.tcl')): if os.path.exists(os.path.join(d, t, 'pkgIndex.tcl')):
try: try:
if Tile.TileVersion < '0.8': top.tk.eval('package require ttk::theme::'+t)
top.tk.eval('package require tile::theme::'+t)
else:
top.tk.eval('package require ttk::theme::'+t)
#print 'load theme:', t #print 'load theme:', t
except: except:
traceback.print_exc() traceback.print_exc()
@ -50,17 +46,12 @@ def init_tile(app, top):
def set_theme(app, top, theme): def set_theme(app, top, theme):
# set theme # set theme
style = ttk.Style(top)
try: try:
Tile.setTheme(top, theme) style.theme_use(theme)
except: except:
print_err(_('invalid theme name: ') + theme) print_err(_('invalid theme name: ') + theme)
Tile.setTheme(top, app.opt.default_tile_theme) style.theme_use(app.opt.default_tile_theme)
## style = Tile.Style(top)
## #all_themes = style.theme_names()
## if theme not in all_themes:
## print_err(_('invalid theme name: ') + theme)
## theme = app.opt.default_tile_theme
## style.theme_use(theme)
def get_font_name(font): def get_font_name(font):

View file

@ -22,7 +22,7 @@
import sys, os import sys, os
from pysollib.settings import TOOLKIT, USE_TILE from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.tile import Tile from pysollib.tile import ttk
from common import base_init_root_window, BaseTkSettings from common import base_init_root_window, BaseTkSettings
@ -33,7 +33,7 @@ def init_root_window(root, app):
pass pass
elif USE_TILE: elif USE_TILE:
theme = app.opt.tile_theme theme = app.opt.tile_theme
style = Tile.Style(root) style = ttk.Style(root)
if theme not in ('winnative', 'xpnative'): if theme not in ('winnative', 'xpnative'):
color = style.lookup('.', 'background') color = style.lookup('.', 'background')
if color: if color:

View file

@ -26,7 +26,7 @@ import tkFont
from pysollib.settings import TITLE from pysollib.settings import TITLE
from pysollib.settings import TOOLKIT, USE_TILE from pysollib.settings import TOOLKIT, USE_TILE
from pysollib.tile import Tile from pysollib.tile import ttk
from common import base_init_root_window, BaseTkSettings, get_font_name from common import base_init_root_window, BaseTkSettings, get_font_name
@ -53,18 +53,14 @@ def init_root_window(root, app):
root.tk.evalfile(f) root.tk.evalfile(f)
except: except:
traceback.print_exc() traceback.print_exc()
f = 'clrpick8.4.tcl' f = 'clrpick8.5.tcl'
if Tile.TileVersion >= '0.8':
f = 'clrpick8.5.tcl'
f = os.path.join(app.dataloader.dir, 'tcl', f) f = os.path.join(app.dataloader.dir, 'tcl', f)
if os.path.exists(f): if os.path.exists(f):
try: try:
root.tk.evalfile(f) root.tk.evalfile(f)
except: except:
traceback.print_exc() traceback.print_exc()
f = 'fsdialog8.4.tcl' f = 'fsdialog8.5.tcl'
if Tile.TileVersion >= '0.8':
f = 'fsdialog8.5.tcl'
f = os.path.join(app.dataloader.dir, 'tcl', f) f = os.path.join(app.dataloader.dir, 'tcl', f)
if os.path.exists(f): if os.path.exists(f):
try: try:
@ -77,14 +73,14 @@ def init_root_window(root, app):
tkFileDialog.SaveAs.command = 'ttk::getSaveFile' tkFileDialog.SaveAs.command = 'ttk::getSaveFile'
tkFileDialog.Directory.command = 'ttk::chooseDirectory' tkFileDialog.Directory.command = 'ttk::chooseDirectory'
style = Tile.Style(root) style = ttk.Style(root)
color = style.lookup('.', 'background') color = style.lookup('.', 'background')
if color: if color:
root.tk_setPalette(color) root.tk_setPalette(color)
root.option_add('*Menu.borderWidth', 1, 60) root.option_add('*Menu.borderWidth', 1, 60)
root.option_add('*Menu.activeBorderWidth', 1, 60) root.option_add('*Menu.activeBorderWidth', 1, 60)
color = style.lookup('.', 'background', 'active') color = style.lookup('.', 'background', ['active'])
if color: if color:
root.option_add('*Menu.activeBackground', color, 60) root.option_add('*Menu.activeBackground', color, 60)
@ -96,11 +92,11 @@ def init_root_window(root, app):
root.option_add('*selectBackground', '#0a5f89', 60) root.option_add('*selectBackground', '#0a5f89', 60)
root.option_add('*inactiveSelectBackground', '#0a5f89', 60) # Tk-8.5 root.option_add('*inactiveSelectBackground', '#0a5f89', 60) # Tk-8.5
color = style.lookup('TEntry', 'selectbackground', 'focus') color = style.lookup('TEntry', 'selectbackground', ['focus'])
if color: if color:
root.option_add('*selectBackground', color, 60) root.option_add('*selectBackground', color, 60)
root.option_add('*inactiveSelectBackground', color, 60) root.option_add('*inactiveSelectBackground', color, 60)
color = style.lookup('TEntry', 'selectforeground', 'focus') color = style.lookup('TEntry', 'selectforeground', ['focus'])
if color: if color:
root.option_add('*selectForeground', color, 60) root.option_add('*selectForeground', color, 60)
@ -118,7 +114,7 @@ def init_root_window(root, app):
f = root.tk.splitlist(root.tk.call('font', 'actual', fn)) f = root.tk.splitlist(root.tk.call('font', 'actual', fn))
root.tk.call('font', 'configure', 'TkHeadingFont', *f) root.tk.call('font', 'configure', 'TkHeadingFont', *f)
else: else:
# use font from Tile settings # use font from ttk settings
font = style.lookup('.', 'font') font = style.lookup('.', 'font')
if font: if font:
fn = get_font_name(font) fn = get_font_name(font)