Exemple #1
0
    def __init__(self, parent, prefsIO):

        wx.Panel.__init__(self, parent)
        self.preferences = prefsIO
        self.SetBackgroundColour(self.preferences.GetValue('M_BG_COLOUR'))

        # Widgets
        label = wx.StaticText(self, label="... this value: ")
        choices = [choice[0] for choice in LabelNumber.choices]
        self.radiobox = wx.RadioBox(self,
                                    label="The tag ",
                                    choices=choices,
                                    majorDimension=1,
                                    style=wx.RA_SPECIFY_COLS)
        self.ctrl = FS.FloatSpin(self,
                                 min_val=0.0,
                                 increment=0.01,
                                 value=0,
                                 digits=3)

        # Layout
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(label, flag=wx.EXPAND | wx.ALL, border=5)
        hbox.Add(self.ctrl, flag=wx.EXPAND | wx.ALL, border=5)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.radiobox, 1, flag=wx.EXPAND | wx.ALL, border=4)
        sizer.Add(hbox, 0, flag=wx.EXPAND | wx.ALL, border=4)
        self.SetSizer(sizer)
Exemple #2
0
    def __init__(self, prnt, orientation):
        wx.Panel.__init__(self, prnt)
        self.mip_size_spin = wx.SpinCtrl(self, -1, min=1, max=240,
                                         initial=const.PROJECTION_MIP_SIZE)
        self.mip_size_spin.SetValue(const.PROJECTION_MIP_SIZE)
        self.mip_size_spin.SetToolTip(wx.ToolTip(_("Number of slices used to compound the visualization.")))
        w, h = self.mip_size_spin.GetTextExtent('M')
        self.mip_size_spin.SetMinSize((5 * w + 10, -1))
        self.mip_size_spin.SetMaxSize((5 * w + 10, -1))

        self.border_spin = FS.FloatSpin(self, -1, min_val=0, max_val=10,
                                        increment=0.1,
                                        value=const.PROJECTION_BORDER_SIZE,
                                        digits=1, agwStyle=FS.FS_LEFT)
        self.border_spin.SetToolTip(wx.ToolTip(_("Controls the sharpness of the"
                                                 " contour. The greater the"
                                                 " value, the sharper the"
                                                 " contour.")))
        w, h = self.border_spin.GetTextExtent('M')
        self.border_spin.SetMinSize((5 * w + 10, -1))
        self.border_spin.SetMaxSize((5 * w + 10, -1))

        self.inverted = wx.CheckBox(self, -1, _("Inverted order"))
        self.inverted.SetToolTip(wx.ToolTip(_("If checked, the slices are"
                                              " traversed in descending"
                                              " order to compound the"
                                              " visualization instead of"
                                              " ascending order.")))
        
        txt_mip_size = wx.StaticText(self, -1, _("Number of slices"), style=wx.ALIGN_CENTER_HORIZONTAL)
        self.txt_mip_border = wx.StaticText(self, -1, _("Sharpness"))

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(txt_mip_size, 0, wx.EXPAND | wx.ALL, 2)
        sizer.Add(self.mip_size_spin, 0, wx.EXPAND)
        sizer.AddSpacer((10, 0))
        sizer.Add(self.txt_mip_border, 0, wx.EXPAND | wx.ALL, 2)
        sizer.Add(self.border_spin, 0, wx.EXPAND)
        sizer.AddSpacer((10, 0))
        sizer.Add(self.inverted, 0, wx.EXPAND)
        self.SetSizer(sizer)
        sizer.Fit(self)

        self.Layout()
        self.Update()
        self.SetAutoLayout(1)

        self.orientation = orientation

        self.mip_size_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPSize)
        self.border_spin.Bind(wx.EVT_SPINCTRL, self.OnSetMIPBorder)
        self.inverted.Bind(wx.EVT_CHECKBOX, self.OnCheckInverted)
        
        Publisher.subscribe(self._set_projection_type, 'Set projection type')
Exemple #3
0
    def InitUI(self):
        headers = ('Name', 'Option', 'X: Interval \nY: Interval',
                   'X: Interval \nY: Point', 'X: Point \nY: Interval',
                   'X: Point \nY: Point')
        # Create columns
        for i, col in enumerate(headers):
            self.InsertColumn(col=i, heading=col)

        self.SetColumnWidth(col=0, width=150)
        self.SetColumnWidth(col=1, width=180)
        self.SetColumnWidth(col=2, width=150)
        self.SetColumnWidth(col=3, width=100)
        self.SetColumnWidth(col=4, width=100)
        self.SetColumnWidth(col=5, width=100)

        # Create first row
        index = self.InsertStringItem(0, headers[0])
        for i, col in enumerate(headers[1:], 1):
            self.SetStringItem(index, i, col)

        # Add rows
        for i, row in enumerate(ALLEN_RELATIONS, 1):
            func, name, opt_label, opt_value, opt_name, desc1, desc2, desc3, desc4 = row

            opt_panel = wx.Panel(self)
            opt_sizer = wx.BoxSizer(wx.HORIZONTAL)

            if isinstance(opt_value, float):
                opt_ctrl = FS.FloatSpin(opt_panel,
                                        min_val=0.001,
                                        increment=0.001,
                                        value=opt_value,
                                        digits=3)
            elif isinstance(opt_value, int):
                opt_ctrl = wx.SpinCtrl(opt_panel, min=1, value=str(opt_value))
            else:
                opt_ctrl = wx.StaticText(opt_panel, label="")

            self._optionCtrlList.append(opt_ctrl)
            opt_text = wx.StaticText(opt_panel, label=opt_label)
            opt_sizer.Add(opt_text)
            opt_sizer.Add(opt_ctrl)
            opt_panel.SetSizer(opt_sizer)

            index = self.InsertStringItem(i, name, 1)
            self.SetItemWindow(index, 1, opt_panel, expand=True)
            self.SetStringItem(index, 2, desc1)
            self.SetStringItem(index, 3, desc2)
            self.SetStringItem(index, 4, desc3)
            self.SetStringItem(index, 5, desc4)

        item = self.GetItem(1)
        self._mainWin.CheckItem(item)
Exemple #4
0
    def __init__(self, name, pref_item, size, parent=None):
        ''' The constructor.

        Parameters
        ----------
        name : String
            The name of the field. It is used as the field label.

        pref_item : :class:`~psysmon.core.preferences.PrefItem`
            The key of the base option edited by this field.

        size : tuple (width, height)
            The size of the field.

        parent :
            The parent wxPyton window of this field.
        '''
        Field.__init__(self,
                       parent=parent,
                       name=name,
                       pref_item=pref_item,
                       size=size)

        # Create the field label.
        self.labelElement = StaticText(parent=self,
                                       ID=wx.ID_ANY,
                                       label=self.label,
                                       style=wx.ALIGN_RIGHT)

        # Create the field spincontrol.
        self.controlElement = FS.FloatSpin(parent=self,
                                           id=wx.ID_ANY,
                                           min_val=pref_item.limit[0],
                                           max_val=pref_item.limit[1],
                                           increment=pref_item.increment,
                                           digits=pref_item.digits,
                                           agwStyle=FS.FS_LEFT)
        self.controlElement.SetFormat(pref_item.spin_format)

        # Add the elements to the field sizer.
        self.addLabel(self.labelElement)
        self.addControl(self.controlElement)

        # Set the value of the control element.
        self.setControlElementValue()

        # Bind the events.
        self.Bind(FS.EVT_FLOATSPIN, self.onValueChange, self.controlElement)
Exemple #5
0
    def _create_content(self):
        # Widgets
        label = wx.StaticText(self, label="... this value in seconds: ")
        choices = [choice[0] for choice in DurationFilterDialog.choices]
        self.radiobox = wx.RadioBox(self, label="The duration",
                                    choices=choices, majorDimension=1)
        self.ctrl = FS.FloatSpin(self, min_val=0.0, increment=0.01, value=0, digits=3)
        # Layout
        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(label,     flag=wx.EXPAND|wx.ALL, border=5)
        hbox.Add(self.ctrl, flag=wx.EXPAND|wx.ALL, border=5)

        content_layout = wx.BoxSizer(wx.VERTICAL)
        content_layout.Add(self.radiobox, 1, flag=wx.EXPAND|wx.ALL, border=0)
        content_layout.Add(hbox,          0, flag=wx.EXPAND|wx.ALL, border=0)
        return content_layout
Exemple #6
0
    def __init__(self, parent, log):

        wx.Panel.__init__(self, parent)
        self.log = log

        self.mainpanel = wx.Panel(self, -1)
        self.sizer_5_staticbox = wx.StaticBox(self.mainpanel, -1, "Example 2")
        self.sizer_7_staticbox = wx.StaticBox(self.mainpanel, -1, "Example 3")
        self.sizer_8_staticbox = wx.StaticBox(self.mainpanel, -1, "Example 4")
        self.sizer_4_staticbox = wx.StaticBox(self.mainpanel, -1, "Example 1")
        self.helptext = wx.StaticText(self.mainpanel, -1,
                                      "Welcome to the FloatSpin Demo")

        self.floatspin1 = FS.FloatSpin(self.mainpanel,
                                       -1,
                                       min_val=0,
                                       max_val=1,
                                       increment=0.01,
                                       value=0.1,
                                       agwStyle=FS.FS_LEFT)
        self.floatspin1.SetFormat("%f")
        self.floatspin1.SetDigits(2)

        self.setvalue1 = wx.Button(self.mainpanel, -1, "Set Value")
        self.textctrlvalue1 = wx.TextCtrl(self.mainpanel, -1, "0.0")
        self.setdigits1 = wx.Button(self.mainpanel, -1, "Set Digits")
        self.textctrldigits1 = wx.TextCtrl(self.mainpanel, -1, "2")
        self.radioformat1 = wx.RadioBox(
            self.mainpanel,
            -1,
            "Set Format",
            choices=["%f", "%F", "%e", "%E", "%g", "%G"],
            majorDimension=2,
            style=wx.RA_SPECIFY_COLS)
        self.setincrement1 = wx.Button(self.mainpanel, -1, "Set Increment")
        self.textctrlincr1 = wx.TextCtrl(self.mainpanel, -1, "0.01")
        self.setfont1 = wx.Button(self.mainpanel, -1, "Set Font")

        self.floatspin2 = FS.FloatSpin(self.mainpanel,
                                       -1,
                                       min_val=-10,
                                       max_val=100,
                                       increment=0.1,
                                       agwStyle=FS.FS_RIGHT)
        self.floatspin2.SetFormat("%e")
        self.floatspin2.SetDigits(4)

        self.setvalue2 = wx.Button(self.mainpanel, -1, "Set Value")
        self.textctrlvalue2 = wx.TextCtrl(self.mainpanel, -1, "0.0")
        self.setdigits2 = wx.Button(self.mainpanel, -1, "Set Digits")
        self.textctrldigits2 = wx.TextCtrl(self.mainpanel, -1, "4")
        self.radioformat2 = wx.RadioBox(
            self.mainpanel,
            -1,
            "Set Format",
            choices=["%f", "%F", "%e", "%E", "%g", "%G"],
            majorDimension=2,
            style=wx.RA_SPECIFY_COLS)
        self.setincrement2 = wx.Button(self.mainpanel, -1, "Set Increment")
        self.textctrlincr2 = wx.TextCtrl(self.mainpanel, -1, "0.1")
        self.setfont2 = wx.Button(self.mainpanel, -1, "Set Font")

        self.floatspin3 = FS.FloatSpin(self.mainpanel,
                                       -1,
                                       min_val=0.01,
                                       max_val=0.05,
                                       increment=0.0001,
                                       agwStyle=FS.FS_CENTRE)
        self.floatspin3.SetFormat("%f")
        self.floatspin3.SetDigits(5)

        self.setvalue3 = wx.Button(self.mainpanel, -1, "Set Value")
        self.textctrlvalue3 = wx.TextCtrl(self.mainpanel, -1, "0.01")
        self.setdigits3 = wx.Button(self.mainpanel, -1, "Set Digits")
        self.textctrldigits3 = wx.TextCtrl(self.mainpanel, -1, "5")
        self.radioformat3 = wx.RadioBox(
            self.mainpanel,
            -1,
            "Set Format",
            choices=["%f", "%F", "%e", "%E", "%g", "%G"],
            majorDimension=2,
            style=wx.RA_SPECIFY_COLS)
        self.setincrement3 = wx.Button(self.mainpanel, -1, "Set Increment")
        self.textctrlincr3 = wx.TextCtrl(self.mainpanel, -1, "0.0001")
        self.setfont3 = wx.Button(self.mainpanel, -1, "Set Font")

        self.floatspin4 = FS.FloatSpin(self.mainpanel,
                                       -1,
                                       min_val=-2,
                                       max_val=20000,
                                       increment=0.1,
                                       agwStyle=FS.FS_READONLY)
        self.floatspin4.SetFormat("%G")
        self.floatspin4.SetDigits(3)

        self.setvalue4 = wx.Button(self.mainpanel, -1, "Set Value")
        self.textctrlvalue4 = wx.TextCtrl(self.mainpanel, -1, "0.0")
        self.setdigits4 = wx.Button(self.mainpanel, -1, "Set Digits")
        self.textctrldigits4 = wx.TextCtrl(self.mainpanel, -1, "3")
        self.radioformat4 = wx.RadioBox(
            self.mainpanel,
            -1,
            "Set Format",
            choices=["%f", "%F", "%e", "%E", "%g", "%G"],
            majorDimension=2,
            style=wx.RA_SPECIFY_COLS)
        self.setincrement4 = wx.Button(self.mainpanel, -1, "Set Increment")
        self.textctrlincr4 = wx.TextCtrl(self.mainpanel, -1, "0.1")
        self.setfont4 = wx.Button(self.mainpanel, -1, "Set Font")

        self.valuebuttons = [
            self.setvalue1, self.setvalue2, self.setvalue3, self.setvalue4
        ]
        self.digitbuttons = [
            self.setdigits1, self.setdigits2, self.setdigits3, self.setdigits4
        ]
        self.radioboxes = [
            self.radioformat1, self.radioformat2, self.radioformat3,
            self.radioformat4
        ]
        self.incrbuttons = [
            self.setincrement1, self.setincrement2, self.setincrement3,
            self.setincrement4
        ]
        self.fontbuttons = [
            self.setfont1, self.setfont2, self.setfont3, self.setfont4
        ]
        self.textvalues = [
            self.textctrlvalue1, self.textctrlvalue2, self.textctrlvalue3,
            self.textctrlvalue4
        ]
        self.textdigits = [
            self.textctrldigits1, self.textctrldigits2, self.textctrldigits3,
            self.textctrldigits4
        ]
        self.textincr = [
            self.textctrlincr1, self.textctrlincr2, self.textctrlincr3,
            self.textctrlincr4
        ]
        self.floatspins = [
            self.floatspin1, self.floatspin2, self.floatspin3, self.floatspin4
        ]

        self.SetProperties()
        self.DoLayout()
        self.BindEvents()
    def __init__(self, parent, id):
    #---------------------------------------------------------------------------
        ExpertSettingPanel.__init__(self, parent, id)

        sizer = wx.GridBagSizer(hgap=5, vgap=5)
        self.SetSizer(sizer)
        
        # roulette wheel selection
        self.roulettWheel = wx.RadioButton(self, -1, "Roulette wheel", \
            name="rouletteWheel")
        sizer.Add(self.roulettWheel, pos=(0,0), \
            flag = wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, border=10)

        self.genericWidgets.append(self.roulettWheel)

        # linear scaled fitness
        self.roulettWheelScaled = wx.RadioButton(self, -1, "Roulette wheel (lin. scaled)", \
            name="rouletteWheelScaled")
        self.roulettWheelScaled.SetValue(True)
        sizer.Add(self.roulettWheelScaled, pos=(1,0), \
            flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10)

        self.roulettWheelPreasure = FS.FloatSpin(self, -1, min_val=0.0, max_val=2.0, \
            increment=0.01, value=2.0)
        self.roulettWheelPreasure.SetFormat("%f")
        self.roulettWheelPreasure.SetDigits(2)
        compat_wx.set_tool_tip(self.roulettWheelPreasure, "The selective pressure")
        sizer.Add(self.roulettWheelPreasure, pos=(1,1), \
            flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10)

        self.genericWidgets.append(self.roulettWheelScaled)
        self.AddChildToParent(self.roulettWheelScaled, self.roulettWheelPreasure)

        # stochastic universal sampling
        self.stochUniSampling = wx.RadioButton(self, -1, "Stochastic universal sampling", \
            name="stochUniSampling")
        sizer.Add(self.stochUniSampling, pos=(2,0), \
            flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10)

        self.genericWidgets.append(self.stochUniSampling)

        # rank selection
        self.rankSelection = wx.RadioButton(self, -1, "Rank selection", name="rankSelection")
        sizer.Add(self.rankSelection, pos=(3,0), \
            flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10)
            
        self.rankSelectionPreasure = FS.FloatSpin(self, -1, min_val=0.0, max_val=2.0, \
            increment=0.01, value=2.0)
        self.rankSelectionPreasure.SetFormat("%f")
        self.rankSelectionPreasure.SetDigits(2)
        self.rankSelectionPreasure.Disable()
        compat_wx.set_tool_tip(self.rankSelectionPreasure, "The selective pressure")
        sizer.Add(self.rankSelectionPreasure, pos=(3,1), \
            flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10)
            
        self.rankSelectionExponent = FS.FloatSpin(self, -1, min_val=0.0, max_val=2.0, \
            increment=0.01, value=1.0)
        self.rankSelectionExponent.SetFormat("%f")
        self.rankSelectionExponent.SetDigits(2)
        self.rankSelectionExponent.Disable()
        compat_wx.set_tool_tip(self.rankSelectionExponent, "Exponent")
        sizer.Add(self.rankSelectionExponent, pos=(3,2), \
            flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10)

        self.genericWidgets.append(self.rankSelection)
        self.AddChildToParent(self.rankSelection, self.rankSelectionPreasure)
        self.AddChildToParent(self.rankSelection, self.rankSelectionExponent)
            
        # tournament selection
        self.TournamentSelection = wx.RadioButton(self, -1, "Tournament selection", \
            name="tournamentSelection")
        sizer.Add(self.TournamentSelection, pos=(4,0), \
            flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10)
            
        self.TournamentSelectionTsize = wx.SpinCtrl(self, -1, size=(100,-1), \
            min=2, max=25, value='3') # TODO: max = popSize
        self.TournamentSelectionTsize.Disable()
        compat_wx.set_tool_tip(self.TournamentSelectionTsize, "Tournament size")
        sizer.Add(self.TournamentSelectionTsize, pos=(4,1), \
            flag = wx.LEFT | wx.RIGHT | wx.EXPAND, border=10)

        self.genericWidgets.append(self.TournamentSelection)
        self.AddChildToParent(self.TournamentSelection, self.TournamentSelectionTsize)

        # random selection
        self.randomSelect = wx.RadioButton(self, -1, "Random selection", \
            name="randomSelection")
        sizer.Add(self.randomSelect, pos=(5,0), \
            flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=10)

        self.genericWidgets.append(self.randomSelect)
            
        # bind the EVT_RADIOBUTTON to the RadioButtons
        self.BindEvent(wx.EVT_RADIOBUTTON, self.OnRadioButton, \
            [self.roulettWheel,
             self.roulettWheelScaled,
             self.stochUniSampling,
             self.rankSelection,
             self.TournamentSelection,
             self.randomSelect])
