Don't use fixed width labels in WAMP and PYRO dialogs
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 08 Jun 2018 15:10:27 +0300
changeset 2180 017ad9cc20b9
parent 2179 84c4e56b38d6
child 2181 52630996e51b
Don't use fixed width labels in WAMP and PYRO dialogs

This causes problems if labels are translated into other languages and
width wasn't enough.
connectors/PYRO/dialog.py
connectors/WAMP/dialog.py
--- a/connectors/PYRO/dialog.py	Thu Jun 07 16:58:13 2018 +0300
+++ b/connectors/PYRO/dialog.py	Fri Jun 08 15:10:27 2018 +0300
@@ -35,20 +35,14 @@
             self.PortText = wx.TextCtrl(parent=self, id=ID_PORTTEXT, size = wx.Size(200, -1))
 
         def _init_sizers(self):
-            self.mainSizer = wx.BoxSizer(wx.VERTICAL)
-            self.uriSizer = wx.BoxSizer(wx.HORIZONTAL)
-            self.portSizer = wx.BoxSizer(wx.HORIZONTAL)
+            self.mainSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=5, vgap=10)
+            self.mainSizer.AddWindow(wx.StaticText(self, label=_("URI host:")),
+                                     flag=wx.ALIGN_CENTER_VERTICAL)
+            self.mainSizer.AddWindow(self.IpText, flag=wx.GROW)
 
-            self.uriSizer.Add(wx.StaticText(self, wx.ID_ANY, _("URI host:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
-            self.uriSizer.AddSpacer((0,0))
-            self.uriSizer.Add(self.IpText, proportion=1, flag=wx.ALIGN_RIGHT)
-            self.mainSizer.Add(self.uriSizer, border=2, flag=wx.ALL)
-
-            self.portSizer.Add(wx.StaticText(self, wx.ID_ANY, _("URI port:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
-            self.portSizer.AddSpacer((0,0))
-            self.portSizer.Add(self.PortText, proportion=1, flag=wx.ALIGN_RIGHT)
-            self.mainSizer.Add(self.portSizer, border=2, flag=wx.ALL)
-
+            self.mainSizer.AddWindow(wx.StaticText(self, label=_("URI port:")),
+                                     flag=wx.ALIGN_CENTER_VERTICAL)
+            self.mainSizer.AddWindow(self.PortText, flag=wx.GROW)
             self.SetSizer(self.mainSizer)
 
         def SetURI(self, uri):
--- a/connectors/WAMP/dialog.py	Thu Jun 07 16:58:13 2018 +0300
+++ b/connectors/WAMP/dialog.py	Fri Jun 08 15:10:27 2018 +0300
@@ -37,33 +37,25 @@
             self.SecureCheckbox = wx.CheckBox(self, ID_SECURECHECKBOX, _("Is connection secure?"))
 
         def _init_sizers(self):
-            self.mainSizer = wx.BoxSizer(wx.VERTICAL)
-            self.uriSizer = wx.BoxSizer(wx.HORIZONTAL)
-            self.portSizer = wx.BoxSizer(wx.HORIZONTAL)
-            self.realmSizer = wx.BoxSizer(wx.HORIZONTAL)
-            self.wampIDSizer = wx.BoxSizer(wx.HORIZONTAL)
+            self.mainSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=5, vgap=10)
+            self.mainSizer.AddWindow(wx.StaticText(self, label=_("URI host:")),
+                                     flag=wx.ALIGN_CENTER_VERTICAL)
+            self.mainSizer.AddWindow(self.IpText, flag=wx.GROW)
 
-            self.uriSizer.Add(wx.StaticText(self, wx.ID_ANY, _("URI host:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
-            self.uriSizer.AddSpacer((0,0))
-            self.uriSizer.Add(self.IpText, proportion=1, flag=wx.ALIGN_RIGHT)
-            self.mainSizer.Add(self.uriSizer, border=2, flag=wx.ALL)
+            self.mainSizer.AddWindow(wx.StaticText(self, label=_("URI port:")),
+                                     flag=wx.ALIGN_CENTER_VERTICAL)
+            self.mainSizer.AddWindow(self.PortText, flag=wx.GROW)
 
-            self.portSizer.Add(wx.StaticText(self, wx.ID_ANY, _("URI port:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
-            self.portSizer.AddSpacer((0,0))
-            self.portSizer.Add(self.PortText, proportion=1, flag=wx.ALIGN_RIGHT)
-            self.mainSizer.Add(self.portSizer, border=2, flag=wx.ALL)
+            self.mainSizer.AddWindow(wx.StaticText(self, label=_("Realm:")),
+                                     flag=wx.ALIGN_CENTER_VERTICAL)
+            self.mainSizer.AddWindow(self.RealmText, flag=wx.GROW)
 
-            self.realmSizer.Add(wx.StaticText(self, wx.ID_ANY, _("Realm:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
-            self.realmSizer.AddSpacer((0, 0))
-            self.realmSizer.Add(self.RealmText, proportion=1, flag=wx.ALIGN_RIGHT)
-            self.mainSizer.Add(self.realmSizer, border=2, flag=wx.ALL)
+            self.mainSizer.AddWindow(wx.StaticText(self, label=_("WAMP ID:")),
+                                     flag=wx.ALIGN_CENTER_VERTICAL)
+            self.mainSizer.AddWindow(self.WAMPIDText, flag=wx.GROW)
 
-            self.wampIDSizer.Add(wx.StaticText(self, wx.ID_ANY, _("WAMP ID:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
-            self.wampIDSizer.AddSpacer((0, 0))
-            self.wampIDSizer.Add(self.WAMPIDText, proportion=1, flag=wx.ALIGN_RIGHT)
-            self.mainSizer.Add(self.wampIDSizer, border=2, flag=wx.ALL)
-
-            self.mainSizer.Add(self.SecureCheckbox, proportion=1, flag=wx.ALIGN_LEFT)
+            self.mainSizer.AddWindow(wx.StaticText(self, label=""), flag=wx.ALIGN_CENTER_VERTICAL)
+            self.mainSizer.AddWindow(self.SecureCheckbox, flag=wx.GROW)
 
             self.SetSizer(self.mainSizer)