Fix bug no title bar on wx.SingleChoiceDialogs
authorLaurent Bessard
Sat, 07 Jul 2012 20:48:23 +0200
changeset 720 2a9d4eafaddd
parent 719 bc2e98641bdd
child 721 f3dffc1a5ffe
Fix bug no title bar on wx.SingleChoiceDialogs
PLCOpenEditor.py
SFCViewer.py
Viewer.py
controls/VariablePanel.py
--- a/PLCOpenEditor.py	Sun Jul 01 23:36:44 2012 +0200
+++ b/PLCOpenEditor.py	Sat Jul 07 20:48:23 2012 +0200
@@ -346,7 +346,7 @@
     split = None
     for idx, tab in enumerate(tabs):
         if len(tab["pages"]) == 0:
-        	raise ValueError, "Not possible"
+            raise ValueError, "Not possible"
         if tab["size"][0] == rect.width:
             if tab["pos"][1] == rect.y:
                 split = (wx.TOP, float(tab["size"][1]) / float(rect.height))
@@ -824,17 +824,18 @@
         tabs = []
         for child in notebook.GetChildren():
             if isinstance(child, wx.aui.AuiTabCtrl):
-                pos = child.GetPosition()
-                tab = {"pos": (pos.x, pos.y), "pages": []}
-                tab_size = child.GetSize()
-                for page_idx in xrange(child.GetPageCount()):
-                    page = child.GetWindowFromIdx(page_idx)
-                    if not tab.has_key("size"):
-                        tab["size"] = (tab_size[0], tab_size[1] + page.GetSize()[1])
-                    tab_infos = self.GetTabInfos(page)
-                    if tab_infos is not None:
-                        tab["pages"].append((tab_infos, page_idx == child.GetActivePage()))
-                tabs.append(tab)
+                if child.GetPageCount() > 0:
+                    pos = child.GetPosition()
+                    tab = {"pos": (pos.x, pos.y), "pages": []}
+                    tab_size = child.GetSize()
+                    for page_idx in xrange(child.GetPageCount()):
+                        page = child.GetWindowFromIdx(page_idx)
+                        if not tab.has_key("size"):
+                            tab["size"] = (tab_size[0], tab_size[1] + page.GetSize()[1])
+                        tab_infos = self.GetTabInfos(page)
+                        if tab_infos is not None:
+                            tab["pages"].append((tab_infos, page_idx == child.GetActivePage()))
+                    tabs.append(tab)
         tabs.sort(lambda x, y: cmp(x["pos"], y["pos"]))
         size = notebook.GetSize()
         return ComputeTabsLayout(tabs, wx.Rect(1, 1, size[0] - NOTEBOOK_BORDER, size[1] - NOTEBOOK_BORDER))
--- a/SFCViewer.py	Sun Jul 01 23:36:44 2012 +0200
+++ b/SFCViewer.py	Sat Jul 07 20:48:23 2012 +0200
@@ -691,7 +691,9 @@
             for block in self.Blocks:
                 if isinstance(block, SFC_Step):
                     choices.append(block.GetName())
-            dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Add a new jump"), _("Please choose a target"), choices, wx.OK|wx.CANCEL)
+            dialog = wx.SingleChoiceDialog(self.ParentWindow, 
+                  _("Add a new jump"), _("Please choose a target"), 
+                  choices, wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
             if dialog.ShowModal() == wx.ID_OK:
                 value = dialog.GetStringSelection()
                 self.SelectedElement.AddOutput()
--- a/Viewer.py	Sun Jul 01 23:36:44 2012 +0200
+++ b/Viewer.py	Sat Jul 07 20:48:23 2012 +0200
@@ -263,7 +263,10 @@
                 if pou_type == "program":
                     location = values[0]
                     if not location.startswith("%"):
-                        dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Select a variable class:"), _("Variable class"), ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
+                        dialog = wx.SingleChoiceDialog(self.ParentWindow, 
+                              _("Select a variable class:"), _("Variable class"), 
+                              ["Input", "Output", "Memory"], 
+                              wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
                         if dialog.ShowModal() == wx.ID_OK:
                             selected = dialog.GetSelection()
                         else:
@@ -2232,7 +2235,9 @@
         for block in self.Blocks.itervalues():
             if isinstance(block, SFC_Step):
                 choices.append(block.GetName())
-        dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Add a new jump"), _("Please choose a target"), choices, wx.OK|wx.CANCEL)
+        dialog = wx.SingleChoiceDialog(self.ParentWindow, 
+              _("Add a new jump"), _("Please choose a target"), 
+              choices, wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
         if dialog.ShowModal() == wx.ID_OK:
             id = self.GetNewId()
             value = dialog.GetStringSelection()
@@ -2535,7 +2540,9 @@
         for block in self.Blocks.itervalues():
             if isinstance(block, SFC_Step):
                 choices.append(block.GetName())
-        dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Edit jump target"), _("Please choose a target"), choices, wx.OK|wx.CANCEL)
+        dialog = wx.SingleChoiceDialog(self.ParentWindow, 
+              _("Edit jump target"), _("Please choose a target"), 
+              choices, wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
         dialog.SetSelection(choices.index(jump.GetTarget()))
         if dialog.ShowModal() == wx.ID_OK:
             value = dialog.GetStringSelection()
--- a/controls/VariablePanel.py	Sun Jul 01 23:36:44 2012 +0200
+++ b/controls/VariablePanel.py	Sat Jul 07 20:48:23 2012 +0200
@@ -272,7 +272,10 @@
                             elif base_type not in LOCATIONDATATYPES[location[0]]:
                                 message = _("Incompatible size of data between \"%s\" and \"%s\"")%(location, variable_type)
                             else:
-                                dialog = wx.SingleChoiceDialog(self.ParentWindow, _("Select a variable class:"), _("Variable class"), ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
+                                dialog = wx.SingleChoiceDialog(self.ParentWindow, 
+                                      _("Select a variable class:"), _("Variable class"), 
+                                      ["Input", "Output", "Memory"], 
+                                      wx.DEFAULT_DIALOG_STYLE|wx.OK|wx.CANCEL)
                                 if dialog.ShowModal() == wx.ID_OK:
                                     selected = dialog.GetSelection()
                                     if selected == 0: