Exemple #1
0
 def __init__(self, util, bgr=None, bb=None, rows=3, cols=3, create_item_method=None, menu_button_layout=None,
              font_size=None, align=ALIGN_CENTER, button_padding_x=None):
     """ Initializer
     
     :param util: utility object
     :param bgr: menu background
     :param bb: bounding box
     :param rows: number of rows in menu
     :param cols: number of columns in menu
     :param create_item_method: factory method for menu item creation
     :param menu_button_layout: menu buttons layout
     """        
     Container.__init__(self, util, bb, bgr)
     self.bb = bb
     self.rows = rows
     self.cols = cols
     self.util = util
     self.menu_button_layout = menu_button_layout
     self.start_listeners = []
     self.move_listeners = []
     self.menu_loaded_listeners = []
     self.font_size = font_size
     self.button_padding_x = button_padding_x
            
     self.buttons = {}
     self.factory = Factory(util)
     self.create_item_method = create_item_method
     self.selected_index = None
     self.align = align
Exemple #2
0
 def __init__(self, util, name, bb, font_size=None, bgr=None, fgr=None, halign=1, valign=4, shift_x=0, shift_y=0, full_width=False, font=None):
     """ Initializer
     
     :param util: utility object
     :param name: component name
     :param bb: bounding box
     :param bgr: background color
     :param fgr: text color
     :param font_size: font size
     :param halign: horizontal alignment
     :param valign: vertical alignment
     :param shift_x: X axis shift
     :param shift_y: Y axis shift
     :param full_width: True - use the whole bounding box width, False - use reduced width
     :param font: the font
     """
     Container.__init__(self, util, background=bgr, bounding_box=bb)
     self.util = util
     self.name = name
     self.default_font_size = font_size       
     self.font = font
     self.fgr = fgr
     self.bgr = bgr
     self.halign = halign
     self.valign = valign
     self.shift_x, self.shift_y = shift_x, shift_y
     self.full_width = full_width
     self.add_bgr()
Exemple #3
0
    def __init__(self, util):
        """ Initializer
        
        :param util: contains configuration object
        """
        Container.__init__(self, util, util.screen_rect, (0, 0, 0))
        self.config = util.config
        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, plugin_folder)
        self.bounding_box = util.screen_rect
        self.name = CLOCK

        military_time_format = self.plugin_config_file.getboolean(
            PLUGIN_CONFIGURATION, MILITARY_TIME_FORMAT)
        if military_time_format:
            self.TIME_FORMAT = "%H:%M"
        else:
            self.TIME_FORMAT = "%I:%M"

        self.animated = self.plugin_config_file.getboolean(
            PLUGIN_CONFIGURATION, ANIMATED)
        if self.animated:
            font_vertical_percent = 20
        else:
            font_vertical_percent = 50

        font_size = int((font_vertical_percent * self.bounding_box.h) / 100)
        self.f = util.get_font(font_size)

        self.component = Component(util)
        self.component.name = GENERATED_IMAGE + self.name
        self.component.image_filename = self.component.name
        self.add_component(self.component)
Exemple #4
0
    def __init__(self, util):
        """ Initializer
        
        :param util: utility object
        """
        self.util = util
        self.config = util.config
        self.screen_w = self.config[SCREEN_INFO][WIDTH]
        self.screen_h = self.config[SCREEN_INFO][HEIGHT]
        self.lines = 12
        line_length = 52
        font_vertical_percent = 5
        self.name = LYRICS

        self.lyrics_util = LyricsUtil(util.k2, self.lines, line_length)
        self.lyrics_not_found_label = self.config[LABELS][LYRICS_NOT_FOUND]

        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, plugin_folder)
        self.bounding_box = util.screen_rect
        Container.__init__(self, util, self.bounding_box, (0, 0, 0))

        font_size = int((font_vertical_percent * self.bounding_box.h) / 100)
        self.f = util.get_font(font_size)
        self.lyrics_not_found = True

        c = Component(util, bgr=(0, 0, 0))
        c.name = "base"
        self.set_not_found(c)
        self.add_component(c)
        self.current_page = 1
        self.current_song = ""
Exemple #5
0
    def __init__(self, util, bounding_box, listeners, bgr):
        """ Initializer
        
        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        :param bgr: menu background        
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "timer.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []
        self.bgr = bgr

        self.layout = GridLayout(bounding_box)
        self.layout.set_pixel_constraints(1, 3, 1, 0)
        self.layout.current_constraints = 0
        self.image_size = 64

        self.home_button = self.add_button(KEY_HOME, KEY_HOME,
                                           listeners[KEY_HOME])
        self.sleep_now_button = self.add_button(SLEEP_NOW, KEY_MUTE,
                                                listeners[SLEEP_NOW])
        self.player_button = self.add_button(KEY_PLAYER, KEY_PLAY_PAUSE,
                                             listeners[KEY_PLAYER])
Exemple #6
0
    def __init__(self, util, listeners, bgr=None, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param listeners: menu listeners
        :param bgr: menu background
        :param bounding_box: bounding box
        """   
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "collection.navigator"
        self.content = self.bounding_box = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        layout = GridLayout(bounding_box)
        layout.set_pixel_constraints(1, 3, 1, 0)
        layout.current_constraints = 0

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(KEY_HOME, KEY_HOME, constr, listeners[KEY_HOME], bgr, IMAGE_SIZE)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(KEY_BACK, KEY_BACK, constr, listeners[KEY_BACK], bgr, IMAGE_SIZE)
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
        
        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(KEY_PLAYER, KEY_PLAY_PAUSE, constr, listeners[KEY_PLAYER], bgr, IMAGE_SIZE)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
