commit/dayOfTheWeek: abdel792: Added the compatibility of the add-on with the NVDA versions that preceded version 2016.4, which included the gui.guiHelper module

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Thu, 12 Oct 2017 23:31:14 +0000 (UTC)

1 new commit in dayOfTheWeek:

https://bitbucket.org/nvdaaddonteam/dayoftheweek/commits/3a338925d8b0/
Changeset:   3a338925d8b0
Branch:      stable
User:        abdel792
Date:        2017-10-12 23:22:24+00:00
Summary:     Added the compatibility of the add-on with the NVDA versions that 
preceded version 2016.4, which included the gui.guiHelper module

Affected #:  2 files

diff --git a/addon/globalPlugins/DayOfTheWeek.py 
b/addon/globalPlugins/DayOfTheWeek.py
index 2be4d38..e0e1925 100644
--- a/addon/globalPlugins/DayOfTheWeek.py
+++ b/addon/globalPlugins/DayOfTheWeek.py
@@ -90,18 +90,39 @@ class DateDialog (wx.Dialog):
                # Translators: The title of the Date Dialog.
                dlgTitle = _("Get the day of the week")
                super (DateDialog,self).__init__(parent,title = dlgTitle)
-               mainSizer = wx.BoxSizer (wx.VERTICAL)
-               sHelper = gui.guiHelper.BoxSizerHelper (self, orientation = 
wx.VERTICAL)
+               self.mainSizer = wx.BoxSizer (wx.VERTICAL)
                # Translators: A label for a list in a dialog.
-               dateLabel = _("Type or select a date")
-               sHelper.addItem (wx.StaticText (self, label = dateLabel))
+               self.dateLabel = _("Type or select a date")
+               # This try/except/else block has been added to ensure the 
compatibility of the add-on with the NVDA versions that preceded version 
2016.4, which included the gui.guiHelper module.
+               try:
+                       import gui.guiHelper
+               except ImportError:
+                       self.showDateDialog ()
+               else:
+                       self.showDateDialogForGuiHelper ()
+
+       def showDateDialogForGuiHelper (self):
+               sHelper = gui.guiHelper.BoxSizerHelper (self, orientation = 
wx.VERTICAL)
+               sHelper.addItem (wx.StaticText (self, label = self.dateLabel))
                self.datePicker = sHelper.addItem (wx.DatePickerCtrl (self))
                sHelper.addDialogDismissButtons (self.CreateButtonSizer 
(wx.OK|wx.CANCEL))
                self.datePicker.Bind (wx.EVT_CHAR, self.onListChar)
                self.Bind (wx.EVT_BUTTON, self.onOk, id = wx.ID_OK)
-               mainSizer.Add (sHelper.sizer, border = 
gui.guiHelper.BORDER_FOR_DIALOGS, flag = wx.ALL)
-               self.Sizer = mainSizer
-               mainSizer.Fit (self)
+               self.mainSizer.Add (sHelper.sizer, border = 
gui.guiHelper.BORDER_FOR_DIALOGS, flag = wx.ALL)
+               self.Sizer = self.mainSizer
+               self.mainSizer.Fit (self)
+               self.datePicker.SetFocus ()
+               self.Center (wx.BOTH | wx.CENTER_ON_SCREEN)
+       def showDateDialog (self):
+               datesLabel = wx.StaticText(self,-1,label=self.dateLabel)
+               self.mainSizer.Add (datesLabel)
+               self.datePicker = wx.DatePickerCtrl (self)
+               self.mainSizer.Add (item = self.datePicker, proportion = 
0,flag=wx.ALL, border = 5)
+               self.mainSizer.Add (self.CreateButtonSizer (wx.OK | wx.CANCEL))
+               self.datePicker.Bind (wx.EVT_CHAR, self.onListChar)
+               self.Bind (wx.EVT_BUTTON, self.onOk, id=wx.ID_OK)
+               self.mainSizer.Fit (self)
+               self.SetSizer (self.mainSizer)
                self.datePicker.SetFocus ()
                self.Center (wx.BOTH | wx.CENTER_ON_SCREEN)
 
