def __init__(
        self,
        parent,
        minus_button_image,
        plus_button_image,
        SetStep=10,
        SetMin=0,
        SetMax=200,
        initial_brightness=0,
        initial_contrast=0,
        initial_gamma=0,
        initial_hue=0,
        initial_saturation=0,
        SetBrightnessCallback=None,
        SetContrastCallback=None,
        SetGammaCallback=None,
        SetHueCallback=None,
        SetSaturationCallback=None,
        scale={
            'brightness': {
                'step': 10,
                'min': 0,
                'max': 200,
                'factor': 100.0,
                'default': 1.0
            },
            'contrast': {
                'step': 10,
                'min': 0,
                'max': 200,
                'factor': 100.0,
                'default': 1.0
            },
            'gamma': {
                'step': 10,
                'min': 1,
                'max': 1000,
                'factor': 100.0,
                'default': 1.0
            },
            'hue': {
                'step': 10,
                'min': 0,
                'max': 360,
                'factor': 1,
                'default': 0
            },
            'saturation': {
                'step': 10,
                'min': 0,
                'max': 300,
                'factor': 100.0,
                'default': 1.0
            }
        }):
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        self.scale = scale
        #self.SetStep = SetStep
        #self.SetMin = SetMin
        #self.SetMax = SetMax

        self.brightness = initial_brightness
        self.contrast = initial_contrast
        self.gamma = initial_gamma
        #self.hue = initial_hue
        #self.saturation = initial_saturation

        self.SetBrightnessCallback = SetBrightnessCallback
        self.SetContrastCallback = SetContrastCallback
        self.SetGammaCallback = SetGammaCallback
        #self.SetHueCallback = SetHueCallback
        #self.SetSaturationCallback = SetSaturationCallback

        #nb = wx.Notebook( self )

        #bp = wx.Panel( nb )
        bp = self
        brightnessL = wx.StaticText(bp, label="Brightness")
        minusBrightnessBtn = wx.StaticBitmap(bp, bitmap=minus_button_image)
        plusBrightnessBtn = wx.StaticBitmap(bp, bitmap=plus_button_image)
        self.brightnessSlider = wx.Slider(bp,
                                          -1,
                                          self.brightness,
                                          self.scale['brightness']['min'],
                                          self.scale['brightness']['max'],
                                          size=(100, -1),
                                          style=wx.SL_AUTOTICKS | wx.SL_LABELS)

        #cp = wx.Panel( nb )
        cp = self
        contrastL = wx.StaticText(cp, label="Contrast")
        minusContrastBtn = wx.StaticBitmap(cp, bitmap=minus_button_image)
        plusContrastBtn = wx.StaticBitmap(cp, bitmap=plus_button_image)
        self.contrastSlider = wx.Slider(cp,
                                        -1,
                                        self.contrast,
                                        self.scale['contrast']['min'],
                                        self.scale['contrast']['max'],
                                        size=(100, -1),
                                        style=wx.SL_AUTOTICKS | wx.SL_LABELS)

        #gp = wx.Panel( nb )
        gp = self
        gammaL = wx.StaticText(gp, label="Gamma")
        minusGammaBtn = wx.StaticBitmap(gp, bitmap=minus_button_image)
        plusGammaBtn = wx.StaticBitmap(gp, bitmap=plus_button_image)
        self.gammaSlider = wx.Slider(gp,
                                     -1,
                                     self.gamma,
                                     self.scale['gamma']['min'],
                                     self.scale['gamma']['max'],
                                     size=(100, -1),
                                     style=wx.SL_AUTOTICKS | wx.SL_LABELS)

        #hp = wx.Panel( nb )
        #hueL = wx.StaticText( hp, label="Hue")
        #minusHueBtn = wx.StaticBitmap( hp, bitmap = minus_button_image )
        #plusHueBtn = wx.StaticBitmap( hp, bitmap = plus_button_image )
        #self.hueSlider = wx.Slider( hp, -1, self.hue, self.scale['hue']['min'], self.scale['hue']['max'], size=(100, -1), style=wx.SL_AUTOTICKS|wx.SL_LABELS)

        #sp = wx.Panel( nb )
        #saturationL = wx.StaticText( sp, label="Saturation")
        #minusSaturationBtn = wx.StaticBitmap( sp, bitmap = minus_button_image )
        #plusSaturationBtn = wx.StaticBitmap( sp, bitmap = plus_button_image )
        #self.saturationSlider = wx.Slider( sp, -1, self.saturation, self.scale['saturation']['min'], self.scale['saturation']['max'], size=(100, -1), style=wx.SL_AUTOTICKS|wx.SL_LABELS)

        resetBtn = wx.Button(self, wx.ID_ANY, label='Reset')
        # Bind controls to events

        self.Bind(wx.EVT_SLIDER, self.OnSetBrightness, self.brightnessSlider)
        self.Bind(wx.EVT_SLIDER, self.OnSetContrast, self.contrastSlider)
        self.Bind(wx.EVT_SLIDER, self.OnSetGamma, self.gammaSlider)
        #self.Bind( wx.EVT_SLIDER, self.OnSetHue, self.hueSlider )
        #self.Bind( wx.EVT_SLIDER, self.OnSetSaturation, self.saturationSlider )

        minusBrightnessBtn.Bind(wx.EVT_LEFT_UP, self.DecreaseBrightness)
        plusBrightnessBtn.Bind(wx.EVT_LEFT_UP, self.IncreaseBrightness)
        minusContrastBtn.Bind(wx.EVT_LEFT_UP, self.DecreaseContrast)
        plusContrastBtn.Bind(wx.EVT_LEFT_UP, self.IncreaseContrast)
        minusGammaBtn.Bind(wx.EVT_LEFT_UP, self.DecreaseGamma)
        plusGammaBtn.Bind(wx.EVT_LEFT_UP, self.IncreaseGamma)
        #minusHueBtn.Bind( wx.EVT_LEFT_UP, self.DecreaseHue )
        #plusHueBtn.Bind( wx.EVT_LEFT_UP, self.IncreaseHue )
        #minusSaturationBtn.Bind( wx.EVT_LEFT_UP, self.DecreaseSaturation )
        #plusSaturationBtn.Bind( wx.EVT_LEFT_UP, self.IncreaseSaturation )
        resetBtn.Bind(wx.EVT_BUTTON, self.Reset)

        # Give a pretty layout to the controls
        ctrlbox = wx.BoxSizer(wx.HORIZONTAL)
        vbox = wx.BoxSizer(wx.VERTICAL)

        gridSizer = wx.FlexGridSizer(rows=2, cols=2, hgap=5, vgap=5)
        gridSizer.AddGrowableCol(1)

        bbox = wx.BoxSizer(wx.HORIZONTAL)
        bbox.Add(minusBrightnessBtn, 0, wx.CENTER)
        bbox.Add(self.brightnessSlider,
                 1,
                 wx.EXPAND | wx.CENTER | wx.BOTTOM,
                 border=15)
        bbox.Add(plusBrightnessBtn, 0, wx.CENTER)

        cbox = wx.BoxSizer(wx.HORIZONTAL)
        cbox.Add(minusContrastBtn, 0, wx.CENTER)
        cbox.Add(self.contrastSlider,
                 1,
                 wx.EXPAND | wx.CENTER | wx.BOTTOM,
                 border=15)
        cbox.Add(plusContrastBtn, 0, wx.CENTER)

        gbox = wx.BoxSizer(wx.HORIZONTAL)
        gbox.Add(minusGammaBtn, 0, wx.CENTER)
        gbox.Add(self.gammaSlider,
                 1,
                 wx.EXPAND | wx.CENTER | wx.BOTTOM,
                 border=15)
        gbox.Add(plusGammaBtn, 0, wx.CENTER)

        #hbox = wx.BoxSizer( wx.HORIZONTAL )
        #hbox.Add( minusHueBtn, 0, wx.CENTER )
        #hbox.Add( self.hueSlider, 1, wx.EXPAND|wx.CENTER|wx.BOTTOM, border=15 )
        #hbox.Add( plusHueBtn, 0, wx.CENTER )
        #
        #sbox = wx.BoxSizer( wx.HORIZONTAL )
        #sbox.Add( minusSaturationBtn, 0, wx.CENTER )
        #sbox.Add( self.saturationSlider, 1, wx.EXPAND|wx.CENTER|wx.BOTTOM, border=15 )
        #sbox.Add( plusSaturationBtn, 0, wx.CENTER )

        gridSizer.AddMany([
            (brightnessL, 0, wx.ALIGN_CENTER_VERTICAL),
            (bbox, 1, wx.EXPAND),
            (contrastL, 0, wx.ALIGN_CENTER_VERTICAL),
            (cbox, 1, wx.EXPAND),
            (gammaL, 0, wx.ALIGN_CENTER_VERTICAL),
            (gbox, 1, wx.EXPAND),
            #( hueL,0,wx.ALIGN_CENTER_VERTICAL ), ( hbox, 1, wx.EXPAND ),
            #( saturationL,0,wx.ALIGN_CENTER_VERTICAL ), ( sbox, 1, wx.EXPAND )
        ])
        vbox.Add(gridSizer, 1, wx.EXPAND | wx.ALL, border=10)
        ctrlbox.Add(vbox, 1, wx.EXPAND | wx.ALL, border=10)
        ctrlbox.Add(resetBtn, 0, wx.ALL, border=10)

        #bp.SetSizer( bbox )
        #cp.SetSizer( cbox )
        #gp.SetSizer( gbox )
        #hp.SetSizer( hbox )
        #sp.SetSizer( sbox )
        #nb.AddPage( bp, 'Brightness' )
        #nb.AddPage( cp, 'Contrast' )
        #nb.AddPage( gp, 'Gamma' )
        #nb.AddPage( hp, 'Hue' )
        #nb.AddPage( sp, 'Saturation' )
        #ctrlbox.Add( nb, 1, wx.EXPAND )

        self.SetSizer(ctrlbox)
Beispiel #2
0
    def _create_axial_slices_pane(self):
        """Create a panel
        """
        panel = wx.Panel(self, -1)

        self.axial = wxVTKRenderWindowInteractor(panel, -1, (600, 800))

        self.slices_sliderA = wx.Slider(panel, -1, 11,
                                        0, 30, wx.DefaultPosition,
                                        wx.Size(100, -1), wx.SL_HORIZONTAL)
        self.slices_spinA = wx.SpinCtrl(panel, wx.ID_ANY,
                                        str(self.slices_sliderA.GetValue()),
                                        wx.DefaultPosition, wx.Size(70, -1),
                                        wx.SP_ARROW_KEYS, 0, 100, 11)
        self.slices_resetA = wx.Button(panel, -1, "Reset Cameras")
        self.text_select1 = wx.StaticText(panel, -1, "Select voxel   ",
                                          wx.Point(0, 0))
        self.select1 = wx.RadioButton(panel, wx.ID_ANY, label=' ')
        self.text_select2 = wx.StaticText(panel, -1, "Select region  ",
                                          wx.Point(0, 0))
        self.select2 = wx.RadioButton(panel, wx.ID_ANY, label=' ')

        self.text_overlay = wx.StaticText(panel, -1, "Show colormap ",
                                          wx.Point(0, 0))
        self.show_overlay = wx.CheckBox(panel, wx.ID_ANY, wx.EmptyString,
                                        wx.DefaultPosition, wx.DefaultSize, 0)
        self.show_overlay.SetValue(False)

        self.text_colormap = wx.StaticText(panel, -1, "Mean ", wx.Point(0, 0))
        self.radio_mean = wx.RadioButton(panel,
                                         wx.ID_ANY,
                                         label=' ',
                                         style=wx.RB_GROUP)
        self.text_radio_mean = wx.StaticText(panel, -1, "STD  ",
                                             wx.Point(0, 0))
        self.radio_std = wx.RadioButton(panel, wx.ID_ANY, label=' ')

        button_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button_sizer.AddSpacer(30)
        button_sizer.Add(self.slices_sliderA)
        button_sizer.Add(self.slices_spinA)
        button_sizer.AddSpacer(30)
        button_sizer.Add(self.slices_resetA)
        button_sizer.AddSpacer(30)
        button_sizer.Add(self.text_select1)
        button_sizer.Add(self.select1)
        button_sizer.Add(self.text_select2)
        button_sizer.Add(self.select2)
        button_sizer.Add(self.text_overlay)
        button_sizer.AddSpacer(10)
        button_sizer.Add(self.show_overlay)
        button_sizer.AddSpacer(15)
        button_sizer.Add(self.text_colormap)
        button_sizer.Add(self.radio_mean)
        button_sizer.Add(self.text_radio_mean)
        button_sizer.Add(self.radio_std)

        button_sizer.AddSpacer(30)

        tl_sizer = wx.BoxSizer(wx.VERTICAL)
        tl_sizer.Add(self.axial, 1, wx.EXPAND | wx.BOTTOM, 7)
        tl_sizer.Add(button_sizer)

        panel.SetSizer(tl_sizer)
        tl_sizer.Fit(panel)

        return panel
def slider(frame, *args, **kwds):
    return wx.Slider(frame, -1, *args, **kwds)
Beispiel #4
0
    def __init__(self, title):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          title,
                          pos=wx.DefaultPosition,
                          size=(550, 500))

        # Menu Bar
        #   File Menu
        self.frame_menubar = wx.MenuBar()
        self.file_menu = wx.Menu()
        self.file_menu.Append(1, "&Open", "Open from file..")
        self.file_menu.AppendSeparator()
        self.file_menu.Append(2, "&Close", "Quit")
        self.Bind(wx.EVT_MENU, self.OnOpen, id=1)
        self.Bind(wx.EVT_MENU, self.OnExit, id=2)
        self.frame_menubar.Append(self.file_menu, "File")
        self.SetMenuBar(self.frame_menubar)

        # Panels
        # The first panel holds the video and it's all black
        self.videopanel = wx.Panel(self, -1)
        self.videopanel.SetBackgroundColour(wx.BLACK)

        # The second panel holds controls
        ctrlpanel = wx.Panel(self, -1)
        self.timeslider = wx.Slider(ctrlpanel, -1, 0, 0, 1000)
        self.timeslider.SetRange(0, 1000)
        pause = wx.Button(ctrlpanel,
                          label="Pause",
                          font=("Helvetica", 14),
                          bg="powder blue")
        play = wx.Button(ctrlpanel,
                         label="Play",
                         font=("Helvetica", 14),
                         bg="powder blue")
        stop = wx.Button(ctrlpanel,
                         label="Stop",
                         font=("Helvetica", 14),
                         bg="powder blue")
        volume = wx.Button(ctrlpanel,
                           label="Volume",
                           font=("Helvetica", 14),
                           bg="powder blue")
        self.volslider = wx.Slider(ctrlpanel, -1, 0, 0, 100, size=(100, -1))

        # Bind controls to events
        self.Bind(wx.EVT_BUTTON, self.OnPlay, play)
        self.Bind(wx.EVT_BUTTON, self.OnPause, pause)
        self.Bind(wx.EVT_BUTTON, self.OnStop, stop)
        self.Bind(wx.EVT_BUTTON, self.OnToggleVolume, volume)
        self.Bind(wx.EVT_SLIDER, self.OnSetVolume, self.volslider)

        # Give a pretty layout to the controls
        ctrlbox = wx.BoxSizer(wx.VERTICAL)
        box1 = wx.BoxSizer(wx.HORIZONTAL)
        box2 = wx.BoxSizer(wx.HORIZONTAL)
        # box1 contains the timeslider
        box1.Add(self.timeslider, 1)
        # box2 contains some buttons and the volume controls
        box2.Add(play, flag=wx.RIGHT, border=5)
        box2.Add(pause)
        box2.Add(stop)
        box2.Add((-1, -1), 1)
        box2.Add(volume)
        box2.Add(self.volslider, flag=wx.TOP | wx.LEFT, border=5)
        # Merge box1 and box2 to the ctrlsizer
        ctrlbox.Add(box1, flag=wx.EXPAND | wx.BOTTOM, border=10)
        ctrlbox.Add(box2, 1, wx.EXPAND)
        ctrlpanel.SetSizer(ctrlbox)
        # Put everything togheter
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.videopanel, 1, flag=wx.EXPAND)
        sizer.Add(ctrlpanel, flag=wx.EXPAND | wx.BOTTOM | wx.TOP, border=10)
        self.SetSizer(sizer)
        self.SetMinSize((350, 300))

        # finally create the timer, which updates the timeslider
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)

        # VLC player controls
        self.Instance = vlc.Instance()
        self.player = self.Instance.media_player_new()
Beispiel #5
0
    def __init__(self, parent, *args, **kwargs):
        """"""
        self.parent = parent
        self.stitch_plan = kwargs.pop('stitch_plan')
        self.target_stitches_per_second = kwargs.pop('stitches_per_second')
        self.target_duration = kwargs.pop('target_duration')
        kwargs['style'] = wx.BORDER_SUNKEN
        wx.Panel.__init__(self, parent, *args, **kwargs)

        self.statusbar = self.GetTopLevelParent().statusbar

        self.drawing_panel = None
        self.num_stitches = 1
        self.current_stitch = 1
        self.speed = 1
        self.direction = 1

        # Widgets
        self.btnMinus = wx.Button(self, -1, label='-')
        self.btnMinus.Bind(wx.EVT_BUTTON, self.animation_slow_down)
        self.btnMinus.SetToolTip(_('Slow down (arrow down)'))
        self.btnPlus = wx.Button(self, -1, label='+')
        self.btnPlus.Bind(wx.EVT_BUTTON, self.animation_speed_up)
        self.btnPlus.SetToolTip(_('Speed up (arrow up)'))
        self.btnBackwardStitch = wx.Button(self, -1, label='<|')
        self.btnBackwardStitch.Bind(wx.EVT_BUTTON,
                                    self.animation_one_stitch_backward)
        self.btnBackwardStitch.SetToolTip(_('Go on step backward (-)'))
        self.btnForwardStitch = wx.Button(self, -1, label='|>')
        self.btnForwardStitch.Bind(wx.EVT_BUTTON,
                                   self.animation_one_stitch_forward)
        self.btnForwardStitch.SetToolTip(_('Go on step forward (+)'))
        self.directionBtn = wx.Button(self, -1, label='<<')
        self.directionBtn.Bind(wx.EVT_BUTTON, self.on_direction_button)
        self.directionBtn.SetToolTip(
            _('Switch direction (arrow left | arrow right)'))
        self.pauseBtn = wx.Button(self, -1, label=_('Pause'))
        self.pauseBtn.Bind(wx.EVT_BUTTON, self.on_pause_start_button)
        self.pauseBtn.SetToolTip(_('Pause (P)'))
        self.restartBtn = wx.Button(self, -1, label=_('Restart'))
        self.restartBtn.Bind(wx.EVT_BUTTON, self.animation_restart)
        self.restartBtn.SetToolTip(_('Restart (R)'))
        self.nppBtn = wx.ToggleButton(self, -1, label=_('O'))
        self.nppBtn.Bind(wx.EVT_TOGGLEBUTTON, self.toggle_npp)
        self.nppBtn.SetToolTip(_('Display needle penetration point (O)'))
        self.quitBtn = wx.Button(self, -1, label=_('Quit'))
        self.quitBtn.Bind(wx.EVT_BUTTON, self.animation_quit)
        self.quitBtn.SetToolTip(_('Quit (Q)'))
        self.slider = wx.Slider(self,
                                -1,
                                value=1,
                                minValue=1,
                                maxValue=2,
                                style=wx.SL_HORIZONTAL | wx.SL_LABELS)
        self.slider.Bind(wx.EVT_SLIDER, self.on_slider)
        self.stitchBox = IntCtrl(self,
                                 -1,
                                 value=1,
                                 min=1,
                                 max=2,
                                 limited=True,
                                 allow_none=True,
                                 style=wx.TE_PROCESS_ENTER)
        self.stitchBox.Bind(wx.EVT_LEFT_DOWN, self.on_stitch_box_focus)
        self.stitchBox.Bind(wx.EVT_SET_FOCUS, self.on_stitch_box_focus)
        self.stitchBox.Bind(wx.EVT_TEXT_ENTER, self.on_stitch_box_focusout)
        self.stitchBox.Bind(wx.EVT_KILL_FOCUS, self.on_stitch_box_focusout)
        self.Bind(wx.EVT_LEFT_DOWN, self.on_stitch_box_focusout)

        # Layout
        self.vbSizer = vbSizer = wx.BoxSizer(wx.VERTICAL)
        self.hbSizer1 = hbSizer1 = wx.BoxSizer(wx.HORIZONTAL)
        self.hbSizer2 = hbSizer2 = wx.BoxSizer(wx.HORIZONTAL)
        hbSizer1.Add(self.slider, 1, wx.EXPAND | wx.ALL, 3)
        hbSizer1.Add(self.stitchBox, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
        vbSizer.Add(hbSizer1, 1, wx.EXPAND | wx.ALL, 3)
        hbSizer2.Add(self.btnMinus, 0, wx.EXPAND | wx.ALL, 2)
        hbSizer2.Add(self.btnPlus, 0, wx.EXPAND | wx.ALL, 2)
        hbSizer2.Add(self.btnBackwardStitch, 0, wx.EXPAND | wx.ALL, 2)
        hbSizer2.Add(self.btnForwardStitch, 0, wx.EXPAND | wx.ALL, 2)
        hbSizer2.Add(self.directionBtn, 0, wx.EXPAND | wx.ALL, 2)
        hbSizer2.Add(self.pauseBtn, 0, wx.EXPAND | wx.ALL, 2)
        hbSizer2.Add(self.restartBtn, 0, wx.EXPAND | wx.ALL, 2)
        hbSizer2.Add(self.nppBtn, 0, wx.EXPAND | wx.ALL, 2)
        hbSizer2.Add(self.quitBtn, 0, wx.EXPAND | wx.ALL, 2)
        vbSizer.Add(hbSizer2, 0, wx.EXPAND | wx.ALL, 3)
        self.SetSizerAndFit(vbSizer)

        # Keyboard Shortcuts
        shortcut_keys = [
            (wx.ACCEL_NORMAL, wx.WXK_RIGHT, self.animation_forward),
            (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_RIGHT, self.animation_forward),
            (wx.ACCEL_NORMAL, wx.WXK_LEFT, self.animation_reverse),
            (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_LEFT, self.animation_reverse),
            (wx.ACCEL_NORMAL, wx.WXK_UP, self.animation_speed_up),
            (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_UP, self.animation_speed_up),
            (wx.ACCEL_NORMAL, wx.WXK_DOWN, self.animation_slow_down),
            (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_DOWN, self.animation_slow_down),
            (wx.ACCEL_NORMAL, ord('+'), self.animation_one_stitch_forward),
            (wx.ACCEL_NORMAL, ord('='), self.animation_one_stitch_forward),
            (wx.ACCEL_SHIFT, ord('='), self.animation_one_stitch_forward),
            (wx.ACCEL_NORMAL, wx.WXK_ADD, self.animation_one_stitch_forward),
            (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_ADD,
             self.animation_one_stitch_forward),
            (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_UP,
             self.animation_one_stitch_forward),
            (wx.ACCEL_NORMAL, ord('-'), self.animation_one_stitch_backward),
            (wx.ACCEL_NORMAL, ord('_'), self.animation_one_stitch_backward),
            (wx.ACCEL_NORMAL, wx.WXK_SUBTRACT,
             self.animation_one_stitch_backward),
            (wx.ACCEL_NORMAL, wx.WXK_NUMPAD_SUBTRACT,
             self.animation_one_stitch_backward),
            (wx.ACCEL_NORMAL, ord('r'), self.animation_restart),
            (wx.ACCEL_NORMAL, ord('o'), self.on_toggle_npp_shortcut),
            (wx.ACCEL_NORMAL, ord('p'), self.on_pause_start_button),
            (wx.ACCEL_NORMAL, wx.WXK_SPACE, self.on_pause_start_button),
            (wx.ACCEL_NORMAL, ord('q'), self.animation_quit)
        ]

        self.accel_entries = []

        for shortcut_key in shortcut_keys:
            eventId = wx.NewId()
            self.accel_entries.append(
                (shortcut_key[0], shortcut_key[1], eventId))
            self.Bind(wx.EVT_MENU, shortcut_key[2], id=eventId)

        self.accel_table = wx.AcceleratorTable(self.accel_entries)
        self.SetAcceleratorTable(self.accel_table)
        self.SetFocus()
Beispiel #6
0
    def __init__(self, title, roscom):
        wx.Frame.__init__(self, None, -1, title, (-1, -1));
        self.roscomms = roscom
        self.joint_map = {}
        panel = wx.Panel(self, wx.ID_ANY);
        box = wx.BoxSizer(wx.VERTICAL)
        masterbox = wx.BoxSizer(wx.VERTICAL)
        font = wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD)
        
        ### Sliders ###
        for name in self.roscomms.joint_list:
            joint = self.roscomms.free_joints[name]

            if joint['min'] == joint['max']:
                continue

            row = wx.FlexGridSizer(3,2)
            label = wx.StaticText(panel, -1, name)
            label.SetFont(font)
            row.Add(label, 1, wx.ALIGN_CENTER_VERTICAL)
            row.Add(wx.StaticText(panel, -1, ''), 1, wx.ALIGN_CENTER_VERTICAL)
            

            display = wx.StaticText (panel,-1, str(0), 
                        style=wx.TE_READONLY | wx.ALIGN_RIGHT)
                        
                        
            display_velocity = wx.StaticText (panel,-1, str(0), 
                        style=wx.TE_READONLY | wx.ALIGN_RIGHT)
