frame.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. """!
  2. @package frame
  3. @brief Timeline Tool
  4. Classes:
  5. - frame::DataCursor
  6. - frame::TimelineFrame
  7. - frame::LookUp
  8. (C) 2012-2014 by the GRASS Development Team
  9. This program is free software under the GNU General Public License
  10. (>=v2). Read the file COPYING that comes with GRASS for details.
  11. @author Anna Kratochvilova <kratochanna gmail.com>
  12. """
  13. import os
  14. import sys
  15. import wx
  16. import signal
  17. from math import ceil
  18. from itertools import cycle
  19. import numpy as np
  20. try:
  21. import matplotlib
  22. # The recommended way to use wx with mpl is with the WXAgg
  23. # backend.
  24. matplotlib.use('WXAgg')
  25. from matplotlib.figure import Figure
  26. from matplotlib.backends.backend_wxagg import \
  27. FigureCanvasWxAgg as FigCanvas, \
  28. NavigationToolbar2WxAgg as NavigationToolbar
  29. import matplotlib.dates as mdates
  30. from matplotlib import cbook
  31. except ImportError:
  32. raise ImportError(_('The Timeline Tool needs "Matplotlib" package to be installed.'))
  33. if __name__ == '__main__':
  34. sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "gui", "wxpython"))
  35. import grass.script as grass
  36. from core.utils import _
  37. import grass.temporal as tgis
  38. from core.gcmd import GError, GException, RunCommand
  39. from gui_core import gselect
  40. from core import globalvar
  41. ALPHA = 0.5
  42. COLORS = ['b', 'g', 'r', 'c', 'm', 'y', 'k']
  43. def check_version(*version):
  44. """!Checks if given version or newer is installed"""
  45. versionInstalled = []
  46. for i in matplotlib.__version__.split('.'):
  47. try:
  48. v = int(i)
  49. versionInstalled.append(v)
  50. except ValueError:
  51. versionInstalled.append(0)
  52. if versionInstalled < list(version):
  53. return False
  54. else:
  55. return True
  56. class TimelineFrame(wx.Frame):
  57. """!The main frame of the application"""
  58. def __init__(self, parent):
  59. wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=_("GRASS GIS Timeline Tool"))
  60. tgis.init(True)
  61. self.datasets = []
  62. self.timeData = {}
  63. self._layout()
  64. self.temporalType = None
  65. self.unit = None
  66. # We create a database interface here to speedup the GUI
  67. self.dbif = tgis.SQLDatabaseInterfaceConnection()
  68. self.dbif.connect()
  69. def __del__(self):
  70. """!Close the database interface and stop the messenger and C-interface
  71. subprocesses.
  72. """
  73. if self.dbif.connected is True:
  74. self.dbif.close()
  75. tgis.stop_subprocesses()
  76. def _layout(self):
  77. """!Creates the main panel with all the controls on it:
  78. * mpl canvas
  79. * mpl navigation toolbar
  80. * Control panel for interaction
  81. """
  82. self.panel = wx.Panel(self)
  83. # Create the mpl Figure and FigCanvas objects.
  84. # 5x4 inches, 100 dots-per-inch
  85. #
  86. # color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BACKGROUND)
  87. self.fig = Figure((5.0, 4.0), facecolor=(1, 1, 1))
  88. self.canvas = FigCanvas(self.panel, wx.ID_ANY, self.fig)
  89. # axes are initialized later
  90. self.axes2d = None
  91. self.axes3d = None
  92. # Create the navigation toolbar, tied to the canvas
  93. #
  94. self.toolbar = NavigationToolbar(self.canvas)
  95. #
  96. # Layout
  97. #
  98. self.vbox = wx.BoxSizer(wx.VERTICAL)
  99. self.vbox.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
  100. self.vbox.Add(self.toolbar, 0, wx.EXPAND)
  101. self.vbox.AddSpacer(10)
  102. gridSizer = wx.GridBagSizer(hgap=5, vgap=5)
  103. self.datasetSelect = gselect.Select(parent=self.panel, id=wx.ID_ANY,
  104. size=globalvar.DIALOG_GSELECT_SIZE,
  105. type='stds', multiple=True)
  106. self.drawButton = wx.Button(self.panel, id=wx.ID_ANY, label=_("Draw"))
  107. self.drawButton.Bind(wx.EVT_BUTTON, self.OnRedraw)
  108. self.helpButton = wx.Button(self.panel, id=wx.ID_ANY, label=_("Help"))
  109. self.helpButton.Bind(wx.EVT_BUTTON, self.OnHelp)
  110. self.view3dCheck = wx.CheckBox(self.panel, id=wx.ID_ANY,
  111. label=_("3D plot of spatio-temporal extents"))
  112. self.view3dCheck.Bind(wx.EVT_CHECKBOX, self.OnRedraw)
  113. if not check_version(1, 0, 0):
  114. self.view3dCheck.SetLabel(_("3D plot of spatio-temporal extents "
  115. "(matplotlib >= 1.0.0)"))
  116. self.view3dCheck.Disable()
  117. gridSizer.Add(wx.StaticText(self.panel, id=wx.ID_ANY,
  118. label=_("Select space time dataset(s):")),
  119. pos=(0, 0), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
  120. gridSizer.Add(self.datasetSelect, pos=(1, 0), flag=wx.EXPAND)
  121. gridSizer.Add(self.drawButton, pos=(1, 1), flag=wx.EXPAND)
  122. gridSizer.Add(self.helpButton, pos=(1, 2), flag=wx.EXPAND)
  123. gridSizer.Add(self.view3dCheck, pos=(2, 0), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
  124. self.vbox.Add(gridSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=10)
  125. self.panel.SetSizer(self.vbox)
  126. self.vbox.Fit(self)
  127. def _getData(self, timeseries):
  128. """!Load data and read properties"""
  129. self.timeData = {}
  130. mode = None
  131. unit = None
  132. for series in timeseries:
  133. name = series[0] + '@' + series[1]
  134. etype = series[2]
  135. sp = tgis.dataset_factory(etype, name)
  136. if not sp.is_in_db(dbif=self.dbif):
  137. GError(self, message=_("Dataset <%s> not found in temporal database") % (name))
  138. return
  139. sp.select(dbif=self.dbif)
  140. self.timeData[name] = {}
  141. self.timeData[name]['elementType'] = series[2]
  142. self.timeData[name]['temporalType'] = sp.get_temporal_type() # abs/rel
  143. if mode is None:
  144. mode = self.timeData[name]['temporalType']
  145. elif self.timeData[name]['temporalType'] != mode:
  146. GError(parent=self, message=_("Datasets have different temporal type "
  147. "(absolute x relative), which is not allowed."))
  148. return
  149. # check topology
  150. maps = sp.get_registered_maps_as_objects(dbif=self.dbif)
  151. self.timeData[name]['validTopology'] = sp.check_temporal_topology(maps=maps, dbif=self.dbif)
  152. self.timeData[name]['temporalMapType'] = sp.get_map_time() # point/interval
  153. self.timeData[name]['unit'] = None # only with relative
  154. if self.timeData[name]['temporalType'] == 'relative':
  155. start, end, self.timeData[name]['unit'] = sp.get_relative_time()
  156. if unit is None:
  157. unit = self.timeData[name]['unit']
  158. elif self.timeData[name]['unit'] != unit:
  159. GError(self, _("Datasets have different time unit which is not allowed."))
  160. return
  161. self.timeData[name]['start_datetime'] = []
  162. # self.timeData[name]['start_plot'] = []
  163. self.timeData[name]['end_datetime'] = []
  164. # self.timeData[name]['end_plot'] = []
  165. self.timeData[name]['names'] = []
  166. self.timeData[name]['north'] = []
  167. self.timeData[name]['south'] = []
  168. self.timeData[name]['west'] = []
  169. self.timeData[name]['east'] = []
  170. columns = ','.join(['name', 'start_time', 'end_time',
  171. 'north', 'south', 'west', 'east'])
  172. rows = sp.get_registered_maps(columns=columns, where=None,
  173. order='start_time', dbif=self.dbif)
  174. if rows is None:
  175. rows = []
  176. for row in rows:
  177. mapName, start, end, north, south, west, east = row
  178. self.timeData[name]['start_datetime'].append(start)
  179. self.timeData[name]['end_datetime'].append(end)
  180. self.timeData[name]['names'].append(mapName)
  181. self.timeData[name]['north'].append(north)
  182. self.timeData[name]['south'].append(south)
  183. self.timeData[name]['west'].append(west)
  184. self.timeData[name]['east'].append(east)
  185. self.temporalType = mode
  186. self.unit = unit
  187. def _draw3dFigure(self):
  188. """!Draws 3d view (spatio-temporal extents).
  189. Only for matplotlib versions >= 1.0.0.
  190. Earlier versions cannot draw time ticks and alpha
  191. and it has a slightly different API.
  192. """
  193. self.axes3d.clear()
  194. self.axes3d.grid(False)
  195. # self.axes3d.grid(True)
  196. if self.temporalType == 'absolute':
  197. if check_version(1, 1, 0):
  198. self.axes3d.zaxis_date()
  199. convert = mdates.date2num
  200. else:
  201. convert = lambda x: x
  202. colors = cycle(COLORS)
  203. plots = []
  204. for name in self.datasets:
  205. name = name[0] + '@' + name[1]
  206. startZ = convert(self.timeData[name]['start_datetime'])
  207. mapType = self.timeData[name]['temporalMapType']
  208. if mapType == 'interval':
  209. dZ = convert(self.timeData[name]['end_datetime']) - startZ
  210. else:
  211. dZ = [0] * len(startZ)
  212. startX = self.timeData[name]['west']
  213. dX = self.timeData[name]['east'] - np.array(startX)
  214. startY = self.timeData[name]['south']
  215. dY = self.timeData[name]['north'] - np.array(startY)
  216. color = colors.next()
  217. plots.append(self.axes3d.bar3d(startX, startY, startZ, dX, dY, dZ,
  218. color=color, alpha=ALPHA))
  219. params = grass.read_command('g.proj', flags='g')
  220. params = grass.parse_key_val(params)
  221. if 'unit' in params:
  222. self.axes3d.set_xlabel(_("X [%s]") % params['unit'])
  223. self.axes3d.set_ylabel(_("Y [%s]") % params['unit'])
  224. else:
  225. self.axes3d.set_xlabel(_("X"))
  226. self.axes3d.set_ylabel(_("Y"))
  227. self.axes3d.set_zlabel(_('Time'))
  228. self.axes3d.mouse_init()
  229. self.canvas.draw()
  230. def _draw2dFigure(self):
  231. """!Draws 2D plot (temporal extents)"""
  232. self.axes2d.clear()
  233. self.axes2d.grid(True)
  234. if self.temporalType == 'absolute':
  235. self.axes2d.xaxis_date()
  236. self.fig.autofmt_xdate()
  237. convert = mdates.date2num
  238. else:
  239. convert = lambda x: x
  240. colors = cycle(COLORS)
  241. yticksNames = []
  242. yticksPos = []
  243. plots = []
  244. lookUp = LookUp(self.timeData)
  245. for i, name in enumerate(self.datasets):
  246. yticksNames.append(name[0]) # just name; with mapset it would be long
  247. name = name[0] + '@' + name[1]
  248. yticksPos.append(i)
  249. barData = []
  250. pointData = []
  251. mapType = self.timeData[name]['temporalMapType']
  252. start = convert(self.timeData[name]['start_datetime'])
  253. # TODO: mixed
  254. if mapType == 'interval':
  255. end = convert(self.timeData[name]['end_datetime'])
  256. lookUpData = zip(start, end)
  257. duration = end - np.array(start)
  258. barData = zip(start, duration)
  259. lookUp.AddDataset(type_='bar', yrange=(i - 0.1, i + 0.1),
  260. xranges=lookUpData, datasetName=name)
  261. else:
  262. # self.timeData[name]['end_plot'] = None
  263. pointData = start
  264. lookUp.AddDataset(type_='point', yrange=i, xranges=pointData, datasetName=name)
  265. color = colors.next()
  266. if mapType == 'interval':
  267. plots.append(self.axes2d.broken_barh(xranges=barData, yrange=(i - 0.1, 0.2),
  268. facecolors=color, alpha=ALPHA))
  269. else:
  270. plots.append(self.axes2d.plot(pointData, [i] * len(pointData),
  271. marker='o', linestyle='None', color=color)[0])
  272. if self.temporalType == 'absolute':
  273. pass
  274. # self.axes2d.set_xlabel(_("Time"))
  275. else:
  276. self.axes2d.set_xlabel(_("Time [%s]") % self.unit)
  277. self.axes2d.set_yticks(yticksPos)
  278. self.axes2d.set_yticklabels(yticksNames)
  279. self.axes2d.set_ylim(min(yticksPos) - 1, max(yticksPos) + 1)
  280. # adjust xlim
  281. xlim = self.axes2d.get_xlim()
  282. padding = ceil((xlim[1] - xlim[0]) / 20.)
  283. self.axes2d.set_xlim(xlim[0] - padding, xlim[1] + padding)
  284. self.canvas.draw()
  285. DataCursor(plots, lookUp, InfoFormat)
  286. def OnRedraw(self, event):
  287. """!Required redrawing."""
  288. datasets = self.datasetSelect.GetValue().strip()
  289. if not datasets:
  290. return
  291. datasets = datasets.split(',')
  292. try:
  293. datasets = self._checkDatasets(datasets)
  294. except GException:
  295. GError(parent=self, message=_("Invalid input data"))
  296. return
  297. self.datasets = datasets
  298. self._redraw()
  299. def _redraw(self):
  300. """!Readraw data.
  301. Decides if to draw also 3D and adjusts layout if needed.
  302. """
  303. self._getData(self.datasets)
  304. # axes3d are physically removed
  305. if not self.axes2d:
  306. self.axes2d = self.fig.add_subplot(1, 1, 1)
  307. self._draw2dFigure()
  308. if check_version(1, 0, 0):
  309. if self.view3dCheck.IsChecked():
  310. self.axes2d.change_geometry(2, 1, 1)
  311. if not self.axes3d:
  312. # do not remove this import - unused but it is required for 3D
  313. from mpl_toolkits.mplot3d import Axes3D # pylint: disable=W0611
  314. self.axes3d = self.fig.add_subplot(2, 1, 2, projection='3d')
  315. self.axes3d.set_visible(True)
  316. self._draw3dFigure()
  317. else:
  318. if self.axes3d:
  319. self.fig.delaxes(self.axes3d)
  320. self.axes3d = None
  321. self.axes2d.change_geometry(1, 1, 1)
  322. self.canvas.draw()
  323. def _checkDatasets(self, datasets):
  324. """!Checks and validates datasets.
  325. Reports also type of dataset (e.g. 'strds').
  326. @return (mapName, mapset, type)
  327. """
  328. validated = []
  329. tDict = tgis.tlist_grouped('stds', group_type=True, dbif=self.dbif)
  330. # nested list with '(map, mapset, etype)' items
  331. allDatasets = [[[(map, mapset, etype) for map in maps]
  332. for etype, maps in etypesDict.iteritems()]
  333. for mapset, etypesDict in tDict.iteritems()]
  334. # flatten this list
  335. allDatasets = reduce(lambda x, y: x + y, reduce(lambda x, y: x + y, allDatasets))
  336. for dataset in datasets:
  337. errorMsg = _("Space time dataset <%s> not found.") % dataset
  338. if dataset.find("@") >= 0:
  339. nameShort, mapset = dataset.split('@', 1)
  340. indices = [n for n, (mapName, mapsetName, etype) in enumerate(allDatasets)
  341. if nameShort == mapName and mapsetName == mapset]
  342. else:
  343. indices = [n for n, (mapName, mapset, etype) in enumerate(allDatasets)
  344. if dataset == mapName]
  345. if len(indices) == 0:
  346. raise GException(errorMsg)
  347. elif len(indices) >= 2:
  348. dlg = wx.SingleChoiceDialog(self,
  349. message=_("Please specify the space time dataset <%s>." % dataset),
  350. caption=_("Ambiguous dataset name"),
  351. choices=[("%(map)s@%(mapset)s: %(etype)s" % {'map': allDatasets[i][0],
  352. 'mapset': allDatasets[i][1],
  353. 'etype': allDatasets[i][2]})
  354. for i in indices],
  355. style=wx.CHOICEDLG_STYLE | wx.OK)
  356. if dlg.ShowModal() == wx.ID_OK:
  357. index = dlg.GetSelection()
  358. validated.append(allDatasets[indices[index]])
  359. else:
  360. validated.append(allDatasets[indices[0]])
  361. return validated
  362. def OnHelp(self, event):
  363. RunCommand('g.manual', quiet=True, entry='g.gui.timeline')
  364. # interface
  365. def SetDatasets(self, datasets):
  366. """!Set data"""
  367. if not datasets:
  368. return
  369. try:
  370. datasets = self._checkDatasets(datasets)
  371. except GException:
  372. GError(parent=self, message=_("Invalid input data"))
  373. return
  374. self.datasets = datasets
  375. self.datasetSelect.SetValue(','.join(map(lambda x: x[0] + '@' + x[1], datasets)))
  376. self._redraw()
  377. def Show3D(self, show):
  378. """!Show also 3D if possible"""
  379. if check_version(1, 0, 0):
  380. self.view3dCheck.SetValue(show)
  381. class LookUp:
  382. """!Helper class for searching info by coordinates"""
  383. def __init__(self, timeData):
  384. self.data = {}
  385. self.timeData = timeData
  386. def AddDataset(self, type_, yrange, xranges, datasetName):
  387. if type_ == 'bar':
  388. self.data[yrange] = {'name': datasetName}
  389. for i, (start, end) in enumerate(xranges):
  390. self.data[yrange][(start, end)] = i
  391. elif type_ == 'point':
  392. self.data[(yrange, yrange)] = {'name': datasetName}
  393. for i, start in enumerate(xranges):
  394. self.data[(yrange, yrange)][(start, start)] = i
  395. def GetInformation(self, x, y):
  396. keys = None
  397. for keyY in self.data.keys():
  398. if keyY[0] <= y <= keyY[1]:
  399. for keyX in self.data[keyY].keys():
  400. if keyX != 'name' and keyX[0] <= x <= keyX[1]:
  401. keys = keyY, keyX
  402. break
  403. if keys:
  404. break
  405. if not keys:
  406. return None
  407. datasetName = self.data[keys[0]]['name']
  408. mapIndex = self.data[keys[0]][keys[1]]
  409. return self.timeData, datasetName, mapIndex
  410. def InfoFormat(timeData, datasetName, mapIndex):
  411. """!Formats information about dataset"""
  412. text = []
  413. etype = timeData[datasetName]['elementType']
  414. name, mapset = datasetName.split('@')
  415. if etype == 'strds':
  416. text.append(_("Space time raster dataset: %s") % name)
  417. elif etype == 'stvds':
  418. text.append(_("Space time vector dataset: %s") % name)
  419. elif etype == 'str3ds':
  420. text.append(_("Space time 3D raster dataset: %s") % name)
  421. text.append(_("Mapset: %s") % mapset)
  422. text.append(_("Map name: %s") % timeData[datasetName]['names'][mapIndex])
  423. text.append(_("Start time: %s") % timeData[datasetName]['start_datetime'][mapIndex])
  424. text.append(_("End time: %s") % timeData[datasetName]['end_datetime'][mapIndex])
  425. if not timeData[datasetName]['validTopology']:
  426. text.append(_("WARNING: invalid topology"))
  427. text.append(_("\nPress Del to dismiss."))
  428. return '\n'.join(text)
  429. class DataCursor(object):
  430. """A simple data cursor widget that displays the x,y location of a
  431. matplotlib artist when it is selected.
  432. Source: http://stackoverflow.com/questions/4652439/
  433. is-there-a-matplotlib-equivalent-of-matlabs-datacursormode/4674445
  434. """
  435. def __init__(self, artists, lookUp, formatFunction, tolerance=5, offsets=(-30, 30),
  436. display_all=False):
  437. """Create the data cursor and connect it to the relevant figure.
  438. "artists" is the matplotlib artist or sequence of artists that will be
  439. selected.
  440. "tolerance" is the radius (in points) that the mouse click must be
  441. within to select the artist.
  442. "offsets" is a tuple of (x,y) offsets in points from the selected
  443. point to the displayed annotation box
  444. "display_all" controls whether more than one annotation box will
  445. be shown if there are multiple axes. Only one will be shown
  446. per-axis, regardless.
  447. """
  448. self.lookUp = lookUp
  449. self.formatFunction = formatFunction
  450. self.offsets = offsets
  451. self.display_all = display_all
  452. if not cbook.iterable(artists):
  453. artists = [artists]
  454. self.artists = artists
  455. self.axes = tuple(set(art.axes for art in self.artists))
  456. self.figures = tuple(set(ax.figure for ax in self.axes))
  457. self.annotations = {}
  458. for ax in self.axes:
  459. self.annotations[ax] = self.annotate(ax)
  460. for artist in self.artists:
  461. artist.set_picker(tolerance)
  462. for fig in self.figures:
  463. fig.canvas.mpl_connect('pick_event', self)
  464. fig.canvas.mpl_connect('key_press_event', self.keyPressed)
  465. def keyPressed(self, event):
  466. """!Key pressed - hide annotation if Delete was pressed"""
  467. if event.key != 'delete':
  468. return
  469. for ax in self.axes:
  470. self.annotations[ax].set_visible(False)
  471. event.canvas.draw()
  472. def annotate(self, ax):
  473. """Draws and hides the annotation box for the given axis "ax"."""
  474. annotation = ax.annotate(self.formatFunction, xy=(0, 0), ha='center',
  475. xytext=self.offsets, textcoords='offset points', va='bottom',
  476. bbox=dict(boxstyle='round,pad=0.5', fc='yellow', alpha=0.7),
  477. arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=0'),
  478. annotation_clip=False, multialignment='left')
  479. annotation.set_visible(False)
  480. return annotation
  481. def __call__(self, event):
  482. """Intended to be called through "mpl_connect"."""
  483. # Rather than trying to interpolate, just display the clicked coords
  484. # This will only be called if it's within "tolerance", anyway.
  485. x, y = event.mouseevent.xdata, event.mouseevent.ydata
  486. annotation = self.annotations[event.artist.axes]
  487. if x is not None:
  488. if not self.display_all:
  489. # Hide any other annotation boxes...
  490. for ann in self.annotations.values():
  491. ann.set_visible(False)
  492. # Update the annotation in the current axis..
  493. annotation.xy = x, y
  494. if 'Line2D' in str(type(event.artist)):
  495. y = event.artist.get_ydata()[0]
  496. xData = event.artist.get_xdata()
  497. x = xData[np.argmin(abs(xData - x))]
  498. info = self.lookUp.GetInformation(x, y)
  499. if not info:
  500. return
  501. text = self.formatFunction(*info)
  502. annotation.set_text(text)
  503. annotation.set_visible(True)
  504. event.canvas.draw()
  505. def run(parent=None, datasets=None):
  506. frame = TimelineFrame(parent)
  507. if datasets:
  508. frame.SetDatasets(datasets)
  509. frame.Show()
  510. if __name__ == '__main__':
  511. run()