Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/timelinelib/wxgui/components
diff options
context:
space:
mode:
Diffstat (limited to 'timelinelib/wxgui/components')
-rw-r--r--timelinelib/wxgui/components/__init__.py23
-rw-r--r--timelinelib/wxgui/components/categorychoice.py12
-rw-r--r--timelinelib/wxgui/components/cattree.py8
-rw-r--r--timelinelib/wxgui/components/numtimepicker.py8
-rw-r--r--timelinelib/wxgui/components/pydatetimepicker.py60
-rw-r--r--timelinelib/wxgui/components/timelineview.py49
-rw-r--r--timelinelib/wxgui/components/wxdatetimepicker.py56
7 files changed, 104 insertions, 112 deletions
diff --git a/timelinelib/wxgui/components/__init__.py b/timelinelib/wxgui/components/__init__.py
index a8a5fad..e69de29 100644
--- a/timelinelib/wxgui/components/__init__.py
+++ b/timelinelib/wxgui/components/__init__.py
@@ -1,23 +0,0 @@
-# Copyright (C) 2009, 2010, 2011 Rickard Lindberg, Roger Lindberg
-#
-# This file is part of Timeline.
-#
-# Timeline is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Timeline is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Timeline. If not, see <http://www.gnu.org/licenses/>.
-
-
-"""
-All GUI components that can be used in multiple places in the GUI.
-
-One component per file.
-"""
diff --git a/timelinelib/wxgui/components/categorychoice.py b/timelinelib/wxgui/components/categorychoice.py
index 1b00362..6901719 100644
--- a/timelinelib/wxgui/components/categorychoice.py
+++ b/timelinelib/wxgui/components/categorychoice.py
@@ -18,11 +18,11 @@
import wx
-from timelinelib.wxgui.dialogs.categoryeditor import WxCategoryEdtiorDialog
+from timelinelib.db.exceptions import TimelineIOError
+from timelinelib.db.objects.category import sort_categories
from timelinelib.wxgui.dialogs.categorieseditor import CategoriesEditor
+from timelinelib.wxgui.dialogs.categoryeditor import WxCategoryEdtiorDialog
import timelinelib.wxgui.utils as gui_utils
-from timelinelib.db.interface import TimelineIOError
-from timelinelib.domain.category import sort_categories
class CategoryChoice(wx.Choice):
@@ -59,7 +59,7 @@ class CategoryChoice(wx.Choice):
selection = self.GetSelection()
category = self.GetClientData(selection)
return category
-
+
def on_choice(self, e):
new_selection_index = e.GetSelection()
if new_selection_index > self.last_real_category_index:
@@ -73,7 +73,7 @@ class CategoryChoice(wx.Choice):
def _add_category(self):
def create_category_editor():
- return WxCategoryEdtiorDialog(self, _("Add Category"),
+ return WxCategoryEdtiorDialog(self, _("Add Category"),
self.timeline, None)
def handle_success(dialog):
if dialog.GetReturnCode() == wx.ID_OK:
@@ -97,4 +97,4 @@ class CategoryChoice(wx.Choice):
gui_utils.handle_db_error_in_dialog(self, e)
gui_utils.show_modal(create_categories_editor,
gui_utils.create_dialog_db_error_handler(self),
- handle_success)
+ handle_success)
diff --git a/timelinelib/wxgui/components/cattree.py b/timelinelib/wxgui/components/cattree.py
index dd7955c..f5b812a 100644
--- a/timelinelib/wxgui/components/cattree.py
+++ b/timelinelib/wxgui/components/cattree.py
@@ -19,8 +19,8 @@
import wx
import wx.lib.agw.customtreectrl as customtreectrl
-from timelinelib.db.interface import STATE_CHANGE_CATEGORY
-from timelinelib.db.interface import TimelineIOError
+from timelinelib.db.exceptions import TimelineIOError
+from timelinelib.db.observer import STATE_CHANGE_CATEGORY
from timelinelib.wxgui.dialogs.categoryeditor import WxCategoryEdtiorDialog
from timelinelib.wxgui.utils import _ask_question
from timelinelib.wxgui.utils import category_tree
@@ -231,8 +231,8 @@ def delete_category(parent_ctrl, db, cat, fn_handle_db_error):
update_warning = _("Events belonging to '%s' will no longer "
"belong to a category.") % cat.name
else:
- update_warning = _("Events belonging to '%(name)s' will now belong to '%(parent)s'.") \
- % {'name': cat.name, 'parent': cat.parent.name}
+ update_warning = _("Events belonging to '%(name)s' will now belong to '%(parent)s'.") \
+ % {'name': cat.name, 'parent': cat.parent.name}
question = "%s\n\n%s" % (delete_warning, update_warning)
if _ask_question(question, parent_ctrl) == wx.YES:
try:
diff --git a/timelinelib/wxgui/components/numtimepicker.py b/timelinelib/wxgui/components/numtimepicker.py
index 2724895..ed3568e 100644
--- a/timelinelib/wxgui/components/numtimepicker.py
+++ b/timelinelib/wxgui/components/numtimepicker.py
@@ -16,20 +16,15 @@
# along with Timeline. If not, see <http://www.gnu.org/licenses/>.
-import os.path
-import re
-
import wx
-from timelinelib.time import NumTimeType
-
class NumTimePicker(wx.Panel):
def __init__(self, parent, show_time=False, config=None):
wx.Panel.__init__(self, parent)
self.time_picker = self._create_gui()
- self.controller = NumTimePickerController(self, 0)
+ self.controller = NumTimePickerController(self, 0)
def get_value(self):
return self.time_picker.GetValue()
@@ -59,7 +54,6 @@ class NumTimePicker(wx.Panel):
class NumTimePickerController(object):
def __init__(self, time_picker, default_num_time):
- import sys
self.time_picker = time_picker
self.time_picker.set_range(-10000, 10000)
self.default_num_time = default_num_time
diff --git a/timelinelib/wxgui/components/pydatetimepicker.py b/timelinelib/wxgui/components/pydatetimepicker.py
index df7c735..78a1656 100644
--- a/timelinelib/wxgui/components/pydatetimepicker.py
+++ b/timelinelib/wxgui/components/pydatetimepicker.py
@@ -131,14 +131,14 @@ class CalendarPopup(wx.PopupTransientWindow):
def _create_calendar_control(self, wx_date, border):
style = self._get_cal_style()
- cal = wx.calendar.CalendarCtrl(self, -1, wx_date,
+ cal = wx.calendar.CalendarCtrl(self, -1, wx_date,
pos=(border,border), style=style)
self._set_cal_range(cal)
return cal
def _get_cal_style(self):
- style = (wx.calendar.CAL_SHOW_HOLIDAYS |
- wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
+ style = (wx.calendar.CAL_SHOW_HOLIDAYS |
+ wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
if self.config.week_start == "monday":
style |= wx.calendar.CAL_MONDAY_FIRST
else:
@@ -186,7 +186,7 @@ class CalendarPopupController(object):
# month or day. The control is closed on a double-click on a day or
# a single click outside of the control
if self.repop and not self.repoped:
- self.calendar_popup.Popup()
+ self.calendar_popup.Popup()
self.repoped = True
@@ -241,8 +241,8 @@ class PyDatePicker(wx.TextCtrl):
elif evt.GetKeyCode() == wx.WXK_DOWN:
self.controller.on_down()
else:
- evt.Skip()
- self.Bind(wx.EVT_KEY_DOWN, on_key_down)
+ evt.Skip()
+ self.Bind(wx.EVT_KEY_DOWN, on_key_down)
def _resize_to_fit_text(self):
w, h = self.GetTextExtent("0000-00-00")
@@ -285,7 +285,7 @@ class PyDatePickerController(object):
self.py_date_picker.SetSelection(start, end)
else:
self._select_region_if_possible(self.region_year)
- self.last_selection = self.py_date_picker.GetSelection()
+ self.last_selection = self.py_date_picker.GetSelection()
def on_kill_focus(self):
if self.last_selection:
@@ -312,8 +312,8 @@ class PyDatePickerController(object):
# To prevent saving of preferred day when year or month is changed
# in on_up() and on_down()...
# Save preferred day only when text is entered in the date text
- # control and not when up or down keys has been used.
- # When up and down keys are used, the preferred day is saved in
+ # control and not when up or down keys has been used.
+ # When up and down keys are used, the preferred day is saved in
# on_up() and on_down() only when day is changed.
if self.save_preferred_day:
self._save_preferred_day(current_date)
@@ -325,9 +325,9 @@ class PyDatePickerController(object):
return date
def increment_month(date):
if date.month < 12:
- return self._set_valid_day(date.year, date.month + 1,
+ return self._set_valid_day(date.year, date.month + 1,
date.day)
- elif date.year < PyTimeType().get_max_time()[0].year - 1:
+ elif date.year < PyTimeType().get_max_time()[0].year - 1:
return self._set_valid_day(date.year + 1, 1, date.day)
return date
def increment_day(date):
@@ -345,8 +345,8 @@ class PyDatePickerController(object):
else:
new_date = increment_day(current_date)
self._save_preferred_day(new_date)
- if current_date != new_date:
- self._set_new_date_and_restore_selection(new_date, selection)
+ if current_date != new_date:
+ self._set_new_date_and_restore_selection(new_date, selection)
def on_down(self):
def decrement_year(date):
@@ -356,7 +356,7 @@ class PyDatePickerController(object):
def decrement_month(date):
if date.month > 1:
return self._set_valid_day(date.year, date.month - 1, date.day)
- elif date.year > PyTimeType().get_min_time()[0].year:
+ elif date.year > PyTimeType().get_min_time()[0].year:
return self._set_valid_day(date.year - 1, 12, date.day)
return date
def decrement_day(date):
@@ -378,8 +378,8 @@ class PyDatePickerController(object):
else:
new_date = decrement_day(current_date)
self._save_preferred_day(new_date)
- if current_date != new_date:
- self._set_new_date_and_restore_selection(new_date, selection)
+ if current_date != new_date:
+ self._set_new_date_and_restore_selection(new_date, selection)
def _change_background_depending_on_date_validity(self):
if self._current_date_is_valid():
@@ -409,7 +409,7 @@ class PyDatePickerController(object):
self.py_date_picker.SetSelection(selection[0], selection[1])
self.save_preferred_day = False
if self.preferred_day != None:
- new_date = self._set_valid_day(new_date.year, new_date.month,
+ new_date = self._set_valid_day(new_date.year, new_date.month,
self.preferred_day)
self.set_py_date(new_date)
restore_selection(selection)
@@ -421,7 +421,7 @@ class PyDatePickerController(object):
try:
date = datetime.date(year=new_year, month=new_month, day=new_day)
done = True
- except Exception, ex:
+ except Exception, ex:
new_day -= 1
return date
@@ -449,16 +449,16 @@ class PyDatePickerController(object):
return self.py_date_picker.GetInsertionPoint() in region_range
def _get_region_range(self, n):
- # Returns a range of valid cursor positions for a valid region year,
+ # Returns a range of valid cursor positions for a valid region year,
# month or day.
def region_is_not_valid(region):
- return region not in (self.region_year, self.region_month,
+ return region not in (self.region_year, self.region_month,
self.region_day)
def date_has_exactly_two_seperators(datestring):
return len(datestring.split(self.separator)) == 3
def calculate_pos_range(region, datestring):
pos_of_separator1 = datestring.find(self.separator)
- pos_of_separator2 = datestring.find(self.separator,
+ pos_of_separator2 = datestring.find(self.separator,
pos_of_separator1 + 1)
if region == self.region_year:
return range(0, pos_of_separator1 + 1)
@@ -526,8 +526,8 @@ class PyTimePicker(wx.TextCtrl):
elif evt.GetKeyCode() == wx.WXK_DOWN:
self.controller.on_down()
else:
- evt.Skip()
- self.Bind(wx.EVT_KEY_DOWN, on_key_down)
+ evt.Skip()
+ self.Bind(wx.EVT_KEY_DOWN, on_key_down)
def _resize_to_fit_text(self):
w, h = self.GetTextExtent("00:00")
@@ -600,7 +600,7 @@ class PyTimePickerController(object):
def increment_minutes(time):
new_hour = time.hour
new_minute = time.minute + 1
- if new_minute > 59:
+ if new_minute > 59:
new_minute = 0
new_hour = time.hour + 1
if new_hour > 23:
@@ -614,8 +614,8 @@ class PyTimePickerController(object):
new_time = increment_hour(current_time)
else:
new_time = increment_minutes(current_time)
- if current_time != new_time:
- self._set_new_time_and_restore_selection(new_time, selection)
+ if current_time != new_time:
+ self._set_new_time_and_restore_selection(new_time, selection)
def on_down(self):
def decrement_hour(time):
@@ -626,7 +626,7 @@ class PyTimePickerController(object):
def decrement_minutes(time):
new_hour = time.hour
new_minute = time.minute - 1
- if new_minute < 0:
+ if new_minute < 0:
new_minute = 59
new_hour = time.hour - 1
if new_hour < 0:
@@ -640,8 +640,8 @@ class PyTimePickerController(object):
new_time = decrement_hour(current_time)
else:
new_time = decrement_minutes(current_time)
- if current_time != new_time:
- self._set_new_time_and_restore_selection(new_time, selection)
+ if current_time != new_time:
+ self._set_new_time_and_restore_selection(new_time, selection)
def _set_new_time_and_restore_selection(self, new_time, selection):
def restore_selection(selection):
@@ -661,7 +661,7 @@ class PyTimePickerController(object):
return
if part == self.hour_part:
self.py_time_picker.SetSelection(0, self._separator_pos())
- else:
+ else:
time_string_len = len(self.py_time_picker.get_time_string())
self.py_time_picker.SetSelection(self._separator_pos() + 1, time_string_len)
self.preferred_part = part
diff --git a/timelinelib/wxgui/components/timelineview.py b/timelinelib/wxgui/components/timelineview.py
index a928884..7879921 100644
--- a/timelinelib/wxgui/components/timelineview.py
+++ b/timelinelib/wxgui/components/timelineview.py
@@ -20,14 +20,20 @@ import wx
from timelinelib.drawing import get_drawer
from timelinelib.view.drawingarea import DrawingArea
+from timelinelib.wxgui.dialogs.duplicateevent import open_duplicate_event_dialog_for_event
+from timelinelib.wxgui.dialogs.eventeditor import open_create_event_editor
+from timelinelib.wxgui.dialogs.eventeditor import open_event_editor_for
from timelinelib.wxgui.utils import _ask_question
class DrawingAreaPanel(wx.Panel):
def __init__(self, parent, status_bar_adapter, divider_line_slider,
- fn_handle_db_error, config):
+ fn_handle_db_error, config, main_frame):
wx.Panel.__init__(self, parent, style=wx.NO_BORDER)
+ self.fn_handle_db_error = fn_handle_db_error
+ self.config = config
+ self.main_frame = main_frame
self.controller = DrawingArea(
self, status_bar_adapter, config, get_drawer(),
divider_line_slider, fn_handle_db_error)
@@ -79,16 +85,31 @@ class DrawingAreaPanel(wx.Panel):
self.Update()
def enable_disable_menus(self):
- wx.GetTopLevelParent(self).enable_disable_menus()
-
- def edit_event(self, event):
- wx.GetTopLevelParent(self).edit_event(event)
-
- def duplicate_event(self, event):
- wx.GetTopLevelParent(self).duplicate_event(event)
-
- def create_new_event(self, start_time, end_time):
- wx.GetTopLevelParent(self).create_new_event(start_time, end_time)
+ self.main_frame.enable_disable_menus()
+
+ def open_event_editor_for(self, event):
+ open_event_editor_for(
+ self,
+ self.config,
+ self.controller.get_timeline(),
+ self.fn_handle_db_error,
+ event)
+
+ def open_duplicate_event_dialog_for_event(self, event):
+ open_duplicate_event_dialog_for_event(
+ self,
+ self.controller.get_timeline(),
+ self.fn_handle_db_error,
+ event)
+
+ def open_create_event_editor(self, start_time, end_time):
+ open_create_event_editor(
+ self,
+ self.config,
+ self.controller.get_timeline(),
+ self.fn_handle_db_error,
+ start_time,
+ end_time)
def start_balloon_show_timer(self, milliseconds=-1, oneShot=False):
self.balloon_show_timer.Start(milliseconds, oneShot)
@@ -164,7 +185,7 @@ class DrawingAreaPanel(wx.Panel):
self.controller.window_resized()
def _on_left_down(self, evt):
- self.controller.left_mouse_down(evt.m_x, evt.m_y, evt.m_controlDown,
+ self.controller.left_mouse_down(evt.m_x, evt.m_y, evt.m_controlDown,
evt.m_shiftDown, evt.m_altDown)
evt.Skip()
@@ -172,7 +193,7 @@ class DrawingAreaPanel(wx.Panel):
self.controller.right_mouse_down(evt.m_x, evt.m_y, evt.m_altDown)
def _on_left_dclick(self, evt):
- self.controller.left_mouse_dclick(evt.m_x, evt.m_y, evt.m_controlDown,
+ self.controller.left_mouse_dclick(evt.m_x, evt.m_y, evt.m_controlDown,
evt.m_altDown)
def _on_middle_up(self, evt):
@@ -188,7 +209,7 @@ class DrawingAreaPanel(wx.Panel):
self.controller.mouse_moved(evt.m_x, evt.m_y, evt.m_altDown)
def _on_mousewheel(self, evt):
- self.controller.mouse_wheel_moved(evt.m_wheelRotation, evt.ControlDown(), evt.ShiftDown())
+ self.controller.mouse_wheel_moved(evt.m_wheelRotation, evt.ControlDown(), evt.ShiftDown(), evt.GetX())
def _on_key_down(self, evt):
self.controller.key_down(evt.GetKeyCode(), evt.AltDown())
diff --git a/timelinelib/wxgui/components/wxdatetimepicker.py b/timelinelib/wxgui/components/wxdatetimepicker.py
index 1d3e541..1267701 100644
--- a/timelinelib/wxgui/components/wxdatetimepicker.py
+++ b/timelinelib/wxgui/components/wxdatetimepicker.py
@@ -72,7 +72,7 @@ class WxDateTimePicker(wx.Panel):
self._position_calendar_popup(evt)
self.calendar_popup.Popup()
except:
- _display_error_message(_("Invalid date"))
+ _display_error_message(_("Invalid date"))
def _create_calendar_popup(self):
wx_date = self.controller.get_value()
@@ -128,14 +128,14 @@ class CalendarPopup(wx.PopupTransientWindow):
wx.PopupTransientWindow.__init__(self, parent, style=wx.BORDER_NONE)
border = 2
style = self._get_cal_style()
- self.cal = wx.calendar.CalendarCtrl(self, -1, wx_date,
+ self.cal = wx.calendar.CalendarCtrl(self, -1, wx_date,
pos=(border,border), style=style)
self._set_cal_range()
self._set_size(border)
self._bind_events()
def _get_cal_style(self):
- style = (wx.calendar.CAL_SHOW_HOLIDAYS |
+ style = (wx.calendar.CAL_SHOW_HOLIDAYS |
wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION)
if self.config.week_start == "monday":
style |= wx.calendar.CAL_MONDAY_FIRST
@@ -183,7 +183,7 @@ class CalendarPopupController(object):
# month or day. The control is closed on a double-click on a day or
# a single click outside of the control
if self.repop and not self.repoped:
- self.calendar_popup.Popup()
+ self.calendar_popup.Popup()
self.repoped = True
@@ -212,7 +212,7 @@ class WxDatePicker(wx.TextCtrl):
self.Bind(wx.EVT_KILL_FOCUS, self._on_kill_focus)
self.Bind(wx.EVT_CHAR, self._on_char)
self.Bind(wx.EVT_TEXT, self._on_text)
- self.Bind(wx.EVT_KEY_DOWN, self._on_key_down)
+ self.Bind(wx.EVT_KEY_DOWN, self._on_key_down)
def _on_set_focus(self, evt):
# CallAfter is a trick to prevent default behavior of selecting all
@@ -244,7 +244,7 @@ class WxDatePicker(wx.TextCtrl):
elif evt.GetKeyCode() == wx.WXK_DOWN:
self.controller.on_down()
else:
- evt.Skip()
+ evt.Skip()
def _resize_to_fit_text(self):
w, h = self.GetTextExtent("0000-00-00")
@@ -287,7 +287,7 @@ class WxDatePickerController(object):
self.wx_date_picker.SetSelection(start, end)
else:
self._select_region_if_possible(self.region_year)
- self.last_selection = self.wx_date_picker.GetSelection()
+ self.last_selection = self.wx_date_picker.GetSelection()
def on_kill_focus(self):
if self.last_selection:
@@ -314,8 +314,8 @@ class WxDatePickerController(object):
# To prevent saving of preferred day when year or month is changed
# in on_up() and on_down()...
# Save preferred day only when text is entered in the date text
- # control and not when up or down keys has been used.
- # When up and down keys are used, the preferred day is saved in
+ # control and not when up or down keys has been used.
+ # When up and down keys are used, the preferred day is saved in
# on_up() and on_down() only when day is changed.
if self.save_preferred_day:
self._save_preferred_day(current_date)
@@ -330,7 +330,7 @@ class WxDatePickerController(object):
else:
new_date = self._increment_day()
self._save_preferred_day(new_date)
- self._set_new_date_and_restore_selection(new_date)
+ self._set_new_date_and_restore_selection(new_date)
def on_down(self):
if not self._current_date_is_valid():
@@ -342,7 +342,7 @@ class WxDatePickerController(object):
else:
new_date = self._decrement_day()
self._save_preferred_day(new_date)
- self._set_new_date_and_restore_selection(new_date)
+ self._set_new_date_and_restore_selection(new_date)
def _increment_year(self):
date = self.get_date()
@@ -354,7 +354,7 @@ class WxDatePickerController(object):
date = self.get_date()
if date.Month < 11:
date = self._set_valid_day(date.Year, date.Month + 1, date.Day)
- elif date.Year < WxTimeType().get_max_time()[0].Year - 1:
+ elif date.Year < WxTimeType().get_max_time()[0].Year - 1:
date = self._set_valid_day(date.Year + 1, 0, date.Day)
return date
@@ -374,7 +374,7 @@ class WxDatePickerController(object):
date = self.get_date()
if date.Month > 0:
date = self._set_valid_day(date.Year, date.Month - 1, date.Day)
- elif date.Year > WxTimeType().get_min_time()[0].Year:
+ elif date.Year > WxTimeType().get_min_time()[0].Year:
date = self._set_valid_day(date.Year - 1, 11, date.Day)
return date
@@ -399,10 +399,10 @@ class WxDatePickerController(object):
def _parse_year_month_day(self):
date_string = self.wx_date_picker.get_date_string()
- date_bc = False
+ date_bc = False
if (date_string[0:1] == self.separator):
date_string = date_string[1:]
- date_bc = True
+ date_bc = True
components = date_string.split(self.separator)
if len(components) != 3:
raise ValueError()
@@ -424,7 +424,7 @@ class WxDatePickerController(object):
selection = self.wx_date_picker.GetSelection()
self.save_preferred_day = False
if self.preferred_day != None:
- new_date = self._set_valid_day(new_date.Year, new_date.Month,
+ new_date = self._set_valid_day(new_date.Year, new_date.Month,
self.preferred_day)
self.set_date(new_date)
restore_selection(selection)
@@ -434,7 +434,7 @@ class WxDatePickerController(object):
while True:
try:
return try_to_create_wx_date_time_from_dmy(new_day, new_month, new_year)
- except ValueError:
+ except ValueError:
new_day -= 1
def _save_preferred_day(self, date):
@@ -462,16 +462,16 @@ class WxDatePickerController(object):
return self.wx_date_picker.GetInsertionPoint() in region_range
def _get_region_range(self, n):
- # Returns a range of valid cursor positions for a valid region year,
+ # Returns a range of valid cursor positions for a valid region year,
# month or day.
def region_is_not_valid(region):
- return region not in (self.region_year, self.region_month,
+ return region not in (self.region_year, self.region_month,
self.region_day)
def date_has_exactly_two_seperators(datestring):
return len(datestring.split(self.separator)) == 3
def calculate_pos_range(region, datestring):
pos_of_separator1 = datestring.find(self.separator)
- pos_of_separator2 = datestring.find(self.separator,
+ pos_of_separator2 = datestring.find(self.separator,
pos_of_separator1 + 1)
if region == self.region_year:
return range(0, pos_of_separator1 + 1)
@@ -513,7 +513,7 @@ class WxTimePicker(wx.TextCtrl):
self.Bind(wx.EVT_KILL_FOCUS, self._on_kill_focus)
self.Bind(wx.EVT_CHAR, self._on_char)
self.Bind(wx.EVT_TEXT, self._on_text)
- self.Bind(wx.EVT_KEY_DOWN, self._on_key_down)
+ self.Bind(wx.EVT_KEY_DOWN, self._on_key_down)
def _on_set_focus(self, evt):
# CallAfter is a trick to prevent default behavior of selecting all
@@ -545,7 +545,7 @@ class WxTimePicker(wx.TextCtrl):
elif evt.GetKeyCode() == wx.WXK_DOWN:
self.controller.on_down()
else:
- evt.Skip()
+ evt.Skip()
def _resize_to_fit_text(self):
w, h = self.GetTextExtent("00:00")
@@ -616,7 +616,7 @@ class WxTimePickerController(object):
new_time = self._increment_hour()
else:
new_time = self._increment_minutes()
- self._set_new_time_and_restore_selection(new_time)
+ self._set_new_time_and_restore_selection(new_time)
def on_down(self):
if not self._time_is_valid():
@@ -625,7 +625,7 @@ class WxTimePickerController(object):
new_time = self._decrement_hour()
else:
new_time = self._decrement_minutes()
- self._set_new_time_and_restore_selection(new_time)
+ self._set_new_time_and_restore_selection(new_time)
def _increment_hour(self):
time = self.get_time()
@@ -639,13 +639,13 @@ class WxTimePickerController(object):
time = self.get_time()
new_hour = time.Hour
new_minute = time.Minute + 1
- if new_minute > 59:
+ if new_minute > 59:
new_minute = 0
new_hour = time.Hour + 1
if new_hour > 23:
new_hour = 0
time.SetHour(new_hour)
- time.SetMinute(new_minute)
+ time.SetMinute(new_minute)
return time
def _decrement_hour(self):
@@ -660,7 +660,7 @@ class WxTimePickerController(object):
time = self.get_time()
new_hour = time.Hour
new_minute = time.Minute - 1
- if new_minute < 0:
+ if new_minute < 0:
new_minute = 59
new_hour = time.Hour - 1
if new_hour < 0:
@@ -688,7 +688,7 @@ class WxTimePickerController(object):
return
if part == self.hour_part:
self.wx_time_picker.SetSelection(0, self._separator_pos())
- else:
+ else:
time_string_len = len(self.wx_time_picker.get_time_string())
self.wx_time_picker.SetSelection(self._separator_pos() + 1, time_string_len)
self.preferred_part = part