mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Kivy/Android
- Introduced tree view generators in menubar.py - applied to the option menu.
This commit is contained in:
parent
1df1f6a80c
commit
c9194ea419
2 changed files with 81 additions and 91 deletions
|
@ -147,7 +147,7 @@ class LAnimationMgr(object):
|
||||||
|
|
||||||
def taskEnd(self, task, value):
|
def taskEnd(self, task, value):
|
||||||
if value:
|
if value:
|
||||||
print('LAnimationMgr: taskEnd = %s %s' % (task, value))
|
# print('LAnimationMgr: taskEnd = %s %s' % (task, value))
|
||||||
self.tasks.remove(task)
|
self.tasks.remove(task)
|
||||||
if not self.checkRunning():
|
if not self.checkRunning():
|
||||||
# print('LAnimationMgr: taskEnd ->', len(self.callbacks), 'callbacks') # noqa
|
# print('LAnimationMgr: taskEnd ->', len(self.callbacks), 'callbacks') # noqa
|
||||||
|
@ -156,7 +156,7 @@ class LAnimationMgr(object):
|
||||||
# print('LAnimationMgr: taskEnd -> callbacks done')
|
# print('LAnimationMgr: taskEnd -> callbacks done')
|
||||||
self.callbacks = []
|
self.callbacks = []
|
||||||
|
|
||||||
print('Clock.get_fps() ->', Clock.get_fps())
|
# print('Clock.get_fps() ->', Clock.get_fps())
|
||||||
|
|
||||||
def create(self, spos, widget, **kw):
|
def create(self, spos, widget, **kw):
|
||||||
x = 0.0
|
x = 0.0
|
||||||
|
|
|
@ -90,18 +90,23 @@ class StringVar(TkVarObj):
|
||||||
value = StringProperty('')
|
value = StringProperty('')
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * Tree Generators
|
# * Common base
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# project study, currently unused
|
|
||||||
|
|
||||||
|
|
||||||
class LTreeGenerator(object):
|
class LMenuBase(object):
|
||||||
def __init__(self, menubar, parent, title, app):
|
def __init__(self, menubar, parent, title, app):
|
||||||
self.menubar = menubar
|
self.menubar = menubar
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.app = app
|
self.app = app
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
||||||
|
def make_pop_command(self, parent, title):
|
||||||
|
def pop_command(event):
|
||||||
|
print('event = %s' % event)
|
||||||
|
parent.popWork(title)
|
||||||
|
return pop_command
|
||||||
|
|
||||||
def closeWindow(self, event):
|
def closeWindow(self, event):
|
||||||
self.parent.popWork(self.title)
|
self.parent.popWork(self.title)
|
||||||
|
|
||||||
|
@ -154,90 +159,53 @@ class LTreeGenerator(object):
|
||||||
command()
|
command()
|
||||||
return _command
|
return _command
|
||||||
|
|
||||||
|
# ************************************************************************
|
||||||
|
# * Tree Generators
|
||||||
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
class LTreeGenerator(LMenuBase):
|
||||||
|
def __init__(self, menubar, parent, title, app):
|
||||||
|
super(LTreeGenerator, self).__init__(menubar, parent, title, app)
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
tv = LTreeRoot(root_options=dict(text='EditTree'))
|
tv = LTreeRoot(root_options=dict(text='EditTree'))
|
||||||
tv.hide_root = True
|
tv.hide_root = True
|
||||||
tv.size_hint = 1, None
|
tv.size_hint = 1, None
|
||||||
tv.bind(minimum_height=tv.setter('height'))
|
tv.bind(minimum_height=tv.setter('height'))
|
||||||
self.buildTree(tv, None)
|
|
||||||
|
gen = self.buildTree(tv, None)
|
||||||
|
|
||||||
|
def process(dt):
|
||||||
|
try:
|
||||||
|
gen.send(None)
|
||||||
|
Clock.schedule_once(process, 0.2)
|
||||||
|
except StopIteration:
|
||||||
|
print('generator: all jobs done')
|
||||||
|
pass
|
||||||
|
|
||||||
|
Clock.schedule_once(process, 0.2)
|
||||||
return tv
|
return tv
|
||||||
|
|
||||||
def buildTree(self, tv, node):
|
def buildTree(self, tv, node):
|
||||||
print('buildTree base')
|
print('buildTree generator function not implemented')
|
||||||
# to implement in dervied class
|
# needs at least on 'yield' statement
|
||||||
pass
|
# not reentrant: do not recurse !
|
||||||
|
# implement it in a dervied class
|
||||||
|
yield
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
# * Menu Dialogs
|
# * Menu Dialogs
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class LMenuDialog(object):
|
class LMenuDialog(LMenuBase):
|
||||||
|
|
||||||
dialogCache = {}
|
dialogCache = {}
|
||||||
|
|
||||||
def make_pop_command(self, parent, title):
|
|
||||||
def pop_command(event):
|
|
||||||
print('event = %s' % event)
|
|
||||||
parent.popWork(title)
|
|
||||||
return pop_command
|
|
||||||
|
|
||||||
def auto_close(self, command):
|
|
||||||
def auto_close_command():
|
|
||||||
command()
|
|
||||||
self.closeWindow(0)
|
|
||||||
return auto_close_command
|
|
||||||
|
|
||||||
def make_auto_command(self, variable, command):
|
|
||||||
def auto_command():
|
|
||||||
variable.set(not variable.get())
|
|
||||||
command()
|
|
||||||
return auto_command
|
|
||||||
|
|
||||||
def addCheckNode(self, tv, rg, title, auto_var, auto_com):
|
|
||||||
command = self.make_auto_command(auto_var, auto_com)
|
|
||||||
rg1 = tv.add_node(
|
|
||||||
LTreeNode(text=title, command=command, variable=auto_var), rg)
|
|
||||||
return rg1
|
|
||||||
|
|
||||||
def make_val_command(self, variable, value, command):
|
|
||||||
def val_command():
|
|
||||||
variable.set(value)
|
|
||||||
command()
|
|
||||||
return val_command
|
|
||||||
|
|
||||||
def make_vars_command(self, command, key):
|
|
||||||
def vars_command():
|
|
||||||
command(key)
|
|
||||||
return vars_command
|
|
||||||
|
|
||||||
def addRadioNode(self, tv, rg, title, auto_var, auto_val, auto_com):
|
|
||||||
command = self.make_val_command(auto_var, auto_val, auto_com)
|
|
||||||
rg1 = tv.add_node(
|
|
||||||
LTreeNode(text=title,
|
|
||||||
command=command,
|
|
||||||
variable=auto_var, value=auto_val), rg)
|
|
||||||
return rg1
|
|
||||||
|
|
||||||
def make_game_command(self, key, command):
|
|
||||||
def game_command():
|
|
||||||
self.closeWindow(0)
|
|
||||||
command(key)
|
|
||||||
return game_command
|
|
||||||
|
|
||||||
def make_command(self, command):
|
|
||||||
def _command():
|
|
||||||
self.closeWindow(0)
|
|
||||||
command()
|
|
||||||
return _command
|
|
||||||
|
|
||||||
def __init__(self, menubar, parent, title, app, **kw):
|
def __init__(self, menubar, parent, title, app, **kw):
|
||||||
super(LMenuDialog, self).__init__()
|
super(LMenuDialog, self).__init__(menubar, parent, title, app)
|
||||||
|
|
||||||
self.menubar = menubar
|
|
||||||
self.parent = parent
|
|
||||||
self.app = app
|
|
||||||
self.title = title
|
|
||||||
self.window = None
|
self.window = None
|
||||||
self.running = False
|
self.running = False
|
||||||
self.persist = False
|
self.persist = False
|
||||||
|
@ -270,29 +238,29 @@ class LMenuDialog(object):
|
||||||
if self.persist:
|
if self.persist:
|
||||||
self.dialogCache[title] = window
|
self.dialogCache[title] = window
|
||||||
|
|
||||||
# Tree skelett.
|
# Tree construct or assign.
|
||||||
|
|
||||||
if self.tvroot is None:
|
if self.tvroot is None:
|
||||||
tv = self.tvroot = LTreeRoot(root_options=dict(text='EditTree'))
|
tv = self.initTree()
|
||||||
tv.hide_root = True
|
|
||||||
tv.size_hint = 1, None
|
|
||||||
tv.bind(minimum_height=tv.setter('height'))
|
|
||||||
|
|
||||||
# menupunkte aufbauen.
|
|
||||||
|
|
||||||
self.buildTree(tv, None)
|
self.buildTree(tv, None)
|
||||||
else:
|
else:
|
||||||
tv = self.tvroot
|
tv = self.tvroot
|
||||||
|
|
||||||
# tree in einem Scrollwindow präsentieren.
|
# show the tree in a scroll window
|
||||||
|
|
||||||
root = LScrollView(pos=(0, 0))
|
root = LScrollView(pos=(0, 0))
|
||||||
root.add_widget(tv)
|
root.add_widget(tv)
|
||||||
self.window.content.add_widget(root)
|
self.window.content.add_widget(root)
|
||||||
|
|
||||||
|
def initTree(self):
|
||||||
|
tv = self.tvroot = LTreeRoot(root_options=dict(text='EditTree'))
|
||||||
|
tv.hide_root = True
|
||||||
|
tv.size_hint = 1, None
|
||||||
|
tv.bind(minimum_height=tv.setter('height'))
|
||||||
|
return tv
|
||||||
|
|
||||||
def buildTree(self, tree, node):
|
def buildTree(self, tree, node):
|
||||||
print('buildTree base')
|
# to implement in dervied class if needed
|
||||||
# to implement in dervied class
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
@ -584,16 +552,12 @@ class AssistMenuDialog(LMenuDialog):
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class OptionsMenuDialog(LMenuDialog):
|
class LOptionsMenuGenerator(LTreeGenerator):
|
||||||
|
def __init__(self, menubar, parent, title, app):
|
||||||
def __init__(self, menubar, parent, title, app, **kw):
|
super(LOptionsMenuGenerator, self).__init__(
|
||||||
kw['size_hint'] = (0.5, 1)
|
menubar, parent, title, app)
|
||||||
kw['persist'] = True
|
|
||||||
super(OptionsMenuDialog, self).__init__(
|
|
||||||
menubar, parent, title, app, **kw)
|
|
||||||
|
|
||||||
def buildTree(self, tv, node):
|
def buildTree(self, tv, node):
|
||||||
|
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Automatic play settings
|
# Automatic play settings
|
||||||
|
|
||||||
|
@ -622,6 +586,7 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
self.menubar.tkopt.quickplay,
|
self.menubar.tkopt.quickplay,
|
||||||
self.menubar.mOptQuickPlay)
|
self.menubar.mOptQuickPlay)
|
||||||
|
|
||||||
|
yield
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Player assistance
|
# Player assistance
|
||||||
|
|
||||||
|
@ -707,6 +672,7 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
|
|
||||||
# submenu.add_separator()
|
# submenu.add_separator()
|
||||||
|
|
||||||
|
yield
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Language options
|
# Language options
|
||||||
|
|
||||||
|
@ -738,6 +704,7 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
self.menubar.tkopt.language, 'ru',
|
self.menubar.tkopt.language, 'ru',
|
||||||
self.menubar.mOptLanguage)
|
self.menubar.mOptLanguage)
|
||||||
|
|
||||||
|
yield
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Sound options
|
# Sound options
|
||||||
|
|
||||||
|
@ -899,6 +866,7 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
self.menubar.tkopt.sound_sample_vars[key],
|
self.menubar.tkopt.sound_sample_vars[key],
|
||||||
self.make_vars_command(self.menubar.mOptSoundSample, key))
|
self.make_vars_command(self.menubar.mOptSoundSample, key))
|
||||||
|
|
||||||
|
yield
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Cardsets and card backside options
|
# Cardsets and card backside options
|
||||||
|
|
||||||
|
@ -914,10 +882,12 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
cs = csm.get(i)
|
cs = csm.get(i)
|
||||||
if cs is None:
|
if cs is None:
|
||||||
break
|
break
|
||||||
|
|
||||||
rg1 = self.addRadioNode(tv, rg,
|
rg1 = self.addRadioNode(tv, rg,
|
||||||
cs.name,
|
cs.name,
|
||||||
self.menubar.tkopt.cardset, i,
|
self.menubar.tkopt.cardset, i,
|
||||||
self.menubar.mOptCardset)
|
self.menubar.mOptCardset)
|
||||||
|
|
||||||
if rg1:
|
if rg1:
|
||||||
cbs = cs.backnames
|
cbs = cs.backnames
|
||||||
self.menubar.tkopt.cardbacks[i] = IntVar()
|
self.menubar.tkopt.cardbacks[i] = IntVar()
|
||||||
|
@ -939,6 +909,7 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
yield
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Table background settings
|
# Table background settings
|
||||||
|
|
||||||
|
@ -1066,6 +1037,7 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
self.menubar.mOptTileSet)
|
self.menubar.mOptTileSet)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
yield
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Card view options
|
# Card view options
|
||||||
|
|
||||||
|
@ -1097,6 +1069,7 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
self.menubar.tkopt.shade_filled_stacks,
|
self.menubar.tkopt.shade_filled_stacks,
|
||||||
self.menubar.mOptShadeFilledStacks)
|
self.menubar.mOptShadeFilledStacks)
|
||||||
|
|
||||||
|
yield
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Animation settins
|
# Animation settins
|
||||||
|
|
||||||
|
@ -1145,6 +1118,7 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
self.menubar.tkopt.win_animation,
|
self.menubar.tkopt.win_animation,
|
||||||
self.menubar.mWinAnimation)
|
self.menubar.mWinAnimation)
|
||||||
|
|
||||||
|
yield
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Touch mode settings
|
# Touch mode settings
|
||||||
|
|
||||||
|
@ -1187,6 +1161,7 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
menu.add_separator()
|
menu.add_separator()
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
yield
|
||||||
# -------------------------------------------
|
# -------------------------------------------
|
||||||
# Toolbar options
|
# Toolbar options
|
||||||
|
|
||||||
|
@ -1317,6 +1292,22 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
self.menubar.tkopt.display_win_message,
|
self.menubar.tkopt.display_win_message,
|
||||||
self.menubar.mWinDialog)
|
self.menubar.mWinDialog)
|
||||||
|
|
||||||
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
class OptionsMenuDialog(LMenuDialog):
|
||||||
|
|
||||||
|
def __init__(self, menubar, parent, title, app, **kw):
|
||||||
|
kw['size_hint'] = (0.5, 1)
|
||||||
|
kw['persist'] = True
|
||||||
|
super(OptionsMenuDialog, self).__init__(
|
||||||
|
menubar, parent, title, app, **kw)
|
||||||
|
|
||||||
|
def initTree(self):
|
||||||
|
og = LOptionsMenuGenerator(
|
||||||
|
self.menubar, self.parent, title=_("Options"), app=self.app)
|
||||||
|
tv = og.generate()
|
||||||
|
return tv
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
@ -1926,8 +1917,7 @@ class PysolMenubarTk:
|
||||||
self.game.setCursor(cursor=CURSOR_WATCH)
|
self.game.setCursor(cursor=CURSOR_WATCH)
|
||||||
after_idle(self.top, self.__restoreCursor)
|
after_idle(self.top, self.__restoreCursor)
|
||||||
|
|
||||||
tv = None
|
OptionsMenuDialog(self, self.top, title=_("Options"), app=self.app)
|
||||||
OptionsMenuDialog(self, self.top, title=_("Options"), app=self.app, tv=tv) # noqa
|
|
||||||
return EVENT_HANDLED
|
return EVENT_HANDLED
|
||||||
|
|
||||||
def mHelpMenuDialog(self, *event):
|
def mHelpMenuDialog(self, *event):
|
||||||
|
|
Loading…
Add table
Reference in a new issue