#            row.Add(display, flag= wx.ALIGN_CENTER| wx.ALIGN_CENTER_VERTICAL)
            
#            position = wx.TextCtrl (panel, value=str(0), 
#                        style=wx.TE_READONLY | wx.ALIGN_RIGHT)
#            row.Add(position, flag= wx.ALIGN_RIGHT| wx.ALIGN_CENTER_VERTICAL)
            
#            box.Add(label, 1, wx.EXPAND) #was adding row
            
            slider = wx.Slider(panel, -1, RANGE/2, 0, RANGE, 
                        style= wx.SL_AUTOTICKS | wx.SL_HORIZONTAL)
            slider_vel = wx.Slider(panel, -1, 50, 0, 100, 	# fixed the resolution o
                        style= wx.SL_AUTOTICKS | wx.SL_HORIZONTAL)
            slider.SetFont(font)
	    slider.isvel = False

            slider_vel.SetFont(font)
            slider_vel.isvel = True
            
            row2 = wx.FlexGridSizer(1,3)  
            row2.AddGrowableCol(0,2)

            refandack = wx.FlexGridSizer(4,1)
            
            row.Add(slider,flag=wx.ALIGN_LEFT| wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)            
            row.Add(display,1,wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
            row.Add(slider_vel,flag=wx.ALIGN_LEFT| wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
            
            row.Add(display_velocity, 1, wx.ALIGN_CENTER_VERTICAL)
            
            
            row.AddGrowableRow(1, 0)
            row.AddGrowableCol(0,1)

            row2.Add(row,flag=wx.ALIGN_LEFT| wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
            
            # Add a "go" buttons
            btnAck = wx.Button(panel, id=wx.ID_ANY, label="Ack", name=name)
            btnRef = wx.Button(panel, id=wx.ID_ANY, label="Ref", name=name)
            btnMove = wx.Button(panel, id=wx.ID_ANY, label="Move", name=name)
            btnVel = wx.Button(panel, id=wx.ID_ANY, label="MoveVel", name=name)
            refandack.Add(btnAck, 1, wx.EXPAND)
            refandack.Add(btnRef, 1, wx.EXPAND)
            refandack.Add(btnMove, 1, wx.EXPAND)
            refandack.Add(btnVel, 1, wx.EXPAND)
            row2.Add(refandack,flag=wx.ALIGN_LEFT| wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
            
            # The status flags
            statusflags = wx.GridSizer(5,4)
            statusflags.Add(wx.StaticText (panel,-1, 'Position:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            positionlabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(positionlabel)
            statusflags.Add(wx.StaticText (panel,-1, 'Current:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            currentlabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(currentlabel)
            statusflags.Add(wx.StaticText (panel,-1, 'Referenced:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            referencedlabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(referencedlabel)
            statusflags.Add(wx.StaticText (panel,-1, 'Moving:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            movinglabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(movinglabel)
            statusflags.Add(wx.StaticText (panel,-1, 'MoveEnd:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            moveendlabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(moveendlabel)
            statusflags.Add(wx.StaticText (panel,-1, 'PosReached:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            posreachedlabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(posreachedlabel)
            statusflags.Add(wx.StaticText (panel,-1, 'Brake:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            brakelabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(brakelabel)
            statusflags.Add(wx.StaticText (panel,-1, 'Error:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            errorlabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(errorlabel)
            statusflags.Add(wx.StaticText (panel,-1, 'Warning:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            warninglabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(warninglabel)
            statusflags.Add(wx.StaticText (panel,-1, 'Error code:', style=wx.TE_READONLY | wx.ALIGN_LEFT))
            errorcodelabel=wx.StaticText (panel,-1, '0', style=wx.TE_READONLY | wx.ALIGN_LEFT)
            statusflags.Add(errorcodelabel)
#            self.celsius =  wx.StaticText(self, -1, '', (150, 150))
            row2.Add(statusflags,flag=wx.ALIGN_LEFT| wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)

            box.Add(row2, 1, wx.EXPAND)
            line =wx.StaticLine(panel, -1)
            line.SetBackgroundColour("Black")
            box.Add(line)

            self.joint_map[name] = {'slidervalue':0, 'display':display, 'display_velocity':display_velocity, 
                                    'slider':slider, 'joint':joint, 
                                    'positionlabel':positionlabel, 'currentlabel':currentlabel,
                                    'referencedlabel':referencedlabel, 'movinglabel':movinglabel,
                                    'moveendlabel':moveendlabel, 'posreachedlabel':posreachedlabel,
                                    'brakelabel':brakelabel, 'errorlabel':errorlabel,
                                    'warninglabel':warninglabel, 'errorcodelabel':errorcodelabel,
                                    'slider_vel': slider_vel }
                                    

        ### Buttons ###
        self.loadbutton = wx.Button(panel, 1, 'Load Pose')
        self.savebutton = wx.Button(panel, 1, 'Save Pose')
        self.ctrbutton = wx.Button(panel, 1, 'Ack All')
        self.refallbutton = wx.Button(panel, 1, 'Ref All')
        self.moveallbutton = wx.Button(panel, 1, 'Move All')
        self.maxcurrentbutton = wx.Button(panel, 1, 'Max Currents')
        self.emergency = wx.Button(panel, 1, 'EMERGENCY STOP')
        self.emergency.SetBackgroundColour("Red")
        
        self.Bind(wx.EVT_SLIDER, self.sliderUpdate)
        basebuttons = wx.GridSizer(2,3)
        basebuttons.Add(self.ctrbutton, 0, wx.EXPAND)
        basebuttons.Add(self.refallbutton, 0, wx.EXPAND)
        basebuttons.Add(self.maxcurrentbutton, 0, wx.EXPAND)
        basebuttons.Add(self.moveallbutton, 0, wx.EXPAND)
        basebuttons.Add(self.loadbutton, 0, wx.EXPAND)
        basebuttons.Add(self.savebutton, 0, wx.EXPAND)
        
        box.Add(basebuttons, 0, wx.EXPAND)
        box.Add(self.emergency, 0, wx.EXPAND)
        
        
        self.Bind(wx.EVT_BUTTON, self.button_event)
        panel.SetSizer(masterbox)
        self.center()
        box.Fit(self)
        masterbox.Add(box,1,wx.EXPAND)
        masterbox.Fit(self)
        self.update_values()
        
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.timer = wx.Timer(self)
        self.timer.Start(100) #10hz
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)  # call the on_timer function
Beispiel #7
0
    def __init__(self, parent, title):
        """
        The application will be made in this function. The style will be adjusted to make it user friendly. Only the
        necessary parameters will be shown in the application. The data, which is used as input data, is obtained by
        tests.
        """

        # Create the main frame
        wx.Frame.__init__(self,
                          parent,
                          title=title,
                          style=wx.DEFAULT_FRAME_STYLE
                          & ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX),
                          size=(1030, 600))
        self.top_panel = wx.Panel(self)
        self.SetBackgroundColour("white")

        # Create the file menu
        file_menu = wx.Menu()
        menu_about = file_menu.Append(wx.ID_ABOUT, "&About",
                                      "Information about this program")
        file_menu.AppendSeparator()
        menu_exit = file_menu.Append(wx.ID_EXIT, "E&xit",
                                     "Terminate the program")

        # Create the menu bar
        menu_bar = wx.MenuBar()
        menu_bar.Append(file_menu, "&File")
        self.SetMenuBar(menu_bar)

        # Creating buttons to reset or Exit the application
        self.exit_button = wx.Button(self.top_panel,
                                     -1,
                                     label='Exit',
                                     pos=(350, 390),
                                     size=(100, 30))
        self.reset_button = wx.Button(self.top_panel,
                                      -1,
                                      label='Reset',
                                      pos=(350, 355),
                                      size=(100, 30))

        # Loading image for the Tacx logo, placement of this photo will also be done right here.
        try:
            base_path = sys._MEIPASS
        except Exception:
            base_path = path.abspath('.')
        image_path = path.join(base_path, 'tacx-logo.png')

        image_file_png = wx.Image(image_path, wx.BITMAP_TYPE_PNG)
        image_file_png.Rescale(image_file_png.GetWidth() * 0.15,
                               image_file_png.GetHeight() * 0.15)
        image_file_png = wx.Bitmap(image_file_png)
        self.image = wx.StaticBitmap(self.top_panel,
                                     -1,
                                     image_file_png,
                                     pos=(335, 167),
                                     size=(image_file_png.GetWidth(),
                                           image_file_png.GetHeight()))

        # Creating panels: Every panel and text, which is shown in the application, is created in this piece of code.
        # Firstly, some font are specified to make the text more dynamic and clean.
        self.font_header = wx.Font(12,
                                   family=wx.FONTFAMILY_DECORATIVE,
                                   style=wx.FONTSTYLE_NORMAL,
                                   weight=wx.FONTWEIGHT_BOLD)
        self.font_header_1 = wx.Font(10,
                                     family=wx.FONTFAMILY_DECORATIVE,
                                     style=wx.FONTSTYLE_NORMAL,
                                     weight=wx.FONTWEIGHT_BOLD)
        self.font_normal = wx.Font(10,
                                   family=wx.FONTFAMILY_DECORATIVE,
                                   style=wx.FONTSTYLE_NORMAL,
                                   weight=wx.FONTWEIGHT_NORMAL)
        self.font_big = wx.Font(12,
                                family=wx.FONTFAMILY_DECORATIVE,
                                style=wx.FONTSTYLE_NORMAL,
                                weight=wx.FONTWEIGHT_NORMAL)
        self.statistics_titles = [
            "Roller diameter", "Contact force between roller and wheel"
        ]

        for i in range(len(self.statistics_titles)):
            self.data_panel = wx.Panel(self.top_panel,
                                       -1,
                                       size=(465, 100),
                                       pos=(10, 10 + (1.2 * i) * 60))
            self.data_panel_header = wx.StaticText(
                self.data_panel, label=self.statistics_titles[i], pos=(4, 2))
            if i == 0:
                self.slider_1 = wx.Slider(self.data_panel,
                                          -1,
                                          30,
                                          20,
                                          70,
                                          pos=(0, 25),
                                          size=(300, -1),
                                          style=wx.SL_HORIZONTAL
                                          | wx.SL_AUTOTICKS)
                self.slider_1.SetTickFreq(10)
                self.panel_output_1 = wx.Panel(self.data_panel,
                                               -1,
                                               style=wx.BORDER_SUNKEN,
                                               size=(40, 27),
                                               pos=(350, 20))
                self.text_1 = wx.StaticText(self.data_panel,
                                            label='mm',
                                            pos=(395, 23))
                self.text_1.SetFont(self.font_big)
                self.data_panel_slider_1 = wx.StaticText(self.panel_output_1,
                                                         label='30',
                                                         pos=(14, 2))
                self.data_panel_slider_1.SetFont(self.font_big)
            if i == 1:
                # TODO: AANPASSEN ALS WE DE ECHTE INDRUKKING WETEN
                self.slider_2 = wx.Slider(self.data_panel,
                                          -1,
                                          3,
                                          1,
                                          7,
                                          pos=(0, 25),
                                          size=(300, -1),
                                          style=wx.SL_HORIZONTAL
                                          | wx.SL_AUTOTICKS)
                self.slider_2.SetTickFreq(1)
                self.panel_output_2 = wx.Panel(self.data_panel,
                                               -1,
                                               style=wx.BORDER_SUNKEN,
                                               size=(40, 27),
                                               pos=(350, 20))
                self.text_1 = wx.StaticText(self.data_panel,
                                            label='mm',
                                            pos=(395, 23))
                self.text_1.SetFont(self.font_big)
                self.data_panel_slider_2 = wx.StaticText(self.panel_output_2,
                                                         label='3',
                                                         pos=(4, 2))
                self.data_panel_slider_2.SetFont(self.font_big)
            self.data_panel_header.SetFont(self.font_header)

        self.output_panel = wx.Panel(self.top_panel,
                                     -1,
                                     style=wx.BORDER_RAISED,
                                     size=(305, 110),
                                     pos=(10, 150))
        self.text = wx.StaticText(
            self.output_panel,
            label='Calculated friction force: \n(bigger = better)',
            pos=(14, 12))
        self.text.SetFont(self.font_header_1)
        self.text = wx.StaticText(
            self.output_panel,
            label='Calculated rolling resistance: \n(smaller = better)',
            pos=(14, 60))
        self.text.SetFont(self.font_header_1)
        self.panel_output_3 = wx.Panel(self.output_panel,
                                       -1,
                                       style=wx.BORDER_SUNKEN,
                                       size=(40, 27),
                                       pos=(230, 17))
        self.data_output_text = wx.StaticText(self.output_panel,
                                              label='N',
                                              pos=(275, 21))
        self.data_output_text.SetFont(self.font_big)
        self.data_panel_friction = wx.StaticText(self.panel_output_3,
                                                 label='30',
                                                 pos=(14, 2))
        self.data_panel_friction.SetFont(self.font_big)

        self.panel_output_4 = wx.Panel(self.output_panel,
                                       -1,
                                       style=wx.BORDER_SUNKEN,
                                       size=(40, 27),
                                       pos=(230, 65))
        self.data_output_text = wx.StaticText(self.output_panel,
                                              label='N',
                                              pos=(275, 69))
        self.data_output_text.SetFont(self.font_big)
        self.data_panel_resistance = wx.StaticText(self.panel_output_4,
                                                   label='30',
                                                   pos=(14, 2))
        self.data_panel_resistance.SetFont(self.font_big)

        # Set start-up message
        welcome_dialog = wx.MessageDialog(
            self.top_panel,
            message=
            "Welcome to the Tacx design tool. \nIf you have read the README.pdf, you're good to go. \nIf you haven't yet, please do.",
            caption="Welcome!")
        welcome_dialog.CenterOnParent()
        if welcome_dialog.ShowModal() == wx.OK:
            welcome_dialog.Destroy()
            return

        # Create status bar
        self.statusbar = self.CreateStatusBar()

        # Create parameter which contains all the tested data. These are the parameters which are fixed and will be
        # used to test the traction and resistance.
        # TODO: ALLES AANPASSEN NAAR RESULTATEN EN DE GEBRUIKTE PARAMETERS ALS DEZE BESCHIKBAAR ZIJN
        self.speed = [5, 10, 20, 30, 40, 50]
        self.diameter = [20, 30, 40, 50, 60, 70]
        self.depth = [1, 2, 3, 4, 5, 6, 7]

        # Traction for each depth at each diameter
        self.traction_dia_20mm = [4, 6, 8, 10, 12, 14, 16]
        self.traction_dia_30mm = [5, 7, 9, 11, 13, 15, 17]
        self.traction_dia_40mm = [6, 8, 10, 12, 14, 16, 18]
        self.traction_dia_50mm = [7, 9, 11, 13, 15, 17, 19]
        self.traction_dia_60mm = [8, 10, 12, 14, 16, 18, 20]
        self.traction_dia_70mm = [9, 11, 13, 15, 17, 19, 21]
        self.traction = [
            self.traction_dia_20mm, self.traction_dia_30mm,
            self.traction_dia_40mm, self.traction_dia_50mm,
            self.traction_dia_60mm, self.traction_dia_70mm
        ]

        # Resistance for each speed at a certain depth and diameter
        self.resistance_dia_20mm_dept_1 = [0, 1, 1, 2, 3, 4]
        self.resistance_dia_20mm_dept_2 = [0, 1, 2, 3, 4, 5]
        self.resistance_dia_20mm_dept_3 = [0, 2, 3, 4, 5, 6]
        self.resistance_dia_20mm_dept_4 = [0, 3, 4, 5, 6, 7]
        self.resistance_dia_20mm_dept_5 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_20mm_dept_6 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_20mm_dept_7 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_20mm = [
            self.resistance_dia_20mm_dept_1, self.resistance_dia_20mm_dept_2,
            self.resistance_dia_20mm_dept_3, self.resistance_dia_20mm_dept_4,
            self.resistance_dia_20mm_dept_5, self.resistance_dia_20mm_dept_6,
            self.resistance_dia_20mm_dept_7
        ]

        self.resistance_dia_30mm_dept_1 = [0, 1, 2, 3, 4, 5]
        self.resistance_dia_30mm_dept_2 = [0, 2, 3, 4, 5, 6]
        self.resistance_dia_30mm_dept_3 = [0, 3, 4, 5, 6, 7]
        self.resistance_dia_30mm_dept_4 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_30mm_dept_5 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_30mm_dept_6 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_30mm_dept_7 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_30mm = [
            self.resistance_dia_30mm_dept_1, self.resistance_dia_30mm_dept_2,
            self.resistance_dia_30mm_dept_3, self.resistance_dia_30mm_dept_4,
            self.resistance_dia_30mm_dept_5, self.resistance_dia_30mm_dept_6,
            self.resistance_dia_30mm_dept_7
        ]

        self.resistance_dia_40mm_dept_1 = [0, 2, 3, 4, 5, 6]
        self.resistance_dia_40mm_dept_2 = [0, 3, 4, 5, 6, 7]
        self.resistance_dia_40mm_dept_3 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_40mm_dept_4 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_40mm_dept_5 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_40mm_dept_6 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_40mm_dept_7 = [0, 8, 9, 10, 11, 12]
        self.resistance_dia_40mm = [
            self.resistance_dia_40mm_dept_1, self.resistance_dia_40mm_dept_2,
            self.resistance_dia_40mm_dept_3, self.resistance_dia_40mm_dept_4,
            self.resistance_dia_40mm_dept_5, self.resistance_dia_40mm_dept_6,
            self.resistance_dia_40mm_dept_7
        ]

        self.resistance_dia_50mmm_dept_1 = [0, 3, 4, 5, 6, 7]
        self.resistance_dia_50mmm_dept_2 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_50mmm_dept_3 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_50mmm_dept_4 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_50mmm_dept_5 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_50mmm_dept_6 = [0, 8, 9, 10, 11, 12]
        self.resistance_dia_50mmm_dept_7 = [0, 9, 10, 11, 12, 13]
        self.resistance_dia_50mm = [
            self.resistance_dia_50mmm_dept_1, self.resistance_dia_50mmm_dept_2,
            self.resistance_dia_50mmm_dept_3, self.resistance_dia_50mmm_dept_4,
            self.resistance_dia_50mmm_dept_5, self.resistance_dia_50mmm_dept_6,
            self.resistance_dia_50mmm_dept_7
        ]

        self.resistance_dia_60mmm_dept_1 = [0, 4, 5, 6, 7, 8]
        self.resistance_dia_60mmm_dept_2 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_60mmm_dept_3 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_60mmm_dept_4 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_60mmm_dept_5 = [0, 8, 9, 10, 11, 12]
        self.resistance_dia_60mmm_dept_6 = [0, 9, 10, 11, 12, 13]
        self.resistance_dia_60mmm_dept_7 = [0, 10, 11, 12, 13, 14]
        self.resistance_dia_60mm = [
            self.resistance_dia_60mmm_dept_1, self.resistance_dia_60mmm_dept_2,
            self.resistance_dia_60mmm_dept_3, self.resistance_dia_60mmm_dept_4,
            self.resistance_dia_60mmm_dept_5, self.resistance_dia_60mmm_dept_6,
            self.resistance_dia_60mmm_dept_7
        ]

        self.resistance_dia_70mmm_dept_1 = [0, 5, 6, 7, 8, 9]
        self.resistance_dia_70mmm_dept_2 = [0, 6, 7, 8, 9, 10]
        self.resistance_dia_70mmm_dept_3 = [0, 7, 8, 9, 10, 11]
        self.resistance_dia_70mmm_dept_4 = [0, 8, 9, 10, 11, 12]
        self.resistance_dia_70mmm_dept_5 = [0, 9, 10, 11, 12, 13]
        self.resistance_dia_70mmm_dept_6 = [0, 10, 11, 12, 13, 14]
        self.resistance_dia_70mmm_dept_7 = [0, 11, 12, 13, 14, 15]
        self.resistance_dia_70mm = [
            self.resistance_dia_70mmm_dept_1, self.resistance_dia_70mmm_dept_2,
            self.resistance_dia_70mmm_dept_3, self.resistance_dia_70mmm_dept_4,
            self.resistance_dia_70mmm_dept_5, self.resistance_dia_70mmm_dept_6,
            self.resistance_dia_70mmm_dept_7
        ]

        self.force = [200, 300, 400, 500, 600, 700, 800]

        # Set events
        self.Bind(wx.EVT_MENU, self.on_about, menu_about)
        self.Bind(wx.EVT_MENU, self.on_exit, menu_exit)
        self.Bind(wx.EVT_SLIDER, self.on_slider_1, self.slider_1)
        self.Bind(wx.EVT_SLIDER, self.on_slider_2, self.slider_2)
        self.exit_button.Bind(wx.EVT_BUTTON, self.on_exit_button)
        self.exit_button.Bind(wx.EVT_ENTER_WINDOW, self.on_exit_widget_enter)
        self.reset_button.Bind(wx.EVT_BUTTON, self.on_reset)
        self.reset_button.Bind(wx.EVT_ENTER_WINDOW, self.on_reset_widget_enter)

        # Create initial plot
        self.figure_panel = wx.Panel(self.top_panel,
                                     -1,
                                     size=(540, 540),
                                     pos=(480, 10))
        self.figure_panel.SetBackgroundColour((255, 255, 255))
        self.figure = wxmplot.PlotPanel(self.figure_panel,
                                        size=(540, 540),
                                        dpi=100,
                                        fontsize=2,
                                        axisbg='#FFFFFF')
        # self.figure.oplot(array(self.testdata[0]), array(self.testdata[1]))

        # Figure cosmetics
        self.figure.set_xlabel("Velocity [km/h]")
        self.figure.set_ylabel("Value")
        # self.figure = Figure()
        # self.plot = self.figure.add_subplot(111)
        # self.canvas = FigureCanvas(self.figure_panel, -1, self.figure)
        # self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        # self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        # self.SetSizer(self.sizer)
        # self.Fit()

        # Some variables needed
        self.value_slider_1 = self.slider_1.GetValue()
        self.value_slider_2 = self.slider_2.GetValue()
        self.interpolation()
Beispiel #8
0
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "SpeedMeter Demo ;-)",
                         wx.DefaultPosition,
                         size=(400,400),
                         style=wx.DEFAULT_FRAME_STYLE |
                         wx.NO_FULL_REPAINT_ON_RESIZE)


        self.SetIcon(GetMondrianIcon())
        self.statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)

        self.statusbar.SetStatusWidths([-2, -1])
        # statusbar fields
        statusbar_fields = [("wxPython SpeedControl Demo, Andrea Gavana @ 25 Sep 2005"),
                            ("Welcome To wxPython!")]
        
        for i in range(len(statusbar_fields)):
            self.statusbar.SetStatusText(statusbar_fields[i], i)
        
        self.SetMenuBar(self.CreateMenuBar())
        
        panel = wx.Panel(self, -1)
        sizer = wx.FlexGridSizer(2, 3, 2, 5)

        # 6 Panels To Hold The SpeedMeters ;-)
        
        panel1 = wx.Panel(panel, -1, style=wx.SUNKEN_BORDER)
        panel2 = wx.Panel(panel, -1, style=wx.RAISED_BORDER)
        panel3 = wx.Panel(panel, -1, style=wx.SUNKEN_BORDER)
        panel4 = wx.Panel(panel, -1, style=wx.RAISED_BORDER)
        panel5 = wx.Panel(panel, -1, style=wx.SUNKEN_BORDER)
        panel6 = wx.Panel(panel, -1, style=wx.RAISED_BORDER)
        
        # First SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_SECTORS: Full Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_MIDDLE_TEXT: We Draw Some Text In The Center Of SpeedMeter
        # SM_DRAW_SECONDARY_TICKS: We Draw Secondary (Intermediate) Ticks Between
        #                          The Main Ticks (Intervals)

        self.SpeedWindow1 = SM.SpeedMeter(panel1,
                                          extrastyle=SM.SM_DRAW_HAND |
                                          SM.SM_DRAW_SECTORS |
                                          SM.SM_DRAW_MIDDLE_TEXT |
                                          SM.SM_DRAW_SECONDARY_TICKS
                                          )

        # Set The Region Of Existence Of SpeedMeter (Always In Radians!!!!)
        self.SpeedWindow1.SetAngleRange(-pi/6, 7*pi/6)

        # Create The Intervals That Will Divide Our SpeedMeter In Sectors        
        intervals = range(0, 201, 20)
        self.SpeedWindow1.SetIntervals(intervals)

        # Assign The Same Colours To All Sectors (We Simulate A Car Control For Speed)
        # Usually This Is Black
        colours = [wx.BLACK]*10
        self.SpeedWindow1.SetIntervalColours(colours)

        # Assign The Ticks: Here They Are Simply The String Equivalent Of The Intervals
        ticks = [str(interval) for interval in intervals]
        self.SpeedWindow1.SetTicks(ticks)
        # Set The Ticks/Tick Markers Colour
        self.SpeedWindow1.SetTicksColour(wx.WHITE)
        # We Want To Draw 5 Secondary Ticks Between The Principal Ticks
        self.SpeedWindow1.SetNumberOfSecondaryTicks(5)

        # Set The Font For The Ticks Markers
        self.SpeedWindow1.SetTicksFont(wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL))
                                       
        # Set The Text In The Center Of SpeedMeter
        self.SpeedWindow1.SetMiddleText("Km/h")
        # Assign The Colour To The Center Text
        self.SpeedWindow1.SetMiddleTextColour(wx.WHITE)
        # Assign A Font To The Center Text
        self.SpeedWindow1.SetMiddleTextFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD))

        # Set The Colour For The Hand Indicator
        self.SpeedWindow1.SetHandColour(wx.Colour(255, 50, 0))

        # Do Not Draw The External (Container) Arc. Drawing The External Arc May
        # Sometimes Create Uglier Controls. Try To Comment This Line And See It
        # For Yourself!
        self.SpeedWindow1.DrawExternalArc(False)        

        # Set The Current Value For The SpeedMeter
        self.SpeedWindow1.SetSpeedValue(44)

        
        # Second SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_SECTORS: Full Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_MIDDLE_TEXT: We Draw Some Text In The Center Of SpeedMeter
        # SM_DRAW_SECONDARY_TICKS: We Draw Secondary (Intermediate) Ticks Between
        #                          The Main Ticks (Intervals)
        # SM_DRAW_PARTIAL_FILLER: The Region Passed By The Hand Indicator Is Highlighted
        #                         With A Different Filling Colour
        # SM_DRAW_SHADOW: A Shadow For The Hand Indicator Is Drawn
        
        self.SpeedWindow2 = SM.SpeedMeter(panel2,
                                          extrastyle=SM.SM_DRAW_HAND |
                                          SM.SM_DRAW_SECTORS |
                                          SM.SM_DRAW_MIDDLE_TEXT |
                                          SM.SM_DRAW_SECONDARY_TICKS |
                                          SM.SM_DRAW_PARTIAL_FILLER |
                                          SM.SM_DRAW_SHADOW
                                          )

        # We Want To Simulate A Clock. Somewhat Tricky, But Did The Job
        self.SpeedWindow2.SetAngleRange(pi/2, 5*pi/2)

        intervals = range(0, 13)
        self.SpeedWindow2.SetIntervals(intervals)

        colours = [wx.SystemSettings_GetColour(0)]*12
        self.SpeedWindow2.SetIntervalColours(colours)

        ticks = [str(interval) for interval in intervals]
        ticks[-1] = ""
        ticks[0] = "12"
        self.SpeedWindow2.SetTicks(ticks)
        self.SpeedWindow2.SetTicksColour(wx.BLUE)
        self.SpeedWindow2.SetTicksFont(wx.Font(11, wx.SCRIPT, wx.NORMAL, wx.BOLD, True))
        self.SpeedWindow2.SetNumberOfSecondaryTicks(4)

        # Set The Colour For The External Arc        
        self.SpeedWindow2.SetArcColour(wx.BLUE)

        self.SpeedWindow2.SetHandColour(wx.BLACK)

        self.SpeedWindow2.SetMiddleText("0 s")
        self.SpeedWindow2.SetMiddleTextColour(wx.RED)

        # We Set The Background Colour Of The SpeedMeter OutSide The Control
        self.SpeedWindow2.SetSpeedBackground(wx.WHITE)

        # Set The Colour For The Shadow
        self.SpeedWindow2.SetShadowColour(wx.Colour(128, 128, 128))        

        self.SpeedWindow2.SetSpeedValue(0.0)


        # Third SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_PARTIAL_SECTORS: Partial Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_MIDDLE_ICON: We Draw An Icon In The Center Of SpeedMeter
        
        self.SpeedWindow3 = SM.SpeedMeter(panel3,
                                          extrastyle=SM.SM_DRAW_HAND |
                                          SM.SM_DRAW_PARTIAL_SECTORS |
                                          SM.SM_DRAW_MIDDLE_ICON
                                          )

        # We Want To Simulate A Car Gas-Control
        self.SpeedWindow3.SetAngleRange(-pi/3, pi/3)

        intervals = range(0, 5)
        self.SpeedWindow3.SetIntervals(intervals)

        colours = [wx.BLACK]*3
        colours.append(wx.RED)
        self.SpeedWindow3.SetIntervalColours(colours)

        ticks = ["F", "", "", "", "E"]
        self.SpeedWindow3.SetTicks(ticks)
        self.SpeedWindow3.SetTicksColour(wx.WHITE)
        
        self.SpeedWindow3.SetHandColour(wx.Colour(255, 255, 0))

        # Define The Icon We Want
        icon = wx.Icon("fuel.ico", wx.BITMAP_TYPE_ICO)
        icon.SetWidth(24)
        icon.SetHeight(24)

        # Draw The Icon In The Center Of SpeedMeter        
        self.SpeedWindow3.SetMiddleIcon(icon)        

        self.SpeedWindow3.SetSpeedBackground(wx.BLACK)        

        self.SpeedWindow3.SetArcColour(wx.WHITE)
        
        self.SpeedWindow3.SetSpeedValue(0.7)

                
        # Fourth SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_SECTORS: Full Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_SHADOW: A Shadow For The Hand Indicator Is Drawn
        # SM_DRAW_MIDDLE_ICON: We Draw An Icon In The Center Of SpeedMeter
        #
        # NOTE: We Use The Mouse Style mousestyle=SM_MOUSE_TRACK. In This Way, Mouse
        # Events Are Catched (Mainly Left Clicks/Drags) And You Can Change The Speed
        # Value Using The Mouse
        
        self.SpeedWindow4 = SM.SpeedMeter(panel4,
                                          extrastyle=SM.SM_DRAW_HAND |
                                          SM.SM_DRAW_SECTORS |
                                          SM.SM_DRAW_SHADOW |
                                          SM.SM_DRAW_MIDDLE_ICON,
                                          mousestyle=SM.SM_MOUSE_TRACK
                                          )

        # We Want To Simulate Some Kind Of Thermometer (In Celsius Degrees!!!)
        self.SpeedWindow4.SetAngleRange(pi, 2*pi)

        intervals = range(35, 44)
        self.SpeedWindow4.SetIntervals(intervals)

        colours = [wx.BLUE]*5
        colours.extend([wx.Colour(255, 255, 0)]*2)
        colours.append(wx.RED)
        self.SpeedWindow4.SetIntervalColours(colours)

        ticks = [str(interval) + "Go" for interval in intervals]
        self.SpeedWindow4.SetTicks(ticks)
        self.SpeedWindow4.SetTicksColour(wx.BLACK)
        self.SpeedWindow4.SetTicksFont(wx.Font(7, wx.TELETYPE, wx.NORMAL, wx.BOLD))
        
        self.SpeedWindow4.SetHandColour(wx.Colour(0, 0, 255))

        self.SpeedWindow4.SetSpeedBackground(wx.SystemSettings_GetColour(0))        

        self.SpeedWindow4.DrawExternalArc(False)

        self.SpeedWindow4.SetHandColour(wx.GREEN)
        self.SpeedWindow4.SetShadowColour(wx.Colour(50, 50, 50))  

        # We Want A Simple Arrow As Indicator, Not The More Scenic Hand ;-)
        self.SpeedWindow4.SetHandStyle("Arrow")

        # Define The Icon We Want
        icon = wx.Icon("temp.ico", wx.BITMAP_TYPE_ICO)
        icon.SetWidth(16)
        icon.SetHeight(16)

        # Draw The Icon In The Center Of SpeedMeter        
        self.SpeedWindow4.SetMiddleIcon(icon)        

        # Quite An High Fever!!!        
        self.SpeedWindow4.SetSpeedValue(41.4)


        # Fifth SpeedMeter: We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_PARTIAL_SECTORS: Partial Sectors Will Be Drawn, To Indicate Different Intervals
        # SM_DRAW_SECONDARY_TICKS: We Draw Secondary (Intermediate) Ticks Between
        #                          The Main Ticks (Intervals)
        # SM_DRAW_MIDDLE_TEXT: We Draw Some Text In The Center Of SpeedMeter
        # SM_ROTATE_TEXT: The Ticks Texts Are Rotated Accordingly To Their Angle
        
        self.SpeedWindow5 = SM.SpeedMeter(panel5,
                                          extrastyle=SM.SM_DRAW_HAND |
                                          SM.SM_DRAW_PARTIAL_SECTORS |
                                          SM.SM_DRAW_SECONDARY_TICKS |
                                          SM.SM_DRAW_MIDDLE_TEXT |
                                          SM.SM_ROTATE_TEXT
                                          )

        # We Want To Simulate The Round Per Meter Control In A Car
        self.SpeedWindow5.SetAngleRange(-pi/6, 7*pi/6)

        intervals = range(0, 9)
        self.SpeedWindow5.SetIntervals(intervals)

        colours = [wx.BLACK]*6
        colours.append(wx.Colour(255, 255, 0))
        colours.append(wx.RED)
        self.SpeedWindow5.SetIntervalColours(colours)

        ticks = [str(interval) for interval in intervals]
        self.SpeedWindow5.SetTicks(ticks)
        self.SpeedWindow5.SetTicksColour(wx.WHITE)
        self.SpeedWindow5.SetTicksFont(wx.Font(7, wx.SWISS, wx.NORMAL, wx.NORMAL))

        self.SpeedWindow5.SetHandColour(wx.Colour(255, 50, 0))

        self.SpeedWindow5.SetSpeedBackground(wx.SystemSettings_GetColour(0))        

        self.SpeedWindow5.DrawExternalArc(False)

        self.SpeedWindow5.SetShadowColour(wx.Colour(50, 50, 50))

        self.SpeedWindow5.SetMiddleText("rpm")
        self.SpeedWindow5.SetMiddleTextColour(wx.WHITE)
        self.SpeedWindow5.SetMiddleTextFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD))
        self.SpeedWindow5.SetSpeedBackground(wx.Colour(160, 160, 160)) 
        
        self.SpeedWindow5.SetSpeedValue(5.6)
        

        # Sixth SpeedMeter: That Is Complete And Complex Example.
        #                   We Use The Following Styles:
        #
        # SM_DRAW_HAND: We Want To Draw The Hand (Arrow) Indicator
        # SM_DRAW_PARTIAL_FILLER: The Region Passed By The Hand Indicator Is Highlighted
        #                         With A Different Filling Colour
        # SM_DRAW_MIDDLE_ICON: We Draw An Icon In The Center Of SpeedMeter
        # SM_DRAW_GRADIENT: A Circular Colour Gradient Is Drawn Inside The SpeedMeter, To
        #                   Give Some Kind Of Scenic Effect
        # SM_DRAW_FANCY_TICKS: We Use wx.lib.
        # SM_DRAW_SHADOW: A Shadow For The Hand Indicator Is Drawn
        
        self.SpeedWindow6 = SM.SpeedMeter(panel6,
                                          extrastyle=SM.SM_DRAW_HAND |
                                          SM.SM_DRAW_PARTIAL_FILLER  |
                                          SM.SM_DRAW_MIDDLE_ICON |
                                          SM.SM_DRAW_GRADIENT |
                                          SM.SM_DRAW_FANCY_TICKS |
                                          SM.SM_DRAW_SHADOW
                                          )

        self.SpeedWindow6.SetAngleRange(0, 4*pi/3)

        intervals = [0, pi/6, sqrt(pi), 2./3.*pi, pi**2/4, pi, 7./6.*pi, 4*pi/3]
        self.SpeedWindow6.SetIntervals(intervals)

        # If You Use The Style SM_DRAW_FANCY_TICKS, Refer To wx.lib.fancytext To Create
        # Correct XML Strings To Put Here
        ticks = ["0", "<pi/>/6", "sq(<pi/>)", "2<pi/>/3", "<pi/><sup>2</sup>/4", "<pi/>", "7<pi/>/6", "4<pi/>/3"]
        self.SpeedWindow6.SetTicks(ticks)
        self.SpeedWindow6.SetTicksColour(wx.Colour(0, 90, 0))
        self.SpeedWindow6.SetTicksFont(wx.Font(6, wx.ROMAN, wx.NORMAL, wx.BOLD))

        self.SpeedWindow6.SetHandColour(wx.Colour(60, 60, 60))

        self.SpeedWindow6.DrawExternalArc(False)

        self.SpeedWindow6.SetFillerColour(wx.Colour(145, 220, 200))        

        self.SpeedWindow6.SetShadowColour(wx.BLACK)

        self.SpeedWindow6.SetDirection("Reverse")        

        self.SpeedWindow6.SetSpeedBackground(wx.SystemSettings_GetColour(0))

        # Set The First Gradient Colour, Which Is The Colour Near The External Arc
        self.SpeedWindow6.SetFirstGradientColour(wx.RED)
        # Set The Second Gradient Colour, Which Is The Colour Near The Center Of The SpeedMeter
        self.SpeedWindow6.SetSecondGradientColour(wx.WHITE)

        icon = wx.Icon("pi.ico", wx.BITMAP_TYPE_ICO)
        icon.SetHeight(12)
        icon.SetWidth(12)
        self.SpeedWindow6.SetMiddleIcon(icon)            
        
        self.SpeedWindow6.SetSpeedValue(pi/3)


        # End Of SpeedMeter Controls Construction. Add Some Functionality

        self.helpbuttons = []
        self.isalive = 0
        
        icononselected = wx.Icon("help.ico", wx.BITMAP_TYPE_ICO, 16, 16)
        icoselected = wx.Icon("pressed.ico", wx.BITMAP_TYPE_ICO, 16, 16)

        bmp1 = wx.EmptyBitmap(16,16)
        bmp1.CopyFromIcon(icononselected)
        bmp2 = wx.EmptyBitmap(16,16)
        bmp2.CopyFromIcon(icoselected)

        for ind in range(6):
            helpbtn = wx.lib.buttons.GenBitmapToggleButton(eval("panel" + str(ind+1)), -1, None,
                                                     size=(20,20), style=wx.NO_BORDER)

            helpbtn.SetBitmapLabel(bmp1)
            helpbtn.SetBitmapSelected(bmp2)
            helpbtn.SetUseFocusIndicator(False)
            helpbtn.Bind(wx.EVT_ENTER_WINDOW, self.EnterWindow)
            helpbtn.Bind(wx.EVT_LEAVE_WINDOW, self.ExitWindow)
            self.helpbuttons.append(helpbtn)

        

        # These Are Cosmetics For The First SpeedMeter Control
        bsizer1 = wx.BoxSizer(wx.VERTICAL)

        hsizer1 = wx.BoxSizer(wx.HORIZONTAL)        
        slider = wx.Slider(panel1, -1, 44, 0, 200, size=(-1, 40), 
                           style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS )
        slider.SetTickFreq(5, 1)
        slider.Bind(wx.EVT_SCROLL, self.OnSliderScroll)
        slider.SetToolTip(wx.ToolTip("Drag The Slider To Change The Speed!"))

        hsizer1.Add(slider, 1, wx.EXPAND)
        hsizer1.Add(self.helpbuttons[0], 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, 5)

        bsizer1.Add(self.SpeedWindow1, 1, wx.EXPAND)
        bsizer1.Add(hsizer1, 0, wx.EXPAND)
        panel1.SetSizer(bsizer1)


        # These Are Cosmetics For The Second SpeedMeter Control
        
        # Create The Timer For The Clock
        self.timer = wx.PyTimer(self.ClockTimer)
        self.currvalue = 0

        bsizer2 = wx.BoxSizer(wx.VERTICAL)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL) 
        stattext2 = wx.StaticText(panel2, -1, "A Simple Clock", style=wx.ALIGN_CENTER)

        button2 = wx.Button(panel2, -1, "Stop")
        self.stopped = 0
        button2.Bind(wx.EVT_BUTTON, self.OnStopClock)
        button2.SetToolTip(wx.ToolTip("Click To Stop/Resume The Clock"))

        hsizer2.Add(button2, 0, wx.LEFT, 5)
        hsizer2.Add(stattext2, 1, wx.EXPAND)
        hsizer2.Add(self.helpbuttons[1], 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, 5)
        
        bsizer2.Add(self.SpeedWindow2, 1, wx.EXPAND)        
        bsizer2.Add(hsizer2, 0, wx.EXPAND)        
        panel2.SetSizer(bsizer2)

        
        # These Are Cosmetics For The Third SpeedMeter Control
        self.timer3 = wx.PyTimer(self.OilTimer)

        bsizer3 = wx.BoxSizer(wx.VERTICAL)
        
        hsizer3 = wx.BoxSizer(wx.HORIZONTAL)
        sc = wx.SpinCtrl(panel3, -1, size=(60,20))
        sc.SetRange(1, 250)
        sc.SetValue(50)

        self.spinctrl = sc
        
        strs = "Change The Speed And See How Much Fuel You Loose"
        self.spinctrl.SetToolTip(wx.ToolTip(strs))
        
        button3 = wx.Button(panel3, -1, "Refill!", size=(60,20))
        button3.SetToolTip(wx.ToolTip("Click Here To Refill!"))
        button3.Bind(wx.EVT_BUTTON, self.OnRefill)

        hsizer3.Add(self.spinctrl, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer3.Add(button3, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer3.Add((1,0), 2, wx.EXPAND)
        hsizer3.Add(self.helpbuttons[2], 0, wx.ALIGN_CENTER | wx.RIGHT, 5)

        bsizer3.Add(self.SpeedWindow3, 1, wx.EXPAND)
        bsizer3.Add(hsizer3, 0, wx.EXPAND)
        panel3.SetSizer(bsizer3)


        # These Are Cosmetics For The Fourth SpeedMeter Control
        bsizer4 = wx.BoxSizer(wx.VERTICAL)

        hsizer4 = wx.BoxSizer(wx.HORIZONTAL)
        stattext4 = wx.StaticText(panel4, -1, "Use The Mouse ;-)")

        hsizer4.Add(stattext4, 1, wx.EXPAND | wx.LEFT, 5)
        hsizer4.Add(self.helpbuttons[3], 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, 5)
        
        bsizer4.Add(self.SpeedWindow4, 1, wx.EXPAND)
        bsizer4.Add(hsizer4, 0, wx.EXPAND)
        panel4.SetSizer(bsizer4)


        # These Are Cosmetics For The Fifth SpeedMeter Control
        bsizer5 = wx.BoxSizer(wx.VERTICAL)

        hsizer5 = wx.BoxSizer(wx.HORIZONTAL)
        
        button5 = wx.Button(panel5, -1, "Simulate")
        button5.SetToolTip(wx.ToolTip("Start A Car Acceleration Simulation"))
        button5.Bind(wx.EVT_BUTTON, self.OnSimulate)

        hsizer5.Add(button5, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer5.Add((1,0), 1, wx.EXPAND)
        hsizer5.Add(self.helpbuttons[4], 0, wx.ALIGN_CENTER | wx.RIGHT, 5)
        
        bsizer5.Add(self.SpeedWindow5, 1, wx.EXPAND)
        bsizer5.Add(hsizer5, 0, wx.EXPAND)
        panel5.SetSizer(bsizer5)


        # These Are Cosmetics For The Sixth SpeedMeter Control
        bsizer6 = wx.BoxSizer(wx.VERTICAL)
        hsizer6 = wx.BoxSizer(wx.HORIZONTAL)
        
        txtctrl6 = wx.TextCtrl(panel6, -1, "60", size=(60, 20))
        txtctrl6.SetToolTip(wx.ToolTip("Insert An Angle In DEGREES"))

        self.txtctrl = txtctrl6        
        
        button6 = wx.Button(panel6, -1, "Go!")
        button6.SetToolTip(wx.ToolTip("Calculate The Equivalent In Radians And Display It"))

        hsizer6.Add(txtctrl6, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer6.Add(button6, 0, wx.EXPAND | wx.LEFT, 5)
        hsizer6.Add((1,0), 1, wx.EXPAND)
        hsizer6.Add(self.helpbuttons[5], 0, wx.ALIGN_CENTER | wx.RIGHT, 5)
        
        button6.Bind(wx.EVT_BUTTON, self.OnCalculate)
        bsizer6.Add(self.SpeedWindow6, 1, wx.EXPAND)
        bsizer6.Add(hsizer6, 0, wx.EXPAND)
        panel6.SetSizer(bsizer6)
        
        bsizer1.Layout()
        bsizer2.Layout()
        bsizer3.Layout()
        bsizer4.Layout()
        bsizer5.Layout()
        bsizer6.Layout()
        
        sizer.Add(panel1, 1, wx.EXPAND)
        sizer.Add(panel2, 1, wx.EXPAND)
        sizer.Add(panel3, 1, wx.EXPAND)
        
        sizer.Add(panel4, 1, wx.EXPAND)
        sizer.Add(panel5, 1, wx.EXPAND)
        sizer.Add(panel6, 1, wx.EXPAND)

        sizer.AddGrowableRow(0)
        sizer.AddGrowableRow(1)
        
        sizer.AddGrowableCol(0)
        sizer.AddGrowableCol(1)
        sizer.AddGrowableCol(2)
        
        panel.SetSizer(sizer)
        sizer.Layout()

        self.timer.Start(1000)
        self.timer3.Start(500)
        
        self.Bind(wx.EVT_CLOSE, self.OnClose)
Beispiel #9
0
    def __init__(self, parent, log):
        self.log = log
        wx.Panel.__init__(self, parent, -1,
                          style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN)

        # Create some controls
        try:
            backend = ""
            if 'wxMSW' in wx.PlatformInfo:
                # the default backend doesn't always send the EVT_MEDIA_LOADED
                # event which we depend upon, so use a different backend by
                # default for this demo.
                backend = wx.media.MEDIABACKEND_QUICKTIME
                
            self.mc = wx.media.PreMediaCtrl()
            ok = self.mc.Create(self, style=wx.SIMPLE_BORDER,
                                szBackend=backend)
            if not ok:
                raise NotImplementedError
        except NotImplementedError:
            self.Destroy()
            raise

        self.Bind(wx.media.EVT_MEDIA_LOADED, self.OnMediaLoaded)

        btn1 = wx.Button(self, -1, "Load File")
        self.Bind(wx.EVT_BUTTON, self.OnLoadFile, btn1)
        
        btn2 = wx.Button(self, -1, "Play")
        self.Bind(wx.EVT_BUTTON, self.OnPlay, btn2)
        self.playBtn = btn2
        
        btn3 = wx.Button(self, -1, "Pause")
        self.Bind(wx.EVT_BUTTON, self.OnPause, btn3)
        
        btn4 = wx.Button(self, -1, "Stop")
        self.Bind(wx.EVT_BUTTON, self.OnStop, btn4)

        slider = wx.Slider(self, -1, 0, 0, 10)
        self.slider = slider
        slider.SetMinSize((150, -1))
        self.Bind(wx.EVT_SLIDER, self.OnSeek, slider)

        self.st_size = StaticText(self, -1, size=(100,-1))
        self.st_len  = StaticText(self, -1, size=(100,-1))
        self.st_pos  = StaticText(self, -1, size=(100,-1))
        
        
        # setup the layout
        sizer = wx.GridBagSizer(5,5)
        sizer.Add(self.mc, (1,1), span=(5,1))#, flag=wx.EXPAND)
        sizer.Add(btn1, (1,3))
        sizer.Add(btn2, (2,3))
        sizer.Add(btn3, (3,3))
        sizer.Add(btn4, (4,3))
        sizer.Add(slider, (6,1), flag=wx.EXPAND)
        sizer.Add(self.st_size, (1, 5))
        sizer.Add(self.st_len,  (2, 5))
        sizer.Add(self.st_pos,  (3, 5))
        self.SetSizer(sizer)

        #self.DoLoadFile(os.path.abspath("data/testmovie.mpg"))
        wx.CallAfter(self.DoLoadFile, os.path.abspath("data/testmovie.mpg"))

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.timer.Start(100)
    def __init__(self, *args, **kwds):
        # begin wxGlade: All_Widgets_Frame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)

        # Menu Bar
        self.All_Widgets_menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(wx.ID_OPEN, _("&Open"),
                                _("Open an existing document"), wx.ITEM_NORMAL)
        wxglade_tmp_menu.Append(wx.ID_CLOSE, _("&Close file"),
                                _("Close current document"), wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendSeparator()
        wxglade_tmp_menu.Append(wx.ID_EXIT, _("E&xit"), _("Finish program"),
                                wx.ITEM_NORMAL)
        self.All_Widgets_menubar.Append(wxglade_tmp_menu, _("&File"))
        wxglade_tmp_menu = wx.Menu()
        self.mn_Unix = wx.MenuItem(wxglade_tmp_menu, wx.ID_ANY, _("Unix"),
                                   _("Use Unix line endings"), wx.ITEM_RADIO)
        wxglade_tmp_menu.AppendItem(self.mn_Unix)
        self.mn_Windows = wx.MenuItem(wxglade_tmp_menu, wx.ID_ANY,
                                      _("Windows"),
                                      _("Use Windows line endings"),
                                      wx.ITEM_RADIO)
        wxglade_tmp_menu.AppendItem(self.mn_Windows)
        wxglade_tmp_menu.AppendSeparator()
        self.mn_RemoveTabs = wx.MenuItem(wxglade_tmp_menu, wx.ID_ANY,
                                         _("Remove Tabs"),
                                         _("Remove all leading tabs"),
                                         wx.ITEM_CHECK)
        wxglade_tmp_menu.AppendItem(self.mn_RemoveTabs)
        self.All_Widgets_menubar.Append(wxglade_tmp_menu, _("&Edit"))
        wxglade_tmp_menu = wx.Menu()
        wxglade_tmp_menu.Append(wx.ID_HELP, _("Manual"),
                                _("Show the application manual"),
                                wx.ITEM_NORMAL)
        wxglade_tmp_menu.AppendSeparator()
        wxglade_tmp_menu.Append(wx.ID_ABOUT, _("About"),
                                _("Show the About dialog"), wx.ITEM_NORMAL)
        self.All_Widgets_menubar.Append(wxglade_tmp_menu, _("&Help"))
        self.SetMenuBar(self.All_Widgets_menubar)
        # Menu Bar end
        self.All_Widgets_statusbar = self.CreateStatusBar(1, wx.ST_SIZEGRIP)

        # Tool Bar
        self.All_Widgets_toolbar = wx.ToolBar(self, -1)
        self.SetToolBar(self.All_Widgets_toolbar)
        self.All_Widgets_toolbar.AddLabelTool(
            wx.ID_UP, _("UpDown"),
            wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_OTHER, (32, 32)),
            wx.ArtProvider.GetBitmap(wx.ART_GO_DOWN, wx.ART_OTHER, (32, 32)),
            wx.ITEM_CHECK, _("Up or Down"), _("Up or Down"))
        self.All_Widgets_toolbar.AddLabelTool(wx.ID_OPEN, _("Open"),
                                              wx.EmptyBitmap(32, 32),
                                              wx.NullBitmap, wx.ITEM_NORMAL,
                                              _("Open a new file"),
                                              _("Open a new file"))
        # Tool Bar end
        self.notebook_1 = wx.Notebook(self, wx.ID_ANY, style=wx.NB_BOTTOM)
        self.notebook_1_wxBitmapButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.bitmap_button_icon1 = wx.BitmapButton(
            self.notebook_1_wxBitmapButton, wx.ID_ANY,
            wx.Bitmap("icon.xpm", wx.BITMAP_TYPE_ANY))
        self.bitmap_button_empty1 = wx.BitmapButton(
            self.notebook_1_wxBitmapButton, wx.ID_ANY, wx.EmptyBitmap(10, 10))
        self.bitmap_button_icon2 = wx.BitmapButton(
            self.notebook_1_wxBitmapButton,
            wx.ID_ANY,
            wx.Bitmap("icon.xpm", wx.BITMAP_TYPE_ANY),
            style=wx.BORDER_NONE | wx.BU_BOTTOM)
        self.bitmap_button_art = wx.BitmapButton(
            self.notebook_1_wxBitmapButton,
            wx.ID_ANY,
            wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_OTHER, (32, 32)),
            style=wx.BORDER_NONE | wx.BU_BOTTOM)
        self.notebook_1_wxButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.button_3 = wx.Button(self.notebook_1_wxButton, wx.ID_BOLD, "")
        self.notebook_1_wxCalendarCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.calendar_ctrl_1 = wx.calendar.CalendarCtrl(
            self.notebook_1_wxCalendarCtrl,
            wx.ID_ANY,
            style=wx.calendar.CAL_MONDAY_FIRST
            | wx.calendar.CAL_SEQUENTIAL_MONTH_SELECTION
            | wx.calendar.CAL_SHOW_SURROUNDING_WEEKS)
        self.notebook_1_wxCheckBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.checkbox_1 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY,
                                      _("one (unchecked)"))
        self.checkbox_2 = wx.CheckBox(self.notebook_1_wxCheckBox, wx.ID_ANY,
                                      _("two (checked)"))
        self.checkbox_3 = wx.CheckBox(self.notebook_1_wxCheckBox,
                                      wx.ID_ANY,
                                      _("three"),
                                      style=wx.CHK_2STATE)
        self.checkbox_4 = wx.CheckBox(self.notebook_1_wxCheckBox,
                                      wx.ID_ANY,
                                      _("four (unchecked)"),
                                      style=wx.CHK_3STATE)
        self.checkbox_5 = wx.CheckBox(self.notebook_1_wxCheckBox,
                                      wx.ID_ANY,
                                      _("five (checked)"),
                                      style=wx.CHK_3STATE
                                      | wx.CHK_ALLOW_3RD_STATE_FOR_USER)
        self.checkbox_6 = wx.CheckBox(self.notebook_1_wxCheckBox,
                                      wx.ID_ANY,
                                      _("six (undetermined)"),
                                      style=wx.CHK_3STATE
                                      | wx.CHK_ALLOW_3RD_STATE_FOR_USER)
        self.notebook_1_wxCheckListBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.check_list_box_1 = wx.CheckListBox(
            self.notebook_1_wxCheckListBox,
            wx.ID_ANY,
            choices=[_("one"), _("two"),
                     _("three"), _("four")])
        self.notebook_1_wxChoice = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.choice_empty = wx.Choice(self.notebook_1_wxChoice,
                                      wx.ID_ANY,
                                      choices=[])
        self.choice_filled = wx.Choice(
            self.notebook_1_wxChoice,
            wx.ID_ANY,
            choices=[_("Item 1"), _("Item 2 (pre-selected)")])
        self.notebook_1_wxComboBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.combo_box_empty = wx.ComboBox(self.notebook_1_wxComboBox,
                                           wx.ID_ANY,
                                           choices=[],
                                           style=wx.CB_DROPDOWN)
        self.combo_box_filled = wx.ComboBox(
            self.notebook_1_wxComboBox,
            wx.ID_ANY,
            choices=[_("Item 1 (pre-selected)"),
                     _("Item 2")],
            style=wx.CB_DROPDOWN)
        self.notebook_1_wxDatePickerCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.datepicker_ctrl_1 = wx.DatePickerCtrl(
            self.notebook_1_wxDatePickerCtrl,
            wx.ID_ANY,
            style=wx.DP_SHOWCENTURY)
        self.notebook_1_wxGauge = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.gauge_1 = wx.Gauge(self.notebook_1_wxGauge, wx.ID_ANY, 20)
        self.notebook_1_wxGrid = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.grid_1 = wx.grid.Grid(self.notebook_1_wxGrid,
                                   wx.ID_ANY,
                                   size=(1, 1))
        self.notebook_1_wxHyperlinkCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.hyperlink_1 = wx.HyperlinkCtrl(self.notebook_1_wxHyperlinkCtrl,
                                            wx.ID_ANY, _("Homepage wxGlade"),
                                            _("http://wxglade.sf.net"))
        self.notebook_1_wxListBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.list_box_empty = wx.ListBox(self.notebook_1_wxListBox,
                                         wx.ID_ANY,
                                         choices=[])
        self.list_box_filled = wx.ListBox(
            self.notebook_1_wxListBox,
            wx.ID_ANY,
            choices=[_("Item 1"), _("Item 2 (pre-selected)")],
            style=wx.LB_MULTIPLE | wx.LB_SORT)
        self.notebook_1_wxListCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.list_ctrl_1 = wx.ListCtrl(self.notebook_1_wxListCtrl,
                                       wx.ID_ANY,
                                       style=wx.BORDER_SUNKEN | wx.LC_REPORT)
        self.notebook_1_wxRadioBox = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.radio_box_empty1 = wx.RadioBox(self.notebook_1_wxRadioBox,
                                            wx.ID_ANY,
                                            _("radio_box_empty1"),
                                            choices=[""],
                                            majorDimension=1,
                                            style=wx.RA_SPECIFY_ROWS)
        self.radio_box_filled1 = wx.RadioBox(self.notebook_1_wxRadioBox,
                                             wx.ID_ANY,
                                             _("radio_box_filled1"),
                                             choices=[
                                                 _("choice 1"),
                                                 _("choice 2 (pre-selected)"),
                                                 _("choice 3")
                                             ],
                                             majorDimension=0,
                                             style=wx.RA_SPECIFY_ROWS)
        self.radio_box_empty2 = wx.RadioBox(self.notebook_1_wxRadioBox,
                                            wx.ID_ANY,
                                            _("radio_box_empty2"),
                                            choices=[""],
                                            majorDimension=1,
                                            style=wx.RA_SPECIFY_COLS)
        self.radio_box_filled2 = wx.RadioBox(
            self.notebook_1_wxRadioBox,
            wx.ID_ANY,
            _("radio_box_filled2"),
            choices=[_("choice 1"),
                     _("choice 2 (pre-selected)")],
            majorDimension=0,
            style=wx.RA_SPECIFY_COLS)
        self.notebook_1_wxRadioButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.radio_btn_1 = wx.RadioButton(self.notebook_1_wxRadioButton,
                                          wx.ID_ANY,
                                          _("Alice"),
                                          style=wx.RB_GROUP)
        self.text_ctrl_1 = wx.TextCtrl(self.notebook_1_wxRadioButton,
                                       wx.ID_ANY, "")
        self.radio_btn_2 = wx.RadioButton(self.notebook_1_wxRadioButton,
                                          wx.ID_ANY, _("Bob"))
        self.text_ctrl_2 = wx.TextCtrl(self.notebook_1_wxRadioButton,
                                       wx.ID_ANY, "")
        self.radio_btn_3 = wx.RadioButton(self.notebook_1_wxRadioButton,
                                          wx.ID_ANY, _("Malroy"))
        self.text_ctrl_3 = wx.TextCtrl(self.notebook_1_wxRadioButton,
                                       wx.ID_ANY, "")
        self.notebook_1_wxSlider = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.slider_1 = wx.Slider(self.notebook_1_wxSlider, wx.ID_ANY, 5, 0,
                                  10)
        self.notebook_1_wxSpinButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.tc_spin_button = wx.TextCtrl(self.notebook_1_wxSpinButton,
                                          wx.ID_ANY,
                                          _("1"),
                                          style=wx.TE_RIGHT)
        self.spin_button = wx.SpinButton(self.notebook_1_wxSpinButton,
                                         wx.ID_ANY,
                                         style=wx.SP_VERTICAL)
        self.notebook_1_wxSpinCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.spin_ctrl_1 = wx.SpinCtrl(self.notebook_1_wxSpinCtrl,
                                       wx.ID_ANY,
                                       "4",
                                       min=0,
                                       max=100,
                                       style=wx.SP_ARROW_KEYS | wx.TE_RIGHT)
        self.notebook_1_wxSplitterWindow_horizontal = wx.ScrolledWindow(
            self.notebook_1, wx.ID_ANY, style=wx.TAB_TRAVERSAL)
        self.splitter_1 = wx.SplitterWindow(
            self.notebook_1_wxSplitterWindow_horizontal, wx.ID_ANY)
        self.splitter_1_pane_1 = wx.Panel(self.splitter_1, wx.ID_ANY)
        self.label_top_pane = wx.StaticText(self.splitter_1_pane_1, wx.ID_ANY,
                                            _("top pane"))
        self.splitter_1_pane_2 = wx.Panel(self.splitter_1, wx.ID_ANY)
        self.label_buttom_pane = wx.StaticText(self.splitter_1_pane_2,
                                               wx.ID_ANY, _("bottom pane"))
        self.notebook_1_wxSplitterWindow_vertical = wx.ScrolledWindow(
            self.notebook_1, wx.ID_ANY, style=wx.TAB_TRAVERSAL)
        self.splitter_2 = wx.SplitterWindow(
            self.notebook_1_wxSplitterWindow_vertical, wx.ID_ANY)
        self.splitter_2_pane_1 = wx.Panel(self.splitter_2, wx.ID_ANY)
        self.label_left_pane = wx.StaticText(self.splitter_2_pane_1, wx.ID_ANY,
                                             _("left pane"))
        self.splitter_2_pane_2 = wx.Panel(self.splitter_2, wx.ID_ANY)
        self.label_right_pane = wx.StaticText(self.splitter_2_pane_2,
                                              wx.ID_ANY, _("right pane"))
        self.notebook_1_wxStaticBitmap = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.bitmap_empty = wx.StaticBitmap(self.notebook_1_wxStaticBitmap,
                                            wx.ID_ANY, wx.EmptyBitmap(32, 32))
        self.bitmap_file = wx.StaticBitmap(
            self.notebook_1_wxStaticBitmap, wx.ID_ANY,
            wx.Bitmap("icon.xpm", wx.BITMAP_TYPE_ANY))
        self.bitmap_nofile = wx.StaticBitmap(
            self.notebook_1_wxStaticBitmap, wx.ID_ANY,
            wx.Bitmap("non-existing.bmp", wx.BITMAP_TYPE_ANY))
        self.bitmap_art = wx.StaticBitmap(
            self.notebook_1_wxStaticBitmap, wx.ID_ANY,
            wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_OTHER, (32, 32)))
        self.notebook_1_wxStaticLine = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.static_line_2 = wx.StaticLine(self.notebook_1_wxStaticLine,
                                           wx.ID_ANY,
                                           style=wx.LI_VERTICAL)
        self.static_line_3 = wx.StaticLine(self.notebook_1_wxStaticLine,
                                           wx.ID_ANY,
                                           style=wx.LI_VERTICAL)
        self.static_line_4 = wx.StaticLine(self.notebook_1_wxStaticLine,
                                           wx.ID_ANY)
        self.static_line_5 = wx.StaticLine(self.notebook_1_wxStaticLine,
                                           wx.ID_ANY)
        self.notebook_1_wxStaticText = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.label_1 = wx.StaticText(self.notebook_1_wxStaticText,
                                     wx.ID_ANY,
                                     _("red text (RGB)"),
                                     style=wx.ALIGN_CENTER)
        self.label_4 = wx.StaticText(self.notebook_1_wxStaticText,
                                     wx.ID_ANY,
                                     _("black on red (RGB)"),
                                     style=wx.ALIGN_CENTER)
        self.label_5 = wx.StaticText(self.notebook_1_wxStaticText,
                                     wx.ID_ANY,
                                     _("green on pink (RGB)"),
                                     style=wx.ALIGN_CENTER)
        self.notebook_1_Spacer = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.label_3 = wx.StaticText(self.notebook_1_Spacer, wx.ID_ANY,
                                     _("Two labels with a"))
        self.label_2 = wx.StaticText(self.notebook_1_Spacer, wx.ID_ANY,
                                     _("spacer between"))
        self.notebook_1_wxTextCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.text_ctrl = wx.TextCtrl(self.notebook_1_wxTextCtrl,
                                     wx.ID_ANY,
                                     _("This\nis\na\nmultiline\nwxTextCtrl"),
                                     style=wx.TE_CHARWRAP | wx.TE_MULTILINE
                                     | wx.TE_WORDWRAP)
        self.notebook_1_wxToggleButton = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.button_2 = wx.ToggleButton(self.notebook_1_wxToggleButton,
                                        wx.ID_ANY, _("Toggle Button 1"))
        self.button_4 = wx.ToggleButton(self.notebook_1_wxToggleButton,
                                        wx.ID_ANY,
                                        _("Toggle Button 2"),
                                        style=wx.BU_BOTTOM | wx.BU_EXACTFIT)
        self.notebook_1_wxTreeCtrl = wx.Panel(self.notebook_1, wx.ID_ANY)
        self.tree_ctrl_1 = wx.TreeCtrl(self.notebook_1_wxTreeCtrl, wx.ID_ANY)
        self.static_line_1 = wx.StaticLine(self, wx.ID_ANY)
        self.button_5 = wx.Button(self, wx.ID_CLOSE, "")
        self.button_1 = wx.Button(self, wx.ID_OK, "", style=wx.BU_TOP)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_MENU, self.onSelectUnix, self.mn_Unix)
        self.Bind(wx.EVT_MENU, self.onSelectWindows, self.mn_Windows)
        self.Bind(wx.EVT_MENU, self.onRemoveTabs, self.mn_RemoveTabs)
        self.Bind(wx.EVT_MENU, self.onShowManual, id=wx.ID_HELP)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnNotebookPageChanged,
                  self.notebook_1)
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnNotebookPageChanging,
                  self.notebook_1)
        self.Bind(wx.EVT_BUTTON, self.onStartConverting, self.button_1)
Beispiel #11
0
    def __init__(self, parent, id):

        # initializations
        self.low_norm_mass = ''  # mass for given height if BMI=20
        self.upp_norm_mass = ''  # mass for given height if BMI=25
        self.focus = 0  # set to avoid error on 'Reset'

        wx.Panel.__init__(self,
                          parent=parent,
                          id=id,
                          pos=wx.DefaultPosition,
                          size=wx.DefaultSize,
                          style=wx.SIMPLE_BORDER | wx.TAB_TRAVERSAL)
        #------------------------------
        #sizer with heading label
        #------------------------------
        label = wx.StaticText(self,
                              -1,
                              _("Current height/mass"),
                              wx.DefaultPosition,
                              wx.DefaultSize,
                              style=wx.ALIGN_CENTRE)
        label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False, ''))
        label.SetForegroundColour(wx.Colour(0, 0, 131))
        szr_upper_heading = wx.BoxSizer(wx.HORIZONTAL)
        szr_upper_heading.Add(label, 1, 0)
        #------------------------------
        #sizer holding the height stuff
        #------------------------------
        label = wx.StaticText(self, -1, _("Height (cm)"), size=(1, 20))
        label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))
        label.SetForegroundColour(wx.Colour(0, 0, 131))

        self.txtheight = wx.TextCtrl(self, -1, "", size=(100, 20))
        self.txtheight.SetFont(
            wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))

        wx.EVT_TEXT(self, self.txtheight.GetId(), self.EvtText_height)
        wx.EVT_SET_FOCUS(self.txtheight, self.OnSetFocus_height)
        wx.EVT_CHAR(self.txtheight, self.EvtChar_height)

        szr_height = wx.BoxSizer(wx.HORIZONTAL)
        szr_height.Add((10, 1), 0, 0)
        szr_height.Add(label, 1, wx.ALIGN_CENTRE_VERTICAL, 0)
        szr_height.Add(self.txtheight, 1, wx.ALIGN_CENTRE_VERTICAL | wx.EXPAND,
                       0)
        #------------------------------
        #sizer holding the mass stuff -- some people incorrectly call this stuff "weight"
        #------------------------------
        label = wx.StaticText(self, -1, _("Mass (kg)"), size=(20, 20))
        label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))
        label.SetForegroundColour(wx.Colour(0, 0, 131))

        self.txtmass = wx.TextCtrl(self, -1, "", size=(100, 20))
        self.txtmass.SetFont(
            wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))

        wx.EVT_TEXT(self, self.txtmass.GetId(), self.EvtText_mass)
        wx.EVT_SET_FOCUS(self.txtmass, self.OnSetFocus_mass)
        wx.EVT_CHAR(self.txtmass, self.EvtChar_mass)

        szr_mass = wx.BoxSizer(wx.HORIZONTAL)
        szr_mass.Add((10, 1), 0, 0)
        szr_mass.Add(label, 1, wx.ALIGN_CENTRE_VERTICAL, 0)
        szr_mass.Add(self.txtmass, 1, wx.ALIGN_CENTRE_VERTICAL | wx.EXPAND, 0)
        szr_mass.Add((5, 5), 1, 0)
        #-----------------)-------------
        #sizer holding the BMI stuff
        #------------------------------
        label = wx.StaticText(self, -1, _("BMI"), size=(100, 20))
        label.SetFont(wx.Font(13, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))
        label.SetForegroundColour(wx.Colour(0, 0, 131))

        self.txtbmi = wx.TextCtrl(self,
                                  -1,
                                  "",
                                  size=(100, 20),
                                  style=wx.TE_READONLY)
        self.txtbmi.Enable(False)
        self.txtbmi.SetFont(
            wx.Font(13, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))

        szr_bmi = wx.BoxSizer(wx.HORIZONTAL)
        szr_bmi.Add((10, 1), 0, 0)
        szr_bmi.Add(label, 1, wx.ALIGN_CENTRE_VERTICAL | 0, 0)
        szr_bmi.Add(self.txtbmi, 1, wx.ALIGN_CENTRE_VERTICAL | wx.EXPAND, 0)
        szr_bmi.Add((5, 5), 1, 0)
        #--------------------------------------------------
        #the color ellipses to show where on scale of mass
        #--------------------------------------------------
        bmi_colour_scale = BMI_Colour_Scale(self)
        bmi_colour_scale.Enable(False)
        szr_col_scale = wx.BoxSizer(wx.HORIZONTAL)
        szr_col_scale.Add(bmi_colour_scale, 1, wx.EXPAND)
        #-----------------------------------------------------
        #put a slider control under the bmi colour range scale
        #-----------------------------------------------------
        self.slider = wx.Slider(
            self, -1, 15, 15, 34, wx.Point(30, 60), wx.Size(324, -1),
            wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
        self.slider.SetTickFreq(1, 1)
        wx.EVT_SCROLL(self.slider, self.SLIDER_EVT)
        wx.EVT_CHAR(self.slider, self.EvtChar_slider)

        szr_slider = wx.BoxSizer(wx.HORIZONTAL)
        szr_slider.Add(self.slider, 1, wx.EXPAND)
        #---------------------------------------------------------------------
        #Add the adjusted values heading, underlined, autoexpand to fill width
        #FIXME: find underline constant
        #---------------------------------------------------------------------
        label = wx.StaticText(self,
                              -1,
                              _("Adjusted Values"),
                              wx.DefaultPosition,
                              wx.DefaultSize,
                              style=wx.ALIGN_CENTRE)  #add underline
        label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD, False, ''))
        label.SetForegroundColour(wx.Colour(0, 0, 131))

        szr_lower_heading = wx.BoxSizer(wx.HORIZONTAL)
        szr_lower_heading.Add(label, 1, wx.EXPAND)
        #-----------------------
        #Put in the goal mass
        #----------------------
        label = wx.StaticText(self, -1, _("Goal mass"), size=(30, 20))
        label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))
        label.SetForegroundColour(wx.Colour(0, 0, 131))

        self.txtgoal = wx.TextCtrl(self, -1, "", size=(100, 20))
        self.txtgoal.SetFont(
            wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))

        wx.EVT_TEXT(self, self.txtgoal.GetId(), self.EvtText_goal)
        wx.EVT_SET_FOCUS(self.txtgoal, self.OnSetFocus_goal)
        wx.EVT_CHAR(self.txtgoal, self.EvtChar_goal)

        szr_goal_mass = wx.BoxSizer(wx.HORIZONTAL)
        szr_goal_mass.Add((10, 1), 0, 0)
        szr_goal_mass.Add(label, 1, wx.ALIGN_CENTRE_VERTICAL, 0)
        szr_goal_mass.Add(self.txtgoal, 1,
                          wx.ALIGN_CENTRE_VERTICAL | wx.EXPAND, 0)
        #-----------------------------
        #and the amount to loose in Kg
        #-----------------------------
        label = wx.StaticText(self, -1, _("kg to lose"), size=(30, 20))
        label.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))
        label.SetForegroundColour(wx.Colour(0, 0, 131))

        self.txtloss = wx.TextCtrl(self, -1, "", size=(100, 20))
        self.txtloss.SetFont(
            wx.Font(12, wx.SWISS, wx.NORMAL, wx.NORMAL, False, ''))

        wx.EVT_TEXT(self, self.txtloss.GetId(), self.EvtText_loss)
        wx.EVT_SET_FOCUS(self.txtloss, self.OnSetFocus_loss)
        wx.EVT_CHAR(self.txtloss, self.EvtChar_loss)

        szr_to_loose = wx.BoxSizer(wx.HORIZONTAL)
        szr_to_loose.Add((10, 1), 0, 0)
        szr_to_loose.Add(label, 1, wx.ALIGN_CENTRE_VERTICAL, 0)
        szr_to_loose.Add(self.txtloss, 1, wx.ALIGN_CENTRE_VERTICAL | wx.EXPAND,
                         0)
        #-----------------------------------------------------------------
        #finally add all the horizontal sizers from top down to main sizer
        #-----------------------------------------------------------------
        szr_main = wx.BoxSizer(wx.VERTICAL)
        szr_main.Add((1, 5), 0, 0)
        szr_main.Add(szr_upper_heading, 0, wx.EXPAND)
        szr_main.Add((1, 5), 0, 0)
        szr_main.Add(szr_height, 0, 0)
        szr_main.Add((1, 5), 0, 0)
        szr_main.Add(szr_mass, 0, 0)
        szr_main.Add((1, 5), 0, 0)
        szr_main.Add(szr_bmi, 0, 0)
        szr_main.Add((1, 20), 0, 0)
        szr_main.Add(szr_col_scale, 0, 0)
        szr_main.Add(szr_slider, 0, 0)
        szr_main.Add(szr_lower_heading, 0, wx.EXPAND)
        szr_main.Add((1, 5), 0, 0)
        szr_main.Add(szr_goal_mass, 0, 0)
        szr_main.Add((1, 5), 0, 0)
        szr_main.Add(szr_to_loose, 0, 0)
        szr_main.Add((1, 20), 0, 0)
        #---------------------------------------
        #set, fit and layout sizer so it appears
        #---------------------------------------
        self.SetSizer(szr_main)
        szr_main.Fit(self)
        self.SetAutoLayout(True)
        self.Show(True)
    def __init__(self, *args, context=None, node=None, **kwds):
        # begin wxGlade: LhyAdvancedPanel.__init__
        kwds["style"] = kwds.get("style", 0)
        wx.Panel.__init__(self, *args, **kwds)
        self.context = context
        self.operation = node

        extras_sizer = wx.BoxSizer(wx.VERTICAL)

        advanced_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Speed Code Features:"), wx.VERTICAL
        )
        extras_sizer.Add(advanced_sizer, 0, wx.EXPAND, 0)

        sizer_11 = wx.BoxSizer(wx.HORIZONTAL)
        advanced_sizer.Add(sizer_11, 0, wx.EXPAND, 0)

        self.check_dratio_custom = wx.CheckBox(self, wx.ID_ANY, "Custom D-Ratio")
        self.check_dratio_custom.SetToolTip(
            "Enables the ability to modify the diagonal ratio."
        )
        sizer_11.Add(self.check_dratio_custom, 1, 0, 0)

        self.text_dratio = TextCtrl(self, wx.ID_ANY, "0.261", limited=True)
        self.text_dratio.SetToolTip(OPERATION_DRATIO_TOOLTIP)
        sizer_11.Add(self.text_dratio, 1, 0, 0)

        sizer_12 = wx.BoxSizer(wx.HORIZONTAL)
        advanced_sizer.Add(sizer_12, 0, wx.EXPAND, 0)

        self.checkbox_custom_accel = wx.CheckBox(self, wx.ID_ANY, "Acceleration")
        self.checkbox_custom_accel.SetToolTip("Enables acceleration override")
        sizer_12.Add(self.checkbox_custom_accel, 1, wx.ALIGN_CENTER_VERTICAL, 0)

        self.slider_accel = wx.Slider(
            self, wx.ID_ANY, 1, 1, 4, style=wx.SL_AUTOTICKS | wx.SL_LABELS
        )
        self.slider_accel.SetToolTip(OPERATION_ACCEL_TOOLTIP)
        sizer_12.Add(self.slider_accel, 1, wx.EXPAND, 0)

        advanced_ppi_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Plot Planner"), wx.HORIZONTAL
        )
        extras_sizer.Add(advanced_ppi_sizer, 0, wx.EXPAND, 0)

        sizer_19 = wx.BoxSizer(wx.VERTICAL)
        advanced_ppi_sizer.Add(sizer_19, 1, wx.EXPAND, 0)

        sizer_20 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_19.Add(sizer_20, 1, wx.EXPAND, 0)

        self.check_dot_length_custom = wx.CheckBox(self, wx.ID_ANY, "Dot Length")
        self.check_dot_length_custom.SetToolTip("Enable Dot Length")
        sizer_20.Add(self.check_dot_length_custom, 1, 0, 0)
        self.text_dot_length = TextCtrl(self, wx.ID_ANY, "1", limited=True)
        self.text_dot_length.SetToolTip(OPERATION_DOTLENGTH_TOOLTIP)
        sizer_20.Add(self.text_dot_length, 1, 0, 0)

        self.combo_dot_length_units = wx.ComboBox(
            self,
            wx.ID_ANY,
            choices=["steps", "mm", "cm", "inch", "mil", "%"],
            style=wx.CB_DROPDOWN | wx.CB_READONLY,
        )
        self.combo_dot_length_units.SetSelection(0)
        sizer_20.Add(self.combo_dot_length_units, 0, 0, 0)

        self.check_shift_enabled = wx.CheckBox(self, wx.ID_ANY, "Pulse Grouping")
        self.check_shift_enabled.SetToolTip(OPERATION_SHIFT_TOOLTIP)
        sizer_19.Add(self.check_shift_enabled, 0, 0, 0)

        self.SetSizer(extras_sizer)

        self.Layout()

        self.Bind(wx.EVT_CHECKBOX, self.on_check_dratio, self.check_dratio_custom)
        self.Bind(wx.EVT_TEXT, self.on_text_dratio, self.text_dratio)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_dratio, self.text_dratio)
        self.Bind(
            wx.EVT_CHECKBOX, self.on_check_acceleration, self.checkbox_custom_accel
        )
        self.Bind(wx.EVT_COMMAND_SCROLL, self.on_slider_accel, self.slider_accel)
        self.Bind(
            wx.EVT_CHECKBOX, self.on_check_dot_length, self.check_dot_length_custom
        )
        self.Bind(wx.EVT_TEXT, self.on_text_dot_length, self.text_dot_length)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_dot_length, self.text_dot_length)
        self.Bind(
            wx.EVT_CHECKBOX, self.on_check_shift_enabled, self.check_shift_enabled
        )