Exemple #7
0
 def __init__(self, util, meter_type, image_folder, ui_refresh_period, left_channel_queue=None, right_channel_queue=None, mono_channel_queue=None):
     """ Initializer
     
     :param util: utility class
     :param meter_type: the type of the meter - linear or circular
     :param image_folder: image folder
     :param ui_refresh_period: refresh interval for animation
     :param left_channel_queue: left channel queue
     :param right_channel_queue: right channel queue
     :param mono_channel_queue: mono channel queue
     """
     self.util = util
     self.config = util.config
     self.meter_type = meter_type
     self.image_folder = image_folder
     self.ui_refresh_period = ui_refresh_period
     self.left_channel_queue = left_channel_queue
     self.right_channel_queue = right_channel_queue
     self.mono_channel_queue = mono_channel_queue
     self.rect = self.config[SCREEN_RECT]
     Container.__init__(self, util, self.rect, (0, 0, 0))
     self.max_volume = 0.0
     self.total_steps = 100
     self.origin_x = self.origin_y = 0
     self.meter_bounding_box = None
     self.bgr = None
     self.fgr = None
     self.left_sprites = None
     self.right_sprites = None
     self.needle_sprites = None
     self.mono_needle_rects = None
     self.left_needle_rects = None
     self.right_needle_rects = None
     self.masks = None
     self.channels = 1
Exemple #8
0
    def __init__(self, util):
        """ Initializer
        
        :param util: contains config object
        """
        self.name = LOGO
        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, self.name, util, plugin_folder)
        Container.__init__(self,
                           util,
                           bounding_box=util.screen_rect,
                           background=self.bg[1],
                           content=self.bg[2],
                           image_filename=self.bg[3])

        self.config = util.config
        self.image_util = util.image_util
        self.util = util
        vertical_size_percent = self.plugin_config_file.getint(
            PLUGIN_CONFIGURATION, VERTICAL_SIZE_PERCENT)
        self.logo_size = int(
            (vertical_size_percent * self.bounding_box.h) / 100)
        self.r = pygame.Rect(0, 0, self.logo_size, self.logo_size)

        self.component = Component(util)
        self.component.name = GENERATED_IMAGE + self.name
        self.component.image_filename = self.component.name
        self.add_component(self.component)
Exemple #9
0
 def __init__(self, util, state):
     """ Initializer
     
     :param util: utility object
     :param state: button state
     """
     self.util = util
     self.config = self.util.config
     Container.__init__(self, util)
     self.set_state(state)
     self.press_listeners = []
     self.release_listeners = []
     self.label_listeners = []
     self.bounding_box = state.bounding_box
     self.bgr = getattr(state, "bgr", (0, 0, 0))
     self.selected = None
     self.press_time = 0
     self.LONG_PRESS_TIME = self.config[USAGE][USE_LONG_PRESS_TIME]
     self.parent_screen = None
     self.key_events = [
         kbd_keys[KEY_LEFT], kbd_keys[KEY_RIGHT], kbd_keys[KEY_UP],
         kbd_keys[KEY_DOWN]
     ]
     self.enter_y = None
     self.ignore_enter_y = True
Exemple #10
0
    def __init__(self, util, bb, callback, screen):
        """ Initializer

        :param util: utility object
        :param bb: bounding box
        :param callback: function to call on Enter
        :param screen: parent screen
        """
        Container.__init__(self, util, bb, (0, 0, 0))
        self.content = None
        self.screen = screen
        self.bb = bb
        self.util = util
        self.config = util.config
        self.callback = callback
        self.move_listeners = []
        self.text_listeners = []
        self.buttons = {}
        self.factory = Factory(util)
        self.caps = False
        self.text = ""

        self.controls = ["Caps", "Del", "abc", "ABC", "123", "#+=", "Enter"]
        self.keyboards = {}
        self.current_keyboard_type = None
        self.create_keyboard(KEYBOARD_abc, LAYOUT_1, TRANSITION_MAP_1)
Exemple #11
0
    def __init__(self, util, bounding_box, listeners):
        """ Initializer

        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "collection.navigator"
        self.content = None
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.listeners = listeners
        self.menu_buttons = []
        self.config = util.config
        self.use_web = self.config[USAGE][USE_WEB]
        self.go_abc = listeners[KEY_ABC]
        self.go_keyboard = listeners[KEY_KEYBOARD_KEY]
        self.keyboard_callback = listeners[KEY_CALLBACK]
        self.bgr = util.config[BACKGROUND][FOOTER_BGR_COLOR]
        self.arrow_layout = BorderLayout(bounding_box)
        self.arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH, PERCENT_ARROW_WIDTH)
        self.collection_topic = None
        self.update_observer = None
        self.redraw_observer = None
        self.menu_button = None
Exemple #12
0
    def __init__(self, util, bounding_box, listeners, show_visibility=True):
        """ Initializer

        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "keyboard.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        if show_visibility:
            n = 5
        else:
            n = 4
        self.layout = GridLayout(bounding_box)
        self.layout.set_pixel_constraints(1, n, 1, 0)
        self.layout.current_constraints = 0
        self.bgr = util.config[COLORS][COLOR_DARK_LIGHT]

        self.add_button(KEY_HOME, KEY_HOME, listeners[KEY_HOME])
        self.add_button(KEY_BACK, KEY_BACK, listeners[KEY_BACK])
        self.add_button(KEY_DELETE, KEY_PARENT, listeners[KEY_DELETE])
        if n == 5:
            self.add_button(KEY_VIEW, KEY_SETUP, listeners[KEY_VIEW])
        self.add_button(KEY_PLAYER, KEY_PLAY_PAUSE, listeners[KEY_PLAYER])
Exemple #13
0
    def __init__(self, util):
        """ Initializer
        
        :param util: contains configuration object
        """
        Container.__init__(self, util, util.screen_rect, (0, 0, 0))
        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, plugin_folder)
        self.util = util
        self.config = util.config
        self.bounding_box = util.screen_rect
        self.default_folder = os.path.join(PACKAGE_SCREENSAVER, plugin_folder,
                                           DEFAULT_SLIDES_FOLDER)
        self.name = SLIDESHOW

        config_slides_folder = self.plugin_config_file.get(
            PLUGIN_CONFIGURATION, CONFIG_SLIDES_FOLDER)
        if config_slides_folder:
            self.current_folder = config_slides_folder
        else:
            self.current_folder = self.default_folder

        self.random = self.plugin_config_file.get(PLUGIN_CONFIGURATION,
                                                  RANDOM_ORDER)

        self.slides = []
        self.component = Component(util)
        self.component.name = self.name
        self.add_component(self.component)
Exemple #14
0
 def __init__(self, util, name, bb, font_size=None, bgr=None, fgr=None, halign=1, valign=4, shift_x=0, shift_y=0, full_width=False, font=None):
     """ Initializer
     
     :param util: utility object
     :param name: component name
     :param bb: bounding box
     :param bgr: background color
     :param fgr: text color
     :param font_size: font size
     :param halign: horizontal alignment
     :param valign: vertical alignment
     :param shift_x: X axis shift
     :param shift_y: Y axis shift
     :param full_width: True - use the whole bounding box width, False - use reduced width
     :param font: the font
     """
     Container.__init__(self, util, background=bgr, bounding_box=bb, content="text")
     self.util = util
     self.name = name
     self.default_font_size = font_size       
     self.font = font
     self.fgr = fgr
     self.bgr = bgr
     self.halign = halign
     self.valign = valign
     self.shift_x, self.shift_y = shift_x, shift_y
     self.full_width = full_width
     self.add_bgr()
     self.active = True
     self.DIGITS = "1234567890"
     self.select_listeners = []
     self.obfuscate_flag = False
Exemple #15
0
 def __init__(self, util, name, bgr, slider_color, img_knob, img_knob_on, key_incr, key_decr, key_knob, bb):
     """ Initializer
     
     :param util: utility object
     :param name: slider name
     :param bgr: slider background color
     :param slider_color: slider center line color
     :param img_knob: knob image
     :param img_knob_on: knob image in on state
     :param key_incr: keyboard key associated with slider increment action
     :param key_decr: keyboard key associated with slider decrement action
     :param key_knob: keyboard key associated with single click on knob
     :param bb: slider bounding box
     """
     Container.__init__(self, util, background=bgr, bounding_box=bb)
     self.util = util
     self.config = util.config
     
     self.lock = RLock()
     self.CURRENT_TIME_LAYER = 3
     self.TOTAL_TIME_LAYER = 2
     # don't increase the following number too much as it affects UV Meter screen-saver performance
     self.LOOP_CYCLES_PER_SECOND = 5 
     self.CYCLE_TIME = 1 / self.LOOP_CYCLES_PER_SECOND
     
     self.active = True    
     comp = Component(self.util, bb)
     comp.name = name + "bgr"
     comp.bgr = bgr
     self.add_component(comp)
     
     layout = BorderLayout(bb)
     layout.set_percent_constraints(0.0, 0.0, 20.0, 20.0)
     
     self.current_time_name = name + "current"
     self.total_time_name = name + "total"
     self.current_time_layout = layout.LEFT
     self.total_time_layout = layout.RIGHT
     
     self.slider = Slider(util, name + "slider", bgr, slider_color, img_knob, img_knob_on, None, key_incr, key_decr, key_knob, layout.CENTER, False)
     self.slider.add_slide_listener(self.slider_action_handler)
     self.total_track_time = 0   
     self.seek_time = 0        
     self.add_component(self.slider)
     
     c = Component(self.util, None) # init total time layer
     self.add_component(c)
     c = Component(self.util, None) # init current time layer
     self.add_component(c)
          
     self.seek_listeners = []
     self.start_timer_listeners = []
     self.stop_timer_listeners = []
     self.update_seek_listeners = True
     self.use_web = self.config[USAGE][USE_WEB]
     
     self.stop_timer()
     thread = Thread(target = self.start_loop)
     thread.start()
Exemple #16
0
    def __init__(self, util, bounding_box, listeners, bgr, pages):
        """ Initializer
        
        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        :param bgr: menu background
        :param pages: number of episodes menu pages       
        """ 
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "podcasts.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        arrow_layout = BorderLayout(bounding_box)
        arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH, PERCENT_ARROW_WIDTH)
        
        if pages > 1:
            constr = arrow_layout.LEFT
            self.left_button = self.factory.create_page_down_button(constr, "0", 40, 100)
            self.left_button.add_release_listener(listeners[GO_LEFT_PAGE])
            self.add_component(self.left_button)
            self.menu_buttons.append(self.left_button)
            
            constr = arrow_layout.RIGHT
            self.right_button = self.factory.create_page_up_button(constr, "0", 40, 100)
            self.right_button.add_release_listener(listeners[GO_RIGHT_PAGE])
            self.add_component(self.right_button)
            self.menu_buttons.append(self.right_button)
            layout = GridLayout(arrow_layout.CENTER)
        else:
            layout = GridLayout(bounding_box)
            
        layout.set_pixel_constraints(1, 4, 1, 0)        
        layout.current_constraints = 0
        image_size = 64 
        
        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(KEY_HOME, KEY_HOME, constr, listeners[KEY_HOME], bgr, image_size_percent=image_size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)
        
        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(KEY_PODCASTS_MENU, KEY_PARENT, constr, listeners[PODCASTS], bgr, image_size_percent=image_size)
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
        
        constr = layout.get_next_constraints()
        self.back_button = self.factory.create_button(KEY_BACK, KEY_BACK, constr, listeners[GO_BACK], bgr, image_size_percent=image_size)
        self.add_component(self.back_button)
        self.menu_buttons.append(self.back_button)
        
        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(KEY_PLAYER, KEY_PLAY_PAUSE, constr, listeners[KEY_PLAYER], bgr, image_size_percent=image_size)       
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
Exemple #17
0
    def __init__(self, util):
        """ Initializer
        
        :param util: contains config object and utility functions
        """
        self.name = "spectrum"
        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, self.name, util, plugin_folder)
        Container.__init__(self,
                           util,
                           bounding_box=util.screen_rect,
                           background=self.bg[1],
                           content=self.bg[2],
                           image_filename=self.bg[3])

        self.config = util.config
        self.image_util = util.image_util
        self.util = util
        self.run_flag = False
        self.run_datasource = False

        self.pipe_name = self.plugin_config_file.get(PLUGIN_CONFIGURATION,
                                                     PIPE_NAME)
        self.PIPE_BUFFER_SIZE = 1048576  # as defined for Raspberry OS in /proc/sys/fs/pipe-max-size
        self.max_value = self.plugin_config_file.getint(
            PLUGIN_CONFIGURATION, MAX_VALUE)
        self.size = self.plugin_config_file.getint(PLUGIN_CONFIGURATION, SIZE)
        self.update_ui_interval = self.plugin_config_file.getfloat(
            PLUGIN_CONFIGURATION, UPDATE_UI_INTERVAL)
        self.amplifier = self.plugin_config_file.getfloat(
            PLUGIN_CONFIGURATION, AMPLIFIER)
        self.pipe_polling_inerval = self.update_ui_interval / 10
        self.bar_heights = [0] * self.size
        self.pipe_size = 4 * self.size

        self.fifth = self.bounding_box.h / 5
        self.unit = (self.fifth * 2) / self.max_value
        self.bar_max_height = int(self.unit * self.max_value * self.amplifier)
        width = int(self.bounding_box.w - self.fifth * 2)
        self.bar_width = int(math.floor(width) / self.size)

        base_line_1 = self.bounding_box.h - (self.fifth * 1.8)
        base_line_2 = self.bounding_box.h - (self.fifth * 3.0)
        base_line_3 = self.bounding_box.h - (self.fifth * 1.0)
        self.base_line = [base_line_1, base_line_2, base_line_3]

        self.indexes = cycle(range(3))
        self.pipe = None

        self.init_images()
        self.init_container()

        if "win" in sys.platform:
            self.windows = True
        else:
            self.windows = False
            thread = Thread(target=self.open_pipe)
            thread.start()
