1457 name="%s_label"%element_infos["name"], parent=parent, |
1470 name="%s_label"%element_infos["name"], parent=parent, |
1458 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
1471 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
1459 boxsizer.AddWindow(statictext, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT) |
1472 boxsizer.AddWindow(statictext, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT) |
1460 id = wx.NewId() |
1473 id = wx.NewId() |
1461 if isinstance(element_infos["type"], types.ListType): |
1474 if isinstance(element_infos["type"], types.ListType): |
1462 combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent, |
1475 if isinstance(element_infos["value"], types.TupleType): |
1463 pos=wx.Point(0, 0), size=wx.Size(300, 28), style=wx.CB_READONLY) |
1476 browse_boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
1464 boxsizer.AddWindow(combobox, 0, border=0, flag=0) |
1477 boxsizer.AddSizer(browse_boxsizer, 0, border=0, flag=0) |
1465 if element_infos["use"] == "optional": |
1478 |
1466 combobox.Append("") |
1479 textctrl = wx.TextCtrl(id=id, name=element_infos["name"], parent=parent, |
1467 if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
1480 pos=wx.Point(0, 0), size=wx.Size(275, 25), style=wx.TE_READONLY) |
1468 for choice, xsdclass in element_infos["type"]: |
1481 if element_infos["value"] is not None: |
1469 combobox.Append(choice) |
1482 textctrl.SetValue(element_infos["value"][0]) |
1470 name = element_infos["name"] |
1483 value_infos = element_infos["value"][1] |
1471 value = element_infos["value"] |
1484 else: |
1472 staticbox = wx.StaticBox(id=-1, label="%s - %s"%(_(name), _(value)), |
1485 value_infos = None |
1473 name='%s_staticbox'%element_infos["name"], parent=parent, |
1486 browse_boxsizer.AddWindow(textctrl, 0, border=0, flag=0) |
1474 pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0) |
1487 button_id = wx.NewId() |
1475 staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
1488 button = wx.Button(id=button_id, name="browse_%s" % element_infos["name"], parent=parent, |
1476 sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
1489 label="...", pos=wx.Point(0, 0), size=wx.Size(25, 25)) |
1477 self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) |
1490 browse_boxsizer.AddWindow(button, 0, border=0, flag=0) |
1478 callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, plugin, element_path) |
1491 button.Bind(wx.EVT_BUTTON, |
|
1492 self.GetBrowseCallBackFunction(element_infos["name"], textctrl, element_infos["type"], |
|
1493 value_infos, plugin, element_path), |
|
1494 id=button_id) |
1479 else: |
1495 else: |
1480 for choice in element_infos["type"]: |
1496 combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent, |
1481 combobox.Append(choice) |
1497 pos=wx.Point(0, 0), size=wx.Size(300, 28), style=wx.CB_READONLY) |
1482 callback = self.GetChoiceCallBackFunction(combobox, plugin, element_path) |
1498 boxsizer.AddWindow(combobox, 0, border=0, flag=0) |
1483 if element_infos["value"] is None: |
1499 if element_infos["use"] == "optional": |
1484 combobox.SetStringSelection("") |
1500 combobox.Append("") |
1485 else: |
1501 if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
1486 combobox.SetStringSelection(element_infos["value"]) |
1502 for choice, xsdclass in element_infos["type"]: |
1487 combobox.Bind(wx.EVT_COMBOBOX, callback, id=id) |
1503 combobox.Append(choice) |
|
1504 name = element_infos["name"] |
|
1505 value = element_infos["value"] |
|
1506 staticbox = wx.StaticBox(id=-1, label="%s - %s"%(_(name), _(value)), |
|
1507 name='%s_staticbox'%element_infos["name"], parent=parent, |
|
1508 pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0) |
|
1509 staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
|
1510 sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
|
1511 self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) |
|
1512 callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, plugin, element_path) |
|
1513 else: |
|
1514 for choice in element_infos["type"]: |
|
1515 combobox.Append(choice) |
|
1516 callback = self.GetChoiceCallBackFunction(combobox, plugin, element_path) |
|
1517 if element_infos["value"] is None: |
|
1518 combobox.SetStringSelection("") |
|
1519 else: |
|
1520 combobox.SetStringSelection(element_infos["value"]) |
|
1521 combobox.Bind(wx.EVT_COMBOBOX, callback, id=id) |
1488 elif isinstance(element_infos["type"], types.DictType): |
1522 elif isinstance(element_infos["type"], types.DictType): |
1489 scmin = -(2**31) |
1523 scmin = -(2**31) |
1490 scmax = 2**31-1 |
1524 scmax = 2**31-1 |
1491 if "min" in element_infos["type"]: |
1525 if "min" in element_infos["type"]: |
1492 scmin = element_infos["type"]["min"] |
1526 scmin = element_infos["type"]["min"] |
1494 scmax = element_infos["type"]["max"] |
1528 scmax = element_infos["type"]["max"] |
1495 spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, |
1529 spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, |
1496 pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) |
1530 pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) |
1497 spinctrl.SetRange(scmin,scmax) |
1531 spinctrl.SetRange(scmin,scmax) |
1498 boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
1532 boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
1499 spinctrl.SetValue(element_infos["value"]) |
1533 if element_infos["value"] is not None: |
|
1534 spinctrl.SetValue(element_infos["value"]) |
1500 spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id) |
1535 spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id) |
1501 else: |
1536 else: |
1502 if element_infos["type"] == "boolean": |
1537 if element_infos["type"] == "boolean": |
1503 checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=parent, |
1538 checkbox = wx.CheckBox(id=id, name=element_infos["name"], parent=parent, |
1504 pos=wx.Point(0, 0), size=wx.Size(17, 25), style=0) |
1539 pos=wx.Point(0, 0), size=wx.Size(17, 25), style=0) |
1505 boxsizer.AddWindow(checkbox, 0, border=0, flag=0) |
1540 boxsizer.AddWindow(checkbox, 0, border=0, flag=0) |
1506 checkbox.SetValue(element_infos["value"]) |
1541 if element_infos["value"] is not None: |
|
1542 checkbox.SetValue(element_infos["value"]) |
1507 checkbox.Bind(wx.EVT_CHECKBOX, self.GetCheckBoxCallBackFunction(checkbox, plugin, element_path), id=id) |
1543 checkbox.Bind(wx.EVT_CHECKBOX, self.GetCheckBoxCallBackFunction(checkbox, plugin, element_path), id=id) |
1508 elif element_infos["type"] in ["unsignedLong", "long","integer"]: |
1544 elif element_infos["type"] in ["unsignedLong", "long","integer"]: |
1509 if element_infos["type"].startswith("unsigned"): |
1545 if element_infos["type"].startswith("unsigned"): |
1510 scmin = 0 |
1546 scmin = 0 |
1511 else: |
1547 else: |
1513 scmax = 2**31-1 |
1549 scmax = 2**31-1 |
1514 spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, |
1550 spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=parent, |
1515 pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) |
1551 pos=wx.Point(0, 0), size=wx.Size(300, 25), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) |
1516 spinctrl.SetRange(scmin, scmax) |
1552 spinctrl.SetRange(scmin, scmax) |
1517 boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
1553 boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
1518 spinctrl.SetValue(element_infos["value"]) |
1554 if element_infos["value"] is not None: |
|
1555 spinctrl.SetValue(element_infos["value"]) |
1519 spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id) |
1556 spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id) |
1520 else: |
1557 else: |
1521 choices = cPickle.loads(str(self.Config.Read(element_path, cPickle.dumps([""])))) |
1558 choices = cPickle.loads(str(self.Config.Read(element_path, cPickle.dumps([""])))) |
1522 textctrl = TextCtrlAutoComplete.TextCtrlAutoComplete(id=id, |
1559 textctrl = TextCtrlAutoComplete.TextCtrlAutoComplete(id=id, |
1523 name=element_infos["name"], |
1560 name=element_infos["name"], |