Beispiel #13
0
 def create_widget(self):
     mi,ma = self.properties["range"].get_tuple()
     value_p = self.properties["value"]
     value = value_p.get()  if value_p.is_active()  else  mi
     self.widget = wx.Slider(self.parent.widget, self.id, value, mi, ma, style=self.style)
	def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 743,483 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
		
		self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
		
		bSizer1 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
		self.m_panel1.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ) )
		
		bSizer4 = wx.BoxSizer( wx.HORIZONTAL )
		
		bSizer6 = wx.BoxSizer( wx.HORIZONTAL )
		
		self.m_grid1 = wx.grid.Grid( self.m_panel1, wx.ID_ANY, wx.DefaultPosition, wx.Size( 200,-1 ), 0 )
		
		# Grid
		self.m_grid1.CreateGrid( 60, 2 )
		self.m_grid1.EnableEditing( False )
		self.m_grid1.EnableGridLines( True )
		self.m_grid1.EnableDragGridSize( False )
		self.m_grid1.SetMargins( 10, 0 )
		
		# Columns
		self.m_grid1.SetColSize( 0, 90 )
		self.m_grid1.SetColSize( 1, 60 )
		self.m_grid1.EnableDragColMove( False )
		self.m_grid1.EnableDragColSize( True )
		self.m_grid1.SetColLabelSize( 30 )
		self.m_grid1.SetColLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
		
		# Rows
		self.m_grid1.SetRowSize( 0, 19 )
		self.m_grid1.SetRowSize( 1, 19 )
		self.m_grid1.SetRowSize( 2, 15 )
		self.m_grid1.SetRowSize( 3, 19 )
		self.m_grid1.SetRowSize( 4, 19 )
		self.m_grid1.AutoSizeRows()
		self.m_grid1.EnableDragRowSize( True )
		self.m_grid1.SetRowLabelSize( 30 )
		self.m_grid1.SetRowLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
		
		# Label Appearance
		self.m_grid1.SetLabelFont( wx.Font( 10, 74, 90, 90, False, "Century Gothic" ) )
		
		# Cell Defaults
		self.m_grid1.SetDefaultCellFont( wx.Font( 11, 74, 90, 90, False, "Century Gothic" ) )
		self.m_grid1.SetDefaultCellAlignment( wx.ALIGN_LEFT, wx.ALIGN_TOP )
		bSizer6.Add( self.m_grid1, 0, wx.ALL|wx.EXPAND, 5 )
		
		
		bSizer4.Add( bSizer6, 1, wx.ALL|wx.EXPAND, 5 )
		
		bSizer7 = wx.BoxSizer( wx.VERTICAL )
		
		bSizer61 = wx.BoxSizer( wx.HORIZONTAL )
		
		bSizer71 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_staticText2 = wx.StaticText( self.m_panel1, wx.ID_ANY, u"Program Counter", wx.DefaultPosition, wx.DefaultSize, 0 )
		self.m_staticText2.Wrap( -1 )
		bSizer71.Add( self.m_staticText2, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
		
		self.pco = wx.StaticText( self.m_panel1, wx.ID_ANY, u"pc", wx.DefaultPosition, wx.Size( 100,-1 ), wx.ALIGN_CENTRE )
		self.pco.Wrap( -1 )
		self.pco.SetFont( wx.Font( 14, 74, 90, 90, False, "Arial" ) )
		self.pco.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNTEXT ) )
		self.pco.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNHIGHLIGHT ) )
		
		bSizer71.Add( self.pco, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
		
		
		bSizer61.Add( bSizer71, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
		
		bSizer8 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_staticText3 = wx.StaticText( self.m_panel1, wx.ID_ANY, u"Instrucción actual", wx.DefaultPosition, wx.DefaultSize, 0 )
		self.m_staticText3.Wrap( -1 )
		bSizer8.Add( self.m_staticText3, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
		
		self.inow = wx.StaticText( self.m_panel1, wx.ID_ANY, u"token", wx.DefaultPosition, wx.Size( 100,-1 ), wx.ALIGN_CENTRE )
		self.inow.Wrap( -1 )
		self.inow.SetFont( wx.Font( 14, 74, 90, 90, False, "Arial" ) )
		self.inow.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNTEXT ) )
		self.inow.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNHIGHLIGHT ) )
		
		bSizer8.Add( self.inow, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
		
		
		bSizer61.Add( bSizer8, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
		
		
		bSizer7.Add( bSizer61, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
		
		bSizer12 = wx.BoxSizer( wx.HORIZONTAL )
		
		bSizer18 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_bpButton2 = wx.BitmapButton( self.m_panel1, wx.ID_ANY, wx.Bitmap( u"ICONO.bmp", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )
		bSizer18.Add( self.m_bpButton2, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
		
		
		bSizer12.Add( bSizer18, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
		
		bSizer16 = wx.BoxSizer( wx.VERTICAL )
		
		bSizer14 = wx.BoxSizer( wx.VERTICAL )
		
		self.titulo = wx.StaticText( self.m_panel1, wx.ID_ANY, u"SIMUSI", wx.DefaultPosition, wx.DefaultSize, 0 )
		self.titulo.Wrap( -1 )
		self.titulo.SetFont( wx.Font( 22, 74, 90, 90, False, "Arial Rounded MT Bold" ) )
		self.titulo.SetForegroundColour( wx.Colour( 70, 57, 234 ) )
		
		bSizer14.Add( self.titulo, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
		
		
		bSizer16.Add( bSizer14, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND|wx.SHAPED, 5 )
		
		bSizer13 = wx.BoxSizer( wx.VERTICAL )
		
		self.b_ejecutar = wx.Button( self.m_panel1, wx.ID_ANY, u"Ejecutar", wx.DefaultPosition, wx.Size( 100,50 ), 0 )
		self.b_ejecutar.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_3DLIGHT ) )
		
		bSizer13.Add( self.b_ejecutar, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
		
		
		bSizer16.Add( bSizer13, 1, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
		
		
		bSizer12.Add( bSizer16, 1, wx.EXPAND, 5 )
		
		
		bSizer7.Add( bSizer12, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5 )
		
		bSizer5 = wx.BoxSizer( wx.HORIZONTAL )
		
		bSizer9 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_staticText1 = wx.StaticText( self.m_panel1, wx.ID_ANY, u"Fuente (txt)", wx.DefaultPosition, wx.DefaultSize, 0 )
		self.m_staticText1.Wrap( -1 )
		bSizer9.Add( self.m_staticText1, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
		
		self.m_filePicker1 = wx.FilePickerCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, u"Select a file", u"*.*", wx.DefaultPosition, wx.DefaultSize, wx.FLP_DEFAULT_STYLE )
		bSizer9.Add( self.m_filePicker1, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
		
		
		bSizer5.Add( bSizer9, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND|wx.SHAPED, 5 )
		
		bSizer11 = wx.BoxSizer( wx.VERTICAL )
		
		self.b_load = wx.Button( self.m_panel1, wx.ID_ANY, u"Cargar", wx.DefaultPosition, wx.DefaultSize, 0 )
		bSizer11.Add( self.b_load, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
		
		
		bSizer5.Add( bSizer11, 1, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND|wx.SHAPED, 5 )
		
		bSizer10 = wx.BoxSizer( wx.VERTICAL )
		
		self.m_staticText4 = wx.StaticText( self.m_panel1, wx.ID_ANY, u"Velocidad", wx.DefaultPosition, wx.DefaultSize, 0 )
		self.m_staticText4.Wrap( -1 )
		bSizer10.Add( self.m_staticText4, 0, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
		
		self.m_slider1 = wx.Slider( self.m_panel1, wx.ID_ANY, 50, 1, 100, wx.DefaultPosition, wx.DefaultSize, wx.SL_SELRANGE|wx.SL_VERTICAL )
		bSizer10.Add( self.m_slider1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
		
		
		bSizer5.Add( bSizer10, 1, wx.ALIGN_CENTER|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND|wx.SHAPED, 5 )
		
		
		bSizer7.Add( bSizer5, 1, wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL, 5 )
		
		
		bSizer4.Add( bSizer7, 1, wx.EXPAND, 5 )
		
		
		self.m_panel1.SetSizer( bSizer4 )
		self.m_panel1.Layout()
		bSizer4.Fit( self.m_panel1 )
		bSizer1.Add( self.m_panel1, 1, 0, 5 )
		
		
		self.SetSizer( bSizer1 )
		self.Layout()
		
		self.Centre( wx.BOTH )
	
                # Connect Events
		self.b_load.Bind(wx.EVT_BUTTON, self.b_loaodOnButtonClick)
		self.b_ejecutar.Bind(wx.EVT_BUTTON, self.b_ejecutarOnButtonClick)
Beispiel #15
0
    def __init__(self,
                 parent=None,
                 giface=None,
                 title=_("GRASS GIS Map Swipe"),
                 name="swipe",
                 **kwargs):
        DoubleMapFrame.__init__(self,
                                parent=parent,
                                title=title,
                                name=name,
                                firstMap=Map(),
                                secondMap=Map(),
                                **kwargs)
        Debug.msg(1, "SwipeMapFrame.__init__()")
        #
        # Add toolbars
        #
        self.AddToolbars()
        self._giface = giface
        #
        # create widgets
        #
        self.splitter = MapSplitter(parent=self, id=wx.ID_ANY)

        self.sliderH = wx.Slider(self, id=wx.ID_ANY, style=wx.SL_HORIZONTAL)
        self.sliderV = wx.Slider(self, id=wx.ID_ANY, style=wx.SL_VERTICAL)

        self.mapWindowProperties = MapWindowProperties()
        self.mapWindowProperties.setValuesFromUserSettings()
        self.mapWindowProperties.autoRenderChanged.connect(
            self.OnAutoRenderChanged)
        self.firstMapWindow = SwipeBufferedWindow(
            parent=self.splitter,
            giface=self._giface,
            properties=self.mapWindowProperties,
            Map=self.firstMap)
        self.secondMapWindow = SwipeBufferedWindow(
            parent=self.splitter,
            giface=self._giface,
            properties=self.mapWindowProperties,
            Map=self.secondMap)
        # bind query signal
        self.firstMapWindow.mapQueried.connect(self.Query)
        self.secondMapWindow.mapQueried.connect(self.Query)

        # bind tracking cursosr to mirror it
        self.firstMapWindow.Bind(wx.EVT_MOTION,
                                 lambda evt: self.TrackCursor(evt))
        self.secondMapWindow.Bind(wx.EVT_MOTION,
                                  lambda evt: self.TrackCursor(evt))

        self.MapWindow = self.firstMapWindow  # current by default
        self.firstMapWindow.zoomhistory = self.secondMapWindow.zoomhistory
        self.SetBindRegions(True)

        self._mode = 'swipe'

        self._addPanes()
        self._bindWindowsActivation()
        self._setUpMapWindow(self.firstMapWindow)
        self._setUpMapWindow(self.secondMapWindow)

        self._mgr.GetPane('sliderV').Hide()
        self._mgr.GetPane('sliderH').Show()
        self.slider = self.sliderH

        self.InitStatusbar()

        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_IDLE, self.OnIdle)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        self.SetSize((800, 600))

        self._mgr.Update()

        self.rasters = {'first': None, 'second': None}

        self._inputDialog = None
        self._preferencesDialog = None
        self._queryDialog = None

        # default action in map toolbar
        self.GetMapToolbar().SelectDefault()

        self.resize = False

        wx.CallAfter(self.CallAfterInit)
Beispiel #16
0
    def ReCreateFoldPanel(self, fpb_flags):

        # delete earlier panel
        self._leftWindow1.DestroyChildren()

        # recreate the foldpanelbar

        self._pnl = fpb.FoldPanelBar(self._leftWindow1, -1, wx.DefaultPosition,
                                     wx.Size(-1,-1), agwStyle=fpb_flags)

        Images = wx.ImageList(16,16)
        Images.Add(GetExpandedIconBitmap())
        Images.Add(GetCollapsedIconBitmap())
            
        item = self._pnl.AddFoldPanel("Caption Colours", collapsed=False,
                                      foldIcons=Images)

        self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Adjust The First Colour"),
                                     fpb.FPB_ALIGN_WIDTH, 5, 20) 

        # RED colour spin control
        self._rslider1 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._rslider1, fpb.FPB_ALIGN_WIDTH, 2, 20) 

        # GREEN colour spin control
        self._gslider1 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._gslider1, fpb.FPB_ALIGN_WIDTH, 0, 20) 

        # BLUE colour spin control
        self._bslider1 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._bslider1, fpb.FPB_ALIGN_WIDTH,  0, 20) 
        
        self._pnl.AddFoldPanelSeparator(item)

        self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Adjust The Second Colour"),
                                     fpb.FPB_ALIGN_WIDTH, 5, 20) 

        # RED colour spin control
        self._rslider2 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._rslider2, fpb.FPB_ALIGN_WIDTH, 2, 20) 

        # GREEN colour spin control
        self._gslider2 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._gslider2, fpb.FPB_ALIGN_WIDTH, 0, 20) 

        # BLUE colour spin control
        self._bslider2 = wx.Slider(item, -1, 0, 0, 255)
        self._pnl.AddFoldPanelWindow(item, self._bslider2, fpb.FPB_ALIGN_WIDTH, 0, 20) 

        self._pnl.AddFoldPanelSeparator(item)
        
        button1 = wx.Button(item, wx.ID_ANY, "Apply To All")
        button1.Bind(wx.EVT_BUTTON, self.OnExpandMe)
        self._pnl.AddFoldPanelWindow(item, button1)

        # read back current gradients and set the sliders
        # for the colour which is now taken as default

        style = self._pnl.GetCaptionStyle(item)
        col = style.GetFirstColour()

        self._rslider1.SetValue(col.Red())
        self._gslider1.SetValue(col.Green())
        self._bslider1.SetValue(col.Blue())

        col = style.GetSecondColour()
        self._rslider2.SetValue(col.Red())
        self._gslider2.SetValue(col.Green())
        self._bslider2.SetValue(col.Blue())

        # put down some caption styles from which the user can
        # select to show how the current or all caption bars will look like

        item = self._pnl.AddFoldPanel("Caption Style", False, foldIcons=Images)

        self.ID_USE_VGRADIENT = wx.NewId()
        self.ID_USE_HGRADIENT = wx.NewId()
        self.ID_USE_SINGLE = wx.NewId()
        self.ID_USE_RECTANGLE = wx.NewId()
        self.ID_USE_FILLED_RECTANGLE = wx.NewId()
        
        currStyle =  wx.RadioButton(item, self.ID_USE_VGRADIENT, "&Vertical Gradient")
        self._pnl.AddFoldPanelWindow(item, currStyle, fpb.FPB_ALIGN_WIDTH,
                                     fpb.FPB_DEFAULT_SPACING, 10)
        
        currStyle.SetValue(True)

        radio1 = wx.RadioButton(item, self.ID_USE_HGRADIENT, "&Horizontal Gradient")
        radio2 = wx.RadioButton(item, self.ID_USE_SINGLE, "&Single Colour")
        radio3 = wx.RadioButton(item, self.ID_USE_RECTANGLE, "&Rectangle Box")
        radio4 = wx.RadioButton(item, self.ID_USE_FILLED_RECTANGLE, "&Filled Rectangle Box")

        currStyle.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio1.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio2.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio3.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        radio4.Bind(wx.EVT_RADIOBUTTON, self.OnStyleChange)
        
        self._pnl.AddFoldPanelWindow(item, radio1, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) 
        self._pnl.AddFoldPanelWindow(item, radio2, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) 
        self._pnl.AddFoldPanelWindow(item, radio3, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) 
        self._pnl.AddFoldPanelWindow(item, radio4, fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10) 

        self._pnl.AddFoldPanelSeparator(item)

        self._single = wx.CheckBox(item, -1, "&Only This Caption")
        self._pnl.AddFoldPanelWindow(item, self._single, fpb.FPB_ALIGN_WIDTH,
                                     fpb.FPB_DEFAULT_SPACING, 10) 

        # one more panel to finish it

        cs = fpb.CaptionBarStyle()
        cs.SetCaptionStyle(fpb.CAPTIONBAR_RECTANGLE)

        item = self._pnl.AddFoldPanel("Misc Stuff", collapsed=True, foldIcons=Images,
                                      cbstyle=cs)

        button2 = wx.Button(item, wx.NewId(), "Collapse All")        
        self._pnl.AddFoldPanelWindow(item, button2) 
        self._pnl.AddFoldPanelWindow(item, wx.StaticText(item, -1, "Enter Some Comments"),
                                     fpb.FPB_ALIGN_WIDTH, 5, 20) 
        self._pnl.AddFoldPanelWindow(item, wx.TextCtrl(item, -1, "Comments"),
                                     fpb.FPB_ALIGN_WIDTH, fpb.FPB_DEFAULT_SPACING, 10)

        button2.Bind(wx.EVT_BUTTON, self.OnCollapseMe)
        self.radiocontrols = [currStyle, radio1, radio2, radio3, radio4]
        
        self._leftWindow1.SizeWindows()
Beispiel #17
0
    def _init_particle_block(self, ctrl_size, value):
        static_box = wx.StaticBox(self._panel, label="Particle")
        box_sizer = wx.StaticBoxSizer(static_box, wx.VERTICAL)

        temp_sizer = wx.GridBagSizer(4, 4)
        text = wx.StaticText(self._panel, label="U speed")
        temp_sizer.Add(text,
                       pos=(0, 0),
                       flag=wx.ALIGN_CENTER | wx.ALL,
                       border=2)
        num_ctrl = NumCtrl(self._panel,
                           size=ctrl_size,
                           autoSize=False,
                           style=wx.TE_CENTER,
                           value=value,
                           min=1,
                           max=99,
                           integerWidth=2,
                           limitOnFieldChange=True)
        self._widgets['u_speed'] = num_ctrl
        temp_sizer.Add(num_ctrl,
                       pos=(0, 1),
                       flag=wx.ALIGN_CENTER | wx.ALL,
                       border=2)
        text = wx.StaticText(self._panel, label="V speed")
        temp_sizer.Add(text,
                       pos=(0, 2),
                       flag=wx.ALIGN_CENTER | wx.ALL,
                       border=2)
        num_ctrl = NumCtrl(self._panel,
                           size=ctrl_size,
                           autoSize=False,
                           style=wx.TE_CENTER,
                           value=value,
                           min=1,
                           max=99,
                           integerWidth=2,
                           limitOnFieldChange=True)
        self._widgets['v_speed'] = num_ctrl
        temp_sizer.Add(num_ctrl,
                       pos=(0, 3),
                       flag=wx.ALIGN_CENTER | wx.ALL,
                       border=2)

        text = wx.StaticText(self._panel, label="Color")
        temp_sizer.Add(text,
                       pos=(1, 0),
                       flag=wx.ALIGN_CENTER | wx.ALL,
                       border=2)
        button = wx.Button(self._panel, style=wx.BORDER_NONE | wx.BU_EXACTFIT)
        button.Bind(wx.EVT_BUTTON, self._on_color_dialog_click)
        self._widgets['color'] = button
        button.SetBackgroundColour(wx.BLACK)
        temp_sizer.Add(button, pos=(1, 1), flag=wx.EXPAND | wx.ALL, border=2)

        text = wx.StaticText(self._panel, label="Lifetime")
        temp_sizer.Add(text,
                       pos=(1, 2),
                       flag=wx.ALIGN_CENTER | wx.ALL,
                       border=2)
        num_ctrl = NumCtrl(self._panel,
                           size=ctrl_size,
                           autoSize=False,
                           style=wx.TE_CENTER,
                           value=50,
                           min=10,
                           max=100,
                           integerWidth=3,
                           limitOnFieldChange=True)
        self._widgets['life_time'] = num_ctrl
        temp_sizer.Add(num_ctrl,
                       pos=(1, 3),
                       flag=wx.ALIGN_CENTER | wx.ALL,
                       border=2)

        text = wx.StaticText(self._panel, label="Weight")
        temp_sizer.Add(text,
                       pos=(2, 0),
                       flag=wx.ALIGN_CENTER | wx.ALL,
                       border=2)
        slider = wx.Slider(self._panel,
                           value=50,
                           minValue=1,
                           maxValue=100,
                           style=wx.SL_HORIZONTAL | wx.SL_VALUE_LABEL)
        self._widgets['mass'] = slider
        temp_sizer.Add(slider,
                       pos=(2, 1),
                       span=(1, 3),
                       flag=wx.EXPAND | wx.ALL,
                       border=2)

        button = wx.Button(self._panel, label="Generate particle")
        button.Bind(wx.EVT_BUTTON, self._on_single_particle_generation_click)
        temp_sizer.Add(button,
                       pos=(3, 0),
                       span=(1, 4),
                       flag=wx.EXPAND | wx.ALL,
                       border=2)

        box_sizer.Add(temp_sizer, flag=wx.EXPAND | wx.ALL, border=1)
        self._panel_sizer.Add(box_sizer,
                              pos=(1, 0),
                              span=(1, 4),
                              flag=wx.EXPAND | wx.ALL,
                              border=6)
Beispiel #18
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
        self.SetBackgroundColour(default_colour)

        self.surface_list = []

        ## LINE 1

        # Combo related to mask naem
        combo_surface_name = wx.ComboBox(self,
                                         -1,
                                         style=wx.CB_DROPDOWN | wx.CB_READONLY)
        #combo_surface_name.SetSelection(0)
        if sys.platform != 'win32':
            combo_surface_name.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
        combo_surface_name.Bind(wx.EVT_COMBOBOX, self.OnComboName)
        self.combo_surface_name = combo_surface_name

        # Mask colour
        button_colour = csel.ColourSelect(self,
                                          -1,
                                          colour=(0, 0, 255),
                                          size=(-1, 22))
        button_colour.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour)
        self.button_colour = button_colour

        # Sizer which represents the first line
        line1 = wx.BoxSizer(wx.HORIZONTAL)
        line1.Add(combo_surface_name, 1,
                  wx.LEFT | wx.EXPAND | wx.GROW | wx.TOP | wx.RIGHT, 7)
        line1.Add(button_colour, 0, wx.TOP | wx.RIGHT, 7)

        ## LINE 2

        text_transparency = wx.StaticText(self, -1, _("Transparency:"))

        slider_transparency = wx.Slider(
            self,
            -1,
            0,
            MIN_TRANSPARENCY,
            MAX_TRANSPARENCY,
            style=wx.SL_HORIZONTAL)  #|wx.SL_AUTOTICKS)
        slider_transparency.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
        slider_transparency.Bind(wx.EVT_SLIDER, self.OnTransparency)
        self.slider_transparency = slider_transparency

        ## MIX LINE 2 AND 3
        flag_link = wx.EXPAND | wx.GROW | wx.RIGHT
        flag_slider = wx.EXPAND | wx.GROW | wx.LEFT | wx.TOP
        flag_combo = wx.EXPAND | wx.GROW | wx.LEFT

        fixed_sizer = wx.BoxSizer(wx.HORIZONTAL)
        fixed_sizer.AddMany([(text_transparency, 0, flag_link, 0),
                             (slider_transparency, 1, flag_slider, 4)])

        # LINE 4
        #cb = wx.CheckBox(self, -1, "Fill largest surface holes")
        #cb.SetValue(True)

        # Add all lines into main sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(line1, 1, wx.GROW | wx.EXPAND | wx.TOP, 10)
        sizer.Add(
            fixed_sizer, 0,
            wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP | wx.BOTTOM, 10)
        #sizer.Add(cb, 0, wx.GROW|wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP|wx.BOTTOM, 5)
        sizer.Fit(self)

        self.SetSizerAndFit(sizer)
        self.Update()
        #self.SetAutoLayout(1)

        self.__bind_events()
Beispiel #19
0
                        size=(widgetL / 2, 65),
                        choices=['Pause', 'Run'],
                        style=wx.RA_SPECIFY_ROWS)
#toggles trails TODO: fix
showTrails = wx.RadioBox(p1,
                         pos=(L + widgetL / 2, 0.21 * L),
                         size=(widgetL / 2, 65),
                         choices=['Hide Trails', 'Show Trails'],
                         style=wx.RA_SPECIFY_ROWS)
trails = not showTrails.GetSelection()

#specifies the frame rate
rateSlider = wx.Slider(p1,
                       pos=(L, .44 * L),
                       size=(widgetL, widgetL),
                       style=wx.SL_LABELS | wx.SL_HORIZONTAL,
                       minValue=1,
                       maxValue=100,
                       value=frameRate)
rateSlider.text = wx.StaticText(p1,
                                pos=(1.0 * L, .41 * L),
                                label='Frames Per Second')
#specifies the time slider
timeSlider = wx.Slider(p1,
                       pos=(L, .35 * L),
                       size=(widgetL, widgetL),
                       style=wx.SL_LABELS | wx.SL_HORIZONTAL,
                       minValue=1,
                       maxValue=300,
                       value=dt)
timeSlider.text = wx.StaticText(p1,
    def __init__(self, *args, **kwds):
        # begin wxGlade: OperationProperty.__init__
        kwds["style"] = kwds.get(
            "style", 0
        ) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT | wx.TAB_TRAVERSAL
        wx.Frame.__init__(self, *args, **kwds)
        self.SetSize((612, 500))

        # Menu Bar
        self.RasterProperty_menubar = wx.MenuBar()
        wxglade_tmp_menu = wx.Menu()
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Clear",
                                       "Delete all the layers")
        self.Bind(wx.EVT_MENU, self.on_menu_clear, id=item.GetId())
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Other/Blue/Red",
                                       "Set layers to the default")
        self.Bind(wx.EVT_MENU, self.on_menu_default0, id=item.GetId())
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Basic", "")
        self.Bind(wx.EVT_MENU, self.on_menu_default1, id=item.GetId())
        wxglade_tmp_menu.AppendSeparator()
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Save",
                                       "Save the current layer set")
        self.Bind(wx.EVT_MENU, self.on_menu_save, id=item.GetId())
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Load",
                                       "Load existing layer sets")
        self.Bind(wx.EVT_MENU, self.on_menu_load, id=item.GetId())
        item = wxglade_tmp_menu.Append(wx.ID_ANY, "Import",
                                       "Import existing layers")
        self.Bind(wx.EVT_MENU, self.on_menu_import, id=item.GetId())
        self.RasterProperty_menubar.Append(wxglade_tmp_menu, "Layers")
        self.SetMenuBar(self.RasterProperty_menubar)
        # Menu Bar end
        self.main_panel = wx.Panel(self, wx.ID_ANY)
        self.button_add_layer = wx.BitmapButton(
            self.main_panel, wx.ID_ANY,
            wx.Bitmap(
                "C:\\Users\\Tat\\PycharmProjects\\meerk40t\\icons8-level-1-50.png",
                wx.BITMAP_TYPE_ANY))
        self.listbox_layer = wx.ListBox(self.main_panel,
                                        wx.ID_ANY,
                                        choices=[],
                                        style=wx.LB_ALWAYS_SB | wx.LB_SINGLE)
        self.button_remove_layer = wx.BitmapButton(
            self.main_panel, wx.ID_ANY,
            wx.Bitmap(
                "C:\\Users\\Tat\\PycharmProjects\\meerk40t\\icons8-level-1-50.png",
                wx.BITMAP_TYPE_ANY))
        self.button_layer_color = wx.Button(self.main_panel, wx.ID_ANY, "")
        self.combo_type = wx.ComboBox(
            self.main_panel,
            wx.ID_ANY,
            choices=["Engrave", "Cut", "Raster", "Image"],
            style=wx.CB_DROPDOWN)
        self.checkbox_output = wx.CheckBox(self.main_panel, wx.ID_ANY,
                                           "Output")
        self.checkbox_show = wx.CheckBox(self.main_panel, wx.ID_ANY, "Show")
        self.text_speed = wx.TextCtrl(self.main_panel, wx.ID_ANY, "20.0")
        self.text_power = wx.TextCtrl(self.main_panel, wx.ID_ANY, "1000.0")
        self.raster_panel = wx.Panel(self.main_panel, wx.ID_ANY)
        self.text_raster_step = wx.TextCtrl(self.raster_panel, wx.ID_ANY, "1")
        self.text_overscan = wx.TextCtrl(self.raster_panel, wx.ID_ANY, "20")
        self.combo_raster_direction = wx.ComboBox(self.raster_panel,
                                                  wx.ID_ANY,
                                                  choices=[
                                                      "Top To Bottom",
                                                      "Bottom To Top",
                                                      "Right To Left",
                                                      "Left To Right",
                                                      "Crosshatch"
                                                  ],
                                                  style=wx.CB_DROPDOWN)
        self.radio_directional_raster = wx.RadioBox(
            self.raster_panel,
            wx.ID_ANY,
            "Directional Raster",
            choices=["Bidirectional", "Unidirectional"],
            majorDimension=1,
            style=wx.RA_SPECIFY_ROWS)
        self.slider_top = wx.Slider(self.raster_panel, wx.ID_ANY, 1, 0, 2)
        self.slider_left = wx.Slider(self.raster_panel,
                                     wx.ID_ANY,
                                     1,
                                     0,
                                     2,
                                     style=wx.SL_VERTICAL)
        self.display_panel = wx.Panel(self.raster_panel, wx.ID_ANY)
        self.slider_right = wx.Slider(self.raster_panel,
                                      wx.ID_ANY,
                                      1,
                                      0,
                                      2,
                                      style=wx.SL_VERTICAL)
        self.slider_bottom = wx.Slider(self.raster_panel, wx.ID_ANY, 1, 0, 2)
        self.checkbox_advanced = wx.CheckBox(self.main_panel, wx.ID_ANY,
                                             "Advanced")
        self.advanced_panel = wx.Panel(self.main_panel, wx.ID_ANY)
        self.checkbox_custom_d_ratio = wx.CheckBox(self.advanced_panel,
                                                   wx.ID_ANY, "Custom D-Ratio")
        self.text_dratio = wx.TextCtrl(self.advanced_panel, wx.ID_ANY, "0.261")
        self.checkbox_custom_accel = wx.CheckBox(self.advanced_panel,
                                                 wx.ID_ANY, "Acceleration")
        self.slider_accel = wx.Slider(self.advanced_panel,
                                      wx.ID_ANY,
                                      1,
                                      1,
                                      4,
                                      style=wx.SL_AUTOTICKS | wx.SL_LABELS)
        self.check_dot_enable = wx.CheckBox(self.advanced_panel, wx.ID_ANY,
                                            "Dot Length (mils)")
        self.text_dot_length = wx.TextCtrl(self.advanced_panel, wx.ID_ANY, "1")
        self.check_group_pulse = wx.CheckBox(self.advanced_panel, wx.ID_ANY,
                                             "Group Pulses")
        self.check_passes = wx.CheckBox(self.advanced_panel, wx.ID_ANY,
                                        "Passes")
        self.text_passes = wx.TextCtrl(self.advanced_panel, wx.ID_ANY, "1")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.on_button_add, self.button_add_layer)
        self.Bind(wx.EVT_LISTBOX, self.on_list_layer_click, self.listbox_layer)
        self.Bind(wx.EVT_LISTBOX_DCLICK, self.on_list_layer_dclick,
                  self.listbox_layer)
        self.Bind(wx.EVT_BUTTON, self.on_button_remove,
                  self.button_remove_layer)
        self.Bind(wx.EVT_BUTTON, self.on_button_layer, self.button_layer_color)
        self.Bind(wx.EVT_COMBOBOX, self.on_combo_operation, self.combo_type)
        self.Bind(wx.EVT_CHECKBOX, self.on_check_output, self.checkbox_output)
        self.Bind(wx.EVT_CHECKBOX, self.on_check_show, self.checkbox_show)
        self.Bind(wx.EVT_TEXT, self.on_text_speed, self.text_speed)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_speed, self.text_speed)
        self.Bind(wx.EVT_TEXT, self.on_text_power, self.text_power)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_power, self.text_power)
        self.Bind(wx.EVT_TEXT, self.on_text_raster_step, self.text_raster_step)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_raster_step,
                  self.text_raster_step)
        self.Bind(wx.EVT_TEXT, self.on_text_overscan, self.text_overscan)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_overscan, self.text_overscan)
        self.Bind(wx.EVT_COMBOBOX, self.on_combo_raster_direction,
                  self.combo_raster_direction)
        self.Bind(wx.EVT_RADIOBOX, self.on_radio_directional,
                  self.radio_directional_raster)
        self.Bind(wx.EVT_SLIDER, self.on_slider_top, self.slider_top)
        self.Bind(wx.EVT_SLIDER, self.on_slider_left, self.slider_left)
        self.Bind(wx.EVT_SLIDER, self.on_slider_right, self.slider_right)
        self.Bind(wx.EVT_SLIDER, self.on_slider_bottom, self.slider_bottom)
        self.Bind(wx.EVT_CHECKBOX, self.on_check_advanced,
                  self.checkbox_advanced)
        self.Bind(wx.EVT_CHECKBOX, self.on_check_dratio,
                  self.checkbox_custom_d_ratio)
        self.Bind(wx.EVT_TEXT, self.on_text_dratio, self.text_dratio)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_dratio, self.text_dratio)
        self.Bind(wx.EVT_CHECKBOX, self.on_check_acceleration,
                  self.checkbox_custom_accel)
        self.Bind(wx.EVT_COMMAND_SCROLL, self.on_slider_accel,
                  self.slider_accel)
        self.Bind(wx.EVT_CHECKBOX, self.on_check_dot_length,
                  self.check_dot_enable)
        self.Bind(wx.EVT_TEXT, self.on_text_dot_length, self.text_dot_length)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_dot_length,
                  self.text_dot_length)
        self.Bind(wx.EVT_CHECKBOX, self.on_check_group_pulses,
                  self.check_group_pulse)