Exemple #18
0
    def __init__(self, util, bounding_box, listeners):
        """ Initializer

        :param util: utility object
        :param bounding_box: bounding box
        :param listeners: buttons listeners
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "collection.navigator"
        self.content = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.listeners = listeners
        self.menu_buttons = []
        self.config = util.config
        self.use_web = self.config[USAGE][USE_WEB]
        self.arrow_layout = BorderLayout(bounding_box)
        self.arrow_layout.set_percent_constraints(0, 0, PERCENT_ARROW_WIDTH,
                                                  PERCENT_ARROW_WIDTH)
        self.update_observer = None
        self.redraw_observer = None
        self.menu_buttons = []

        constr = self.arrow_layout.LEFT
        self.left_button = self.factory.create_page_down_button(
            constr, "0", 40, 100)
        self.left_button.add_release_listener(self.listeners[GO_LEFT_PAGE])
        self.add_component(self.left_button)
        self.menu_buttons.append(self.left_button)

        constr = self.arrow_layout.RIGHT
        self.right_button = self.factory.create_page_up_button(
            constr, "0", 40, 100)
        self.right_button.add_release_listener(self.listeners[GO_RIGHT_PAGE])
        self.add_component(self.right_button)
        self.menu_buttons.append(self.right_button)

        layout = GridLayout(self.arrow_layout.CENTER)
        layout.set_pixel_constraints(1, 5, 1, 0)
        layout.current_constraints = 0

        bgr = util.config[BACKGROUND][FOOTER_BGR_COLOR]
        self.add_button(KEY_HOME, KEY_HOME, layout, self.listeners[KEY_HOME],
                        bgr)
        self.add_button(COLLECTION, KEY_PARENT, layout,
                        self.listeners[COLLECTION], bgr)
        self.add_button(KEY_LIST, KEY_MENU, layout,
                        self.listeners[COLLECTION_TOPIC], bgr)
        self.add_button(KEY_DETAIL, KEY_SETUP, layout,
                        self.listeners[TOPIC_DETAIL], bgr)
        self.add_button(KEY_PLAYER, KEY_PLAY_PAUSE, layout,
                        self.listeners[KEY_PLAYER], bgr)

        if self.use_web and self.update_observer != None:
            self.add_observers(self.update_observer, self.redraw_observer)
Exemple #19
0
    def __init__(self, util, name, bgr, slider_color, img_knob, img_knob_on, key_incr, key_decr, key_knob, bb, f, key_incr_alt=None, key_decr_alt=None):
        """ Initializer
        
        :param util: utility object
        :param name: slider name
        :param bgr: slider background color
        :param slider_color: slider center line color
        :param img_knob: knob image
        :param img_knob_on: knob image in on state
        :param key_incr: keyboard key associated with slider increment action
        :param key_decr: keyboard key associated with slider decrement action
        :param key_knob: keyboard key associated with single click on knob
        :param bb: slider bounding box
        :param key_incr_alt: alternative keyboard key associated with slider increment action
        :param key_decr_alt: alternative keyboard key associated with slider decrement action
        """
        Container.__init__(self, util, background=bgr, bounding_box=bb)
        self.content = None
        self.util = util
        self.config = util.config
        self.bgr = bgr
        
        self.lock = RLock()
        # don't increase the following number too much as it affects VU Meter screen-saver performance
        self.LOOP_CYCLES_PER_SECOND = 5 
        self.CYCLE_TIME = 1 / self.LOOP_CYCLES_PER_SECOND        
        self.active = True    

        layout = BorderLayout(bb)
        layout.set_percent_constraints(0.0, 0.0, 20.0, 20.0)
        
        current_time_name = name + "current"
        total_time_name = name + "total"
        current_time_layout = layout.LEFT
        total_time_layout = layout.RIGHT

        self.slider = Slider(util, name + "slider", bgr, slider_color, img_knob, img_knob_on, None, key_incr, key_decr, key_knob, layout.CENTER, False, key_incr_alt=key_incr_alt, key_decr_alt=key_decr_alt)
        self.slider.add_slide_listener(self.slider_action_handler)
        self.total_track_time = 0
        self.seek_time = 0     
        self.add_component(self.slider)
        
        height = 36
        font_size = int((current_time_layout.h * height)/100.0)
        c = self.config[COLORS][COLOR_BRIGHT]
        self.current = f.create_output_text(current_time_name, current_time_layout, bgr, c, font_size)
        self.total = f.create_output_text(total_time_name, total_time_layout, bgr, c, font_size)        
        self.add_component(self.current)
        self.add_component(self.total)

        self.seek_listeners = []
        self.start_timer_listeners = []
        self.stop_timer_listeners = []
        self.update_seek_listeners = True
        self.use_web = self.config[USAGE][USE_WEB]
        self.timer_started = False
Exemple #20
0
    def __init__(self, listeners, util):
        """ Initializer
        
        :param util: utility object
        :param listener: screen menu event listener
        """
        self.util = util
        self.config = util.config
        Container.__init__(self, util, background=(0, 0, 0))
        self.factory = Factory(util)
        self.bounding_box = self.config[SCREEN_RECT]
        layout = BorderLayout(self.bounding_box)
        k = self.bounding_box.w/self.bounding_box.h
        percent_menu_width = (100.0 - PERCENT_TOP_HEIGHT - PERCENT_BOTTOM_HEIGHT)/k
        panel_width = (100.0 - percent_menu_width)/2.0
        layout.set_percent_constraints(PERCENT_TOP_HEIGHT, PERCENT_BOTTOM_HEIGHT, panel_width, panel_width)
        self.genres = util.load_menu(GENRE_ITEMS, GENRE)        
        self.current_genre = self.genres[self.config[CURRENT][PLAYLIST]]
        self.items_per_line = self.items_per_line(layout.CENTER.w)
        self.playlist = Playlist(self.config[CURRENT][LANGUAGE], self.current_genre.genre, util, self.items_per_line)
        
        font_size = (layout.TOP.h * PERCENT_TITLE_FONT)/100.0
        color_dark = self.config[COLORS][COLOR_DARK]
        color_contrast = self.config[COLORS][COLOR_CONTRAST]
        self.screen_title = self.factory.create_dynamic_text("station_screen_title", layout.TOP, color_dark, color_contrast, int(font_size))
        Container.add_component(self, self.screen_title)

        self.station_menu = StationMenu(self.playlist, util, (0, 0, 0), layout.CENTER)
        self.screen_title.set_text(self.station_menu.button.state.l_name)        
        Container.add_component(self, self.station_menu)
        
        self.create_left_panel(layout, listeners)
        self.create_right_panel(layout, listeners)        

        self.home_button.add_release_listener(listeners["go home"])
        self.genres_button.add_release_listener(listeners["go genres"])
        self.shutdown_button.add_release_listener(listeners["shutdown"])
        self.left_button.add_release_listener(self.station_menu.switch_to_previous_station)
        self.left_button.add_release_listener(self.update_arrow_button_labels)
        self.page_down_button.add_release_listener(self.station_menu.switch_to_previous_page)
        self.page_down_button.add_release_listener(self.update_arrow_button_labels)
        self.right_button.add_release_listener(self.station_menu.switch_to_next_station)
        self.right_button.add_release_listener(self.update_arrow_button_labels)
        self.page_up_button.add_release_listener(self.station_menu.switch_to_next_page)
        self.page_up_button.add_release_listener(self.update_arrow_button_labels)               
        self.station_menu.add_listener(listeners["play"])
        self.station_menu.add_listener(self.screen_title.set_state)
        self.station_menu.add_listener(self.update_arrow_button_labels)        
        self.station_menu.add_mode_listener(self.mode_listener)
        
        self.volume = self.factory.create_volume_control(layout.BOTTOM)
        self.volume.add_slide_listener(listeners["set volume"])
        self.volume.add_slide_listener(listeners["set config volume"])
        self.volume.add_slide_listener(listeners["set screensaver volume"])
        self.volume.add_knob_listener(listeners["mute"])        
        Container.add_component(self, self.volume)
Exemple #21
0
 def __init__(self, util):
     """ Initializer
     
     :param util: utility object
     """
     self.util = util
     self.config = util.config
     Container.__init__(self, util, background=(0, 0, 0))
     self.bounding_box = util.screen_rect
     self.start_listeners = []
Exemple #22
0
    def __init__(self, util):
        """ Initializer
        
        :param util: contains config object and utility functions
        """
        self.config = util.config
        self.bounding_box = self.config[SCREEN_RECT]
        bgr = (0, 0, 0)
        Container.__init__(self, util, self.bounding_box, bgr)
        plugin_folder = type(self).__name__.lower()
        Screensaver.__init__(self, plugin_folder)
        self.util = util
        self.run_flag = False
        self.run_datasource = False

        self.pipe_name = self.plugin_config_file.get(PLUGIN_CONFIGURATION,
                                                     PIPE_NAME)
        self.pipe_polling_interval = self.plugin_config_file.getfloat(
            PLUGIN_CONFIGURATION, PIPE_POLLING_INTERVAL)
        self.max_value = self.plugin_config_file.getint(
            PLUGIN_CONFIGURATION, MAX_VALUE)
        self.size = self.plugin_config_file.getint(PLUGIN_CONFIGURATION, SIZE)
        self.update_ui_interval = self.plugin_config_file.getfloat(
            PLUGIN_CONFIGURATION, UPDATE_UI_INTERVAL)
        self.amplifier = self.plugin_config_file.getfloat(
            PLUGIN_CONFIGURATION, AMPLIFIER)

        self.bar_heights = [0] * self.size
        self.pipe_size = 4 * self.size

        self.fifth = self.bounding_box.h / 5
        self.unit = (self.fifth * 2) / self.max_value
        self.bar_max_height = int(self.unit * self.max_value * self.amplifier)
        width = int(self.bounding_box.w - self.fifth * 2)
        self.bar_width = int(math.floor(width) / self.size)

        base_line_1 = self.bounding_box.h - (self.fifth * 1.8)
        base_line_2 = self.bounding_box.h - (self.fifth * 3.0)
        base_line_3 = self.bounding_box.h - (self.fifth * 1.0)
        self.base_line = [base_line_1, base_line_2, base_line_3]

        self.indexes = cycle(range(3))
        self.pipe = None

        self.init_images()
        self.init_container()

        if "win" in sys.platform:
            self.windows = True
            self.update_ui_interval = 0.1
        else:
            self.windows = False
            thread = Thread(target=self.open_pipe)
            thread.start()
Exemple #23
0
    def __init__(self,
                 util,
                 bgr=None,
                 bb=None,
                 rows=3,
                 cols=3,
                 create_item_method=None,
                 menu_button_layout=None,
                 font_size=None,
                 align=ALIGN_CENTER,
                 button_padding_x=None,
                 bgr_component=None,
                 horizontal_layout=True):
        """ Initializer
        
        :param util: utility object
        :param bgr: menu background
        :param bb: bounding box
        :param rows: number of rows in menu
        :param cols: number of columns in menu
        :param create_item_method: factory method for menu item creation
        :param menu_button_layout: menu buttons layout
        :param font_size: font size
        :param align: label alignment
        :param button_padding_x: padding X
        :param bgr_component: menu background component
        """
        Container.__init__(self, util, bb, bgr)
        self.content = None
        self.bb = bb
        self.rows = rows
        self.cols = cols
        self.util = util
        self.menu_button_layout = menu_button_layout
        self.start_listeners = []
        self.move_listeners = []
        self.menu_loaded_listeners = []
        self.font_size = font_size
        self.button_padding_x = button_padding_x
        self.horizontal_layout = horizontal_layout

        self.buttons = {}
        self.factory = Factory(util)
        self.create_item_method = create_item_method
        self.selected_index = None
        self.align = align

        self.update_observer = None
        self.redraw_observer = None
        self.press = False
        self.release = False

        if bgr_component:
            self.add_component(bgr_component)
Exemple #24
0
	def __init__(self, position=Vector3(0,0,0), size=Vector2i(1,1), tabs=[], **kwargs):
		for x in tabs:
			if not isinstance(x, Tab):
				raise ValueError, 'TabView can only contain Tabs, not %s', type(x)
			
		self._children = [x.widget for x in tabs]
		self._titles = [x.title for x in tabs]

		Container.__init__(self, children=self._children)
		CairoWidget.__init__(self, position, size, **kwargs)
		
		self._font = self.create_font(size=9)
		self._selected = 0
Exemple #25
0
 def __init__(self, util, state):
     """ Initializer
     
     :param util: utility object
     :param state: button state
     """        
     self.util = util
     Container.__init__(self, util)
     self.set_state(state)
     self.press_listeners = list()
     self.release_listeners = list()
     self.bounding_box = state.bounding_box
     self.bgr = getattr(state, "bgr", (0, 0, 0))       
Exemple #26
0
    def __init__(self, position=Vector3(0, 0, 0), size=Vector2i(1, 1), tabs=[], **kwargs):
        for x in tabs:
            if not isinstance(x, Tab):
                raise ValueError, "TabView can only contain Tabs, not %s", type(x)

        self._children = [x.widget for x in tabs]
        self._titles = [x.title for x in tabs]

        Container.__init__(self, children=self._children)
        CairoWidget.__init__(self, position, size, **kwargs)

        self._font = self.create_font(size=9)
        self._selected = 0
    def __init__(self, f, id, util, name, bgr, slider_color, img_knob, img_knob_on, key_incr, key_decr, key_knob, bb, listener, label):
        """ Initializer
        
        :param id: band ID
        :param util: utility object
        :param name: slider name
        :param bgr: slider background color
        :param slider_color: slider center line color
        :param img_knob: knob image
        :param img_knob_on: knob image in on state
        :param key_incr: keyboard key associated with slider increment action
        :param key_decr: keyboard key associated with slider decrement action
        :param key_knob: keyboard key associated with single click on knob
        :param bb: slider bounding box
        """
        Container.__init__(self, util, background=bgr, bounding_box=bb, content=None)
        self.util = util
        self.config = util.config
        self.bgr = bgr
        
        self.VALUE_LAYER = 2
        self.LABEL_LAYER = 1
        
        layout = BorderLayout(bb)
        layout.set_percent_constraints(10.0, 10.0, 0.0, 0.0)
        
        self.id = id
        self.value_name = name + ".value." + str(id)
        self.label_name = name + ".label." + str(id)
        self.value_layout = layout.TOP
        self.label_layout = layout.BOTTOM
        self.label_layout.y -= 1
        self.label_layout.h += 2
        
        self.slider = Slider(util, "slider." + str(id), bgr, slider_color, img_knob, img_knob_on, None, key_incr, key_decr, key_knob, layout.CENTER)
        self.slider.add_slide_listener(listener)
        self.add_component(self.slider)
        
        height = 60
        font_size = int((self.value_layout.h * height)/100.0)
        c = self.config[COLORS][COLOR_BRIGHT]
        self.top = f.create_output_text("top.label." + str(id), self.value_layout, bgr, c, font_size)
        self.bottom = f.create_output_text("bottom.label." + str(id), self.label_layout, bgr, c, font_size)        
        self.bottom.set_text(label)

        self.add_component(self.top)
        self.add_component(self.bottom)
        
        self.seek_listeners = []
        self.update_seek_listeners = True
        self.use_web = self.config[USAGE][USE_WEB]
Exemple #28
0
    def __init__(self, util, handle_slider_event, bounding_box=None):
        """ Initializer
        
        :param util: utility object
        :param handle_slider_event: slider event handler
        :param listeners: menu listeners
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        self.labels = [
            "31", "63", "125", "250", "500", "1k", "2k", "4k", "8k", "16k"
        ]

        self.util = util
        Container.__init__(self, util)
        name = "equalizermenu"
        self.factory = Factory(util)

        self.bounding_box = bounding_box
        self.bounding_box.y += 1
        self.bounding_box.h -= 1
        self.bgr_color = util.config[BACKGROUND][MENU_BGR_COLOR]

        self.eq_layout = BorderLayout(self.bounding_box)
        self.eq_layout.set_percent_constraints(0, 0, 5, 5)

        self.bands = 10
        self.sliders = self.add_sliders(handle_slider_event)
        self.current_slider = -1

        self.left_filler = Component(util, self.eq_layout.LEFT)
        self.left_filler.name = name + ".bgr.left"
        self.left_filler.bgr = self.bgr_color
        self.add_component(self.left_filler)

        self.right_filler = Component(util, self.eq_layout.RIGHT)
        self.right_filler.name = name + ".bgr.right"
        self.right_filler.bgr = self.bgr_color
        self.add_component(self.right_filler)

        self.SLOW_INCREMENT = 1
        self.FAST_INCREMENT = self.sliders[0].slider.knob_height / 2

        self.mouse_events = [
            pygame.MOUSEBUTTONUP, pygame.MOUSEBUTTONDOWN, pygame.MOUSEMOTION
        ]
