当前位置: 首页>>代码示例>>Python>>正文


Python Timeline.run方法代码示例

本文整理汇总了Python中timeline.Timeline.run方法的典型用法代码示例。如果您正苦于以下问题:Python Timeline.run方法的具体用法?Python Timeline.run怎么用?Python Timeline.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在timeline.Timeline的用法示例。


在下文中一共展示了Timeline.run方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_button_press

# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import run [as 别名]
 def handle_button_press(self, cr, rect, event_x, event_y):
     if self.is_expandable:
         if not self.in_animation:
             if self.has_expand:
                 text_width, text_height = self.shrink_button_width, self.shrink_button_height
             else:
                 text_width, text_height = self.expand_button_width, self.expand_button_height
             if is_in_rect((event_x, event_y), 
                           (rect.width - (rect.width - self.label_wrap_width) / 2 - text_width,
                            rect.height - text_height,
                            text_width,
                            text_height)):
                 
                 if self.has_expand:
                     start_position = self.expand_height
                     animation_distance = self.init_height - self.expand_height
                 else:
                     start_position = self.init_height
                     animation_distance = self.expand_height - self.init_height
                 
                 self.in_animation = True    
                     
                 timeline = Timeline(self.animation_time, CURVE_SINE)
                 timeline.connect('update', lambda source, status: 
                                  self.update(source,
                                              status, 
                                              start_position,
                                              animation_distance))
                 timeline.connect("completed", self.completed)
                 timeline.run()
     else:
         print "no expand button"
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:34,代码来源:resizable_label.py

示例2: start_animation

# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import run [as 别名]
 def start_animation(self, index, tab_start_x):
     if not self.in_animiation:
         self.in_animiation = True
         
         source_tab_x = tab_start_x + self.tab_index * self.tab_width
         target_tab_x = tab_start_x + index * self.tab_width
         
         timeline = Timeline(self.tab_animation_time, CURVE_SINE)
         timeline.connect('update', lambda source, status: self.update_animation(source, status, source_tab_x, (target_tab_x - source_tab_x)))
         timeline.connect("completed", lambda source: self.completed_animation(source, index))
         timeline.run()
         
         self.emit("tab-switch-start", index)
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:15,代码来源:tab_switcher.py

示例3: set_value

# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import run [as 别名]
 def set_value(self, value):
     if (not self.in_animation) and value != self.value:
         self.start_value = self.value
         self.range = value - self.value
         times = int(abs(self.range)) * 10
         from timeline import Timeline, CURVE_SINE
         timeline = Timeline(times * 10, CURVE_SINE)
         timeline.connect("start", self.start_animation)
         timeline.connect("stop", self.stop_animation)
         timeline.connect("update", self.update_animation)
         timeline.run()
         
     return False    
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:15,代码来源:box.py

示例4: start_animation

# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import run [as 别名]
    def start_animation(self, animation_time, index=None):
        # Update ticker with active index if option index is None.
        if index == None:
            if self.active_index >= self.image_number - 1:
                index = 0
            else:
                index = self.active_index + 1

        if not self.in_animiation:
            self.in_animiation = True
            self.target_index = index

            timeline = Timeline(animation_time, CURVE_SINE)
            timeline.connect("update", self.update_animation)
            timeline.connect("completed", lambda source: self.completed_animation(source, index))
            timeline.run()

        return True
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:20,代码来源:slide_switcher.py

示例5: slide_to

# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import run [as 别名]
    def slide_to(self, widget):

        self.active_widget = widget

        def update(source, status):
            pos = end_position - start_position
            adjustment.set_value(start_position + int(round(status * pos)))

        adjustment = self.get_hadjustment()
        start_position = adjustment.get_value()
        end_position = widget.get_allocation().x

        if start_position != end_position:
            timeline = Timeline(500, CURVE_SINE)
            timeline.connect('update', update)
            timeline.run()
            
        if self.slide_callback:    
            self.slide_callback(self.layout.get_children().index(widget), widget)
开发者ID:netphi,项目名称:deepin-ui,代码行数:21,代码来源:slider.py

示例6: HSlider

# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import run [as 别名]
class HSlider(gtk.Viewport):
    '''
    HSlider class.
    
    @undocumented: slide_to_page
    @undocumented: set_to_page
    @undocumented: append_page
    '''
    
    __gsignals__ = {
            "start_slide" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
            "completed_slide" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
            }
    
    def __init__(self, 
                 slide_time=200,
                 ):
        '''
        Initialize HSlider class.
        
        @param slide_time: The animation of slide time, default is 200ms.
        '''
        gtk.Viewport.__init__(self)
        self.set_shadow_type(gtk.SHADOW_NONE)
        self.fixed = gtk.Fixed()
        self.add(self.fixed)
        self.slide_time = slide_time
        self.pre_widget = None
        self.active_widget = None
        self.connect("realize", self._update_size)
        self.connect("size_allocate", self._update_size)
        self.page_width = 0
        self.page_height = 0
        self.in_sliding = False

    def _update_size(self, w=None, _w=None):
        self.page_width = self.allocation.width
        self.page_height = self.allocation.height
        if self.active_widget:
            self.active_widget.set_size_request(self.page_width, self.page_height)
        if self.pre_widget:
            self.pre_widget.set_size_request(self.page_width, self.page_height)
        self.show_all()

    def _to_right(self, percent):
        self.offset = int(round(percent * self.page_width)) 
        
        if self.pre_widget:
            self.fixed.move(self.pre_widget, - self.offset, 0)
        
        self.fixed.move(self.active_widget, self.page_width - self.offset, 0)
        
    def _to_left(self, percent):
        self.offset = int(round(percent * self.page_width))
        
        if self.pre_widget:
            self.fixed.move(self.pre_widget, self.offset, 0)
        
        self.fixed.move(self.active_widget, self.offset - self.page_width, 0)

    def _no_effect(self):
        self.offset = self.page_width

        if self.pre_widget:
            self.fixed.remove(self.pre_widget)
        self.fixed.move(self.active_widget, 0, 0)

    def to_page(self, w, direction):
        '''
        Slide to given page.
        
        @param w: gtk.Widget to slide.
        @param direction: The direction of slide animation, can use below value:
         - \"right\"    slide from right to left
         - \"left\"     slide from left to right
         - None         no animation effect, slide directly
        '''
        if self.in_sliding:
            return

        if w != self.active_widget:
            w.set_size_request(self.page_width, self.page_height)
            if w.parent != self.fixed:
                self.fixed.put(w, self.page_width, 0)
            self.active_widget = w

            self.timeline = Timeline(self.slide_time, CURVE_SINE)
            if direction == "right":
                self.timeline.connect('update', lambda source, status: self._to_right(status))
            elif direction == "left":
                self.timeline.connect('update', lambda source, status: self._to_left(status))
            else:
                self._no_effect()

            self.timeline.connect("start", lambda source: self._start())
            self.timeline.connect("completed", lambda source: self._completed())
            self.timeline.run()
            self.in_sliding = True

            self.show_all()
#.........这里部分代码省略.........
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:103,代码来源:slider.py

示例7: WizardBox

# 需要导入模块: from timeline import Timeline [as 别名]
# 或者: from timeline.Timeline import run [as 别名]

#.........这里部分代码省略.........
        if self.show_button and self.target_index == self.slider_numuber - 1:
            if self.button_hover_flag:
                pixbuf = self.button_press_pixbuf
            else:    
                pixbuf = self.button_normal_pixbuf
            draw_pixbuf(cr, pixbuf, rect.x + self.button_rect.x, rect.y + self.button_rect.y)    
        return True    
    
    def handle_animation(self, widget, event):    
        self.motion_index = None
        for index, rect in self.pointer_coords.items():
            if rect.x <= event.x <= rect.x + rect.width and rect.y <= event.y <= rect.y + rect.height:
                set_cursor(widget, gtk.gdk.HAND2)
                self.motion_index = index
                break    
        else:    
            self.motion_index = None
            set_cursor(widget, None)
    
    def on_motion_notify(self, widget, event):
        self.handle_animation(widget, event)
        if is_in_rect((event.x, event.y), self.button_rect):    
            self.button_hover_flag = True
        else:    
            self.button_hover_flag = False
        self.queue_draw()    
    
    def on_enter_notify(self, widget, event):
        if self.auto_animation_id is not None:
            gobject.source_remove(self.auto_animation_id)
            self.auto_animation_id = None
    
    def on_leave_notify(self, widget, event):
        self.auto_animation()
        set_cursor(widget, None)
    
    def on_button_press(self, widget, event):
        if self.motion_index != None:
            self.start_animation(self.slider_timeout, self.motion_index)
            
        if is_in_rect((event.x, event.y), self.close_rect):
            self.emit("close")
            
        if is_in_rect((event.x, event.y), self.button_rect):    
            self.emit("close")
                            
    
    def auto_animation(self):
        self.auto_animation_id = gobject.timeout_add(self.auto_animation_timeout, 
                                                 lambda : self.start_animation(self.slider_timeout))
    
    def start_animation(self, animation_time, target_index=None, direction="left"):
        if target_index is None:
            if self.active_index >= self.slider_numuber - 1:
                return False
                target_index = 0
            else:    
                target_index = self.active_index + 1
        else:        
            if target_index < self.active_index:
                direction = "right"
                
        if not self.in_animation:        
            self.in_animation = True
            self.target_index = target_index
            
            self.timeline = Timeline(animation_time, CURVE_SINE)
            self.timeline.connect("update", lambda source, status: self.update_animation(source, status, direction))
            self.timeline.connect("completed", lambda source: self.completed_animation(source, target_index))
            self.timeline.run()
        return True    
    
    def update_animation(self, source, status, direction):
        self.active_alpha = 1.0 - status
        self.target_alpha = status
        
        if direction == "right":
            self._to_right(status)
        else:    
            self._to_left(status)
            
        self.queue_draw()    
        
    def completed_animation(self, source, index):    
        self.active_index = index
        self.active_alpha = 1.0
        # self.target_index = None
        self.target_alpha = 0.0
        self.in_animation = False
        self.active_x = 0
        self.target_x = None
        self.queue_draw()
        
    def _to_right(self, status):    
        self.active_x = self.slider_width * status
        self.target_x = 0
        
    def _to_left(self, status):    
        self.active_x = 0 - (self.slider_width * status)
        self.target_x = 0
开发者ID:Jiarui315,项目名称:deepin-ui,代码行数:104,代码来源:slider.py


注:本文中的timeline.Timeline.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。