Exemple #8
0
	def listAndButtonSizer(self):
		sz = wx.BoxSizer(wx.VERTICAL)
		sz.AddSpacer(20)
		sz.Add(wx.StaticText(self, wx.ID_ANY, "Object List:"))

		hsz = wx.BoxSizer(wx.HORIZONTAL)
		self.objListBox = wx.ListBox(self, wx.ID_ANY, size=(200, 200))
		self.Bind(wx.EVT_LISTBOX, self.onLbProp, self.objListBox)
		hsz.Add(self.objListBox, 1, wx.ALIGN_CENTER_HORIZONTAL)

		hsz.AddSpacer(10)

		vsz = wx.BoxSizer(wx.VERTICAL)

		bhsz = wx.BoxSizer(wx.HORIZONTAL)

		self.bScrollUp = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("scrollup"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBScrollUp, self.bScrollUp)
		self.bScrollUp.SetToolTip("Move the selection cursor up 1 line")
		self.bScrollUp.Enable(False)
		bhsz.Add(self.bScrollUp)

		bhsz.AddSpacer(20)

		self.bMoveUp = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("moveup"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBMoveUp, self.bMoveUp)
		self.bMoveUp.SetToolTip("Move the selected object up 1 line")
		self.bMoveUp.Enable(False)
		bhsz.Add(self.bMoveUp)

		vsz.Add(bhsz)
		vsz.AddSpacer(20)

		bhsz = wx.BoxSizer(wx.HORIZONTAL)
		self.bScrollDown = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("scrolldown"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBScrollDown, self.bScrollDown)
		self.bScrollDown.SetToolTip("Move the selection cursor down 1 line")
		self.bScrollDown.Enable(False)
		bhsz.Add(self.bScrollDown)

		bhsz.AddSpacer(20)

		self.bMoveDown = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("movedown"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBMoveDown, self.bMoveDown)
		self.bMoveDown.SetToolTip("Move the selected object down 1 line")
		self.bMoveDown.Enable(False)
		bhsz.Add(self.bMoveDown)

		vsz.Add(bhsz)
		hsz.Add(vsz)

		sz.Add(hsz)
		sz.AddSpacer(10)

		vsz = wx.BoxSizer(wx.VERTICAL)

		vsz.AddSpacer(5)

		box = wx.StaticBox(self, wx.ID_ANY, " Material Dimensions ")
		vbsizer = wx.StaticBoxSizer(box, wx.VERTICAL)
		bsizer = wx.BoxSizer(wx.HORIZONTAL)

		bsizer.AddSpacer(SBMARGIN)
		bsizer.Add(wx.StaticText(self, wx.ID_ANY, "Wd:"), 0, wx.TOP, 9)

		self.fsWidth = FS.FloatSpin(self, wx.ID_ANY, size=SPDIM, min_val=0, max_val=400,
				   increment=0.1, value=self.material.getWidth(), agwStyle=FS.FS_RIGHT)
		self.fsWidth.SetFormat("%f")
		self.fsWidth.SetDigits(1)
		bsizer.Add(self.fsWidth, 0, wx.TOP+wx.BOTTOM, 5)
		self.fsWidth.Bind(FS.EVT_FLOATSPIN, self.onFSMaterialWidth)

		bsizer.AddSpacer(SBMARGIN)
		bsizer.Add(wx.StaticText(self, wx.ID_ANY, "Ht:"), 0, wx.TOP, 9)

		self.fsHeight = FS.FloatSpin(self, wx.ID_ANY, size=SPDIM, min_val=0, max_val=400,
				   increment=0.1, value=self.material.getHeight(), agwStyle=FS.FS_RIGHT)
		self.fsHeight.SetFormat("%f")
		self.fsHeight.SetDigits(1)
		bsizer.Add(self.fsHeight, 0, wx.TOP+wx.BOTTOM, 5)
		self.fsHeight.Bind(FS.EVT_FLOATSPIN, self.onFSMaterialHeight)

		bsizer.AddSpacer(SBMARGIN)
		bsizer.Add(wx.StaticText(self, wx.ID_ANY, "Thk:"), 0, wx.TOP, 9)

		self.fsThick = FS.FloatSpin(self, wx.ID_ANY, size=SPDIM, min_val=0, max_val=50,
					increment=0.1, value=self.material.getThickness(), agwStyle=FS.FS_RIGHT)
		self.fsThick.SetFormat("%f")
		self.fsThick.SetDigits(1)
		bsizer.Add(self.fsThick, 0, wx.TOP+wx.BOTTOM, 5)
		self.fsThick.Bind(FS.EVT_FLOATSPIN, self.onFSMaterialThick)

		bsizer.AddSpacer(SBMARGIN)

		vbsizer.AddSpacer(SBMARGIN)
		vbsizer.Add(bsizer)
		vbsizer.AddSpacer(SBMARGIN)
		vsz.Add(vbsizer)

		sz.Add(vsz)

		sz.AddSpacer(10)

		bsz = wx.BoxSizer(wx.HORIZONTAL)
		self.bAdd = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("add"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBAdd, self.bAdd)
		self.bAdd.SetToolTip("Add a new object to the bottom of the list")
		bsz.Add(self.bAdd)

		bsz.AddSpacer(10)

		self.bDel = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("delete"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBDel, self.bDel)
		self.bDel.SetToolTip("Delete the selected object")
		self.bDel.Enable(False)
		bsz.Add(self.bDel)

		bsz.AddSpacer(10)

		self.bRender = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("render"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBRender, self.bRender)
		self.bRender.SetToolTip("Render the G Code and save to file")
		self.bRender.Enable(False)
		bsz.Add(self.bRender)

		bsz.AddSpacer(10)

		self.bNew = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("new"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBNew, self.bNew)
		self.bNew.SetToolTip("Create a new empty model")
		bsz.Add(self.bNew)

		bsz.AddSpacer(10)

		self.bLoad = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("open"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBLoad, self.bLoad)
		self.bLoad.SetToolTip("Load a model from file")
		bsz.Add(self.bLoad)

		bsz.AddSpacer(10)

		self.bSave = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("save"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBSave, self.bSave)
		self.bSave.SetToolTip("Save the model to the current file")
		self.bSave.Enable(False)
		bsz.Add(self.bSave)

		bsz.AddSpacer(10)

		self.bSaveAs = wx.BitmapButton(self, wx.ID_ANY, self.images.getByName("saveas"), size=BTNDIM)
		self.Bind(wx.EVT_BUTTON, self.onBSaveAs, self.bSaveAs)
		self.bSaveAs.SetToolTip("Save the model to a named file")
		self.bSaveAs.Enable(False)
		bsz.Add(self.bSaveAs)

		sz.AddSpacer(10)
		sz.Add(bsz, 0, wx.ALIGN_CENTER_HORIZONTAL)
		sz.AddSpacer(20)

		hsz = wx.BoxSizer(wx.HORIZONTAL)
		hsz.AddSpacer(20)
		hsz.Add(sz)

		return hsz
Exemple #9
0
    def __init__(self, parent, id):
    #---------------------------------------------------------------------------
        ExpertSettingPanel.__init__(self, parent, id)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # ---------------- generic crossovers ----------------
        genericBox = wx.StaticBox(self, -1, "Generic operations", size=(500,-1))
        genericBoxSizer = wx.StaticBoxSizer(genericBox, wx.VERTICAL)
        genericFlexGridSizer = wx.FlexGridSizer(0, 2, 5, 5)
        genericBoxSizer.Add(genericFlexGridSizer, 0)
        sizer.Add(genericBoxSizer, 0, wx.ALL | wx.EXPAND, 10)

        # n point crossover (default: one point crossover)
        nPointSizer = wx.BoxSizer(wx.HORIZONTAL)
        genericBoxSizer.Add(nPointSizer, 0, wx.EXPAND)
        
        self.nPointCrossover = wx.CheckBox(self, -1, "N-Point crossover", \
            name = "nPointCrossover")
        genericFlexGridSizer.Add(self.nPointCrossover, 0, \
            wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)
        
        self.nPointCrossoverN = wx.SpinCtrl(self, -1, size=(100,-1), \
            min=1, max=10, value='1') # TODO: max = vector dimension
        self.nPointCrossoverN.Disable()
        compat_wx.set_tool_tip(self.nPointCrossoverN, "num crossover points")
        genericFlexGridSizer.Add(self.nPointCrossoverN, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5)

        self.genericWidgets.append(self.nPointCrossover)
        self.AddChildToParent(self.nPointCrossover, self.nPointCrossoverN)

        # uniform crossover
        self.uniformCrossover = wx.CheckBox(self, -1, "Uniform crossover", \
            name = "uniformCrossover")
        self.uniformCrossover.SetValue(True)
        genericFlexGridSizer.Add(self.uniformCrossover, 0, \
            wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)

        self.uniformCrossoverPref = FS.FloatSpin(self, -1, min_val=0.0, max_val=1.0, \
            increment=0.01, value=0.5)
        self.uniformCrossoverPref.SetFormat("%f")
        self.uniformCrossoverPref.SetDigits(2)
        compat_wx.set_tool_tip(self.uniformCrossoverPref, "Preference")
        genericFlexGridSizer.Add(self.uniformCrossoverPref, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5)

        self.genericWidgets.append(self.uniformCrossover)
        self.AddChildToParent(self.uniformCrossover, self.uniformCrossoverPref)

        # ---------------- real crossovers ----------------
        realBox = wx.StaticBox(self, -1, "Real operations (affects only feature weighting)", size=(500,-1))
        realBoxSizer = wx.StaticBoxSizer(realBox, wx.VERTICAL)
        realBoxFlexGridSizer = wx.FlexGridSizer(0, 2, 5, 5)
        realBoxSizer.Add(realBoxFlexGridSizer, 0)
        sizer.Add(realBoxSizer, 0, wx.ALL | wx.EXPAND, 10)
        
        # simulated binary crossover
        self.sbxCrossover = wx.CheckBox(self, -1, "SBX Crossover", \
            name = "SBXcrossover")
        self.sbxCrossover.SetValue(True)
        self.sbxCrossover.Disable()
        realBoxFlexGridSizer.Add(self.sbxCrossover, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)
        
        self.sbxCrossoverEta = FS.FloatSpin(self, -1, min_val=0.01, max_val=10.0, \
            increment=0.01, value=1.0)
        self.sbxCrossoverEta.SetFormat("%f")
        self.sbxCrossoverEta.SetDigits(2)
        self.sbxCrossoverEta.Disable()
        compat_wx.set_tool_tip(self.sbxCrossoverEta, "eta the amount of exploration "\
            "OUTSIDE the parents in BLX-alpha notation")
        realBoxFlexGridSizer.Add(self.sbxCrossoverEta, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5)

        self.weightingWidgets.append(self.sbxCrossover)
        self.AddChildToParent(self.sbxCrossover, self.sbxCrossoverEta)
        
        # segment crossover
        self.segmentCrossover = wx.CheckBox(self, -1, "Segment Crossover", \
            name = "segmentCrossover")
        self.segmentCrossover.Disable()
        realBoxFlexGridSizer.Add(self.segmentCrossover, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)

        self.segmentCrossoverAlpha = FS.FloatSpin(self, -1, min_val=0.01, max_val=10.0, \
            increment=0.01, value=1.0)
        self.segmentCrossoverAlpha.SetFormat("%f")
        self.segmentCrossoverAlpha.SetDigits(2)
        self.segmentCrossoverAlpha.Disable()
        compat_wx.set_tool_tip(self.segmentCrossoverAlpha, "alpha the amount of exploration "\
            "OUTSIDE the parents in BLX-alpha notation")
        realBoxFlexGridSizer.Add(self.segmentCrossoverAlpha, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5)
        
        self.weightingWidgets.append(self.segmentCrossover)
        self.AddChildToParent(self.segmentCrossover, self.segmentCrossoverAlpha)
        
        # hypercube crossover
        self.hypercubeCrossover = wx.CheckBox(self, -1, "Hypercube Crossover", \
            name = "hypercubeCrossover")
        self.hypercubeCrossover.Disable()
        realBoxFlexGridSizer.Add(self.hypercubeCrossover, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)
        
        self.hypercubeCrossoverAlpha = FS.FloatSpin(self, -1, min_val=0.01, max_val=10.0, \
            increment=0.01, value=1.0)
        self.hypercubeCrossoverAlpha.SetFormat("%f")
        self.hypercubeCrossoverAlpha.SetDigits(2)
        self.hypercubeCrossoverAlpha.Disable()
        compat_wx.set_tool_tip(self.hypercubeCrossoverAlpha, "alpha the amount of exploration "\
            "OUTSIDE the parents in BLX-alpha notation")
        realBoxFlexGridSizer.Add(self.hypercubeCrossoverAlpha, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5)
        
        self.weightingWidgets.append(self.hypercubeCrossover)
        self.AddChildToParent(self.hypercubeCrossover, self.hypercubeCrossoverAlpha)
        
        # bind the EVT_CHECKBOX to the CheckBoxes
        self.BindEvent(wx.EVT_CHECKBOX, self.OnCheckBox, \
            [self.nPointCrossover,
             self.uniformCrossover,
             self.sbxCrossover,
             self.segmentCrossover,
             self.hypercubeCrossover])
Exemple #10
0
    def __init__(self,
                 parent=None,
                 id=wx.ID_ANY,
                 bgColor="ghostwhite",
                 penColor="black"):
        wx.Panel.__init__(self,
                          parent=parent,
                          id=id,
                          style=wx.FULL_REPAINT_ON_RESIZE)
        self.SetMinSize((-1, 30))
        self.SetMaxSize((-1, 30))

        # The logging logger instance.
        loggerName = __name__ + "." + self.__class__.__name__
        self.logger = logging.getLogger(loggerName)

        self.startTime = None
        self.endTime = None
        self.scale = None

        sizer = wx.GridBagSizer(0, 0)

        self.dummy80 = wx.StaticText(self, wx.ID_ANY, '', size=(80, 10))
        self.dummy100 = wx.StaticText(self, wx.ID_ANY, '', size=(100, 10))
        #self.startTimeButton = platebtn.PlateButton(self, wx.ID_ANY, str(self.startTime),
        #                                            style=platebtn.PB_STYLE_DEFAULT|platebtn.PB_STYLE_SQUARE
        #                                           )

        self.startDatePicker = DatePickerCtrl(self,
                                              id=wx.ID_ANY,
                                              style=wx.DP_DEFAULT
                                              | wx.DP_SHOWCENTURY)

        self.startTimePicker = MaskedTextCtrl(self,
                                              wx.ID_ANY,
                                              '',
                                              mask='##:##:##.######',
                                              excludeChars='',
                                              formatcodes='F!',
                                              includeChars='')

        size = self.startTimePicker.GetSize()
        self.startTimeGoButton = wx.Button(self,
                                           id=wx.ID_ANY,
                                           label="go",
                                           size=(40, size[1]))

        self.durationFloatSpin = floatspin.FloatSpin(
            self,
            wx.ID_ANY,
            min_val=0,
            max_val=None,
            increment=1,
            value=60,
            agwStyle=floatspin.FS_RIGHT)
        self.durationFloatSpin.SetDigits(3)
        self.durationFloatSpin.SetFormat('%f')
        self.durationFloatSpin.SetRange(min_val=0.1, max_val=None)

        sizer.Add(self.dummy80, pos=(0, 0), flag=wx.ALL, border=0)
        sizer.Add(self.startDatePicker,
                  pos=(0, 1),
                  flag=wx.ALL | wx.ALIGN_BOTTOM,
                  border=0)
        sizer.Add(self.startTimePicker,
                  pos=(0, 2),
                  flag=wx.ALL | wx.ALIGN_BOTTOM,
                  border=0)
        sizer.Add(self.startTimeGoButton,
                  pos=(0, 3),
                  flag=wx.ALL | wx.ALIGN_BOTTOM,
                  border=0)
        sizer.Add(self.durationFloatSpin,
                  pos=(0, 4),
                  flag=wx.ALL | wx.ALIGN_BOTTOM,
                  border=0)
        sizer.Add(self.dummy100, pos=(0, 5), flag=wx.ALL, border=0)

        sizer.AddGrowableRow(0)
        sizer.AddGrowableCol(3)

        self.SetSizer(sizer)

        self.SetBackgroundColour(bgColor)

        self.Bind(floatspin.EVT_FLOATSPIN, self.onDurationFloatSpin,
                  self.durationFloatSpin)
        #self.Bind(wx.EVT_TEXT, self.onStartTimePicker, self.startTimePicker)
        self.Bind(wx.EVT_BUTTON, self.onStartTimeGo, self.startTimeGoButton)