@@ -143,17 +164,28 @@ class DayOfWeekSettingsDialog (SettingsDialog):
        )
 
        def makeSettings (self, settingsSizer):
-               settingsSizerHelper = gui.guiHelper.BoxSizerHelper (self, sizer 
= settingsSizer)
                # Translators: The label of the checkbox to enable or disable 
the date selector accessibility.
-               enableAnnounces = _("En&able the accessibility of the date 
selector:")
-               self.enableAnnouncesCheckBox = wx.CheckBox (parent = self, 
label = enableAnnounces)
+               self.enableAnnounces = _("En&able the accessibility of the date 
selector:")
+               # Translators: The label for an item to select the level of the 
announces of labels (short, long or disabled).
+               self.labelAnnounceLevelText = _("Level of the announces of 
&labels:")
+               # Translators: The label of the checkbox to enable or disable 
the current date field value only announcement when moving vertically.
+               self.valueAnnounce = _("Enable announcements of the current 
date field value only, when moving &vertically:")
+               # This try/except/else block has been added to ensure the 
compatibility of the add-on with the NVDA versions that preceded version 
2016.4, which included the gui.guiHelper module.
+               try:
+                       import gui.guiHelper
+               except ImportError:
+                       self.showSettingsDialog (settingsSizer = settingsSizer)
+               else:
+                       self.showSettingsDialogForGuiHelper (settingsSizer = 
settingsSizer)
+
+       def showSettingsDialogForGuiHelper (self, settingsSizer):
+               settingsSizerHelper = gui.guiHelper.BoxSizerHelper (self, sizer 
= settingsSizer)
+               self.enableAnnouncesCheckBox = wx.CheckBox (self, label = 
self.enableAnnounces)
                self.enableAnnouncesCheckBox.SetValue 
(config.conf["dayOfWeek"]["enableAnnounces"])
                settingsSizerHelper.addItem (self.enableAnnouncesCheckBox)
 
-               # Translators: The label for an item to select the level of the 
announces of labels (short, long or disabled).
-               labelAnnounceLevelText = _("Level of the announces of &labels:")
                labelAnnounceLevelChoices = [name for level, name in 
self.LABEL_ANNOUNCE_LEVELS]
-               self.labelAnnounceLevelsList = 
settingsSizerHelper.addLabeledControl(labelAnnounceLevelText, wx.Choice, 
choices = labelAnnounceLevelChoices)
+               self.labelAnnounceLevelsList = 
settingsSizerHelper.addLabeledControl(self.labelAnnounceLevelText, wx.Choice, 
choices = labelAnnounceLevelChoices)
                curLevel = config.conf["dayOfWeek"]["labelAnnounceLevel"]
                for index, (level, name) in 
enumerate(self.LABEL_ANNOUNCE_LEVELS):
                        if level == curLevel:
@@ -163,14 +195,39 @@ class DayOfWeekSettingsDialog (SettingsDialog):
                                log.debugWarning("Could not set level list to 
current level of the announces of labels")
                self.labelAnnounceLevelsList.Enabled = 
self.enableAnnouncesCheckBox.IsChecked ()
 
-               # Translators: The label of the checkbox to enable or disable 
the current date field value only announcement when moving vertically.
-               valueAnnounce = _("Enable announcements of the current date 
field value only, when moving &vertically:")
-               self.reportDateFieldValuesCheckBox = wx.CheckBox (parent = 
self, label = valueAnnounce)
+               self.reportDateFieldValuesCheckBox = wx.CheckBox (self, label = 
self.valueAnnounce)
                self.reportDateFieldValuesCheckBox.SetValue 
(config.conf["dayOfWeek"]["reportFieldsValuesWhenMovingVertically"])
                settingsSizerHelper.addItem (self.reportDateFieldValuesCheckBox)
                self.reportDateFieldValuesCheckBox.Enabled = 
self.enableAnnouncesCheckBox.IsChecked ()
                self.enableAnnouncesCheckBox.Bind (wx.EVT_CHECKBOX, 
self.onCheckAnnounces)
 
+       def showSettingsDialog (self, settingsSizer):
+               dialogSizer = wx.BoxSizer (wx.VERTICAL)
+               self.enableAnnouncesCheckBox = wx.CheckBox (self, label = 
self.enableAnnounces)
+               self.enableAnnouncesCheckBox.SetValue 
(config.conf["dayOfWeek"]["enableAnnounces"])
+               dialogSizer.Add (self.enableAnnouncesCheckBox)
+
+               labelAnnounceLevelChoices = [name for level, name in 
self.LABEL_ANNOUNCE_LEVELS]
+               labelAnnounce = wx.StaticText 
(self,label=self.labelAnnounceLevelText)
+               dialogSizer.Add (labelAnnounce)
+               self.labelAnnounceLevelsList = wx.Choice (self, choices = 
labelAnnounceLevelChoices)
+               curLevel = config.conf["dayOfWeek"]["labelAnnounceLevel"]
+               for index, (level, name) in 
enumerate(self.LABEL_ANNOUNCE_LEVELS):
+                       if level == curLevel:
+                               self.labelAnnounceLevelsList.SetSelection(index)
+                               break
+                       else:
+                               log.debugWarning("Could not set level list to 
current level of the announces of labels")
+               dialogSizer.Add (self.labelAnnounceLevelsList)
+               self.labelAnnounceLevelsList.Enabled = 
self.enableAnnouncesCheckBox.IsChecked ()
+
+               self.reportDateFieldValuesCheckBox = wx.CheckBox (self, label = 
self.valueAnnounce)
+               self.reportDateFieldValuesCheckBox.SetValue 
(config.conf["dayOfWeek"]["reportFieldsValuesWhenMovingVertically"])
+               dialogSizer.Add (self.reportDateFieldValuesCheckBox)
+               settingsSizer.Add (dialogSizer, border=10, flag=wx.BOTTOM)
+               self.reportDateFieldValuesCheckBox.Enabled = 
self.enableAnnouncesCheckBox.IsChecked ()
+               self.enableAnnouncesCheckBox.Bind (wx.EVT_CHECKBOX, 
self.onCheckAnnounces)
+
        def postInit (self):
                self.enableAnnouncesCheckBox.SetFocus ()
 

diff --git a/readme.md b/readme.md
index a26d96c..53e14ef 100644
--- a/readme.md
+++ b/readme.md
@@ -30,7 +30,8 @@ It adds a submenu in the NVDA Preferences menu named "Day of 
the week", containi
 
 ## Changes for 4.0 ##
 
-*       The add-on is now able to recognize all the regional date formats that 
the user can choose.
+*       The add-on is now able to recognize all the regional date formats that 
the user can choose.;
+*       Added the backward compatibility of the add-on with the NVDA versions 
that preceded version 2016.4, which included the gui.guiHelper module.
 
 ## Changes for 3.1 ##
 
@@ -54,4 +55,4 @@ It adds a submenu in the NVDA Preferences menu named "Day of 
the week", containi
 
 [1]: 
https://github.com/abdel792/dayOfTheWeek/releases/download/v4.0/dayOfTheWeek-4.0.nvda-addon
 
-[2]: 
https://github.com/abdel792/dayOfTheWeek/releases/download/v4.0-dev/dayOfTheWeek-4.0-dev.nvda-addon
+[2]: 
https://github.com/abdel792/dayOfTheWeek/releases/download/v4.0/dayOfTheWeek-4.0.nvda-addon

Repository URL: https://bitbucket.org/nvdaaddonteam/dayoftheweek/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.

Other related posts:

  • » commit/dayOfTheWeek: abdel792: Added the compatibility of the add-on with the NVDA versions that preceded version 2016.4, which included the gui.guiHelper module - commits-noreply