class Tree (wx.TreeCtrl):\r
""":class:`wx.TreeCtrl` subclass handling playlist and curve selection.\r
"""\r
- def __init__(self, config, callbacks, *args, **kwargs):\r
+ def __init__(self, *args, **kwargs):\r
+ self._panel = kwargs['parent']\r
+ self._callbacks = self._panel._callbacks # TODO: CallbackClass.set_callback{,s}()\r
super(Tree, self).__init__(*args, **kwargs)\r
imglist = wx.ImageList(width=16, height=16, mask=True, initialCount=2)\r
imglist.Add(wx.ArtProvider.GetBitmap(\r
self.Bind(wx.EVT_RIGHT_DOWN, self._on_context_menu)\r
self.Bind(wx.EVT_TREE_SEL_CHANGED, self._on_select)\r
\r
- self.config = config\r
- self._callbacks = callbacks\r
self._setup_playlists()\r
\r
def _setup_playlists(self):\r
self._id_for_name = {} # {name: id}\r
self._name_for_id = {} # {id: name}\r
\r
- def _name(self, name):\r
- """Cleanup names according to configured preferences.\r
- """\r
- if self.config['hide extensions'] == 'True': # HACK: config should decode\r
- name,ext = os.path.splitext(name)\r
- return name\r
-\r
def _is_curve(self, name): # name from ._id_for_name / ._name_for_id\r
"""Return `True` if `name` corresponds to a :class:`hooke.curve.Curve`.\r
"""\r
self._playlists[playlist.name] = playlist\r
p_id = self.AppendItem(\r
parent=self._c['root'],\r
- text=self._name(playlist.name),\r
+ text=self._panel._hooke_frame._file_name(playlist.name),\r
image=self.image['playlist'])\r
self._id_for_name[playlist.name] = p_id\r
self._name_for_id[p_id] = playlist.name\r
p.append(curve)\r
c_id = self.AppendItem(\r
parent=self._id_for_name[playlist_name],\r
- text=self._name(curve.name),\r
+ text=self._panel._hooke_frame._file_name(curve.name),\r
image=self.image['curve'])\r
self._id_for_name[(p.name, curve.name)] = c_id\r
self._name_for_id[c_id] = (p.name, curve.name)\r
class Playlist (Panel, wx.Panel):\r
""":class:`wx.Panel` subclass wrapper for :class:`Tree`.\r
"""\r
- def __init__(self, config, callbacks, *args, **kwargs):\r
+ def __init__(self, callbacks=None, **kwargs):\r
# Use the WANTS_CHARS style so the panel doesn't eat the Return key.\r
- super(Playlist, self).__init__(*args, **kwargs)\r
- self.name = 'playlist panel'\r
-\r
+ super(Playlist, self).__init__(\r
+ name='playlist', callbacks=callbacks, **kwargs)\r
self._c = {\r
'tree': Tree(\r
- config=config,\r
- callbacks=callbacks,\r
parent=self,\r
size=wx.Size(160, 250),\r
style=wx.TR_DEFAULT_STYLE | wx.NO_BORDER | wx.TR_HIDE_ROOT),\r