Skip to content

Commit

Permalink
Add row parameter to the control timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Mar 27, 2019
1 parent 59869d4 commit c7189db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pyforms_gui.controls.control_event_timeline.graphs.win_graph_to_event import Graph2Event
from pyforms_gui.controls.control_event_timeline.graphs.win_graph_properties import GraphsProperties
from pyforms_gui.controls.control_event_timeline.graphs.win_events_generator import GraphsEventsGenerator

import traceback


class ControlEventTimeline(ControlBase, QWidget):
Expand Down Expand Up @@ -217,14 +217,15 @@ def __sub__(self, other):
self._graph2event_win -= other
return self

def add_event(self, begin, end, title='', row=0):
def add_event(self, begin, end, title='', row=0, track=None):
"""
:param begin: Initial frame
:param end: Last frame
:param title: Event title
:param row: Row to which the event should be added.
"""
self._time.add_event(begin, end, title=title, row=row)

self._time.add_event(begin, end, title=title, track=track, row=row)
self._time.repaint()

def add_graph(self, name, data):
Expand Down Expand Up @@ -512,6 +513,7 @@ def __export(self):
self._time.exportmatrix_events_to_csvwriter(spamwriter)

except Exception as e:
traceback.print_exc()
m = QMessageBox(QMessageBox.Critical, 'Error', str(e))
m.exec_()

Expand All @@ -530,6 +532,7 @@ def __export_2_csv_matrix(self):
spamwriter = csv.writer(csvfile, dialect='excel')
self._time.exportmatrix_events_to_csvwriter(spamwriter)
except Exception as e:
traceback.print_exc()
m = QMessageBox(QMessageBox.Critical, 'Error', str(e))
m.exec_()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pyforms_gui.controls.control_number import ControlNumber
from pyforms_gui.controls.control_label import ControlLabel
from AnyQt.QtWidgets import QMessageBox
import traceback

class Graph2Event(BaseWidget):

Expand Down Expand Up @@ -109,6 +110,7 @@ def __generage_events_evt(self):
if last_value and (max_frame-last_index) >= self._mindiff.value:
self._timeline.add_event(last_index, max_frame, title=self._eventname.value, row=int(self._rownumber.value) )
except Exception as e:
traceback.print_exc()
QMessageBox.warning( self, "Error!", str(e) )


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def add_track(self, title='', color=None):
self.setMinimumHeight(Track.which_top(len(self._tracks)))
return t

def add_event(self, begin, end, title='', track=None, lock=False, color=None):
def add_event(self, begin, end, title='', track=None, lock=False, color=None, row=0):
"""
Add a new event to the timeline.
:param int begin: Initial frame of the event.
Expand All @@ -147,6 +147,10 @@ def add_event(self, begin, end, title='', track=None, lock=False, color=None):
:param QColor color: Color of the event.
:return: Return the created Event object.
"""
if track is None:
for i in range( len(self._tracks), row+1):
self.add_track()
track = self._tracks[row]
return Event( begin, end, title=title, lock=lock, color=color, track=track, widget=self)

def remove_selected_event(self):
Expand Down

0 comments on commit c7189db

Please sign in to comment.