Exemple #29
0
    def draw_weather(self):
        """ Draw weather forecast  """

        Container.__init__(self, self.util, self.rect, BLACK)

        c = Component(self.util)
        c.name = "forecast.bgr"
        c.content = self.initial_image
        c.content_x = 0
        c.content_y = 0
        c.bounding_box = self.rect
        self.add_component(c)

        widths = self.get_widths()
        heights = self.get_heights()

        self.draw_tiles(widths, heights)
Exemple #30
0
    def __init__(self, util, listeners, bgr=None, bounding_box=None):
        """ Initializer

        :param util: utility object
        :param listeners: menu listeners
        :param bgr: menu background
        :param bounding_box: bounding box
        """
        Container.__init__(self, util)
        self.factory = Factory(util)
        self.name = "saver.navigator"
        self.content = self.bounding_box = bounding_box
        self.content_x = bounding_box.x
        self.content_y = bounding_box.y
        self.menu_buttons = []

        layout = GridLayout(bounding_box)

        layout.set_pixel_constraints(1, 3, 1, 0)
        layout.current_constraints = 0
        size = 64  # button image size in percent

        constr = layout.get_next_constraints()
        self.home_button = self.factory.create_button(KEY_HOME, KEY_HOME,
                                                      constr,
                                                      listeners[KEY_HOME], bgr,
                                                      size)
        self.add_component(self.home_button)
        self.menu_buttons.append(self.home_button)

        constr = layout.get_next_constraints()
        self.start_saver_button = self.factory.create_button(
            KEY_START_SAVER, KEY_MENU, constr, listeners[KEY_START_SAVER], bgr,
            75)
        self.add_component(self.start_saver_button)
        self.menu_buttons.append(self.start_saver_button)

        constr = layout.get_next_constraints()
        self.player_button = self.factory.create_button(
            KEY_PLAYER, KEY_PLAY_PAUSE, constr, listeners[KEY_PLAYER], bgr,
            size)
        self.add_component(self.player_button)
        self.menu_buttons.append(self.player_button)
