예제 #1
0
 def choose_strip(self, metrics, appearance):
     # Choose an exponent that will make the minor strip just larger than
     # the displayed period:
     #
     #     10**x > period_delta   =>
     #     x > log(period_delta)
     exponent = int(math.log(metrics.time_period.delta().value, 10)) + 1
     # Keep decreasing the exponent until the minor strip is small enough.
     while True:
         if exponent == 0:
             break
         next_minor_strip_with_px = metrics.calc_exact_width(
             TimePeriod(NumTime(0), NumTime(10**(exponent - 1))))
         if next_minor_strip_with_px > 30:
             exponent -= 1
         else:
             break
     return (NumStrip(10**(exponent + 1)), NumStrip(10**exponent))
예제 #2
0
 def parse_time(self, time_string):
     match = re.search(r"^([-]?\d+(.\d+)?(e[+]\d+)?)$", time_string)
     if match:
         if '.' in time_string or 'e' in time_string:
             time = float(match.group(1))
         else:
             time = int(match.group(1))
         try:
             return NumTime(time)
         except ValueError:
             raise ValueError("Invalid time, time string = '%s'" % time_string)
     else:
         raise ValueError("Time not on correct format = '%s'" % time_string)
예제 #3
0
def go_to_zero_fn(main_frame, current_period, navigation_fn):
    navigation_fn(lambda tp: tp.center(NumTime(0)))
예제 #4
0
 def start(self, time):
     start = int((time.value / self.size)) * self.size
     if time < NumTime(0):
         start -= self.size
     return NumTime(start)
예제 #5
0
 def now(self):
     return NumTime(0)
예제 #6
0
 def get_default_time_period(self):
     return time_period_center(NumTime(0), NumDelta(100))
예제 #7
0
 def get_value(self):
     return NumTime(int(self.time_picker.GetValue()))