Ejemplo n.º 1
0
class ScrubberDemo(HasTraits):

    # Define some sample ranges and values:
    simple_integer = Range(0, 100)
    rollover_float = Range(-10.0, 10.0)
    bordered_unbounded = Float
    themed_dynamic_low = Range(high=-0.01, value=-10.0)
    themed_dynamic_high = Range(low=0.01, value=10.0)
    themed_dynamic_value = Range('themed_dynamic_low', 'themed_dynamic_high',
                                 0.0)

    # Define the demo view:
    view = View(HGroup(
        VGroup(Item('simple_integer', editor=ScrubberEditor()),
               Item('rollover_float',
                    editor=ScrubberEditor(hover_color=0xFFFFFF,
                                          active_color=0xA0CD9E)),
               Item('bordered_unbounded',
                    editor=ScrubberEditor(hover_color=0xFFFFFF,
                                          active_color=0xA0CD9E,
                                          border_color=0x808080)),
               TItem('themed_dynamic_low'),
               TItem('themed_dynamic_high'),
               TItem('themed_dynamic_value'),
               show_border=True,
               label='Scrubber Editors'),
        VGroup(Item('simple_integer'),
               Item('rollover_float'),
               Item('bordered_unbounded'),
               Item('themed_dynamic_low'),
               Item('themed_dynamic_high'),
               Item('themed_dynamic_value'),
               show_border=True,
               label='Default Editors'), spring),
                title='Scrubber Editor Demo')
Ejemplo n.º 2
0
from enthought.traits.api import \
    Str, Float, HasTraits, Property, cached_property, Range, Instance, on_trait_change, Enum

from enthought.chaco.api import Plot, AbstractPlotData, ArrayPlotData, VPlotContainer

from enthought.traits.ui.api import \
    Item, View, VGroup, HSplit, ScrubberEditor, VSplit

from enthought.enable.api import Component, ComponentEditor
from enthought.chaco.tools.api import PanTool, ZoomTool

import numpy as np

# 鼠标拖动修改值的控件的样式
scrubber = ScrubberEditor(hover_color=0xFFFFFF,
                          active_color=0xA0CD9E,
                          border_color=0x808080)


# 取FFT计算的结果freqs中的前n项进行合成,返回合成结果,计算loops个周期的波形
def fft_combine(freqs, n, loops=1):
    length = len(freqs) * loops
    data = np.zeros(length)
    index = loops * np.arange(0, length, 1.0) / length * (2 * np.pi)
    for k, p in enumerate(freqs[:n]):
        if k != 0: p *= 2  # 除去直流成分之外,其余的系数都*2
        data += np.real(p) * np.cos(k * index)  # 余弦成分的系数为实数部
        data -= np.imag(p) * np.sin(k * index)  # 正弦成分的系数为负的虚数部
    return index, data

Ejemplo n.º 3
0
def scrubber(inc):
    '''创建不同增量的ScrubberEditor'''
    return ScrubberEditor(hover_color=0xFFFFFF,
                          active_color=0xA0CD9E,
                          border_color=0x808080,
                          increment=inc)
Ejemplo n.º 4
0
class TItem(Item):
    editor = ScrubberEditor()
    item_theme = ATheme('@std:LG')