45 self.output = output |
45 self.output = output |
46 |
46 |
47 def writelines(self, l): |
47 def writelines(self, l): |
48 map(self.write, l) |
48 map(self.write, l) |
49 |
49 |
50 def write(self, s): |
50 def write(self, s, style = None): |
51 if self.default_style != self.black_white: |
51 if not style : style=self.black_white |
52 self.output.SetDefaultStyle(self.black_white) |
52 if self.default_style != style: |
53 self.default_style = self.black_white |
53 self.output.SetDefaultStyle(style) |
|
54 self.default_style = style |
54 self.output.AppendText(s) |
55 self.output.AppendText(s) |
55 |
56 |
56 def write_warning(self, s): |
57 def write_warning(self, s): |
57 if self.default_style != self.red_white: |
58 self.write(s,self.red_white) |
58 self.output.SetDefaultStyle(self.red_white) |
|
59 self.default_style = self.red_white |
|
60 self.output.AppendText(s) |
|
61 |
59 |
62 def write_error(self, s): |
60 def write_error(self, s): |
63 if self.default_style != self.red_yellow: |
61 self.write(s,self.red_yellow) |
64 self.output.SetDefaultStyle(self.red_yellow) |
|
65 self.default_style = self.red_yellow |
|
66 self.output.AppendText(s) |
|
67 |
62 |
68 def flush(self): |
63 def flush(self): |
69 self.output.SetValue("") |
64 self.output.SetValue("") |
70 |
65 |
71 def isatty(self): |
66 def isatty(self): |
568 else: |
563 else: |
569 for choice in element_infos["type"]: |
564 for choice in element_infos["type"]: |
570 choicectrl.Append(choice) |
565 choicectrl.Append(choice) |
571 callback = self.GetChoiceCallBackFunction(choicectrl, element_path) |
566 callback = self.GetChoiceCallBackFunction(choicectrl, element_path) |
572 choicectrl.Bind(wx.EVT_CHOICE, callback, id=id) |
567 choicectrl.Bind(wx.EVT_CHOICE, callback, id=id) |
573 choicectrl.SetStringSelection(element_infos["value"]) |
568 if element_infos["value"]: |
|
569 choicectrl.SetStringSelection(element_infos["value"]) |
574 elif isinstance(element_infos["type"], types.DictType): |
570 elif isinstance(element_infos["type"], types.DictType): |
575 boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
571 boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
576 if first: |
572 if first: |
577 sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
573 sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.ALL) |
578 else: |
574 else: |
580 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
576 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
581 name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
577 name="%s_label"%element_infos["name"], parent=self.ParamsPanel, |
582 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
578 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
583 boxsizer.AddWindow(statictext, 0, border=0, flag=wx.TOP|wx.LEFT|wx.BOTTOM) |
579 boxsizer.AddWindow(statictext, 0, border=0, flag=wx.TOP|wx.LEFT|wx.BOTTOM) |
584 id = wx.NewId() |
580 id = wx.NewId() |
585 min = max = -1 |
581 min = -sys.maxint-1 |
|
582 max = sys.maxint |
586 if "min" in element_infos["type"]: |
583 if "min" in element_infos["type"]: |
587 min = element_infos["type"]["min"] |
584 min = element_infos["type"]["min"] |
588 if "max" in element_infos["type"]: |
585 if "max" in element_infos["type"]: |
589 max = element_infos["type"]["max"] |
586 max = element_infos["type"]["max"] |
590 spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
587 spinctrl = wx.SpinCtrl(id=id, name=element_infos["name"], parent=self.ParamsPanel, |
634 textctrl.SetValue(str(element_infos["value"])) |
631 textctrl.SetValue(str(element_infos["value"])) |
635 first = False |
632 first = False |
636 |
633 |
637 def OnNewProjectMenu(self, event): |
634 def OnNewProjectMenu(self, event): |
638 defaultpath = self.PluginRoot.GetProjectPath() |
635 defaultpath = self.PluginRoot.GetProjectPath() |
639 if defaultpath == "": |
636 if not defaultpath: |
640 defaultpath = os.getcwd() |
637 defaultpath = os.getcwd() |
641 dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON) |
638 dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON) |
642 if dialog.ShowModal() == wx.ID_OK: |
639 if dialog.ShowModal() == wx.ID_OK: |
643 projectpath = dialog.GetPath() |
640 projectpath = dialog.GetPath() |
644 dialog.Destroy() |
641 dialog.Destroy() |