Exemple #31
0
    def __init__(self, util, bb, gap, digits, listener, timer_lock,
                 clock_change_callback, change_codes):
        """ Initializer
        
        :param util: utility object
        :param bb: menu bounding box
        :param gap: gap between hours and minutes
        :param digits: clock digits 0-9
        :param listener: the listener
        :param timer_lock: lock object
        :param clock_change_callback: callback function
        :param change_codes: change codes
        """
        self.util = util
        self.name = SLEEP + "_" + POWEROFF
        self.config = self.util.config
        self.factory = Factory(util)
        sleep_icon_size = 0.64
        poweroff_icon_size = 0.56
        Container.__init__(self, util, bb.CENTER)
        border_x = bb.RIGHT.x
        c = GridLayout(Rect(border_x + 1, bb.y + 1, bb.w - border_x, bb.h - 1))
        c.set_pixel_constraints(2, 1)
        self.bgr = (0, 0, 0, 0)

        self.sleep_selected = self.config[TIMER][SLEEP]
        self.poweroff_selected = self.config[TIMER][POWEROFF]

        self.clock = Clock(self.util, SLEEP, SLEEP_TIME, digits, bb,
                           timer_lock, clock_change_callback, change_codes)
        self.add_component(self.clock)

        s = c.get_next_constraints()
        self.sleep_button = self.add_button(SLEEP, s, kbd_keys[KEY_SETUP],
                                            self.sleep_selected,
                                            sleep_icon_size, listener)
        n = c.get_next_constraints()
        h = bb.h - s.height - 2
        r = Rect(n.x, n.y + 1, n.w, h)
        self.poweroff_button = self.add_button(POWEROFF, r, kbd_keys[KEY_END],
                                               self.poweroff_selected,
                                               poweroff_icon_size, listener)
        self.bounding_box = bb.CENTER