Beispiel #21
0
    def __init__(self, parent, scene=None):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.Size(500, 300),
                          style=wx.TAB_TRAVERSAL)
        #self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.canvas = Canvas3D(self, scene)
        self.toolbar = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition,
                                wx.DefaultSize)
        tsizer = wx.BoxSizer(wx.HORIZONTAL)

        root = osp.abspath(osp.dirname(__file__))

        #self.SetIcon(wx.Icon('data/logo.ico', wx.BITMAP_TYPE_ICO))

        self.btn_x = wx.BitmapButton(
            self.toolbar, wx.ID_ANY,
            make_bitmap(
                wx.Bitmap(osp.join(root, 'imgs/x-axis.png'),
                          wx.BITMAP_TYPE_ANY)), wx.DefaultPosition,
            wx.DefaultSize, wx.BU_AUTODRAW)
        tsizer.Add(self.btn_x, 0, wx.ALIGN_CENTER | wx.ALL, 0)
        self.btn_y = wx.BitmapButton(
            self.toolbar, wx.ID_ANY,
            make_bitmap(
                wx.Bitmap(osp.join(root, 'imgs/y-axis.png'),
                          wx.BITMAP_TYPE_ANY)), wx.DefaultPosition,
            wx.DefaultSize, wx.BU_AUTODRAW)
        tsizer.Add(self.btn_y, 0, wx.ALIGN_CENTER | wx.ALL, 0)
        self.btn_z = wx.BitmapButton(
            self.toolbar, wx.ID_ANY,
            make_bitmap(
                wx.Bitmap(osp.join(root, 'imgs/z-axis.png'),
                          wx.BITMAP_TYPE_ANY)), wx.DefaultPosition,
            wx.DefaultSize, wx.BU_AUTODRAW)
        tsizer.Add(self.btn_z, 0, wx.ALIGN_CENTER | wx.ALL, 0)
        tsizer.Add(
            wx.StaticLine(self.toolbar, wx.ID_ANY, wx.DefaultPosition,
                          wx.DefaultSize, wx.LI_VERTICAL), 0,
            wx.ALL | wx.EXPAND, 2)
        self.btn_pers = wx.BitmapButton(
            self.toolbar, wx.ID_ANY,
            make_bitmap(
                wx.Bitmap(osp.join(root, 'imgs/isometric.png'),
                          wx.BITMAP_TYPE_ANY)), wx.DefaultPosition,
            wx.DefaultSize, wx.BU_AUTODRAW)
        tsizer.Add(self.btn_pers, 0, wx.ALIGN_CENTER | wx.ALL, 0)
        self.btn_orth = wx.BitmapButton(
            self.toolbar, wx.ID_ANY,
            make_bitmap(
                wx.Bitmap(osp.join(root, 'imgs/parallel.png'),
                          wx.BITMAP_TYPE_ANY)), wx.DefaultPosition,
            wx.DefaultSize, wx.BU_AUTODRAW)
        tsizer.Add(self.btn_orth, 0, wx.ALIGN_CENTER | wx.ALL, 0)
        tsizer.Add(
            wx.StaticLine(self.toolbar, wx.ID_ANY, wx.DefaultPosition,
                          wx.DefaultSize, wx.LI_VERTICAL), 0,
            wx.ALL | wx.EXPAND, 2)
        self.btn_open = wx.BitmapButton(
            self.toolbar, wx.ID_ANY,
            make_bitmap(
                wx.Bitmap(osp.join(root, 'imgs/open.png'),
                          wx.BITMAP_TYPE_ANY)), wx.DefaultPosition,
            wx.DefaultSize, wx.BU_AUTODRAW)
        tsizer.Add(self.btn_open, 0, wx.ALIGN_CENTER | wx.ALL, 0)
        self.btn_stl = wx.BitmapButton(
            self.toolbar, wx.ID_ANY,
            make_bitmap(
                wx.Bitmap(osp.join(root, 'imgs/stl.png'), wx.BITMAP_TYPE_ANY)),
            wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW)
        tsizer.Add(self.btn_stl, 0, wx.ALIGN_CENTER | wx.ALL, 0)
        #pan = wx.Panel(self.toolbar, size=(50, 50))
        self.btn_color = wx.ColourPickerCtrl(
            self.toolbar, wx.ID_ANY, wx.Colour(128, 128,
                                               128), wx.DefaultPosition,
            [(33, 38), (-1, -1)][platform.system() in ['Windows', 'Linux']],
            wx.CLRP_DEFAULT_STYLE)
        tsizer.Add(
            self.btn_color, 0,
            wx.ALL | (0, wx.EXPAND)[platform.system() in ['Windows', 'Linux']],
            0)
        tsizer.Add(
            wx.StaticLine(self.toolbar, wx.ID_ANY, wx.DefaultPosition,
                          wx.DefaultSize, wx.LI_VERTICAL), 0,
            wx.ALL | wx.EXPAND, 2)
        self.cho_light = wx.Choice(
            self.toolbar, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
            ['force light', 'normal light', 'weak light', 'off light'], 0)
        self.cho_light.SetSelection(1)
        tsizer.Add(self.cho_light, 0, wx.ALIGN_CENTER | wx.ALL, 1)
        self.cho_bg = wx.Choice(
            self.toolbar, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
            ['force scatter', 'normal scatter', 'weak scatter', 'off scatter'],
            0)
        self.cho_bg.SetSelection(1)
        tsizer.Add(self.cho_bg, 0, wx.ALIGN_CENTER | wx.ALL, 1)

        self.toolbar.SetSizer(tsizer)
        tsizer.Layout()

        self.settingbar = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition,
                                   wx.DefaultSize, wx.TAB_TRAVERSAL)
        ssizer = wx.BoxSizer(wx.HORIZONTAL)

        self.m_staticText1 = wx.StaticText(self.settingbar, wx.ID_ANY,
                                           u"Object:", wx.DefaultPosition,
                                           wx.DefaultSize, 0)
        self.m_staticText1.Wrap(-1)
        ssizer.Add(self.m_staticText1, 0, wx.ALIGN_CENTER | wx.LEFT, 10)

        cho_objChoices = ['None']
        self.cho_obj = wx.Choice(self.settingbar, wx.ID_ANY,
                                 wx.DefaultPosition, wx.DefaultSize,
                                 cho_objChoices, 0)
        self.cho_obj.SetSelection(0)
        ssizer.Add(self.cho_obj, 0, wx.ALIGN_CENTER | wx.ALL, 1)

        self.chk_visible = wx.CheckBox(self.settingbar, wx.ID_ANY, u"visible",
                                       wx.DefaultPosition, wx.DefaultSize, 0)
        ssizer.Add(self.chk_visible, 0, wx.ALIGN_CENTER | wx.LEFT, 10)

        self.col_color = wx.ColourPickerCtrl(self.settingbar, wx.ID_ANY,
                                             wx.BLACK, wx.DefaultPosition,
                                             wx.DefaultSize,
                                             wx.CLRP_DEFAULT_STYLE)
        ssizer.Add(self.col_color, 0, wx.ALIGN_CENTER | wx.ALL, 1)

        self.m_staticText2 = wx.StaticText(self.settingbar, wx.ID_ANY,
                                           u"Alpha:", wx.DefaultPosition,
                                           wx.DefaultSize, 0)
        self.m_staticText2.Wrap(-1)
        ssizer.Add(self.m_staticText2, 0, wx.ALIGN_CENTER | wx.LEFT, 10)

        self.sli_alpha = wx.Slider(self.settingbar, wx.ID_ANY, 10, 0, 10,
                                   wx.DefaultPosition, wx.DefaultSize,
                                   wx.SL_HORIZONTAL)
        ssizer.Add(self.sli_alpha, 0, wx.ALIGN_CENTER | wx.ALL, 1)
        self.settingbar.SetSizer(ssizer)

        self.m_staticText2 = wx.StaticText(self.settingbar, wx.ID_ANY,
                                           u"Mode:", wx.DefaultPosition,
                                           wx.DefaultSize, 0)
        self.m_staticText2.Wrap(-1)
        ssizer.Add(self.m_staticText2, 0, wx.ALIGN_CENTER | wx.LEFT, 10)

        cho_objChoices = ['mesh', 'grid']
        self.cho_mode = wx.Choice(self.settingbar, wx.ID_ANY,
                                  wx.DefaultPosition, wx.DefaultSize,
                                  cho_objChoices, 0)
        self.cho_mode.SetSelection(0)
        ssizer.Add(self.cho_mode, 0, wx.ALIGN_CENTER | wx.ALL, 1)

        sizer.Add(self.toolbar, 0, wx.EXPAND | wx.ALL, 0)
        sizer.Add(self.canvas, 1, wx.EXPAND | wx.ALL, 0)
        sizer.Add(self.settingbar, 0, wx.EXPAND | wx.ALL, 0)

        self.SetSizer(sizer)
        self.Layout()
        self.Centre(wx.BOTH)

        self.view_x = self.canvas.view_x
        self.view_y = self.canvas.view_y
        self.view_z = self.canvas.view_z
        self.set_pers = self.canvas.set_pers
        self.set_background = self.canvas.set_background
        self.set_scatter = self.canvas.set_scatter
        self.set_bright = self.canvas.set_bright

        self.on_bgcolor = lambda e: self.canvas.set_background(
            np.array(e.GetColour()[:3]) / 255)
        self.on_bg = lambda e: self.canvas.set_scatter(
            (3 - e.GetSelection()) / 3)
        self.on_light = lambda e: self.canvas.set_bright(
            (3 - e.GetSelection()) / 3)

        self.btn_x.Bind(wx.EVT_BUTTON, self.view_x)
        self.btn_y.Bind(wx.EVT_BUTTON, self.view_y)
        self.btn_z.Bind(wx.EVT_BUTTON, self.view_z)
        self.btn_open.Bind(wx.EVT_BUTTON, self.on_open)
        self.btn_stl.Bind(wx.EVT_BUTTON, self.on_stl)
        self.btn_pers.Bind(wx.EVT_BUTTON, lambda evt, f=self.set_pers: f(True))
        self.btn_orth.Bind(wx.EVT_BUTTON,
                           lambda evt, f=self.set_pers: f(False))
        self.btn_color.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_bgcolor)

        self.cho_obj.Bind(wx.EVT_CHOICE, self.on_select)
        self.cho_mode.Bind(wx.EVT_CHOICE, self.on_mode)
        self.cho_light.Bind(wx.EVT_CHOICE, self.on_light)
        self.cho_bg.Bind(wx.EVT_CHOICE, self.on_bg)
        self.chk_visible.Bind(wx.EVT_CHECKBOX, self.on_visible)
        self.sli_alpha.Bind(wx.EVT_SCROLL, self.on_alpha)
        self.col_color.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_color)

        if scene != None: self.cho_obj.Set(list(scene.objs.keys()))
    def __init__(self, parent, spectrum, settings):
        self.spectrum = spectrum
        self.settings = settings
        self.smoothed = None

        wx.Dialog.__init__(self,
                           parent=parent,
                           title='Smooth Spectrum',
                           style=wx.RESIZE_BORDER | wx.CAPTION | wx.SYSTEM_MENU
                           | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX | wx.CLOSE_BOX)

        self.queue = Queue.Queue()
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.__on_timer, self.timer)
        self.timer.Start(self.POLL)

        self.figure = matplotlib.figure.Figure(facecolor='white')
        self.canvas = FigureCanvas(self, -1, self.figure)
        settings = copy.copy(settings)
        settings.plotFunc = PlotFunc.NONE
        self.plot = Plotter(self.queue, self.figure, settings)

        textFunc = wx.StaticText(self, label='Window function')
        self.choiceFunc = wx.Choice(self, choices=WINFUNC[::2])
        self.choiceFunc.SetSelection(WINFUNC[::2].index(settings.smoothFunc))

        textRatio = wx.StaticText(self, label='Smoothing')
        self.slideRatio = wx.Slider(self,
                                    value=settings.smoothRatio,
                                    minValue=2,
                                    maxValue=100,
                                    style=wx.SL_INVERSE)

        buttonSmooth = wx.Button(self, label='Smooth')
        self.Bind(wx.EVT_BUTTON, self.__on_smooth, buttonSmooth)

        sizerButtons = wx.StdDialogButtonSizer()
        self.buttonOk = wx.Button(self, wx.ID_OK)
        self.buttonOk.Disable()
        buttonCancel = wx.Button(self, wx.ID_CANCEL)
        sizerButtons.AddButton(self.buttonOk)
        sizerButtons.AddButton(buttonCancel)
        sizerButtons.Realize()
        self.Bind(wx.EVT_BUTTON, self.__on_ok, self.buttonOk)

        sizerGrid = wx.GridBagSizer(5, 5)
        sizerGrid.Add(self.canvas,
                      pos=(0, 0),
                      span=(10, 6),
                      flag=wx.EXPAND | wx.ALL,
                      border=5)
        sizerGrid.Add(textFunc, pos=(1, 6), border=5)
        sizerGrid.Add(self.choiceFunc,
                      pos=(2, 6),
                      span=(1, 2),
                      flag=wx.ALL,
                      border=5)
        sizerGrid.Add(textRatio, pos=(3, 6), flag=wx.ALL, border=5)
        sizerGrid.Add(self.slideRatio,
                      pos=(4, 6),
                      span=(1, 2),
                      flag=wx.ALL,
                      border=5)
        sizerGrid.Add(buttonSmooth,
                      pos=(5, 6),
                      span=(1, 2),
                      flag=wx.ALL,
                      border=5)
        sizerGrid.Add(sizerButtons,
                      pos=(11, 6),
                      span=(1, 2),
                      flag=wx.ALIGN_RIGHT | wx.ALL,
                      border=5)
        sizerGrid.AddGrowableCol(0)
        sizerGrid.AddGrowableRow(0)

        self.SetSizerAndFit(sizerGrid)

        self.__draw_plot(self.spectrum)
