diff --git a/pysollib/tile/menubar.py b/pysollib/tile/menubar.py
index 0be598ba..845a0040 100644
--- a/pysollib/tile/menubar.py
+++ b/pysollib/tile/menubar.py
@@ -54,111 +54,7 @@ from solverdialog import connect_game_solver_dialog
from tkconst import TOOLBAR_BUTTONS
-
-# ************************************************************************
-# *
-# ************************************************************************
-
-def createToolbarMenu(menubar, menu):
- tearoff = menu.cget('tearoff')
-## data_dir = os.path.join(menubar.app.dataloader.dir, 'images', 'toolbar')
-## submenu = MfxMenu(menu, label=n_('Style'), tearoff=tearoff)
-## for f in os.listdir(data_dir):
-## d = os.path.join(data_dir, f)
-## if os.path.isdir(d) and os.path.exists(os.path.join(d, 'small')):
-## name = f.replace('_', ' ').capitalize()
-## submenu.add_radiobutton(label=name,
-## variable=menubar.tkopt.toolbar_style,
-## value=f, command=menubar.mOptToolbarStyle)
- submenu = MfxMenu(menu, label=n_('Compound'), tearoff=tearoff)
- for comp, label in COMPOUNDS:
- submenu.add_radiobutton(
- label=label, variable=menubar.tkopt.toolbar_compound,
- value=comp, command=menubar.mOptToolbarCompound)
- menu.add_separator()
- menu.add_radiobutton(label=n_("Hide"),
- variable=menubar.tkopt.toolbar, value=0,
- command=menubar.mOptToolbar)
- menu.add_radiobutton(label=n_("Top"),
- variable=menubar.tkopt.toolbar, value=1,
- command=menubar.mOptToolbar)
- menu.add_radiobutton(label=n_("Bottom"),
- variable=menubar.tkopt.toolbar, value=2,
- command=menubar.mOptToolbar)
- menu.add_radiobutton(label=n_("Left"),
- variable=menubar.tkopt.toolbar, value=3,
- command=menubar.mOptToolbar)
- menu.add_radiobutton(label=n_("Right"),
- variable=menubar.tkopt.toolbar, value=4,
- command=menubar.mOptToolbar)
-## menu.add_separator()
-## menu.add_radiobutton(label=n_("Small icons"),
-## variable=menubar.tkopt.toolbar_size, value=0,
-## command=menubar.mOptToolbarSize)
-## menu.add_radiobutton(label=n_("Large icons"),
-## variable=menubar.tkopt.toolbar_size, value=1,
-## command=menubar.mOptToolbarSize)
- menu.add_separator()
- submenu = MfxMenu(menu, label=n_('Visible buttons'), tearoff=tearoff)
- for w in TOOLBAR_BUTTONS:
- submenu.add_checkbutton(label=_(w.capitalize()),
- variable=menubar.tkopt.toolbar_vars[w],
- command=lambda m=menubar, w=w: m.mOptToolbarConfig(w))
-
-
-# ************************************************************************
-# *
-# ************************************************************************
-
-class MfxMenubar(Tkinter.Menu):
- addPath = None
-
- def __init__(self, master, **kw):
- self.name = kw["name"]
- tearoff = 0
- self.n = kw["tearoff"] = int(kw.get("tearoff", tearoff))
- Tkinter.Menu.__init__(self, master, **kw)
-
- def labeltoname(self, label):
- #print label, type(label)
- name = re.sub(r"[^0-9a-zA-Z]", "", label).lower()
- label = _(label)
- underline = label.find('&')
- if underline >= 0:
- label = label.replace('&', '')
- return name, label, underline
-
- def add(self, itemType, cnf={}):
- label = cnf.get("label")
- if label:
- name = cnf.get('name')
- if name:
- del cnf['name'] # TclError: unknown option "-name"
- else:
- name, label, underline = self.labeltoname(label)
- cnf["underline"] = cnf.get("underline", underline)
- cnf["label"] = label
- if name and self.addPath:
- path = str(self._w) + "." + name
- self.addPath(path, self, self.n, cnf.get("menu"))
- Tkinter.Menu.add(self, itemType, cnf)
- self.n = self.n + 1
-
-
-class MfxMenu(MfxMenubar):
- def __init__(self, master, label, underline=None, **kw):
- if 'name' in kw:
- name, label_underline = kw['name'], -1
- else:
- name, label, label_underline = self.labeltoname(label)
- kwdefault(kw, name=name)
- MfxMenubar.__init__(self, master, **kw)
- if underline is None:
- underline = label_underline
- if master:
- master.add_cascade(menu=self, name=name, label=label, underline=underline)
-
-
+from pysollib.ui.tktile.menubar import createToolbarMenu, MfxMenubar, MfxMenu
# ************************************************************************
# * - create menubar
# * - update menubar
diff --git a/pysollib/tk/menubar.py b/pysollib/tk/menubar.py
index 44bb3d87..d572beff 100644
--- a/pysollib/tk/menubar.py
+++ b/pysollib/tk/menubar.py
@@ -54,111 +54,7 @@ from solverdialog import connect_game_solver_dialog
from tkconst import TOOLBAR_BUTTONS
-
-# ************************************************************************
-# *
-# ************************************************************************
-
-def createToolbarMenu(menubar, menu):
- tearoff = menu.cget('tearoff')
-## data_dir = os.path.join(menubar.app.dataloader.dir, 'images', 'toolbar')
-## submenu = MfxMenu(menu, label=n_('Style'), tearoff=tearoff)
-## for f in os.listdir(data_dir):
-## d = os.path.join(data_dir, f)
-## if os.path.isdir(d) and os.path.exists(os.path.join(d, 'small')):
-## name = f.replace('_', ' ').capitalize()
-## submenu.add_radiobutton(label=name,
-## variable=menubar.tkopt.toolbar_style,
-## value=f, command=menubar.mOptToolbarStyle)
- submenu = MfxMenu(menu, label=n_('Compound'), tearoff=tearoff)
- for comp, label in COMPOUNDS:
- submenu.add_radiobutton(
- label=label, variable=menubar.tkopt.toolbar_compound,
- value=comp, command=menubar.mOptToolbarCompound)
- menu.add_separator()
- menu.add_radiobutton(label=n_("Hide"),
- variable=menubar.tkopt.toolbar, value=0,
- command=menubar.mOptToolbar)
- menu.add_radiobutton(label=n_("Top"),
- variable=menubar.tkopt.toolbar, value=1,
- command=menubar.mOptToolbar)
- menu.add_radiobutton(label=n_("Bottom"),
- variable=menubar.tkopt.toolbar, value=2,
- command=menubar.mOptToolbar)
- menu.add_radiobutton(label=n_("Left"),
- variable=menubar.tkopt.toolbar, value=3,
- command=menubar.mOptToolbar)
- menu.add_radiobutton(label=n_("Right"),
- variable=menubar.tkopt.toolbar, value=4,
- command=menubar.mOptToolbar)
-## menu.add_separator()
-## menu.add_radiobutton(label=n_("Small icons"),
-## variable=menubar.tkopt.toolbar_size, value=0,
-## command=menubar.mOptToolbarSize)
-## menu.add_radiobutton(label=n_("Large icons"),
-## variable=menubar.tkopt.toolbar_size, value=1,
-## command=menubar.mOptToolbarSize)
- menu.add_separator()
- submenu = MfxMenu(menu, label=n_('Visible buttons'), tearoff=tearoff)
- for w in TOOLBAR_BUTTONS:
- submenu.add_checkbutton(label=_(w.capitalize()),
- variable=menubar.tkopt.toolbar_vars[w],
- command=lambda m=menubar, w=w: m.mOptToolbarConfig(w))
-
-
-# ************************************************************************
-# *
-# ************************************************************************
-
-class MfxMenubar(Tkinter.Menu):
- addPath = None
-
- def __init__(self, master, **kw):
- self.name = kw["name"]
- tearoff = 0
- self.n = kw["tearoff"] = int(kw.get("tearoff", tearoff))
- Tkinter.Menu.__init__(self, master, **kw)
-
- def labeltoname(self, label):
- #print label, type(label)
- name = re.sub(r"[^0-9a-zA-Z]", "", label).lower()
- label = _(label)
- underline = label.find('&')
- if underline >= 0:
- label = label.replace('&', '')
- return name, label, underline
-
- def add(self, itemType, cnf={}):
- label = cnf.get("label")
- if label:
- name = cnf.get('name')
- if name:
- del cnf['name'] # TclError: unknown option "-name"
- else:
- name, label, underline = self.labeltoname(label)
- cnf["underline"] = cnf.get("underline", underline)
- cnf["label"] = label
- if name and self.addPath:
- path = str(self._w) + "." + name
- self.addPath(path, self, self.n, cnf.get("menu"))
- Tkinter.Menu.add(self, itemType, cnf)
- self.n = self.n + 1
-
-
-class MfxMenu(MfxMenubar):
- def __init__(self, master, label, underline=None, **kw):
- if 'name' in kw:
- name, label_underline = kw['name'], -1
- else:
- name, label, label_underline = self.labeltoname(label)
- kwdefault(kw, name=name)
- MfxMenubar.__init__(self, master, **kw)
- if underline is None:
- underline = label_underline
- if master:
- master.add_cascade(menu=self, name=name, label=label, underline=underline)
-
-
+from pysollib.ui.tktile.menubar import createToolbarMenu, MfxMenubar, MfxMenu
# ************************************************************************
# * - create menubar
# * - update menubar
diff --git a/pysollib/tk/tkconst.py b/pysollib/tk/tkconst.py
deleted file mode 100644
index e844ccee..00000000
--- a/pysollib/tk/tkconst.py
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/env python
-# -*- mode: python; coding: utf-8; -*-
-##---------------------------------------------------------------------------##
-##
-## Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
-## Copyright (C) 2003 Mt. Hood Playing Card Co.
-## Copyright (C) 2005-2009 Skomoroh
-##
-## This program is free software: you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation, either version 3 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program. If not, see .
-##
-##---------------------------------------------------------------------------##
-
-__all__ = ['EVENT_HANDLED',
- 'EVENT_PROPAGATE',
- 'CURSOR_DRAG',
- 'CURSOR_WATCH',
- 'CURSOR_DOWN_ARROW',
- 'ANCHOR_CENTER',
- 'ANCHOR_N',
- 'ANCHOR_NW',
- 'ANCHOR_NE',
- 'ANCHOR_S',
- 'ANCHOR_SW',
- 'ANCHOR_SE',
- 'ANCHOR_W',
- 'ANCHOR_E',
- 'TOOLBAR_BUTTONS',
- ]
-
-# imports
-import Tkinter
-
-from pysollib.mygettext import _, n_
-
-# ************************************************************************
-# * constants
-# ************************************************************************
-
-EVENT_HANDLED = "break"
-EVENT_PROPAGATE = None
-
-CURSOR_DRAG = "hand1"
-CURSOR_WATCH = "watch"
-CURSOR_DOWN_ARROW = 'sb_down_arrow'
-
-ANCHOR_CENTER = Tkinter.CENTER
-ANCHOR_N = Tkinter.N
-ANCHOR_NW = Tkinter.NW
-ANCHOR_NE = Tkinter.NE
-ANCHOR_S = Tkinter.S
-ANCHOR_SW = Tkinter.SW
-ANCHOR_SE = Tkinter.SE
-ANCHOR_W = Tkinter.W
-ANCHOR_E = Tkinter.E
-
-COMPOUNDS = (
- ##(Tkinter.BOTTOM, 'bottom'),
- ##(Tkinter.CENTER, 'center'),
- ##(Tkinter.RIGHT, 'right'),
- (Tkinter.NONE, n_('Icons only')),
- (Tkinter.TOP, n_('Text below icons')),
- (Tkinter.LEFT, n_('Text beside icons')),
- ('text', n_('Text only')),
- )
-
-TOOLBAR_BUTTONS = (
- "new",
- "restart",
- "open",
- "save",
- "undo",
- "redo",
- "autodrop",
- "shuffle",
- "pause",
- "statistics",
- "rules",
- "quit",
- "player",
- )
-
diff --git a/pysollib/ui/__init__.py b/pysollib/ui/__init__.py
new file mode 100644
index 00000000..49ecb276
--- /dev/null
+++ b/pysollib/ui/__init__.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+# -*- mode: python; coding: utf-8; -*-
+##---------------------------------------------------------------------------##
+##
+## Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
+## Copyright (C) 2003 Mt. Hood Playing Card Co.
+## Copyright (C) 2005-2009 Skomoroh
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see .
+##
+##---------------------------------------------------------------------------##
diff --git a/pysollib/ui/tktile/__init__.py b/pysollib/ui/tktile/__init__.py
new file mode 100644
index 00000000..49ecb276
--- /dev/null
+++ b/pysollib/ui/tktile/__init__.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+# -*- mode: python; coding: utf-8; -*-
+##---------------------------------------------------------------------------##
+##
+## Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
+## Copyright (C) 2003 Mt. Hood Playing Card Co.
+## Copyright (C) 2005-2009 Skomoroh
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see .
+##
+##---------------------------------------------------------------------------##
diff --git a/pysollib/ui/tktile/menubar.py b/pysollib/ui/tktile/menubar.py
new file mode 100644
index 00000000..e4d9ed2d
--- /dev/null
+++ b/pysollib/ui/tktile/menubar.py
@@ -0,0 +1,109 @@
+import re
+import Tkinter
+
+from pysollib.mfxutil import kwdefault
+from pysollib.mygettext import _, n_
+
+from tkconst import EVENT_HANDLED, EVENT_PROPAGATE, CURSOR_WATCH, COMPOUNDS
+from tkconst import TOOLBAR_BUTTONS
+
+def createToolbarMenu(menubar, menu):
+ tearoff = menu.cget('tearoff')
+## data_dir = os.path.join(menubar.app.dataloader.dir, 'images', 'toolbar')
+## submenu = MfxMenu(menu, label=n_('Style'), tearoff=tearoff)
+## for f in os.listdir(data_dir):
+## d = os.path.join(data_dir, f)
+## if os.path.isdir(d) and os.path.exists(os.path.join(d, 'small')):
+## name = f.replace('_', ' ').capitalize()
+## submenu.add_radiobutton(label=name,
+## variable=menubar.tkopt.toolbar_style,
+## value=f, command=menubar.mOptToolbarStyle)
+ submenu = MfxMenu(menu, label=n_('Compound'), tearoff=tearoff)
+ for comp, label in COMPOUNDS:
+ submenu.add_radiobutton(
+ label=label, variable=menubar.tkopt.toolbar_compound,
+ value=comp, command=menubar.mOptToolbarCompound)
+ menu.add_separator()
+ menu.add_radiobutton(label=n_("Hide"),
+ variable=menubar.tkopt.toolbar, value=0,
+ command=menubar.mOptToolbar)
+ menu.add_radiobutton(label=n_("Top"),
+ variable=menubar.tkopt.toolbar, value=1,
+ command=menubar.mOptToolbar)
+ menu.add_radiobutton(label=n_("Bottom"),
+ variable=menubar.tkopt.toolbar, value=2,
+ command=menubar.mOptToolbar)
+ menu.add_radiobutton(label=n_("Left"),
+ variable=menubar.tkopt.toolbar, value=3,
+ command=menubar.mOptToolbar)
+ menu.add_radiobutton(label=n_("Right"),
+ variable=menubar.tkopt.toolbar, value=4,
+ command=menubar.mOptToolbar)
+## menu.add_separator()
+## menu.add_radiobutton(label=n_("Small icons"),
+## variable=menubar.tkopt.toolbar_size, value=0,
+## command=menubar.mOptToolbarSize)
+## menu.add_radiobutton(label=n_("Large icons"),
+## variable=menubar.tkopt.toolbar_size, value=1,
+## command=menubar.mOptToolbarSize)
+ menu.add_separator()
+ submenu = MfxMenu(menu, label=n_('Visible buttons'), tearoff=tearoff)
+ for w in TOOLBAR_BUTTONS:
+ submenu.add_checkbutton(label=_(w.capitalize()),
+ variable=menubar.tkopt.toolbar_vars[w],
+ command=lambda m=menubar, w=w: m.mOptToolbarConfig(w))
+
+
+# ************************************************************************
+# *
+# ************************************************************************
+
+class MfxMenubar(Tkinter.Menu):
+ addPath = None
+
+ def __init__(self, master, **kw):
+ self.name = kw["name"]
+ tearoff = 0
+ self.n = kw["tearoff"] = int(kw.get("tearoff", tearoff))
+ Tkinter.Menu.__init__(self, master, **kw)
+
+ def labeltoname(self, label):
+ #print label, type(label)
+ name = re.sub(r"[^0-9a-zA-Z]", "", label).lower()
+ label = _(label)
+ underline = label.find('&')
+ if underline >= 0:
+ label = label.replace('&', '')
+ return name, label, underline
+
+ def add(self, itemType, cnf={}):
+ label = cnf.get("label")
+ if label:
+ name = cnf.get('name')
+ if name:
+ del cnf['name'] # TclError: unknown option "-name"
+ else:
+ name, label, underline = self.labeltoname(label)
+ cnf["underline"] = cnf.get("underline", underline)
+ cnf["label"] = label
+ if name and self.addPath:
+ path = str(self._w) + "." + name
+ self.addPath(path, self, self.n, cnf.get("menu"))
+ Tkinter.Menu.add(self, itemType, cnf)
+ self.n = self.n + 1
+
+
+class MfxMenu(MfxMenubar):
+ def __init__(self, master, label, underline=None, **kw):
+ if 'name' in kw:
+ name, label_underline = kw['name'], -1
+ else:
+ name, label, label_underline = self.labeltoname(label)
+ kwdefault(kw, name=name)
+ MfxMenubar.__init__(self, master, **kw)
+ if underline is None:
+ underline = label_underline
+ if master:
+ master.add_cascade(menu=self, name=name, label=label, underline=underline)
+
+
diff --git a/pysollib/tile/tkconst.py b/pysollib/ui/tktile/tkconst.py
similarity index 100%
rename from pysollib/tile/tkconst.py
rename to pysollib/ui/tktile/tkconst.py
diff --git a/setup.py b/setup.py
index d5c11539..8a610d6a 100644
--- a/setup.py
+++ b/setup.py
@@ -78,6 +78,7 @@ kw = {
'pysollib.tk',
'pysollib.tile',
'pysollib.pysolgtk',
+ 'pysollib.ui',
'pysollib.games',
'pysollib.games.special',
'pysollib.games.ultra',