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


Python ToolButton.queue_draw方法代码示例

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


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

示例1: InkToolBar

# 需要导入模块: from sugar.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar.graphics.toolbutton.ToolButton import queue_draw [as 别名]

#.........这里部分代码省略.........
        separator.set_draw(False)
        self.insert(separator, -1)
        separator.show()
        
        # Undo
        self.__undo = ToolButton('edit-undo')
        self.insert(self.__undo, -1)
        self.__undo.show()
        self.__undo.set_tooltip(_('Undo'))
        self.__undo.connect('clicked', self.undo)
        
        # Redo
        self.__redo = ToolButton('edit-redo')
        self.insert(self.__redo, -1)
        self.__redo.show()
        self.__redo.set_tooltip(_('Redo'))
        self.__redo.connect('clicked', self.redo)
        
        separator = gtk.SeparatorToolItem()
        separator.set_draw(False)
        separator.set_expand(True)
        self.insert(separator, -1)
        separator.show()
        
        self.__submit = ToolButton('broadcast')
        self.insert(self.__submit, -1)
        self.__submit.show()
        self.__submit.set_tooltip(_('Broadcast Submission'))
        self.__submit.connect('clicked', self.submit_ink_cb)
        
        self.__arbiter.connect_joined(self.activity_joined_cb)

        self.set_tool_buttons()
        self.show()
        self.update_buttons()
    
    def activity_joined_cb(self, widget):
        self.__submit.set_tooltip(_('Submit Ink'))
        self.__submit.set_icon('dialog-ok')
    
    def set_cur_pen(self, widget, size):
        self.__arbiter.do_set_pen(size)

    def set_ink_color(self, widget, r, g, b, color):    
        self.__arbiter.do_set_color(r, g, b)

    def erase_btn_clicked(self, widget):
        self.__arbiter.do_clear_ink()
        
    def set_tool_buttons(self):    
        if self.__cur_color == (1.0, 0.0, 0.0):
            self.__red.set_active(True)
        elif self.__cur_color == (0.0, 1.0, 0.0):
            self.__green.set_active(True)
        elif self.__cur_color == (0.0, 0.0, 1.0):
            self.__blue.set_active(True)
        else:
            self.__black.set_active(True)
            
        if self.__cur_pen == 2:
            self.__pencil.set_active(True)
        elif self.__cur_pen == 5:
            self.__brush.set_active(True)
            
    
    def submit_ink_cb(self, widget):
        if self.__arbiter.get_is_instructor():
            self.__logger.debug("Broadcast clicked")
            self.broadcast_ink()
        else:
            self.__logger.debug("Submit clicked")
            self.__submit.set_sensitive(False)
            self.__timer = threading.Timer(10.0, self.reenable_submissions)
            self.__timer.start()
            self.__arbiter.do_submit_ink()
        
    def broadcast_ink(self):
        self.__arbiter.do_broadcast_ink()
    
    def reenable_submissions(self):
        gtk.gdk.threads_enter()
        self.__submit.set_sensitive(True)
        self.__submit.queue_draw()
        gtk.gdk.threads_leave()
    
    def undo(self, widget):
        self.__arbiter.do_undo()
    
    def redo(self, widget):
        self.__arbiter.do_redo()
    
    def update_buttons(self, widget=None):
        can_undo, can_redo = self.__arbiter.get_can_undo_redo()
        self.__undo.set_sensitive(can_undo)
        self.__redo.set_sensitive(can_redo)
        if self.__arbiter.get_is_instructor():
            if self.__arbiter.get_active_submission() == -1:
                self.__submit.set_sensitive(False)
            else:
                self.__submit.set_sensitive(True)
开发者ID:Jian117,项目名称:Classroom-Presenter,代码行数:104,代码来源:toolbars.py

示例2: InkToolBar

# 需要导入模块: from sugar.graphics.toolbutton import ToolButton [as 别名]
# 或者: from sugar.graphics.toolbutton.ToolButton import queue_draw [as 别名]

#.........这里部分代码省略.........
        separator.set_draw(False)
        self.insert(separator, -1)
        separator.show()
        
        # Undo
        self.__undo = ToolButton('edit-undo')
        self.insert(self.__undo, -1)
        self.__undo.show()
        self.__undo.set_tooltip('Undo')
        self.__undo.connect('clicked', self.undo)
        
        # Redo
        self.__redo = ToolButton('edit-redo')
        self.insert(self.__redo, -1)
        self.__redo.show()
        self.__redo.set_tooltip('Redo')
        self.__redo.connect('clicked', self.redo)
        
        separator = gtk.SeparatorToolItem()
        separator.set_draw(False)
        separator.set_expand(True)
        self.insert(separator, -1)
        separator.show()
        
        self.__submit = ToolButton('dialog-ok') #FIXME (though actually not a terrible icon)
        self.insert(self.__submit, -1)
        self.__submit.show()
        self.__submit.set_tooltip('Broadcast Submission')
        self.__submit.connect('clicked', self.submit_ink)
        
        self.__deck.connect('instr_state_propagate', self.instructor_state_cb)
        
        self.set_tool_buttons()
        self.show()
    
    def instructor_state_cb(self, widget, is_instr):
        self.__is_instr = is_instr
        if is_instr:
            self.__submit.set_tooltip('Broadcast Submission')
        else:
            self.__submit.set_tooltip('Submit Ink')
            
    
    def set_cur_pen(self, widget, size):
        self.__slideviewer.set_pen(size)

    def set_ink_color(self, widget, r, g, b, color):    
        self.__slideviewer.set_color(r, g, b)
            
    
    def set_erase(self, widget):
        self.__slideviewer.clear_ink()
        
    def set_tool_buttons(self): 
        if self.__cur_color == (1.0, 0.0, 0.0):
            self.__red.set_active(True)
        elif self.__cur_color == (0.0, 1.0, 0.0):
            self.__green.set_active(True)
        elif self.__cur_color == (0.0, 0.0, 1.0):
            self.__blue.set_active(True)
        else:
            self.__black.set_active(True)
            
        if self.__cur_pen == 2:
            self.__pencil.set_active(True)
        elif self.__cur_pen == 5:
            self.__brush.set_active(True)
            
    
    def submit_ink(self, widget):
        if self.__is_instr:
            self.broadcast_ink()
        else:
            self.__submit.set_sensitive(False)
            self.__timer = threading.Timer(3.0, self.reenable_submissions)
            self.__timer.start()
            self.__slideviewer.submit_ink()
        
    def broadcast_ink(self):
        self.__slideviewer.broadcast_ink()
    
    def reenable_submissions(self):
        self.__submit.set_sensitive(True)
        self.__submit.queue_draw()
    
    def undo(self, widget):
        self.__slideviewer.undo()
    
    def redo(self, widget):
        self.__slideviewer.redo()
    
    def update_buttons(self, widget=None):
        can_undo, can_redo = self.__slideviewer.can_undo_redo()
        self.__undo.set_sensitive(can_undo)
        self.__redo.set_sensitive(can_redo)
        if self.__is_instr:
            if self.__deck.getActiveSubmission() == -1:
                self.__submit.set_sensitive(False)
            else:
                self.__submit.set_sensitive(True)
开发者ID:Daksh,项目名称:showntell,代码行数:104,代码来源:toolbars.py


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