Exemple #32
0
 def __init__(self, util, state):
     """ Initializer
     
     :param util: utility object
     :param state: button state
     """
     self.util = util
     self.config = self.util.config
     Container.__init__(self, util)
     self.LABEL_PADDING = 6
     self.set_state(state)
     self.press_listeners = []
     self.release_listeners = []
     self.label_listeners = []
     self.bounding_box = state.bounding_box
     self.bgr = getattr(state, "bgr", (0, 0, 0))
     self.selected = None
     self.press_time = 0
     self.LONG_PRESS_TIME = self.config[USAGE][USE_LONG_PRESS_TIME]
Exemple #33
0
    def __init__(self, util, bb, gap, digits, listener, timer_lock,
                 clock_change_callback, change_codes):
        """ Initializer
        
        :param util: utility object
        :param bb: menu bounding box
        :param gap: gap between hours and minutes
        :param digits: clock digits 0-9
        :param listener: the listener
        :param timer_lock: lock object
        :param clock_change_callback: callback function
        :param change_codes: change codes
        """
        self.util = util
        self.name = WAKE_UP
        self.config = self.util.config
        self.factory = Factory(util)
        icon_size = 0.43
        Container.__init__(self, util, bb)
        self.bgr = (0, 0, 0, 0)

        self.clock = Clock(self.util, WAKE_UP, WAKE_UP_TIME, digits, bb, gap,
                           icon_size, timer_lock, clock_change_callback,
                           change_codes)
        self.add_component(self.clock)

        border_x = bb.RIGHT.x
        d = {}
        d["name"] = WAKE_UP
        d["bounding_box"] = pygame.Rect(border_x + 1, bb.y + 1,
                                        bb.w - border_x, bb.h - 1)
        d["keyboard_key"] = kbd_keys[KEY_BACK]
        d["image_size_percent"] = icon_size
        d["bgr"] = self.config[COLORS][COLOR_DARK]

        switch_on = self.config[TIMER][WAKE_UP]
        self.button_selected = switch_on
        self.button = self.factory.create_timer_button(**d)
        self.button.set_selected(switch_on)
        self.button.add_release_listener(listener)

        self.add_component(self.button)
Exemple #34
0
    def __init__(self, util):
        """ Initializer
        
        :param util: utility object
        """
        self.util = util
        self.config = util.config
        self.color_web_bgr = self.config[COLORS][COLOR_WEB_BGR]
        Container.__init__(self, util, background=self.color_web_bgr)
        self.bounding_box = util.screen_rect
        self.start_listeners = []
        factory = Factory(util)
        edition = "Holbein Edition"

        layout = BorderLayout(self.bounding_box)
        layout.set_percent_constraints(0, PERCENT_FOOTER_HEIGHT, 0, 0)
        release_font_size = (layout.BOTTOM.h * PERCENT_FOOTER_FONT) / 100.0

        color_logo = self.config[COLORS][COLOR_LOGO]
        button = factory.create_image_button("peppy",
                                             bounding_box=layout.CENTER,
                                             bgr=self.color_web_bgr,
                                             image_size_percent=68,
                                             selected=False)
        x = layout.CENTER.w / 2 - button.components[1].content.get_size()[0] / 2
        y = layout.CENTER.h / 2 - button.components[1].content.get_size()[1] / 2
        button.components[1].content_x = x
        button.components[1].content_y = y
        self.add_component(button)

        layout.BOTTOM.y -= 1
        layout.BOTTOM.h += 1
        release = factory.create_output_text("about-name",
                                             layout.BOTTOM,
                                             self.color_web_bgr,
                                             color_logo,
                                             int(release_font_size),
                                             full_width=True,
                                             valign=V_ALIGN_TOP)
        release.set_text_no_draw(edition)
        self.add_component(release)