Beispiel #23
0
    def create_base_ui(self):
        self.CreateStatusBar(1)
        self.SetStatusText(
            _("Layer number and Z position show here when you scroll"))

        hpanel = wx.Panel(self, -1)
        hbox = wx.BoxSizer(wx.HORIZONTAL)

        panel = wx.Panel(hpanel, -1)
        vbox = wx.BoxSizer(wx.VERTICAL)

        vbox = wx.BoxSizer(wx.VERTICAL)
        self.toolbar = wx.ToolBar(panel,
                                  -1,
                                  style=wx.TB_HORIZONTAL | wx.NO_BORDER
                                  | wx.TB_HORZ_TEXT)
        self.toolbar.AddTool(
            1,
            '',
            wx.Image(imagefile('zoom_in.png'),
                     wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
            _("Zoom In [+]"),
        )
        self.toolbar.AddTool(
            2, '',
            wx.Image(imagefile('zoom_out.png'),
                     wx.BITMAP_TYPE_PNG).ConvertToBitmap(), _("Zoom Out [-]"))
        self.toolbar.AddSeparator()
        self.toolbar.AddTool(
            3, '',
            wx.Image(imagefile('arrow_up.png'),
                     wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
            _("Move Up a Layer [U]"))
        self.toolbar.AddTool(
            4, '',
            wx.Image(imagefile('arrow_down.png'),
                     wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
            _("Move Down a Layer [D]"))
        self.toolbar.AddTool(5,
                             " " + _("Reset view"),
                             wx.Image(imagefile('reset.png'),
                                      wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                             shortHelp=_("Reset view"))
        self.toolbar.AddSeparator()
        self.toolbar.AddTool(
            6,
            '',
            wx.Image(imagefile('inject.png'),
                     wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
            wx.NullBitmap,
            shortHelp=_("Inject G-Code"),
            longHelp=_("Insert code at the beginning of this layer"))
        self.toolbar.AddTool(7,
                             '',
                             wx.Image(imagefile('edit.png'),
                                      wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
                             wx.NullBitmap,
                             shortHelp=_("Edit layer"),
                             longHelp=_("Edit the G-Code of this layer"))

        vbox.Add(self.toolbar, 0, border=5)

        panel.SetSizer(vbox)

        hbox.Add(panel, 1, flag=wx.EXPAND)
        self.layerslider = wx.Slider(hpanel,
                                     style=wx.SL_VERTICAL | wx.SL_AUTOTICKS
                                     | wx.SL_LEFT | wx.SL_INVERSE)
        self.layerslider.Bind(wx.EVT_SCROLL, self.process_slider)
        hbox.Add(self.layerslider, 0, border=5, flag=wx.LEFT | wx.EXPAND)
        hpanel.SetSizer(hbox)

        return panel, vbox
	def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Servo controller", pos = wx.DefaultPosition, size = wx.Size( 500,570 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
		
		self.SetSizeHintsSz( wx.Size( 300,570 ), wx.DefaultSize )
		
		mainFrameSizer = wx.BoxSizer( wx.VERTICAL )
		
		self.plotPanel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
		self.plotPanel.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOW ) )
		
		mainFrameSizer.Add( self.plotPanel, 1, wx.EXPAND|wx.ALL, 5 )
		
		self.frameHorDividerLine = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
		mainFrameSizer.Add( self.frameHorDividerLine, 0, wx.EXPAND |wx.ALL, 5 )
		
		self.controlPanel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
		self.controlPanel.SetMinSize( wx.Size( -1,120 ) )
		
		controlPanerHorSizer = wx.BoxSizer( wx.HORIZONTAL )
		
		demandSliderVertSizer = wx.BoxSizer( wx.VERTICAL )
		
		self.demandSliderLabel = wx.StaticText( self.controlPanel, wx.ID_ANY, u"Angle demand [degrees]", wx.DefaultPosition, wx.DefaultSize, 0 )
		self.demandSliderLabel.Wrap( -1 )
		demandSliderVertSizer.Add( self.demandSliderLabel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
		
		self.demandSlider = wx.Slider( self.controlPanel, wx.ID_ANY, 0, -90, 90, wx.DefaultPosition, wx.DefaultSize, wx.SL_LABELS )
		demandSliderVertSizer.Add( self.demandSlider, 1, wx.ALIGN_BOTTOM|wx.ALL|wx.EXPAND, 5 )
		
		
		controlPanerHorSizer.Add( demandSliderVertSizer, 1, wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, 5 )
		
		buttonAndDropdownVertSizer = wx.BoxSizer( wx.VERTICAL )
		
		self.portChoiceLabel = wx.StaticText( self.controlPanel, wx.ID_ANY, u"Serial port:", wx.DefaultPosition, wx.DefaultSize, 0 )
		self.portChoiceLabel.Wrap( -1 )
		buttonAndDropdownVertSizer.Add( self.portChoiceLabel, 0, wx.ALL|wx.EXPAND, 5 )
		
		portChoiceChoices = []
		self.portChoice = wx.Choice( self.controlPanel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, portChoiceChoices, 0 )
		self.portChoice.SetSelection( 0 )
		buttonAndDropdownVertSizer.Add( self.portChoice, 0, wx.ALIGN_BOTTOM|wx.ALIGN_RIGHT|wx.ALL|wx.EXPAND, 5 )
		
		buttonHorSizer = wx.BoxSizer( wx.HORIZONTAL )
		
		self.pauseButton = wx.Button( self.controlPanel, wx.ID_ANY, u"Pause", wx.DefaultPosition, wx.DefaultSize, 0 )
		buttonHorSizer.Add( self.pauseButton, 0, wx.ALL|wx.EXPAND, 5 )
		
		self.updatePortsButton = wx.Button( self.controlPanel, wx.ID_ANY, u"Update ports", wx.DefaultPosition, wx.DefaultSize, 0 )
		buttonHorSizer.Add( self.updatePortsButton, 0, wx.ALL|wx.EXPAND, 5 )
		
		
		buttonAndDropdownVertSizer.Add( buttonHorSizer, 1, wx.EXPAND, 5 )
		
		
		controlPanerHorSizer.Add( buttonAndDropdownVertSizer, 0, wx.ALL|wx.EXPAND, 5 )
		
		
		self.controlPanel.SetSizer( controlPanerHorSizer )
		self.controlPanel.Layout()
		controlPanerHorSizer.Fit( self.controlPanel )
		mainFrameSizer.Add( self.controlPanel, 0, wx.ALL|wx.EXPAND, 5 )
		
		
		self.SetSizer( mainFrameSizer )
		self.Layout()
		self.mainFrameMenuBar = wx.MenuBar( 0 )
		self.fileMenu = wx.Menu()
		self.exitItem = wx.MenuItem( self.fileMenu, wx.ID_ANY, u"Exit", wx.EmptyString, wx.ITEM_NORMAL )
		self.fileMenu.AppendItem( self.exitItem )
		
		self.mainFrameMenuBar.Append( self.fileMenu, u"File" ) 
		
		self.helpMenu = wx.Menu()
		self.helpItem = wx.MenuItem( self.helpMenu, wx.ID_ANY, u"Help", wx.EmptyString, wx.ITEM_NORMAL )
		self.helpMenu.AppendItem( self.helpItem )
		
		self.mainFrameMenuBar.Append( self.helpMenu, u"Help" ) 
		
		self.SetMenuBar( self.mainFrameMenuBar )
		
		
		self.Centre( wx.BOTH )
		
		# Connect Events
		self.Bind( wx.EVT_CLOSE, self.onClose )
		self.demandSlider.Bind( wx.EVT_SCROLL, self.onSliderPositionChanged )
		self.portChoice.Bind( wx.EVT_CHOICE, self.onChoseSerialPort )
		self.pauseButton.Bind( wx.EVT_BUTTON, self.onPause )
		self.updatePortsButton.Bind( wx.EVT_BUTTON, self.onUpdatePorts )
		self.Bind( wx.EVT_MENU, self.onClose, id = self.exitItem.GetId() )
		self.Bind( wx.EVT_MENU, self.onHelp, id = self.helpItem.GetId() )
Beispiel #25
0
def slider(element, parent):
    return update(element, wx.Slider(parent))
Beispiel #26
0
    def __init__(self, parent, model, mesh, solver):
        wx.Panel.__init__(self, parent)
        self.parent = parent
        self.model = model
        self.mesh = mesh
        self.solver = solver
        self.spec_list = []

        # layout
        box = wx.BoxSizer(wx.VERTICAL)

        box.AddSpacer(10)
        box.Add(wx.StaticText(self, -1, "Simulation Time (Sec)"),
                0,
                wx.ALIGN_CENTER,
                border=10)
        self.simtime_txt = wx.StaticText(self, -1,
                                         "%e" % (self.solver.getTime()))
        box.AddSpacer(10)
        box.Add(self.simtime_txt, 0, wx.ALIGN_CENTER, border=10)

        static1 = wx.StaticText(self, -1, "Stop at (Sec)")
        self.stoptime_text = wx.TextCtrl(self, -1, "1e-3")
        box.AddSpacer(10)
        box.Add(static1, 0, wx.ALIGN_CENTER, border=10)
        box.AddSpacer(10)
        box.Add(self.stoptime_text, 0, wx.ALIGN_CENTER, border=10)

        static2 = wx.StaticText(self, -1, "Advance Interval (Sec)")
        self.advance_text = wx.TextCtrl(self, -1, "1e-5")

        box.AddSpacer(10)
        box.Add(static2, 0, wx.ALIGN_CENTER, border=10)
        box.AddSpacer(10)
        box.Add(self.advance_text, 0, wx.ALIGN_CENTER, border=10)

        self.runbtn = wx.Button(self, -1, "Run")
        box.AddSpacer(10)
        box.Add(self.runbtn, 0, wx.ALIGN_CENTER, border=10)

        #self.replaybtn = wx.Button(self, -1, "Replay")
        #box.AddSpacer(10)
        #box.Add(self.replaybtn, 0, wx.ALIGN_CENTER, border = 10)

        box.AddSpacer(10)
        btn_box = wx.BoxSizer(wx.HORIZONTAL)
        self.savebtn = wx.Button(self, -1, "Save")
        btn_box.AddSpacer(5)
        btn_box.Add(self.savebtn, 0, wx.ALIGN_CENTER, border=10)

        self.loadbtn = wx.Button(self, -1, "Load")
        btn_box.AddSpacer(5)
        btn_box.Add(self.loadbtn, 0, wx.ALIGN_CENTER, border=10)

        box.Add(btn_box, 0, wx.ALIGN_CENTER, border=5)

        box.AddSpacer(20)
        box.Add(wx.StaticText(self, -1, "Species"),
                0,
                wx.ALIGN_CENTER,
                border=10)
        box.AddSpacer(10)
        self.spec_listbox = wx.ListBox(self, -1, style=wx.LB_SINGLE)
        box.Add(self.spec_listbox, 1, wx.ALIGN_CENTER, border=10)

        color_box = wx.BoxSizer(wx.HORIZONTAL)
        color_box.AddSpacer(10)
        self.specdisp_check = wx.CheckBox(self, -1, "Display")
        color_box.Add(self.specdisp_check, 0, wx.ALIGN_CENTER, border=10)
        self.speccolor_select = csel.ColourSelect(self, -1, colour=wx.RED)
        color_box.AddSpacer(10)
        color_box.Add(self.speccolor_select, 0, wx.ALIGN_CENTER, border=10)
        self.specsize_spin = wx.SpinCtrl(self, -1, "Size")
        self.specsize_spin.SetRange(1, 100)
        self.specsize_spin.SetValue(4)

        box.AddSpacer(10)
        box.Add(color_box, 0, wx.ALIGN_CENTER, border=10)

        size_box = wx.BoxSizer(wx.HORIZONTAL)
        size_box.AddSpacer(10)
        size_box.Add(wx.StaticText(self, -1, "Spec Size"),
                     0,
                     wx.ALIGN_CENTER,
                     border=10)
        size_box.AddSpacer(10)
        size_box.Add(self.specsize_spin, 0, wx.ALIGN_CENTER, border=10)

        box.AddSpacer(5)
        box.Add(size_box, 0, wx.ALIGN_CENTER, border=10)

        mesh_box = wx.BoxSizer(wx.HORIZONTAL)
        mesh_box.Add(wx.StaticText(self, -1, "Mesh Color"),
                     0,
                     wx.ALIGN_CENTER,
                     border=10)
        self.meshcolor_select = csel.ColourSelect(self, -1, colour=wx.BLACK)
        mesh_box.AddSpacer(20)
        mesh_box.Add(self.meshcolor_select, 0, wx.ALIGN_CENTER, border=10)

        box.AddSpacer(20)
        box.Add(mesh_box, 0, wx.ALIGN_CENTER, border=10)

        box.AddSpacer(5)
        box.Add(wx.StaticText(self, -1, "Transparency"),
                0,
                wx.ALIGN_CENTER,
                border=10)

        self.alpha_slider = wx.Slider(self,
                                      -1,
                                      255,
                                      0,
                                      255,
                                      style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS
                                      | wx.SL_LABELS)
        box.Add(self.alpha_slider, 0, wx.ALIGN_CENTER, border=10)

        background_box = wx.BoxSizer(wx.HORIZONTAL)
        background_box.Add(wx.StaticText(self, -1, "BG Color"),
                           0,
                           wx.ALIGN_CENTER,
                           border=10)
        self.backgroundcolor_select = csel.ColourSelect(self,
                                                        -1,
                                                        colour=wx.WHITE)
        background_box.AddSpacer(10)
        background_box.Add(self.backgroundcolor_select,
                           0,
                           wx.ALIGN_CENTER,
                           border=10)

        box.AddSpacer(10)
        box.Add(background_box, 0, wx.ALIGN_CENTER, border=10)

        box.AddSpacer(10)
        box.Add(wx.StaticText(self, -1, "Rotation"),
                0,
                wx.ALIGN_CENTER,
                border=10)
        self.rotatebox = wx.RadioBox(self, -1, "", wx.DefaultPosition,
                                     wx.DefaultSize, ["X", "Y", "Z"], 1,
                                     wx.RA_SPECIFY_ROWS)
        box.Add(self.rotatebox, 0, wx.ALIGN_CENTER, border=10)
        self.rotate_slider = wx.Slider(self,
                                       -1,
                                       20,
                                       -180,
                                       180,
                                       style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS
                                       | wx.SL_LABELS)
        box.Add(self.rotate_slider, 0, wx.ALIGN_CENTER, border=10)
        self.resetbtn = wx.Button(self, -1, "Reset")
        box.Add(self.resetbtn, 0, wx.ALIGN_CENTER, border=10)

        box.AddSpacer(20)
        self.SetSizerAndFit(box)

        # event binding
        self.meshcolor_select.Bind(csel.EVT_COLOURSELECT,
                                   self.OnMeshColorChange,
                                   id=self.meshcolor_select.GetId())
        self.alpha_slider.Bind(wx.EVT_SCROLL,
                               self.OnMeshAlphaChange,
                               id=self.alpha_slider.GetId())
        self.backgroundcolor_select.Bind(
            csel.EVT_COLOURSELECT,
            self.OnBGColorChange,
            id=self.backgroundcolor_select.GetId())
        self.spec_listbox.Bind(wx.EVT_LISTBOX,
                               self.OnSpecSelectChange,
                               id=self.spec_listbox.GetId())
        self.specdisp_check.Bind(wx.EVT_CHECKBOX,
                                 self.OnSpecDispChange,
                                 id=self.specdisp_check.GetId())
        self.speccolor_select.Bind(csel.EVT_COLOURSELECT,
                                   self.OnSpecColorChange,
                                   id=self.speccolor_select.GetId())
        self.specsize_spin.Bind(wx.EVT_SPINCTRL,
                                self.OnSpecSizeChange,
                                id=self.specsize_spin.GetId())
        self.runbtn.Bind(wx.EVT_BUTTON, self.OnRun, id=self.runbtn.GetId())
        self.rotatebox.Bind(wx.EVT_RADIOBOX,
                            self.OnCordChange,
                            id=self.rotatebox.GetId())
        self.rotate_slider.Bind(wx.EVT_SCROLL,
                                self.OnRotateDisp,
                                id=self.rotate_slider.GetId())
        self.resetbtn.Bind(wx.EVT_BUTTON,
                           self.OnResetView,
                           id=self.resetbtn.GetId())
        self.savebtn.Bind(wx.EVT_BUTTON, self.OnSave, id=self.savebtn.GetId())
        self.loadbtn.Bind(wx.EVT_BUTTON, self.OnLoad, id=self.loadbtn.GetId())
Beispiel #27
0
    def __init__(self, parent, log):
        self.log = log
        wx.Panel.__init__(self, parent, -1,
                          style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN)

        # Create some controls
        try:
            backend = "" # let MediaCtrl choose default backend
            #backend=wx.media.MEDIABACKEND_DIRECTSHOW
            #backend=wx.media.MEDIABACKEND_WMP10
            self.mc = wx.media.MediaCtrl()
            ok = self.mc.Create(self, style=wx.SIMPLE_BORDER,
                                szBackend=backend)
            if not ok:
                raise NotImplementedError
        except NotImplementedError:
            self.Destroy()
            raise

        # the following event is not sent with the Windows default backend
        # MEDIABACKEND_DIRECTSHOW
        # choose above e.g. MEDIABACKEND_WMP10 if this is a problem for you
        self.Bind(wx.media.EVT_MEDIA_LOADED, self.OnMediaLoaded)

        btn1 = wx.Button(self, -1, "Load File")
        self.Bind(wx.EVT_BUTTON, self.OnLoadFile, btn1)

        btn2 = wx.Button(self, -1, "Play")
        self.Bind(wx.EVT_BUTTON, self.OnPlay, btn2)
        self.playBtn = btn2

        btn3 = wx.Button(self, -1, "Pause")
        self.Bind(wx.EVT_BUTTON, self.OnPause, btn3)

        btn4 = wx.Button(self, -1, "Stop")
        self.Bind(wx.EVT_BUTTON, self.OnStop, btn4)

        slider = wx.Slider(self, -1, 0, 0, 10)
        self.slider = slider
        slider.SetMinSize((150, -1))
        self.Bind(wx.EVT_SLIDER, self.OnSeek, slider)

        self.st_size = StaticText(self, -1, size=(100,-1))
        self.st_len  = StaticText(self, -1, size=(100,-1))
        self.st_pos  = StaticText(self, -1, size=(100,-1))


        # setup the layout
        sizer = wx.GridBagSizer(5,5)
        sizer.Add(self.mc, (1,1), span=(5,1))#, flag=wx.EXPAND)
        sizer.Add(btn1, (1,3))
        sizer.Add(btn2, (2,3))
        sizer.Add(btn3, (3,3))
        sizer.Add(btn4, (4,3))
        sizer.Add(slider, (6,1), flag=wx.EXPAND)
        sizer.Add(self.st_size, (1, 5))
        sizer.Add(self.st_len,  (2, 5))
        sizer.Add(self.st_pos,  (3, 5))
        self.SetSizer(sizer)

        #self.DoLoadFile(os.path.abspath("data/testmovie.mpg"))
        wx.CallAfter(self.DoLoadFile, os.path.abspath("data/testmovie.mpg"))

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.timer.Start(100)
Beispiel #28
0
    def CreatePreferencePanel(self, prefpaneldata):
        """Create a preference panel for the given data."""

        panel = wx.Panel(self.notebook, -1)
        border = wx.BoxSizer(wx.VERTICAL)
        show_restart = False

        for group in prefpaneldata:
            # Create a header for each group of settings
            bsizer = wx.BoxSizer(wx.VERTICAL)
            bsizer.Add((0, 5))
            hsizer = wx.BoxSizer(wx.HORIZONTAL)
            hsizer.Add((12, 0))
            h = wx.StaticText(panel, -1, group.keys()[0])
            font = h.GetFont()
            font.SetWeight(wx.FONTWEIGHT_BOLD)
            h.SetFont(font)
            hsizer.Add(h)
            bsizer.Add(hsizer)
            bsizer.Add((0, 7))
            # Create a FlexGridSizer to contain the group of settings
            fgsizer = wx.FlexGridSizer(len(group.values()[0]), 4, 10, 4)
            fgsizer.AddGrowableCol(2, 1)
            # Create controls for each setting
            for setting in group.values()[0]:
                fgsizer.Add((24, 0))
                # Show the restart asterisk for this setting if required
                restart = str('*' if 'restart' in setting else '')
                if ('restart' in setting):
                    if (setting['restart'] == True):
                        show_restart = True
                t = wx.StaticText(panel,
                                  -1,
                                  setting['name'] + restart + ':',
                                  style=wx.ALIGN_RIGHT)
                fgsizer.Add(t, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
                sizer = wx.BoxSizer(wx.HORIZONTAL)

                # Get the setting value
                value = GetValue(self.values, setting)
                # Save the setting value in case it hasn't been saved previously
                SetValue(self.values, setting['callback'], value)

                # If this is a choice setting
                if (setting['type'] == 'choice'):
                    c = wx.Choice(panel, -1, choices=setting['values'])
                    c.SetStringSelection(value)
                    sizer.Add(c, 0, wx.ALIGN_CENTER)
                    # Add control to the callback dict
                    self.callbackdict[c] = setting['callback']
                    self.Bind(wx.EVT_CHOICE, self.OnUpdateChoice, c)
                # If this is a checkbox setting
                elif (setting['type'] == 'checkbox'):
                    c = wx.CheckBox(panel, -1, setting['name'] + restart)
                    c.SetValue(value)
                    sizer.Add(c, 0, wx.ALIGN_CENTER)
                    # Remove the label preceding the checkbox
                    t = self.FindWindowById(c.PrevControlId(c.GetId()))
                    t.SetLabel('')
                    # Adjust the sizer preceding the label
                    fgsizer.GetItem(0).SetSpacer((20, 0))
                    # Add control to the callback dict
                    self.callbackdict[c] = setting['callback']
                    self.Bind(wx.EVT_CHECKBOX, self.OnUpdateCheckbox, c)
                # If this is a range setting
                elif (setting['type'] == 'range'):
                    s = wx.Slider(panel,
                                  -1,
                                  value,
                                  setting['values'][0],
                                  setting['values'][1],
                                  size=(120, -1),
                                  style=wx.SL_HORIZONTAL)
                    sizer.Add(s, 0, wx.ALIGN_CENTER)
                    t = wx.StaticText(panel, -1, str(value))
                    sizer.Add((3, 0))
                    sizer.Add(t, 0, wx.ALIGN_CENTER)
                    sizer.Add((6, 0))
                    t = wx.StaticText(panel, -1, setting['units'])
                    sizer.Add(t, 0, wx.ALIGN_CENTER)
                    # Add control to the callback dict
                    self.callbackdict[s] = setting['callback']
                    self.Bind(wx.EVT_COMMAND_SCROLL_THUMBTRACK,
                              self.OnUpdateSlider, s)
                    self.Bind(wx.EVT_COMMAND_SCROLL_CHANGED,
                              self.OnUpdateSlider, s)
                # If this is a directory location setting
                elif (setting['type'] == 'directory'):
                    # Check if the value is a valid directory,
                    # otherwise set it to the default directory
                    if not os.path.isdir(value):
                        value = setting['default']
                        SetValue(self.values, setting['callback'], value)
                    t = wx.TextCtrl(panel, -1, value, style=wx.TE_READONLY)
                    sizer.Add(t, 1, wx.ALIGN_CENTER)
                    sizer.Add((5, 0))
                    b = wx.Button(panel, -1, "Browse...")
                    sizer.Add(b, 0, wx.ALIGN_CENTER)
                    # Add control to the callback dict
                    self.callbackdict[b] = setting['callback']
                    self.Bind(wx.EVT_BUTTON, self.OnUpdateDirectory, b)
                # Modify the control and font size on Mac
                for child in panel.GetChildren():
                    guiutil.adjust_control(child)
                fgsizer.Add(sizer, 1, wx.EXPAND | wx.ALL)
                fgsizer.Add((12, 0))
            bsizer.Add(fgsizer, 0, wx.EXPAND | wx.ALL)
            border.Add(bsizer, 0, wx.EXPAND | wx.ALL, 2)
        border.Add((60, 20), 0, wx.EXPAND | wx.ALL)
        # Show the restart text for this group if required for >= 1 setting
        if show_restart:
            r = wx.StaticText(panel, -1,
                              '* Restart ' + self.appname + \
                              ' for this setting to take effect.',
                              style=wx.ALIGN_CENTER)
            font = r.GetFont()
            font.SetWeight(wx.FONTWEIGHT_BOLD)
            r.SetFont(font)
            border.Add((0, 0), 1, wx.EXPAND | wx.ALL)
            rhsizer = wx.BoxSizer(wx.HORIZONTAL)
            rhsizer.Add((0, 0), 1, wx.EXPAND | wx.ALL)
            rhsizer.Add(r)
            rhsizer.Add((0, 0), 1, wx.EXPAND | wx.ALL)
            border.Add(rhsizer, 0, wx.EXPAND | wx.ALL)
            border.Add((0, 5))
        panel.SetSizer(border)

        return panel
Beispiel #29
0
    def __init__(self, parent):
        wx.Frame.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          title=_(u"Subtitle Speech Synchronizer"),
                          pos=wx.DefaultPosition,
                          size=wx.Size(-1, -1),
                          style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL,
                          name=u"Subtitle Speech Synchronizer")

        self.SetSizeHints(wx.Size(-1, -1), wx.DefaultSize)

        bSizer1 = wx.BoxSizer(wx.VERTICAL)

        self.m_panelMain = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition,
                                    wx.DefaultSize, wx.TAB_TRAVERSAL)
        bSizer2 = wx.BoxSizer(wx.VERTICAL)

        self.m_panel2 = wx.Panel(self.m_panelMain, wx.ID_ANY,
                                 wx.DefaultPosition, wx.DefaultSize,
                                 wx.TAB_TRAVERSAL)
        fgSizer1 = wx.FlexGridSizer(0, 1, 0, 0)
        fgSizer1.AddGrowableCol(0)
        fgSizer1.AddGrowableRow(5)
        fgSizer1.SetFlexibleDirection(wx.BOTH)
        fgSizer1.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.m_staticText3 = wx.StaticText(self.m_panel2, wx.ID_ANY,
                                           _(u"Subtitles:"),
                                           wx.DefaultPosition, wx.DefaultSize,
                                           0)
        self.m_staticText3.Wrap(-1)

        fgSizer1.Add(self.m_staticText3, 0,
                     wx.EXPAND | wx.TOP | wx.RIGHT | wx.LEFT, 5)

        self.m_panelSub = SubPanel(self.m_panel2, wx.ID_ANY,
                                   wx.DefaultPosition, wx.DefaultSize,
                                   wx.TAB_TRAVERSAL)
        fgSizer1.Add(self.m_panelSub, 1, wx.EXPAND | wx.ALL, 5)

        self.m_staticText31 = wx.StaticText(
            self.m_panel2, wx.ID_ANY,
            _(u"References (video or other subtitles):"), wx.DefaultPosition,
            wx.DefaultSize, 0)
        self.m_staticText31.Wrap(-1)

        fgSizer1.Add(self.m_staticText31, 0,
                     wx.TOP | wx.RIGHT | wx.LEFT | wx.EXPAND, 5)

        self.m_panelRef = RefPanel(self.m_panel2, wx.ID_ANY,
                                   wx.DefaultPosition, wx.DefaultSize,
                                   wx.TAB_TRAVERSAL)
        fgSizer1.Add(self.m_panelRef, 1, wx.EXPAND | wx.ALL, 5)

        fgSizer5 = wx.FlexGridSizer(1, 0, 0, 0)
        fgSizer5.AddGrowableCol(2)
        fgSizer5.AddGrowableRow(0)
        fgSizer5.SetFlexibleDirection(wx.BOTH)
        fgSizer5.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.m_staticText32 = wx.StaticText(self.m_panel2, wx.ID_ANY,
                                            _(u"Max adjustment:"),
                                            wx.DefaultPosition, wx.DefaultSize,
                                            0)
        self.m_staticText32.Wrap(-1)

        fgSizer5.Add(self.m_staticText32, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                     5)

        self.m_buttonMaxDistInfo = PopupInfoButton(
            self.m_panel2, wx.ID_ANY, wx.NullBitmap, wx.DefaultPosition,
            wx.DefaultSize, wx.BU_AUTODRAW | 0 | wx.BORDER_NONE)

        self.m_buttonMaxDistInfo.SetBitmap(
            wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_BUTTON))
        fgSizer5.Add(
            self.m_buttonMaxDistInfo, 0,
            wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND,
            5)

        self.m_sliderMaxDist = wx.Slider(self.m_panel2, wx.ID_ANY, 30, 5, 180,
                                         wx.DefaultPosition, wx.DefaultSize,
                                         wx.SL_HORIZONTAL)
        fgSizer5.Add(
            self.m_sliderMaxDist, 0, wx.ALL | wx.EXPAND
            | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL, 5)

        self.m_textMaxDist = wx.StaticText(self.m_panel2, wx.ID_ANY,
                                           _(u"999 min"), wx.DefaultPosition,
                                           wx.DefaultSize, wx.ST_NO_AUTORESIZE)
        self.m_textMaxDist.Wrap(-1)

        fgSizer5.Add(self.m_textMaxDist, 0,
                     wx.ALIGN_CENTER_VERTICAL | wx.ALL | wx.FIXED_MINSIZE, 5)

        fgSizer1.Add(fgSizer5, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)

        fgSizer1.Add((0, 0), 1, wx.EXPAND, 5)

        self.m_staticline1 = wx.StaticLine(self.m_panel2, wx.ID_ANY,
                                           wx.DefaultPosition, wx.DefaultSize,
                                           wx.LI_HORIZONTAL)
        fgSizer1.Add(self.m_staticline1, 0, wx.EXPAND | wx.ALL, 5)

        fgSizer8 = wx.FlexGridSizer(1, 0, 0, 0)
        fgSizer8.SetFlexibleDirection(wx.BOTH)
        fgSizer8.SetNonFlexibleGrowMode(wx.FLEX_GROWMODE_SPECIFIED)

        self.m_buttonMenu = wx.Button(self.m_panel2, wx.ID_ANY, _(u"Menu"),
                                      wx.DefaultPosition, wx.DefaultSize,
                                      wx.BU_EXACTFIT)
        self.m_menu = wx.Menu()
        self.m_menuItemBatchProcessing = wx.MenuItem(self.m_menu, wx.ID_ANY,
                                                     _(u"Batch processing"),
                                                     wx.EmptyString,
                                                     wx.ITEM_NORMAL)
        self.m_menu.Append(self.m_menuItemBatchProcessing)

        self.m_menu.AppendSeparator()

        self.m_menuItemSettings = wx.MenuItem(self.m_menu, wx.ID_PROPERTIES,
                                              _(u"Settings"), wx.EmptyString,
                                              wx.ITEM_NORMAL)
        self.m_menu.Append(self.m_menuItemSettings)

        self.m_menuItemCheckUpdate = wx.MenuItem(self.m_menu, wx.ID_ANY,
                                                 _(u"Check for updates"),
                                                 wx.EmptyString,
                                                 wx.ITEM_NORMAL)
        self.m_menu.Append(self.m_menuItemCheckUpdate)

        self.m_menu.AppendSeparator()

        self.m_menuItemAbout = wx.MenuItem(self.m_menu, wx.ID_ABOUT,
                                           _(u"About"), wx.EmptyString,
                                           wx.ITEM_NORMAL)
        self.m_menu.Append(self.m_menuItemAbout)

        self.m_buttonMenu.Bind(wx.EVT_RIGHT_DOWN,
                               self.m_buttonMenuOnContextMenu)

        fgSizer8.Add(self.m_buttonMenu, 1, wx.ALL | wx.EXPAND, 5)

        self.m_buttonClose = wx.Button(self.m_panel2, wx.ID_CLOSE, _(u"Close"),
                                       wx.DefaultPosition, wx.DefaultSize, 0)
        fgSizer8.Add(self.m_buttonClose, 1, wx.ALL | wx.EXPAND, 5)

        self.m_buttonStart = wx.Button(self.m_panel2, wx.ID_OK, _(u"Start"),
                                       wx.DefaultPosition, wx.DefaultSize, 0)

        self.m_buttonStart.SetDefault()
        fgSizer8.Add(self.m_buttonStart, 1, wx.ALL | wx.EXPAND, 5)

        fgSizer1.Add(fgSizer8, 1, wx.ALIGN_RIGHT, 5)

        self.m_panel2.SetSizer(fgSizer1)
        self.m_panel2.Layout()
        fgSizer1.Fit(self.m_panel2)
        bSizer2.Add(self.m_panel2, 1, wx.EXPAND | wx.ALL, 5)

        self.m_panelMain.SetSizer(bSizer2)
        self.m_panelMain.Layout()
        bSizer2.Fit(self.m_panelMain)
        bSizer1.Add(self.m_panelMain, 1, wx.EXPAND, 5)

        self.SetSizer(bSizer1)
        self.Layout()
        bSizer1.Fit(self)

        # Connect Events
        self.Bind(wx.EVT_CLOSE, self.onClose)
        self.m_sliderMaxDist.Bind(wx.EVT_SCROLL, self.onSliderMaxDistScroll)
        self.m_buttonMenu.Bind(wx.EVT_BUTTON, self.onButtonMenuClick)
        self.Bind(wx.EVT_MENU,
                  self.onMenuItemBatchProcessingClick,
                  id=self.m_menuItemBatchProcessing.GetId())
        self.Bind(wx.EVT_MENU,
                  self.onMenuItemSettingsClick,
                  id=self.m_menuItemSettings.GetId())
        self.Bind(wx.EVT_MENU,
                  self.onMenuItemCheckUpdateClick,
                  id=self.m_menuItemCheckUpdate.GetId())
        self.Bind(wx.EVT_MENU,
                  self.onMenuItemAboutClick,
                  id=self.m_menuItemAbout.GetId())
        self.m_buttonClose.Bind(wx.EVT_BUTTON, self.onButtonCloseClick)
        self.m_buttonStart.Bind(wx.EVT_BUTTON, self.onButtonStartClick)
    def __init__(self,
                 parent,
                 minus_button_image,
                 plus_button_image,
                 initial_visual_effect='',
                 initial_equalizer_active=False,
                 initial_equalizer_preset='',
                 SetStep=10,
                 SetMin=0,
                 SetMax=100,
                 initial_preamp=0,
                 SetPreampCallback=None):
        '''
Visualizer filter
   General:
	  --effect-list=<string>     Effects list
		  A list of visual effect, separated by commas.
Current effects
		  include: dummy, scope, spectrum, spectrometer and vuMeter.
	  --effect-width=<integer [-2147483648 .. 2147483647]>
								 Video width
		  The width of the effects video window, in pixels.
	  --effect-height=<integer [-2147483648 .. 2147483647]>
								 Video height
		  The height of the effects video window, in pixels.
   Spectrum analyser:
	  --visual-80-bands, --no-visual-80-bands
								 Show 80 bands instead of 20 (default enabled)
		  Show 80 bands instead of 20 (default enabled)
	  --visual-peaks, --no-visual-peaks
								 Draw peaks in the analyzer (default enabled)
		  Draw peaks in the analyzer (default enabled)
   Spectrometer:
	  --spect-show-original, --no-spect-show-original
								 Enable original graphic spectrum (default
								 disabled)
		  Enable the "flat" spectrum analyzer in the spectrometer. (default
		  disabled)
	  --spect-show-base, --no-spect-show-base
								 Draw the base of the bands (default enabled)
		  Draw the base of the bands (default enabled)
	  --spect-radius=<integer [-2147483648 .. 2147483647]>
								 Base pixel radius
		  Defines radius size in pixels, of base of bands(beginning).
	  --spect-sections=<integer [-2147483648 .. 2147483647]>
								 Spectral sections
		  Determines how many sections of spectrum will exist.
	  --spect-color=<integer [-2147483648 .. 2147483647]>
								 V-plane color
		  YUV-Color cube shifting across the V-plane ( 0 - 127 ).
	  --spect-show-bands, --no-spect-show-bands
								 Draw bands in the spectrometer (default
								 enabled)
		  Draw bands in the spectrometer (default enabled)
	  --spect-80-bands, --no-spect-80-bands
								 Show 80 bands instead of 20 (default enabled)
		  Show 80 bands instead of 20 (default enabled)
	  --spect-separ=<integer [-2147483648 .. 2147483647]>
								 Number of blank pixels between bands.
		  Number of blank pixels between bands.
	  --spect-amp=<integer [-2147483648 .. 2147483647]>
								 Amplification
		  This is a coefficient that modifies the height of the bands.
	  --spect-show-peaks, --no-spect-show-peaks
								 Draw peaks in the analyzer (default enabled)
		  Draw peaks in the analyzer (default enabled)
	  --spect-peak-width=<integer [-2147483648 .. 2147483647]>
								 Peak extra width
		  Additions or subtractions of pixels on the peak width.
	  --spect-peak-height=<integer [-2147483648 .. 2147483647]>
								 Peak height
		  Total pixel height of the peak items.

 libprojectM effect
	  --projectm-preset-path=<string>
								 projectM preset path
		  Path to the projectM preset directory
	  --projectm-title-font=<string>
								 Title font
		  Font used for the titles
	  --projectm-menu-font=<string>
								 Font menu
		  Font used for the menus
	  --projectm-width=<integer [-2147483648 .. 2147483647]>
								 Video width
		  The width of the video window, in pixels.
	  --projectm-height=<integer [-2147483648 .. 2147483647]>
								 Video height
		  The height of the video window, in pixels.
	  --projectm-meshx=<integer [-2147483648 .. 2147483647]>
								 Mesh width
		  The width of the mesh, in pixels.
	  --projectm-meshy=<integer [-2147483648 .. 2147483647]>
								 Mesh height
		  The height of the mesh, in pixels.
	  --projectm-texture-size=<integer [-2147483648 .. 2147483647]>
								 Texture size
		  The size of the texture, in pixels.

 Goom effect
	  --goom-width=<integer [-2147483648 .. 2147483647]>
								 Goom display width
		  This allows you to set the resolution of the Goom display (bigger
		  resolution will be prettier but more CPU intensive).
	  --goom-height=<integer [-2147483648 .. 2147483647]>
								 Goom display height
		  This allows you to set the resolution of the Goom display (bigger
		  resolution will be prettier but more CPU intensive).
	  --goom-speed=<integer [1 .. 10]>
								 Goom animation speed
		  This allows you to set the animation speed (between 1 and 10,
		  defaults to 6).
		  '''
        wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

        initial_visual_effect, initial_equalizer_active, initial_equalizer_preset

        #visual_effects_label = wx.StaticText( self, label ='Visual effects' )
        #
        #visual_effects_dropdown = wx.ComboBox( self, wx.ID_ANY, value = initial_visual_effect,  choices = ['dummy', 'scope', 'spectrum', 'spectrometer', 'vuMeter', 'libprojectM', 'goom' ])
        #equalizer_ctrl = wx.CheckBox( self, wx.ID_ANY, 'Equalizer effects' )
        #self.equalizer_presets_dropdown = wx.ComboBox( self, wx.ID_ANY, value = initial_equalizer_preset, style = wx.CB_READONLY|wx.CB_SORT, choices = ['flat', 'classical', 'club' ,'dance', 'fullbass', 'fullbasstreble', 'fulltreble', 'headphones', 'largehall', 'live', 'party', 'pop', 'reggae', 'rock', 'ska', 'soft', 'softrock', 'techno' ] )

        #if( initial_equalizer_active ):
        #equalizer_ctrl.SetValue( True )
        #else:
        #equalizer_ctrl.SetValue( False )
        #self.equalizer_presets_dropdown.Enable( False )

        #equalizer_ctrl.Bind( wx.EVT_CHECKBOX, self.EnableEqualizerPresets )

        self.SetStep = SetStep
        self.SetMin = -100  #SetMin
        self.SetMax = 100  #SetMax

        self.preamp = initial_preamp

        self.SetPreampCallback = SetPreampCallback
        preampL = wx.StaticText(self, label="Preamp")
        minusPreampBtn = wx.StaticBitmap(self, bitmap=minus_button_image)
        plusPreampBtn = wx.StaticBitmap(self, bitmap=plus_button_image)
        self.preampSlider = wx.Slider(self,
                                      -1,
                                      self.preamp,
                                      self.SetMin,
                                      self.SetMax,
                                      size=(100, -1),
                                      style=wx.SL_AUTOTICKS | wx.SL_LABELS)
        self.Bind(wx.EVT_SLIDER, self.OnSetPreamp, self.preampSlider)
        minusPreampBtn.Bind(wx.EVT_LEFT_UP, self.DecreasePreamp)
        plusPreampBtn.Bind(wx.EVT_LEFT_UP, self.IncreasePreamp)

        ctrlbox = wx.BoxSizer(wx.VERTICAL)

        gridSizer = wx.FlexGridSizer(rows=2, cols=2, hgap=5, vgap=5)
        gridSizer.AddGrowableCol(1)

        pbox = wx.BoxSizer(wx.HORIZONTAL)
        pbox.Add(minusPreampBtn, 0, wx.CENTER)
        pbox.Add(self.preampSlider,
                 1,
                 wx.EXPAND | wx.CENTER | wx.BOTTOM,
                 border=15)
        pbox.Add(plusPreampBtn, 0, wx.CENTER)

        gridSizer.AddMany([
            #( visual_effects_label,0,wx.ALIGN_CENTER_VERTICAL ), ( visual_effects_dropdown, 1, wx.EXPAND ),
            #( equalizer_ctrl,0,wx.ALIGN_CENTER_VERTICAL ), ( self.equalizer_presets_dropdown, 1, wx.EXPAND )
            (preampL, 0, wx.ALIGN_CENTER_VERTICAL),
            (pbox, 1, wx.EXPAND),
        ])
        ctrlbox.Add(gridSizer, 1, wx.EXPAND | wx.ALL, border=10)

        self.SetSizer(ctrlbox)