@@ -29,71 +29,67 @@ def __init__(self, parent):
2929 ProfilesDialog ._instance = self
3030 # Translators: The title of the Configuration Profiles dialog.
3131 super (ProfilesDialog , self ).__init__ (parent , title = _ ("Configuration Profiles" ))
32- mainSizer = wx .BoxSizer (wx .VERTICAL )
3332
3433 self .currentAppName = (gui .mainFrame .prevFocus or api .getFocusObject ()).appModule .appName
3534 self .profileNames = [None ]
3635 self .profileNames .extend (config .conf .listProfiles ())
3736
38- profilesListGroupSizer = wx .StaticBoxSizer (wx .StaticBox (self , wx .ID_ANY ), wx .HORIZONTAL )
37+ mainSizer = wx .BoxSizer (wx .VERTICAL )
38+ sHelper = guiHelper .BoxSizerHelper (self ,orientation = wx .VERTICAL )
39+ profilesListGroupSizer = wx .StaticBoxSizer (wx .StaticBox (self ), wx .HORIZONTAL )
40+ profilesListGroupContents = wx .BoxSizer (wx .HORIZONTAL )
3941
40- sizer = wx .BoxSizer (wx .VERTICAL )
42+ #contains the profile list and activation button in vertical arrangement.
43+ changeProfilesSizer = wx .BoxSizer (wx .VERTICAL )
4144 item = self .profileList = wx .ListBox (self ,
4245 choices = [self .getProfileDisplay (name , includeStates = True ) for name in self .profileNames ])
4346 item .Bind (wx .EVT_LISTBOX , self .onProfileListChoice )
4447 item .Selection = self .profileNames .index (config .conf .profiles [- 1 ].name )
45- sizer .Add (item , proportion = 1.0 )
48+ changeProfilesSizer .Add (item , proportion = 1.0 )
4649
47- spaceBetweenItemsInGroupSizer = 5
48- profilesListGroupSizer .Add (sizer , border = spaceBetweenItemsInGroupSizer , flag = wx .EXPAND | wx .ALL )
50+ changeProfilesSizer .AddSpacer (guiHelper .SPACE_BETWEEN_BUTTONS_VERTICALLY )
4951
50- item = self .changeStateButton = wx .Button (self )
51- item .Bind (wx .EVT_BUTTON , self .onChangeState )
52- self .AffirmativeId = item .Id
53- item .SetDefault ()
54- sizer .AddSpacer (spaceBetweenItemsInGroupSizer )
55- sizer .Add (item )
52+ self .changeStateButton = wx .Button (self )
53+ self .changeStateButton .Bind (wx .EVT_BUTTON , self .onChangeState )
54+ self .AffirmativeId = self .changeStateButton .Id
55+ self .changeStateButton .SetDefault ()
56+ changeProfilesSizer .Add (self .changeStateButton )
57+
58+ profilesListGroupContents .Add (changeProfilesSizer , flag = wx .EXPAND )
59+ profilesListGroupContents .AddSpacer (guiHelper .SPACE_BETWEEN_ASSOCIATED_CONTROL_HORIZONTAL )
5660
57- sizer = wx . BoxSizer (wx .VERTICAL )
61+ buttonHelper = guiHelper . ButtonHelper (wx .VERTICAL )
5862 # Translators: The label of a button to create a new configuration profile.
59- item = newButton = wx .Button (self , label = _ ("&New" ))
60- item .Bind (wx .EVT_BUTTON , self .onNew )
61- buttonsToAdd = [item ,]
63+ newButton = buttonHelper .addButton (self , label = _ ("&New" ))
64+ newButton .Bind (wx .EVT_BUTTON , self .onNew )
6265
6366 # Translators: The label of a button to rename a configuration profile.
64- item = self .renameButton = wx .Button (self , label = _ ("&Rename" ))
65- item .Bind (wx .EVT_BUTTON , self .onRename )
66- buttonsToAdd .append (item )
67+ self .renameButton = buttonHelper .addButton (self , label = _ ("&Rename" ))
68+ self .renameButton .Bind (wx .EVT_BUTTON , self .onRename )
6769
6870 # Translators: The label of a button to delete a configuration profile.
69- item = self .deleteButton = wx .Button (self , label = _ ("&Delete" ))
70- item .Bind (wx .EVT_BUTTON , self .onDelete )
71- buttonsToAdd .append (item )
72- # these buttons are closely related, and are stacked vertically. They look better closer together
73- spaceBetweenButtons = 3
74- guiHelper .addItemsToSizer (sizer , buttonsToAdd , spaceBetweenButtons )
75- profilesListGroupSizer .Add (sizer , border = spaceBetweenItemsInGroupSizer , flag = wx .ALL )
71+ self .deleteButton = buttonHelper .addButton (self , label = _ ("&Delete" ))
72+ self .deleteButton .Bind (wx .EVT_BUTTON , self .onDelete )
7673
77- mainSizer .Add (profilesListGroupSizer , flag = wx .ALL , border = 5 )
74+ profilesListGroupContents .Add (buttonHelper .sizer )
75+ profilesListGroupSizer .Add (profilesListGroupContents , border = guiHelper .BORDER_FOR_DIALOGS , flag = wx .ALL )
76+ sHelper .addItem (profilesListGroupSizer )
7877
79- sizer = wx .BoxSizer (wx .HORIZONTAL )
8078 # Translators: The label of a button to manage triggers
8179 # in the Configuration Profiles dialog.
8280 # See the Configuration Profiles section of the User Guide for details.
8381 triggersButton = wx .Button (self , label = _ ("&Triggers..." ))
8482 triggersButton .Bind (wx .EVT_BUTTON , self .onTriggers )
85- sizer .Add (triggersButton )
86- sizer .AddSpacer (5 )
83+
8784 # Translators: The label of a checkbox in the Configuration Profiles dialog.
88- item = self .disableTriggersToggle = wx .CheckBox (self , label = _ ("Temporarily d&isable all triggers" ))
89- item .Value = not config .conf .profileTriggersEnabled
90- sizer .Add (item , flag = wx .ALIGN_CENTER_VERTICAL )
91- mainSizer .Add (sizer , flag = wx .ALL , border = 10 )
85+ self .disableTriggersToggle = wx .CheckBox (self , label = _ ("Temporarily d&isable all triggers" ))
86+ self .disableTriggersToggle .Value = not config .conf .profileTriggersEnabled
87+ sHelper .addItem (guiHelper .associateElements (triggersButton ,self .disableTriggersToggle ))
9288
9389 # Translators: The label of a button to close a dialog.
94- item = wx .Button (self , wx .ID_CLOSE , label = _ ("&Close" ))
95- item .Bind (wx .EVT_BUTTON , lambda evt : self .Close ())
96- mainSizer . Add ( item , flag = wx . ALL , border = 10 )
90+ closeButton = wx .Button (self , wx .ID_CLOSE , label = _ ("&Close" ))
91+ closeButton .Bind (wx .EVT_BUTTON , lambda evt : self .Close ())
92+ sHelper . addItem ( closeButton )
9793 self .Bind (wx .EVT_CLOSE , self .onClose )
9894 self .EscapeId = wx .ID_CLOSE
9995
@@ -102,6 +98,7 @@ def __init__(self, parent):
10298 item .Disable ()
10399 self .onProfileListChoice (None )
104100
101+ mainSizer .Add (sHelper .sizer , flag = wx .ALL , border = guiHelper .BORDER_FOR_DIALOGS )
105102 mainSizer .Fit (self )
106103 self .Sizer = mainSizer
107104 self .profileList .SetFocus ()
@@ -287,6 +284,7 @@ def __init__(self, parent):
287284 # Translators: The title of the configuration profile triggers dialog.
288285 super (TriggersDialog , self ).__init__ (parent , title = _ ("Profile Triggers" ))
289286 mainSizer = wx .BoxSizer (wx .VERTICAL )
287+ sHelper = guiHelper .BoxSizerHelper (self , orientation = wx .VERTICAL )
290288
291289 processed = set ()
292290 triggers = self .triggers = []
@@ -311,34 +309,29 @@ def __init__(self, parent):
311309 continue
312310 triggers .append (TriggerInfo (spec , disp , profile ))
313311
314- sizer = wx . BoxSizer ( wx . VERTICAL )
312+
315313 # Translators: The label of the triggers list in the Configuration Profile Triggers dialog.
316- sizer .Add (wx .StaticText (self , label = _ ("Triggers" )))
317- item = self .triggerList = wx .ListBox (self , choices = [trig .display for trig in triggers ])
318- item .Bind (wx .EVT_LISTBOX , self .onTriggerListChoice )
319- item .Selection = 0
320- sizer .Add (item , flag = wx .EXPAND )
321- mainSizer .Add (sizer , border = 10 , flag = wx .ALL | wx .EXPAND )
314+ triggersText = _ ("Triggers" )
315+ triggerChoices = [trig .display for trig in triggers ]
316+ self .triggerList = sHelper .addLabeledControl (triggersText , wx .ListBox , choices = triggerChoices )
317+ self .triggerList .Bind (wx .EVT_LISTBOX , self .onTriggerListChoice )
318+ self .triggerList .Selection = 0
322319
323- sizer = wx .BoxSizer (wx .HORIZONTAL )
324320 # Translators: The label of the profile list in the Configuration Profile Triggers dialog.
325- sizer .Add (wx .StaticText (self , label = _ ("Profile" )), flag = wx .ALIGN_CENTER_VERTICAL )
326- sizer .AddSpacer (5 )
327- item = self .profileList = wx .Choice (self ,
328- choices = [parent .getProfileDisplay (name ) for name in parent .profileNames ])
329- item .Bind (wx .EVT_CHOICE , self .onProfileListChoice )
330- sizer .Add (item , proportion = 1.0 )
331- mainSizer .Add (sizer , border = 10 , flag = wx .ALL | wx .EXPAND )
332-
333- item = wx .Button (self , wx .ID_CLOSE , label = _ ("&Close" ))
334- item .Bind (wx .EVT_BUTTON , lambda evt : self .Close ())
335- mainSizer .Add (item , border = 10 , flag = wx .ALL )
321+ profileText = _ ("Profile" )
322+ profileChoices = [parent .getProfileDisplay (name ) for name in parent .profileNames ]
323+ self .profileList = sHelper .addLabeledControl (profileText , wx .Choice , choices = profileChoices )
324+ self .profileList .Bind (wx .EVT_CHOICE , self .onProfileListChoice )
325+
326+ closeButton = sHelper .addItem (wx .Button (self , wx .ID_CLOSE , label = _ ("&Close" )))
327+ closeButton .Bind (wx .EVT_BUTTON , lambda evt : self .Close ())
336328 self .Bind (wx .EVT_CLOSE , self .onClose )
337329 self .AffirmativeId = wx .ID_CLOSE
338- item .SetDefault ()
330+ closeButton .SetDefault ()
339331 self .EscapeId = wx .ID_CLOSE
340332
341333 self .onTriggerListChoice (None )
334+ mainSizer .Add (sHelper .sizer , border = guiHelper .BORDER_FOR_DIALOGS , flag = wx .ALL )
342335 mainSizer .Fit (self )
343336 self .Sizer = mainSizer
344337 self .Center (wx .BOTH | wx .CENTER_ON_SCREEN )
0 commit comments