Exemple #11
0
    def initSpinControl(self, splist):
        combo_box = None
        sb = wx.StaticBox(self, label=self.label)
        self.stbox = wx.StaticBoxSizer(sb, orient=wx.VERTICAL)
        for d in splist:
            sb1 = wx.StaticBox(self, label=d[1])
            sb1.SetBackgroundColour("green")
            hbs1 = wx.StaticBoxSizer(sb1, orient=wx.HORIZONTAL)

            if d[0] == 'CB':
                self.__obj.append(
                    wx.ComboBox(self,
                                choices=[str(x) for x in d[2]],
                                style=wx.CB_READONLY))
                self.__obj[-1].SetValue(str(d[3]))
                self.__obj[-1].Bind(wx.EVT_COMBOBOX, d[4])
                hbs1.Add(self.__obj[-1], 1, wx.EXPAND, 10)
                combo_box = self.__obj[-1]

            else:
                #--- min button
                self.__obj.append(
                    wx.Button(self,
                              wx.NewId(),
                              label="|<",
                              style=wx.BU_EXACTFIT,
                              name="MIN"))
                self.__obj[-1].Bind(wx.EVT_BUTTON, self.OnClickMinMax)
                hbs1.Add(self.__obj[-1], 0, wx.LEFT, 5)
                #---SpinCrtl
                if d[0] == 'SP':
                    self.__obj.append(
                        wx.SpinCtrl(self,
                                    wx.NewId(),
                                    style=wx.SP_ARROW_KEYS | wx.SP_WRAP
                                    | wx.TE_PROCESS_ENTER | wx.ALIGN_RIGHT))
                    # self.__obj.append( wx.SpinButton(self,wx.NewId(),style=wx.SP_ARROW_KEYS|wx.SP_WRAP|wx.TE_PROCESS_ENTER|wx.ALIGN_RIGHT))
                    self.__obj[-1].SetToolTipString("Min: " + str(d[1]) +
                                                    "  Max: " + str(d[2]))
                    self.__obj[-1].SetRange(d[2], d[3])
                    self.__obj[-1].SetValue(d[4])
                    self.__obj[-1].Bind(wx.EVT_SPINCTRL, d[5])
                    hbs1.Add(self.__obj[-1], 1, wx.EXPAND, 10)
        #---FloatSpinCrtl
                elif d[0] == "SPF":
                    self.__obj.append(
                        FS.FloatSpin(self,
                                     wx.NewId(),
                                     min_val=d[2],
                                     max_val=d[3],
                                     increment=d[4],
                                     value=1.0,
                                     agwStyle=FS.FS_RIGHT))
                    self.__obj[-1].SetFormat("%f")
                    self.__obj[-1].SetDigits(3)
                    self.__obj[-1].SetValue(d[4])
                    self.__obj[-1].Bind(FS.EVT_FLOATSPIN, d[6])
                    self.__obj_spf.append(self.__obj[-1])
                    hbs1.Add(self.__obj[-1], 1, wx.EXPAND, 10)
        #--- max button
                self.__obj.append(
                    wx.Button(self,
                              wx.NewId(),
                              label=">|",
                              style=wx.BU_EXACTFIT,
                              name="MAX"))
                self.__obj[-1].Bind(wx.EVT_BUTTON, self.OnClickMinMax)
                hbs1.Add(self.__obj[-1], 0, wx.RIGHT, 5)

            self.stbox.Add(hbs1, 1, wx.EXPAND, 5)

            #--- update SPFs increment factor
            if combo_box:
                self.spf_set_inc_factor(combo_box.GetValue())

        return self.stbox
Exemple #12
0
    def __init__(self, parent, format):
        wx.Dialog.__init__(self, parent, -1, _(u"Format de ligne"))

        self.format = format

        self.lineStyle = [
            _(u"ligne continue"),  #solid line style
            _(u"pointillés"),  #dashed line style
            _(u"mixte"),  #dash-dot line style
            _(u"points"),  #dotted line style
        ]

        self.lineStyleMpl = ['-', '--', '-.', ':']

        #
        # Style
        #
        txtStyle = wx.StaticText(self, -1, _("Style de ligne :"))
        selStyle = PenStyleComboBox(self,
                                    choices=self.lineStyle,
                                    style=wx.CB_READONLY,
                                    pos=(20, 40),
                                    size=(100, -1))
        selStyle.SetToolTipString(_(u"Modifier le style de la ligne"))
        selStyle.SetValue(self.lineStyle[self.lineStyleMpl.index(format.styl)])

        #
        # Epaisseur
        #
        txtWidth = wx.StaticText(self, -1, _("Epaisseur :"))
        #        selWidth = wx.SpinCtrl(self, -1, "", size=(100, -1))
        selWidth = FS.FloatSpin(self,
                                -1,
                                min_val=0.01,
                                max_val=10.0,
                                increment=0.1,
                                value=1.0,
                                agwStyle=FS.FS_LEFT)
        selWidth.SetFormat("%f")
        selWidth.SetDigits(2)

        selWidth.SetToolTipString(_(u"Modifier l'épaisseur de la ligne"))
        #        selWidth.SetRange(1,6)
        selWidth.SetValue(format.epais)

        #
        # Couleur
        #
        txtColor = wx.StaticText(self, -1, _("Couleur :"))
        selColor = wx.Button(self, -1, "", size=(100, 22))
        selColor.SetToolTipString(_(u"Modifier la couleur de la ligne"))
        selColor.SetBackgroundColour(format.coul)

        #
        # Les boutons standards
        #
        btnsizer = wx.StdDialogButtonSizer()

        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_OK)
        btn.SetHelpText("The OK button completes the dialog")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL)
        btn.SetHelpText("The Cancel button cancels the dialog. (Cool, huh?)")
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        #
        # Mise en place
        #
        sizer = wx.GridBagSizer()
        sizer.Add(txtStyle, (0, 0),
                  flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  border=5)
        sizer.Add(txtWidth, (1, 0),
                  flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  border=5)
        sizer.Add(txtColor, (2, 0),
                  flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  border=5)
        sizer.Add(selStyle, (0, 1),
                  flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  border=5)
        sizer.Add(selWidth, (1, 1),
                  flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  border=5)
        sizer.Add(selColor, (2, 1),
                  flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                  border=5)
        sizer.Add(btnsizer, (3, 0), (1, 2),
                  flag=wx.ALIGN_CENTER | wx.ALL,
                  border=5)
        self.SetSizerAndFit(sizer)

        #
        # Les évenements
        #
        self.Bind(wx.EVT_BUTTON, self.OnClick, selColor)
        self.Bind(wx.EVT_COMBOBOX, self.OnCombo, selStyle)
        self.Bind(wx.EVT_SPINCTRL, self.OnSpin, selWidth)
        self.selColor = selColor
        self.selStyle = selStyle
