Beispiel #1
0
Datei: page.py Projekt: herzi/ccc
    def __init__(self):
        self.title = 'Empty Page'
        
        # Create CCCanvas item and widget with this item as root
        self.cc_item = cccanvas.Item() 
        self.widget = cccanvas.view_widget_new_root(self.cc_item)

        # show the widget
        self.widget.show()
Beispiel #2
0
    def __init__(self):
        self.title = 'Crossing'
        
        self.colors = [ cccanvas.color_new_rgb(0.0,0.0,0.0),
                        cccanvas.color_new_rgb(1.0,0.0,0.0) ]

        self.brushs = []
        
        self.brushs.append(cccanvas.BrushColor(self.colors[0]))
        self.brushs.append(cccanvas.BrushColor(self.colors[1]))

        #self.brushs = [ cccanvas.BrushColor(self.colors[0]),
        #                cccanvas.BrushColor(self.colors[1]) ]

        # main widget
        self.widget = gtk.VBox(False, 6)
        self.widget.set_border_width(6)

        # Scroll
        #swin = gtk.ScrolledWindow()
        #self.widget.pack_start(swin)

        # Create CCCanvas item and widget with this item as root
        self.root = cccanvas.Item() 
        self.view = cccanvas.view_widget_new_root(self.root)
        self.view.show()

        self.widget.pack_start(self.view)

        # Label
        self.label = gtk.Label('Move the mouse over a circle')
        self.label.show()
        self.widget.pack_start(self.label)

        n_circles = 12
        center = 130.0
        radius = 125.0

        r = [ 25.5,
              15.0,
              9.0,
              5.4,
              3.24 ]
        r.append( r[4]*0.6 )
        r.append( r[5]*0.6 )
        r.append( r[6]*0.6 )
 
        
        for i in range(n_circles):
            out = 0
            for r_el in r:
                circle = cccanvas.Circle()
                out += r_el
                circle.set_anchor( center + (radius - out) * sin(2.0*pi*i/n_circles),
                                   center - (radius - out) * cos(2.0*pi*i/n_circles))
                circle.set_radius( r_el );
                circle.set_brush_border (self.brushs[0])
                
                circle.connect("enter-notify-event", self.enter_callback)
                circle.connect("leave-notify-event", self.leave_callback)

                self.root.append(circle)
                
        self.widget.show()
Beispiel #3
0
    def __init__(self):
        self.title = 'Text Element'
        self.widget = gtk.VBox(False, 6)

        self.root = cc.Item()
        self.text = cc.Text()

        self.text.SET_FLAGS(cc.CAN_FOCUS)

        self.text.set_editable(True)

        self.root.append(self.text)

        self.rect = cc.Rectangle()
        self.rect.set_grid_aligned(True)

        self.root.append(self.rect)

        self.arrow = cc.Line()
        self.arrow.set_grid_aligned(True)
        self.arrow.line(5.0, 0.0)
        self.arrow.line(0.0, 5.0)
        self.arrow.line(0.0, 0.0)
        self.arrow.line(5.0, 0.0)

        self.root.append(self.arrow)
        self.arrow.set_brush_border(
            cc.BrushColor(cc.color_new_rgba(0.0, 0.0, 1.0, 0.5)))
        self.rect.set_brush_border(
            cc.BrushColor(cc.color_new_rgba(1.0, 0.0, 0.0, 0.5)))
        
        self.text.connect("all-bounds-changed", self.update_bounds, self.rect)

        self.canvas = cc.view_widget_new_root(self.root)
        self.canvas.set_flags(gtk.CAN_FOCUS)
        
        self.widget.pack_start(self.canvas)

        self.notebook = gtk.Notebook()
        self.widget.pack_start(self.notebook, False, False, 0)

        props = herzi_properties.HerziProperties()

        prop_group = props.add("Canvas View")

        widget = gtk.ToggleButton()
        widget.set_use_underline(True)
        widget.connect("toggled", self.canvas_center_view_toggled, self.canvas)

        self.canvas_center_view_toggled(widget, self.canvas)

        prop_group.add("_Center View", widget)        

        widget = gtk.SpinButton(climb_rate=0.01, digits=2)
        widget.set_range(0, 30)
        widget.set_increments(0.01, 0.1)
        
        widget.set_value(self.canvas.get_zoom())

        widget.connect("value-changed", self.canvas_zoom_changed, self.canvas)
        
        prop_group.add("_Zoom", widget)        

        self.notebook.append_page(props, gtk.Label("Canvas View"))

        props = herzi_properties.HerziProperties()

        prop_group = props.add("Text Element")
         
        widget = herzi_combo.HerziCombo(gtk.ANCHOR_CENTER)
        widget.connect("changed", self.text_anchor_type_changed, self.text)
        self.text_anchor_type_changed(widget, self.text)
        prop_group.add("_Anchor Type", widget)

        widget = gtk.ToggleButton()
        widget.set_use_underline(True)
        widget.connect("toggled", self.text_size_pixels_toggled, self.text)
        self.text_size_pixels_toggled(widget, self.text)
 
        prop_group.add("_Size in Pixels", widget)        

        widget = gtk.Entry()
        widget.connect("notify::text", self.text_text_changed, self.text)
        widget.set_text('libccc 0.0.2')
        
        self.text.connect("notify::text", self.update_entry_from_layout, widget)
        prop_group.add("_Text", widget)
        
        self.notebook.append_page(props, gtk.Label("Text Element"))
        
        self.widget.show_all()