Exemple #35
0
    def draw_weather(self):
        """ Draw Today's weather """

        Container.__init__(self, self.util, self.rect, BLACK)

        c = Component(self.util)
        c.name = "today"
        c.content = self.initial_image
        c.content_x = 0
        c.content_y = 0
        c.bounding_box = self.rect
        self.add_component(c)

        top_height = self.draw_top_background()
        self.draw_bottom_background()
        self.draw_city(top_height)
        self.draw_time(top_height)
        self.draw_code()
        self.draw_temp()
        self.draw_high_low()
        self.draw_details()
Exemple #36
0
 def __init__(self, util, bgr=None, bb=None, rows=3, cols=3, create_item_method=None):
     """ Initializer
     
     :param util: utility object
     :param bgr: menu background
     :param bb: bounding box
     :param rows: number of rows in menu
     :param cols: number of columns in menu
     :param create_item_method: factory method for menu item creation
     """        
     Container.__init__(self, util, bb, bgr)
     self.rows = rows
     self.cols = cols
     self.start_listeners = []
     self.move_listeners = []
     self.layout = GridLayout(bb)
     self.layout.set_pixel_constraints(self.rows, self.cols, 1, 1)        
     self.items = {}
     self.buttons = {}
     self.factory = Factory(util)
     self.create_item_method = create_item_method
     self.selected_index = None
Exemple #37
0
    def __init__(self, util, title_key):
        """ Initializer
        
        :param util: utility object
        :param title_key: the resource bundle key for the screen title
        """
        Container.__init__(self, util)
        self.util = util
        factory = Factory(util)
        config = util.config
        self.bounding_box = config[SCREEN_RECT]
        self.bgr = (0, 0, 0)
        self.layout = BorderLayout(config[SCREEN_RECT])
        self.layout.set_percent_constraints(PERCENT_TOP_HEIGHT, 0, 0, 0)

        font_size = (self.layout.TOP.h * PERCENT_TITLE_FONT)/100.0
        d = config[COLORS][COLOR_DARK]
        c = config[COLORS][COLOR_CONTRAST]
        self.screen_title = factory.create_output_text("screen_title", self.layout.TOP, d, c, int(font_size))
        label = config[LABELS][title_key]
        self.screen_title.set_text(label) 
        self.add_component(self.screen_title)
Exemple #38
0
 def __init__(self, columns, rows, *widgets):
     Container.__init__(self, children=widgets)
     Widget.__init__(self)
     self._cols = int(columns)
     self._rows = int(rows)
Exemple #39
0
 def __init__(self, util, name, bgr, slider_color, img_knob, img_knob_on, img_selected, key_incr, key_decr, key_knob, bb):
     """ Initializer
     
     :param util: utility object
     :param name: slider name
     :param bgr: slider background color
     :param slider_color: slider center line color
     :param img_knob: knob image
     :param img_knob_on: knob image in on state
     :param img_selected: knob image in selected state
     :param key_incr: keyboard key associated with slider increment action
     :param key_decr: keyboard key associated with slider decrement action
     :param key_knob: keyboard key associated with single click on knob
     :param bb: slider bounding box
     """
     Container.__init__(self, util, background=bgr, bounding_box=bb)
     self.util = util
     self.name = name
     self.img_knob = img_knob[1]
     self.img_knob_on = img_knob_on[1]
     self.img_selected = img_selected
     self.knob_width = self.img_knob.get_size()[0]
     self.knob_height = self.img_knob.get_size()[1]
     self.knob_filename = img_knob[0]
     self.knob_on_filename = img_knob_on[0]
     self.selected = False
     self.dragging = False
     self.initial_level = 0
     self.current_img = self.img_knob
     self.current_filename = self.knob_filename
     self.clicked = False
     self.press_listeners = list()
     self.slide_listeners = list()
     self.knob_listeners = list()
     self.motion_listeners = list()
     pygame.key.set_repeat(50, 10)
     self.step = 10
     self.key_incr = key_incr
     self.key_decr = key_decr
     self.key_knob = key_knob
     slider_x = self.knob_width/2
     self.bounding_box.h += 1
     slider_y = self.bounding_box.y + self.bounding_box.height - self.bounding_box.height/2
     slider_width = self.bounding_box.width - self.knob_width
     slider_height = 2
     self.slider = pygame.Rect(slider_x, slider_y, slider_width, slider_height)
     self.slider_max_x = self.bounding_box.width - self.knob_width/2
     self.slider_min_x = self.knob_width/2
     self.slide_increment = (self.slider_max_x - self.slider_min_x)/100.0
     self.last_knob_position = (int)(self.initial_level * self.slide_increment)
     self.knob_y = self.bounding_box.y + self.bounding_box.height/2 - self.knob_height/2
     self.event_source_local = True 
     
     comp = Component(self.util, self.bounding_box)
     comp.name = self.name + ".bgr"
     comp.bgr = bgr
     self.add_component(comp)
     
     comp = Component(self.util, self.slider)
     comp.name = self.name + ".slider"
     comp.thickness = 1
     comp.content_x = slider_x
     comp.content_y = slider_y
     comp.bgr = slider_color
     self.add_component(comp)
     
     comp = Component(self.util, self.current_img)
     comp.name = self.name + ".knob"
     h = self.current_img.get_size()[1]
     comp.content_y = bb.y + (bb.h - h)/2
     comp.image_filename = self.knob_filename
     self.add_component(comp)
Exemple #40
0
	def __init__(self, position=Vector3(0,0,0), size=Vector2i(1,1), *widgets):
		Container.__init__(self, children=widgets)
		Widget.__init__(self, position, size)