Exemple #13
0
    def __init__(self, parent, id):
    #---------------------------------------------------------------------------
        ExpertSettingPanel.__init__(self, parent, id)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # ---------------- generic mutations ----------------
        genericBox = wx.StaticBox(self, -1, "Generic operations", size=(500,-1))
        genericBoxSizer = wx.StaticBoxSizer(genericBox, wx.HORIZONTAL)
        sizer.Add(genericBoxSizer, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 10)
        
        # shift mutation
        self.shiftMutation = wx.CheckBox(self, -1, "Shift Mutation", \
            name = "shiftMutation")
        genericBoxSizer.Add(self.shiftMutation, 0, \
            wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)

        self.genericWidgets.append(self.shiftMutation)
        
        # swap mutation
        self.swapMutation = wx.CheckBox(self, -1, "Swap Mutation", \
            name = "swapMuation")
        self.swapMutation.SetValue(True)
        genericBoxSizer.Add(self.swapMutation, 0, \
            wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)

        self.genericWidgets.append(self.swapMutation)
        
        # inversion mutation
        self.inversionOrderMutation = wx.CheckBox(self, -1, "Inversion Order", \
            name = "inversionMutation")
        genericBoxSizer.Add(self.inversionOrderMutation, 0, \
            wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)

        self.genericWidgets.append(self.inversionOrderMutation)
        
        # ---------------- binary mutations ----------------
        binaryBox = wx.StaticBox(self, -1, "Binary operations (affects only feature selection)", size=(500,-1))
        binaryBoxSizer = wx.StaticBoxSizer(binaryBox, wx.HORIZONTAL)
        sizer.Add(binaryBoxSizer, 0, wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 10)
        
        # bit flip mutation
        self.binaryMutation = wx.CheckBox(self, -1, "Binary Mutation", \
            name = "binaryMutation")
        self.binaryMutation.SetValue(True)
        binaryBoxSizer.Add(self.binaryMutation, 0, \
            wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)

        self.binaryMutationRate = FS.FloatSpin(self, -1, min_val=0.0, max_val=1.0, \
            increment=0.01, value=0.05)
        self.binaryMutationRate.SetFormat("%f")
        self.binaryMutationRate.SetDigits(2)
        self.binaryMutationRate.SetToolTipString("Rate of mutation")
        binaryBoxSizer.Add(self.binaryMutationRate, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5)
        
        self.selectionWidgets.append(self.binaryMutation)
        self.AddChildToParent(self.binaryMutation, self.binaryMutationRate)
        
        # ---------------- real mutations ----------------
        realBox = wx.StaticBox(self, -1, "Real operations (affects only feature weighting)", size=(500,-1))
        realBoxSizer = wx.StaticBoxSizer(realBox, wx.VERTICAL)
        realBoxFlexGridSizer = wx.FlexGridSizer(0, 3, 5, 5)
        realBoxSizer.Add(realBoxFlexGridSizer, 0)
        sizer.Add(realBoxSizer, 0, wx.ALL | wx.EXPAND, 10)
        
        # gauss mutation
        self.gaussMutation = wx.CheckBox(self, -1, "Gauss Mutation", \
            name = "gaussMutation")
        self.gaussMutation.SetValue(True)
        self.gaussMutation.Disable()
        realBoxFlexGridSizer.Add(self.gaussMutation, 0, \
            wx.LEFT | wx.TOP | wx.RIGHT | wx.EXPAND, 5)
        
        self.gaussMutationSigma = FS.FloatSpin(self, -1, min_val=0.01, max_val=10.0, \
            increment=0.01, value=0.5)
        self.gaussMutationSigma.SetFormat("%f")
        self.gaussMutationSigma.SetDigits(2)
        self.gaussMutationSigma.Disable()
        self.gaussMutationSigma.SetToolTipString("sigma the range for uniform nutation")
        realBoxFlexGridSizer.Add(self.gaussMutationSigma, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5)
        
        self.gaussMutationPchance = FS.FloatSpin(self, -1, min_val=0.0, max_val=1.0, \
            increment=0.01, value=0.5)
        self.gaussMutationPchance.SetFormat("%f")
        self.gaussMutationPchance.SetDigits(2)
        self.gaussMutationPchance.Disable()
        self.gaussMutationPchance.SetToolTipString("p_change the probability to "\
            "change a given coordinate")
        realBoxFlexGridSizer.Add(self.gaussMutationPchance, 0, wx.LEFT | wx.TOP | wx.RIGHT, 5)
        
        self.weightingWidgets.append(self.gaussMutation)
        self.AddChildToParent(self.gaussMutation, self.gaussMutationSigma)
        self.AddChildToParent(self.gaussMutation, self.gaussMutationPchance)
            
        # bind the EVT_CHECKBOX to the CheckBoxes
        self.BindEvent(wx.EVT_CHECKBOX, self.OnCheckBox, \
            [self.shiftMutation,
             self.swapMutation,
             self.inversionOrderMutation,
             self.binaryMutation,
             self.gaussMutation])
Exemple #14
0
    def initControl(self,splist):
        if np.ndim(splist) > 1:
           row  = len( splist   )
        else:
           row = 1
           
        col  = 4
        ds   = 5
        fgs1 = wx.FlexGridSizer(row,col,ds,ds)
        empty_cell=(0,0)
        
        for d in splist:
          
            fgs1.Add( wx.StaticText(self,-1,label=d[1]),0,wx.LEFT,ds)
           #---Button      
            if d[0] == "BT":
               self.__obj.append(wx.Button(self,wx.NewId(),label=d[2],style=wx.BU_EXACTFIT))
               self.__obj[-1].SetName(d[3])
               self.__obj[-1].Bind(wx.EVT_BUTTON,d[-1])
               fgs1.Add(empty_cell,0,wx.LEFT|wx.EXPAND,ds) # skip min bt
               fgs1.Add(self.__obj[-1],0,wx.LEFT|wx.EXPAND,ds)
               fgs1.Add(empty_cell,0,wx.LEFT|wx.EXPAND,ds) # skip max bt
            elif d[0] == 'CK':   
               self.__obj.append( wx.CheckBox(self,wx.NewId(),label=d[2] ) )  
               self.__obj[-1].SetValue(d[3])
               self.__obj[-1].Bind(wx.EVT_CHECKBOX, d[-1])  
               fgs1.Add(empty_cell,0,wx.LEFT|wx.EXPAND,ds) # skip min bt
               fgs1.Add(self.__obj[-1],0,wx.EXPAND,ds)
               fgs1.Add(empty_cell,0,wx.LEFT|wx.EXPAND,ds) # skip max bt
               
            #---ComboBox      
            elif d[0] == "COMBO":
               self.__obj.append(wx.ComboBox(self,wx.NewId(),choices=d[3],style=wx.CB_READONLY))
               self.__obj[-1].SetName(d[1])           
               self.__obj[-1].SetValue(d[2])
               self.__obj[-1].Bind(wx.EVT_COMBOBOX,d[-1])
               fgs1.Add(empty_cell,0,wx.LEFT|wx.EXPAND,ds) # skip min bt
               fgs1.Add(self.__obj[-1],0,wx.LEFT|wx.EXPAND,ds)
               fgs1.Add(empty_cell,0,wx.LEFT|wx.EXPAND,ds) # skip max bt
          #---wx.TextCtrl     
            elif d[0] == 'TXT':
                 self.__obj.append( wx.TextCtrl(self,wx.NewId() ))   
                 self.__obj[-1].SetName(d[1])
                 self.__obj[-1].SetValue(d[2])
                  #if d[3]:
                  #   self.__obj[-1].Bind(wx.EVT_TXTCTRL, d[3])  #6 
                 fgs1.Add(empty_cell,0,wx.LEFT|wx.EXPAND,ds) # skip min bt
                 fgs1.Add(self.__obj[-1],0,wx.LEFT|wx.EXPAND,ds)
                 fgs1.Add(empty_cell,0,wx.LEFT|wx.EXPAND,ds) # skip max bt
        
         #---  MIN/MAXSpin Buttons
            else: 
           #--- min button 
               self.__obj.append( wx.Button(self,wx.NewId(),label="|<",style=wx.BU_EXACTFIT,name="MIN") ) 
               self.__obj[-1].Bind(wx.EVT_BUTTON,self.OnClickMinMax)  
               fgs1.Add(self.__obj[-1],0,wx.LEFT,ds)
           #---SpinCrtl     
               if d[0] == 'SP':   
                  self.__obj.append( wx.SpinCtrl(self,wx.NewId(),style=wx.SP_ARROW_KEYS|wx.SP_WRAP|wx.TE_PROCESS_ENTER|wx.ALIGN_RIGHT)) 
                  self.__obj[-1].SetLabel(d[1])
                  self.__obj[-1].SetToolTipString("Min: " + str(d[2][0]) +"  Max: " + str(d[2][1]) )
                  self.__obj[-1].SetRange(d[2][0],d[2][1])
                  self.__obj[-1].SetValue(d[3])
                  self.__obj[-1].Bind(wx.EVT_SPINCTRL, d[-1])  #5
                  fgs1.Add(self.__obj[-1],1,wx.EXPAND,ds)
           #---FloatSpinCrtl      
               elif d[0] == "SPF":
                  self.__obj.append( FS.FloatSpin(self,wx.NewId(),min_val=d[2][0],max_val=d[2][1],increment=d[2][2],value=1.0,agwStyle=FS.FS_RIGHT) )   
                  self.__obj[-1].SetLabel(d[1])
                  self.__obj[-1].SetFormat("%f")
                  self.__obj[-1].SetDigits(3)
                  self.__obj[-1].SetValue(d[3])
                 # self.__obj[-1].Bind(FS.EVT_FLOATSPIN, d[-1])  #6 
                  self.__obj[-1].Bind(wx.EVT_SPINCTRL, d[-1])  #6 
                  #self.__obj_spf.append( self.__obj[-1] )
                  fgs1.Add(self.__obj[-1],1,wx.EXPAND,ds) 
               else:
                  fgs1.Add(wx.StaticText(self,-1,label="NOT A CONTROLL"),wx.EXPAND,ds)
                    
           #--- max button   
               self.__obj.append( wx.Button(self,wx.NewId(),label=">|",style=wx.BU_EXACTFIT,name="MAX") )  
               self.__obj[-1].Bind(wx.EVT_BUTTON,self.OnClickMinMax)  
               fgs1.Add(self.__obj[-1],0,wx.RIGHT,ds)
 
        return fgs1                    
