mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
python3 adaptations
This commit is contained in:
parent
22948a8b3e
commit
76568a3f1e
7 changed files with 63 additions and 38 deletions
|
@ -65,6 +65,20 @@ from kivy.cache import Cache
|
||||||
def get_platform():
|
def get_platform():
|
||||||
return platform
|
return platform
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# kivy EventDispatcher passes keywords, that to not correspond to properties
|
||||||
|
# to the base classes. Finally they will reach 'object'. With python3 (but not
|
||||||
|
# python2) 'object' throws an exception 'takes no parameters' in that a
|
||||||
|
# situation. We therefore underlay a base class (right outside), which
|
||||||
|
# swallows up remaining keywords. Thus the keywords do not reach 'object' any
|
||||||
|
# more.
|
||||||
|
|
||||||
|
|
||||||
|
class LBase(object):
|
||||||
|
def __init__(self, **kw):
|
||||||
|
super(LBase, self).__init__()
|
||||||
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,7 +160,7 @@ LSoundLoader = SoundLoader
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LBoxLayout(BoxLayout):
|
class LBoxLayout(BoxLayout, LBase):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
super(LBoxLayout, self).__init__(**kw)
|
super(LBoxLayout, self).__init__(**kw)
|
||||||
|
|
||||||
|
@ -159,7 +173,7 @@ class LBoxLayout(BoxLayout):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LImage(KivyImage):
|
class LImage(KivyImage, LBase):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(LImage, self).__init__(**kwargs)
|
super(LImage, self).__init__(**kwargs)
|
||||||
|
@ -278,7 +292,7 @@ def LColorToKivy(outline):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LText(Widget):
|
class LText(Widget, LBase):
|
||||||
text = StringProperty('')
|
text = StringProperty('')
|
||||||
|
|
||||||
def __init__(self, canvas, x, y, **kwargs):
|
def __init__(self, canvas, x, y, **kwargs):
|
||||||
|
@ -306,8 +320,13 @@ class LText(Widget):
|
||||||
# print('LText: font = %s, font_size = %s' % (font, fontsize))
|
# print('LText: font = %s, font_size = %s' % (font, fontsize))
|
||||||
# print('LText: text = %s' % (self.text))
|
# print('LText: text = %s' % (self.text))
|
||||||
|
|
||||||
self.label = Label(font=font, font_size=fontsize, **kwargs)
|
kwargs['font'] = font
|
||||||
# self.label = Label(font=font, font_size=fontsize)
|
kwargs['font_size'] = fontsize
|
||||||
|
|
||||||
|
class MyLabel(Label, LBase):
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.label = MyLabel(**kwargs)
|
||||||
self.label.texture_update()
|
self.label.texture_update()
|
||||||
self.coreSize = self.label.texture_size
|
self.coreSize = self.label.texture_size
|
||||||
self.corePos = (x, y)
|
self.corePos = (x, y)
|
||||||
|
@ -354,7 +373,7 @@ class LEvent(object):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LLine(Widget):
|
class LLine(Widget, LBase):
|
||||||
def __init__(self, canvas, args, **kw):
|
def __init__(self, canvas, args, **kw):
|
||||||
super(LLine, self).__init__(**kw)
|
super(LLine, self).__init__(**kw)
|
||||||
|
|
||||||
|
@ -527,7 +546,7 @@ class LLine(Widget):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LRectangle(Widget):
|
class LRectangle(Widget, LBase):
|
||||||
def __init__(self, prnt, args, **kw):
|
def __init__(self, prnt, args, **kw):
|
||||||
super(LRectangle, self).__init__(**kw)
|
super(LRectangle, self).__init__(**kw)
|
||||||
self.prnt = prnt
|
self.prnt = prnt
|
||||||
|
@ -638,7 +657,7 @@ class LRectangle(Widget):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LImageItem(BoxLayout):
|
class LImageItem(BoxLayout, LBase):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
super(LImageItem, self).__init__(**kw)
|
super(LImageItem, self).__init__(**kw)
|
||||||
self.game = None
|
self.game = None
|
||||||
|
@ -780,13 +799,13 @@ class LImageItem(BoxLayout):
|
||||||
# Treeview
|
# Treeview
|
||||||
|
|
||||||
|
|
||||||
class LTreeRoot(TreeView):
|
class LTreeRoot(TreeView, LBase):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
super(LTreeRoot, self).__init__(**kw)
|
super(LTreeRoot, self).__init__(**kw)
|
||||||
self.kw = kw
|
self.kw = kw
|
||||||
|
|
||||||
|
|
||||||
class LTreeNode(ButtonBehavior, TreeViewLabel):
|
class LTreeNode(ButtonBehavior, TreeViewLabel, LBase):
|
||||||
|
|
||||||
# def __init__(self, gameview, **kw):
|
# def __init__(self, gameview, **kw):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
|
@ -941,7 +960,7 @@ class LTreeNode(ButtonBehavior, TreeViewLabel):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LTopLevelContent(BoxLayout):
|
class LTopLevelContent(BoxLayout, LBase):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
super(LTopLevelContent, self).__init__(**kw)
|
super(LTopLevelContent, self).__init__(**kw)
|
||||||
|
|
||||||
|
@ -962,7 +981,7 @@ class LTopLevelContent(BoxLayout):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LTopLine(ButtonBehavior, Label):
|
class LTopLine(ButtonBehavior, Label, LBase):
|
||||||
|
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
super(LTopLine, self).__init__(**kw)
|
super(LTopLine, self).__init__(**kw)
|
||||||
|
@ -985,10 +1004,11 @@ class LTopLine(ButtonBehavior, Label):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LTopLevel0(BoxLayout):
|
class LTopLevel0(BoxLayout, LBase):
|
||||||
def __init__(self, top, title=None, **kw):
|
def __init__(self, top, title=None, **kw):
|
||||||
self.main = top
|
self.main = top
|
||||||
super(LTopLevel0, self).__init__(orientation="vertical", **kw)
|
super(LTopLevel0, self).__init__(
|
||||||
|
orientation="vertical", **kw)
|
||||||
|
|
||||||
# self.canvas.add(Color(0, 1, 0, 0.4))
|
# self.canvas.add(Color(0, 1, 0, 0.4))
|
||||||
# self.canvas.add(Rectangle(pos=(100, 100), size=(100, 100)))
|
# self.canvas.add(Rectangle(pos=(100, 100), size=(100, 100)))
|
||||||
|
@ -1024,10 +1044,11 @@ class LTopLevel0(BoxLayout):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LTopLevel(BoxLayout):
|
class LTopLevel(BoxLayout, LBase):
|
||||||
def __init__(self, parent, title=None, **kw):
|
def __init__(self, parent, title=None, **kw):
|
||||||
self.mainwindow = parent
|
self.mainwindow = parent
|
||||||
super(LTopLevel, self).__init__(orientation="vertical", **kw)
|
super(LTopLevel, self).__init__(
|
||||||
|
orientation="vertical", **kw)
|
||||||
|
|
||||||
if ('size_hint' not in kw):
|
if ('size_hint' not in kw):
|
||||||
self.size_hint = (0.5, 1.0)
|
self.size_hint = (0.5, 1.0)
|
||||||
|
@ -1044,7 +1065,7 @@ class LTopLevel(BoxLayout):
|
||||||
# class LMenuBar(ActionBar):
|
# class LMenuBar(ActionBar):
|
||||||
|
|
||||||
|
|
||||||
class LMenuBar(BoxLayout):
|
class LMenuBar(BoxLayout, LBase):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
super(LMenuBar, self).__init__(**kw)
|
super(LMenuBar, self).__init__(**kw)
|
||||||
self.menu = None
|
self.menu = None
|
||||||
|
@ -1071,14 +1092,18 @@ class LMenuBar(BoxLayout):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LMenu(ActionView):
|
class LMenu(ActionView, LBase):
|
||||||
def __init__(self, prev, **kw):
|
def __init__(self, prev, **kw):
|
||||||
print('prev = %s, kw = %s' % (prev, kw))
|
|
||||||
super(LMenu, self).__init__(**kw)
|
super(LMenu, self).__init__(**kw)
|
||||||
self.ap = ap = ActionPrevious(
|
|
||||||
with_previous=prev, size_hint=(.01, 1), **kw)
|
class MyActionPrev(ActionPrevious, LBase):
|
||||||
ap.app_icon = 'data/images/misc/pysol01.png'
|
pass
|
||||||
self.add_widget(ap)
|
|
||||||
|
kw['app_icon'] = 'data/images/misc/pysol01.png'
|
||||||
|
kw['with_previous'] = prev
|
||||||
|
kw['size_hint'] = (.01, 1)
|
||||||
|
self.ap = MyActionPrev(**kw)
|
||||||
|
self.add_widget(self.ap)
|
||||||
self.bar = None
|
self.bar = None
|
||||||
self.uppermenu = None
|
self.uppermenu = None
|
||||||
|
|
||||||
|
@ -1131,7 +1156,7 @@ class LMenu(ActionView):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LMenuItem(ActionButton):
|
class LMenuItem(ActionButton, LBase):
|
||||||
|
|
||||||
def __init__(self, menu, **kw):
|
def __init__(self, menu, **kw):
|
||||||
super(LMenuItem, self).__init__(**kw)
|
super(LMenuItem, self).__init__(**kw)
|
||||||
|
@ -1175,7 +1200,7 @@ class LMenuItem(ActionButton):
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
|
||||||
class LScrollView(ScrollView):
|
class LScrollView(ScrollView, LBase):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
super(LScrollView, self).__init__(**kw)
|
super(LScrollView, self).__init__(**kw)
|
||||||
self.delayDown = False
|
self.delayDown = False
|
||||||
|
|
|
@ -940,12 +940,12 @@ class OptionsMenuDialog(LMenuDialog):
|
||||||
if rg:
|
if rg:
|
||||||
self.addRadioNode(tv, rg,
|
self.addRadioNode(tv, rg,
|
||||||
'Drag-and-Drop',
|
'Drag-and-Drop',
|
||||||
self.menubar.tkopt.mouse_type, u'drag-n-drop',
|
self.menubar.tkopt.mouse_type, 'drag-n-drop',
|
||||||
self.menubar.mOptMouseType)
|
self.menubar.mOptMouseType)
|
||||||
|
|
||||||
self.addRadioNode(tv, rg,
|
self.addRadioNode(tv, rg,
|
||||||
'Point-and-Click',
|
'Point-and-Click',
|
||||||
self.menubar.tkopt.mouse_type, u'point-n-click',
|
self.menubar.tkopt.mouse_type, 'point-n-click',
|
||||||
self.menubar.mOptMouseType)
|
self.menubar.mOptMouseType)
|
||||||
|
|
||||||
# sinnlos mit touch-device:
|
# sinnlos mit touch-device:
|
||||||
|
|
|
@ -60,7 +60,6 @@ class SelectGameNode(SelectDialogTreeNode):
|
||||||
node = SelectGameLeaf(self.tree, self, name, key=id)
|
node = SelectGameLeaf(self.tree, self, name, key=id)
|
||||||
contents.append(node)
|
contents.append(node)
|
||||||
else:
|
else:
|
||||||
# for gi in self.tree.data.all_games_gi:
|
|
||||||
for gi in self.tree.all_games_gi:
|
for gi in self.tree.all_games_gi:
|
||||||
if gi and self.select_func is None:
|
if gi and self.select_func is None:
|
||||||
# All games
|
# All games
|
||||||
|
@ -72,7 +71,7 @@ class SelectGameNode(SelectDialogTreeNode):
|
||||||
name = gi.name
|
name = gi.name
|
||||||
node = SelectGameLeaf(self.tree, self, name, key=gi.id)
|
node = SelectGameLeaf(self.tree, self, name, key=gi.id)
|
||||||
contents.append(node)
|
contents.append(node)
|
||||||
return contents or self.tree.data.no_games
|
return contents or self.tree.no_games
|
||||||
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
@ -84,7 +83,8 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
SelectDialogTreeData.__init__(self)
|
SelectDialogTreeData.__init__(self)
|
||||||
|
|
||||||
# originale.
|
# originale.
|
||||||
self.all_games_gi = map(app.gdb.get, app.gdb.getGamesIdSortedByName())
|
self.all_games_gi = list(
|
||||||
|
map(app.gdb.get, app.gdb.getGamesIdSortedByName()))
|
||||||
self.no_games = [SelectGameLeaf(None, None, _("(no games)"), None), ]
|
self.no_games = [SelectGameLeaf(None, None, _("(no games)"), None), ]
|
||||||
#
|
#
|
||||||
s_by_type = s_oriental = s_special = None
|
s_by_type = s_oriental = s_special = None
|
||||||
|
@ -191,7 +191,7 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
ul_alternate_names = UserList(
|
ul_alternate_names = UserList(
|
||||||
list(app.gdb.getGamesTuplesSortedByAlternateName()))
|
list(app.gdb.getGamesTuplesSortedByAlternateName()))
|
||||||
#
|
#
|
||||||
self.rootnodes = filter(None, (
|
self.rootnodes = [_f for _f in (
|
||||||
# SelectGameNode(None, _("All Games"), None),
|
# SelectGameNode(None, _("All Games"), None),
|
||||||
SelectGameNode(None, _("Popular Games"),
|
SelectGameNode(None, _("Popular Games"),
|
||||||
lambda gi: gi.si.game_flags & GI.GT_POPULAR),
|
lambda gi: gi.si.game_flags & GI.GT_POPULAR),
|
||||||
|
@ -280,7 +280,7 @@ class SelectGameData(SelectDialogTreeData):
|
||||||
)),
|
)),
|
||||||
s_original,
|
s_original,
|
||||||
s_contrib,
|
s_contrib,
|
||||||
))
|
) if _f]
|
||||||
|
|
||||||
|
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
|
@ -209,7 +209,7 @@ class MfxCanvasImage(object):
|
||||||
self.addtag(group)
|
self.addtag(group)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
print('MfxCanvasImage: __del__()')
|
print('MfxCanvasImage: __del__(%s)' % self.image)
|
||||||
self.canvas.clear_widgets([self.image])
|
self.canvas.clear_widgets([self.image])
|
||||||
|
|
||||||
def config(self, **kw):
|
def config(self, **kw):
|
||||||
|
|
|
@ -594,7 +594,7 @@ class HTMLViewer:
|
||||||
writer = tkHTMLWriter(self.text, self, self.app)
|
writer = tkHTMLWriter(self.text, self, self.app)
|
||||||
fmt = formatter.AbstractFormatter(writer)
|
fmt = formatter.AbstractFormatter(writer)
|
||||||
parser = tkHTMLParser(fmt)
|
parser = tkHTMLParser(fmt)
|
||||||
parser.feed(data)
|
parser.feed(str(data))
|
||||||
parser.close()
|
parser.close()
|
||||||
self.text.config(state="disabled")
|
self.text.config(state="disabled")
|
||||||
if 0.0 <= xview <= 1.0:
|
if 0.0 <= xview <= 1.0:
|
||||||
|
|
|
@ -66,6 +66,7 @@ class AbstractToolbarButton:
|
||||||
|
|
||||||
if True:
|
if True:
|
||||||
from pysollib.kivy.LApp import LImage
|
from pysollib.kivy.LApp import LImage
|
||||||
|
from pysollib.kivy.LApp import LBase
|
||||||
# from LApp import LMainWindow
|
# from LApp import LMainWindow
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
# from kivy.uix.button import Button
|
# from kivy.uix.button import Button
|
||||||
|
@ -76,7 +77,7 @@ if True:
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class MyButton(ButtonBehavior, KivyImage):
|
class MyButton(ButtonBehavior, KivyImage, LBase):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(MyButton, self).__init__(**kwargs)
|
super(MyButton, self).__init__(**kwargs)
|
||||||
# super(MyButton, self).__init__()
|
# super(MyButton, self).__init__()
|
||||||
|
@ -98,7 +99,7 @@ class MyButton(ButtonBehavior, KivyImage):
|
||||||
self.command()
|
self.command()
|
||||||
|
|
||||||
|
|
||||||
class MyCheckButton(ButtonBehavior, KivyImage):
|
class MyCheckButton(ButtonBehavior, KivyImage, LBase):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(MyCheckButton, self).__init__(**kwargs)
|
super(MyCheckButton, self).__init__(**kwargs)
|
||||||
# super(MyCheckButton, self).__init__()
|
# super(MyCheckButton, self).__init__()
|
||||||
|
@ -277,7 +278,6 @@ class PysolToolbarTk(BoxLayout):
|
||||||
bd = TkSettings.toolbar_button_borderwidth
|
bd = TkSettings.toolbar_button_borderwidth
|
||||||
padx, pady = TkSettings.toolbar_button_padding
|
padx, pady = TkSettings.toolbar_button_padding
|
||||||
kw = {
|
kw = {
|
||||||
# 'position' : position,
|
|
||||||
'toolbar': self,
|
'toolbar': self,
|
||||||
'toolbar_name': name,
|
'toolbar_name': name,
|
||||||
'command': command,
|
'command': command,
|
||||||
|
|
|
@ -269,7 +269,7 @@ class KivyAudioClient(AbstractAudioClient):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
AbstractAudioClient.__init__(self)
|
AbstractAudioClient.__init__(self)
|
||||||
from kivy.LApp import LSoundLoader
|
from pysollib.kivy.LApp import LSoundLoader
|
||||||
self.audiodev = LSoundLoader
|
self.audiodev = LSoundLoader
|
||||||
self.sound = None
|
self.sound = None
|
||||||
self.queue = []
|
self.queue = []
|
||||||
|
|
Loading…
Add table
Reference in a new issue