Exemple #15
0
    def __init__(self, parent, title=DEFAULT_TITLE):
        wx.Dialog.__init__(self, parent, wx.ID_ANY, title)
        self.Bind(wx.EVT_CLOSE, self.onClose)
        self.parent = parent
        self.images = self.parent.images
        self.modified = False

        self.mirrorX = False
        self.mirrorY = False

        boxTrans = wx.StaticBox(self, wx.ID_ANY, "Translate")

        topBorder = boxTrans.GetBordersForSizer()[0]
        bsizer = wx.BoxSizer(wx.VERTICAL)
        bsizer.AddSpacer(topBorder + 10)

        tsizer = wx.BoxSizer(wx.HORIZONTAL)
        tsizer.AddSpacer(10)

        vsz = wx.BoxSizer(wx.VERTICAL)
        hsz = wx.BoxSizer(wx.HORIZONTAL)

        hsz.Add(wx.StaticText(boxTrans, wx.ID_ANY, "X:"), 1,
                wx.ALIGN_CENTER_VERTICAL)
        hsz.AddSpacer(10)

        self.scX = FS.FloatSpin(boxTrans,
                                wx.ID_ANY,
                                min_val=-500,
                                max_val=500,
                                increment=0.1,
                                value=0,
                                agwStyle=FS.FS_RIGHT)

        self.scX.SetDigits(2)
        self.Bind(wx.EVT_SPINCTRL, self.onChange, self.scX)
        hsz.Add(self.scX)

        vsz.Add(hsz)
        vsz.AddSpacer(5)

        hsz = wx.BoxSizer(wx.HORIZONTAL)
        r1 = wx.RadioButton(boxTrans, wx.ID_ANY, "1", style=wx.RB_GROUP)
        self.Bind(wx.EVT_RADIOBUTTON, self.onXRadio, r1)
        hsz.Add(r1)
        r2 = wx.RadioButton(boxTrans, wx.ID_ANY, "0.1")
        self.Bind(wx.EVT_RADIOBUTTON, self.onXRadio, r2)
        hsz.Add(r2)
        r3 = wx.RadioButton(boxTrans, wx.ID_ANY, "0.01")
        self.Bind(wx.EVT_RADIOBUTTON, self.onXRadio, r3)
        hsz.Add(r3)
        r2.SetValue(True)
        vsz.Add(hsz)

        tsizer.Add(vsz)
        tsizer.AddSpacer(10)

        vsz = wx.BoxSizer(wx.VERTICAL)
        hsz = wx.BoxSizer(wx.HORIZONTAL)

        hsz.Add(wx.StaticText(boxTrans, wx.ID_ANY, "Y:"), 1,
                wx.ALIGN_CENTER_VERTICAL)
        hsz.AddSpacer(10)

        self.scY = FS.FloatSpin(boxTrans,
                                wx.ID_ANY,
                                min_val=-500,
                                max_val=500,
                                increment=0.1,
                                value=0,
                                agwStyle=FS.FS_RIGHT)

        self.scY.SetDigits(2)
        self.Bind(wx.EVT_SPINCTRL, self.onChange, self.scY)
        hsz.Add(self.scY)

        vsz.Add(hsz)
        vsz.AddSpacer(5)

        hsz = wx.BoxSizer(wx.HORIZONTAL)
        r1 = wx.RadioButton(boxTrans, wx.ID_ANY, "1", style=wx.RB_GROUP)
        self.Bind(wx.EVT_RADIOBUTTON, self.onYRadio, r1)
        hsz.Add(r1)
        r2 = wx.RadioButton(boxTrans, wx.ID_ANY, "0.1")
        self.Bind(wx.EVT_RADIOBUTTON, self.onYRadio, r2)
        hsz.Add(r2)
        r3 = wx.RadioButton(boxTrans, wx.ID_ANY, "0.01")
        self.Bind(wx.EVT_RADIOBUTTON, self.onYRadio, r3)
        hsz.Add(r3)
        r2.SetValue(True)
        vsz.Add(hsz)

        tsizer.Add(vsz)
        tsizer.AddSpacer(20)

        self.bShift = wx.BitmapButton(boxTrans,
                                      wx.ID_ANY,
                                      self.images.pngTranslate,
                                      size=BTNDIM)
        self.bShift.SetToolTip("Apply translation values")
        tsizer.Add(self.bShift)
        self.Bind(wx.EVT_BUTTON, self.bShiftPressed, self.bShift)

        tsizer.AddSpacer(10)
        bsizer.Add(tsizer)
        bsizer.AddSpacer(10)

        boxTrans.SetSizer(bsizer)

        boxMirr = wx.StaticBox(self, wx.ID_ANY, "Mirror")

        topBorder = boxTrans.GetBordersForSizer()[0]
        bsizer = wx.BoxSizer(wx.VERTICAL)
        bsizer.AddSpacer(topBorder + 10)

        tsizer = wx.BoxSizer(wx.HORIZONTAL)
        tsizer.AddSpacer(10)

        self.bMirrorX = wx.BitmapButton(boxMirr,
                                        wx.ID_ANY,
                                        self.images.pngMirrorx,
                                        size=BTNDIM)
        self.bMirrorX.SetToolTip("Mirror about X axis")
        tsizer.Add(self.bMirrorX)
        self.Bind(wx.EVT_BUTTON, self.bMirrorXPressed, self.bMirrorX)

        tsizer.AddSpacer(50)

        self.bMirrorY = wx.BitmapButton(boxMirr,
                                        wx.ID_ANY,
                                        self.images.pngMirrory,
                                        size=BTNDIM)
        self.bMirrorY.SetToolTip("Mirror about Y axis")
        tsizer.Add(self.bMirrorY)
        self.Bind(wx.EVT_BUTTON, self.bMirrorYPressed, self.bMirrorY)

        tsizer.AddSpacer(10)
        bsizer.Add(tsizer, 1, wx.ALIGN_CENTER_HORIZONTAL)
        bsizer.AddSpacer(10)

        boxMirr.SetSizer(bsizer)

        vsz = wx.BoxSizer(wx.VERTICAL)
        vsz.AddSpacer(5)
        vsz.Add(boxTrans)
        vsz.AddSpacer(5)
        vsz.Add(boxMirr, 1, wx.EXPAND)
        vsz.AddSpacer(5)

        self.bCancel = wx.BitmapButton(self,
                                       wx.ID_ANY,
                                       self.images.pngCancel,
                                       size=BTNDIM)
        self.bCancel.SetToolTip("Cancel with no changes")
        vsz.Add(self.bCancel, 0, wx.ALIGN_CENTER_HORIZONTAL)
        self.Bind(wx.EVT_BUTTON, self.bCancelPressed, self.bCancel)

        vsz.AddSpacer(5)

        hsz = wx.BoxSizer(wx.HORIZONTAL)
        hsz.AddSpacer(10)
        hsz.Add(vsz)
        hsz.AddSpacer(10)

        self.SetSizer(hsz)
        self.Layout()
        self.Fit()