Пример #1
0
        def __init__(self, pf, box , win, path):
            
            self.box = box
            self.win = win
            self.pf = pf
            self.path = path
            
            self.allowed = True
            self.scroll = 0
            
            self.dW = 0
            self.DH = 0
            
            self.mpx = 0
            self.mpy = 0
            self.mpf = ""
            
            
            cblndr = ""
             
             
                                        
            try:
                bv = open(self.pf+"/py_data/blenderver.data", "r")
                bv = bv.read().split("\n")
                
                print "BLENDER VERSION YOU LOOOKING FOR IS : ", bv
                
                if int(bv[0]) > 0:
                    cblndr = bv[int(bv[0])]+"/"
            except:
                print "COULNT LOAD THE RIGHT BLENDER"
            
            
            
            
            self.objicon = gtk.gdk.pixbuf_new_from_file(self.pf+"/py_data/icons/obj_asset_undone.png")
            self.chricon = gtk.gdk.pixbuf_new_from_file(self.pf+"/py_data/icons/chr_asset_undone.png")
            self.vehicon = gtk.gdk.pixbuf_new_from_file(self.pf+"/py_data/icons/veh_asset_undone.png")
            self.locicon = gtk.gdk.pixbuf_new_from_file(self.pf+"/py_data/icons/loc_asset_undone.png")
            self.settingsicon = gtk.gdk.pixbuf_new_from_file(self.pf+"/py_data/icons/settings.png")
            self.collectionicon = gtk.gdk.pixbuf_new_from_file(self.pf+"/py_data/icons/collection.png")
            self.meshicon = gtk.gdk.pixbuf_new_from_file(self.pf+"/py_data/icons/mesh.png")
            
            self.blendericon = gtk.gdk.pixbuf_new_from_file(self.pf+"/py_data/icons/blender.png")
            self.plus = gtk.gdk.pixbuf_new_from_file(self.pf+"/py_data/icons/plus.png")
            
            self.blenddata = []
            
            
            # FOR THE CREATOR OF THE AST
            self.itemblends = []
            self.itemblendsselect = 0
            
            l = 0
            for FILE in os.walk(self.pf+"/dev/"+self.path).next()[2]:
            
                if FILE.endswith(".blend"):
                
                    self.itemblends.append(FILE)
                    
                    print FILE, "BLENDFILE "
                    
                    
                    if FILE == self.path[4:]+".blend":
                        
                        
                        self.itemblendsselect = l
                        print FILE, "THIS IS THE ONE", self.itemblendsselect
                    
                    l = l + 1
            
            
            def framegraph(widget, event):
                                                                
                w, h = widget.window.get_size()
                xgc = widget.window.new_gc()
                
                mx, my, fx  = widget.window.get_pointer()
                
                
                # GETTING WHETHER THE WINDOW IS ACTIVE
                
                self.winactive = self.win.is_active()
                
                ctx = widget.window.cairo_create()
                #ctx.select_font_face("Sawasdee", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
                ctx.set_source_rgb(1,1,1)
                
                xgc.line_width = 2
                
                # BACKGROUND COLOR
                xgc.set_rgb_fg_color(gtk.gdk.color_parse("#2b2b2b")) ## CHOSE COLOR
                widget.window.draw_rectangle(xgc, True, 0, 0, w, h)  ## FILL FRAME 
                
                # the asset blendfile to read from
                assetblend = self.pf+"/ast/"+self.path+".blend"
                
                
                
                # IF THE AST FILE IS ASSINGED
                
                
                if os.path.exists(assetblend): 
                    
                
                
                    #FILENAME
                    ctx.set_font_size(15)
                    ctx.move_to( 22,20+self.scroll)
                    ctx.show_text("/ast/"+self.path+".blend") 
                
                
                
                    if len(self.blenddata) == 0:
                        
                        # READING DATA
                        
                        checkframes = Popen([cblndr+"blender", "-b", assetblend , "-P", self.pf+"/py_data/modules/get_linkdata.py"],stdout=PIPE, universal_newlines=True)

                        checkframes.wait()
                        checkstring = checkframes.stdout.read()
                    
                        #print checkstring
                        
                        #self.blenddata.append(checkstring)
                        
                        print "########## ALL THE DATA FROM BLENDER ##########\n\n", checkstring, "\n\n############## DONE ##############"
                        
                        
                        if "VERSION = SUCCESS" in checkstring:
                            
                            currentcollection = []
                            colname = ""
                            
                            for collection in checkstring.split("\n"):
                                if collection.startswith(">>>"):
                                    #print collection, "TESTING HERE"
                                    
                                    if " <== " in collection:
                                        coln = collection[4:collection.find(" <== ")]
                                        if coln != colname:
                                            print coln, "COLLECTION"
                                            
                                            
                                            self.blenddata.append([[False, colname], currentcollection])
                                            currentcollection = []
                                        print "    |", collection[collection.find(" <== ")+5:], "OBJECT"
                                        
                                        currentcollection.append([False, collection[collection.find(" <== ")+5:]])
                                        colname = coln
                                    else:
                                          coln = collection[4:]
                                          self.blenddata.append([[False, coln], []])
                                          
                                          #colname = coln
                                    
                                if collection.startswith("VERSION"): # GETTING THE LAST THING IN THE LIST
                                    self.blenddata.append([[False, colname], currentcollection])
                                
                                
                            self.blenddata = self.blenddata[1:]
                            self.load()
                            #print self.blenddata
                                    
                        else:      
                            ctx.set_font_size(15)
                            ctx.move_to( 22,40)
                            ctx.show_text("Please update to Blender 2.80 or later") 
                            self.allowed = False
                
                
                
                    # WHEN DATA ALREADY LOADED
                    coly = 50
                    objy = 50
                    
                    ctx.set_font_size(14)
                    ctx.move_to( 22, 45+self.scroll)
                    ctx.show_text("Collections To Link") 
                    
                    xgc.set_rgb_fg_color(gtk.gdk.color_parse("#222222")) ## CHOSE COLOR
                    widget.window.draw_rectangle(xgc, True, 0, 55+self.scroll,  w/2-5, h-self.scroll)
                    
                    
                    
                    ctx.set_font_size(14)
                    ctx.move_to( w/2 + 22, 45+self.scroll)
                    ctx.show_text("Make Proxies") 
                    
                    xgc.set_rgb_fg_color(gtk.gdk.color_parse("#222222")) ## CHOSE COLOR
                    widget.window.draw_rectangle(xgc, True, w/2, 55+self.scroll,  w/2, h-self.scroll)
                    
                    
                    
                    for coln, collection in enumerate(self.blenddata): #FOR ALL THE COLLECTIONS
                        
                        
                        
                        colactive = collection[0][0] #WHETHER IS SELECTED
                        colname = collection[0][1] #NAME OF THE COLLECTION
                        colobjs = collection[1] #OBJECTS IN THIS COLLECTION
                        
                        
                        coly = coly + 22
                        
                        
                        #mouse over
                        if my in range(coly-18+self.scroll, coly+self.scroll) and my in range(0, h) and mx in range(0,w/2-5):
                            xgc.set_rgb_fg_color(gtk.gdk.color_parse("#3f3f3f")) ## CHOSE COLOR
                            widget.window.draw_rectangle(xgc, True, 0, coly-18+self.scroll,  w/2-5, 22)
                            
                            
                            if "GDK_BUTTON1" in str(fx) and self.allowed and "GDK_BUTTON1" not in str(self.mpf) and win.is_active(): #IF CLICKED
                                
                                self.blenddata[coln][0][0] = not colactive
                                self.save()
                                
                        
                        if colactive:
                            xgc.set_rgb_fg_color(gtk.gdk.color_parse("#395384")) ## CHOSE COLOR
                            widget.window.draw_rectangle(xgc, True, 0, coly-18+self.scroll,  w/2-5, 22)
                        
                        
                        
                        ctx.set_font_size(15)
                        ctx.move_to( 22, coly+self.scroll)
                        ctx.show_text(colname) 
                        
                        widget.window.draw_pixbuf(None, self.collectionicon, 0, 0, 1, coly+self.scroll-18, -1, -1, gtk.gdk.RGB_DITHER_NONE, 0, 0) 
                        
                        
                        
                        
                        if colactive:  #IF THIS COLLECTION IS ACTIVE
                            for objn, obj in enumerate(colobjs):
                                
                                
                                
                                objactive = obj[0]
                                objname = obj[1]
                                
                                
                                objy = objy + 22
                                
                                
                                #mouse over
                                if my in range(objy-18+self.scroll, objy+self.scroll) and my in range(0, h) and mx in range(w/2,w):
                                    xgc.set_rgb_fg_color(gtk.gdk.color_parse("#3f3f3f")) ## CHOSE COLOR
                                    widget.window.draw_rectangle(xgc, True, w/2, objy-18+self.scroll,  w, 22)
                                    
                                    
                                    if "GDK_BUTTON1" in str(fx) and self.allowed and "GDK_BUTTON1" not in str(self.mpf) and win.is_active(): #IF CLICKED
                                        
                                        self.blenddata[coln][1][objn][0] = not objactive
                                        self.save()
                                
                                if objactive:
                                    xgc.set_rgb_fg_color(gtk.gdk.color_parse("#395384")) ## CHOSE COLOR
                                    widget.window.draw_rectangle(xgc, True, w/2, objy-18+self.scroll,  w, 22)
                                    
                                
                                
                                
                                ctx.set_font_size(15)
                                ctx.move_to( w/2+22, objy+self.scroll)
                                ctx.show_text(objname) 
                        
                                widget.window.draw_pixbuf(None, self.meshicon, 0, 0, w/2, objy+self.scroll-18, -1, -1, gtk.gdk.RGB_DITHER_NONE, 0, 0) 
                
                                
                
                
                
                # IF ASSET FILE IS STILL NOT ASSINGED
                
                else:
                    
                    
                    percent = checklist.partcalculate(checklist.openckecklist(self.pf+"/dev/"+self.path+"/asset.progress"))
                    
                    
                    # IF CHECKLIST IF NOT YET FULLY DONE
                    if percent < 0.99:
                        
                        #test
                        ctx.set_font_size(15)
                        ctx.move_to( 20,20)
                        ctx.show_text("Checklist is at "+str(percent*100)+"%") 
                    
                        ctx.set_font_size(15)
                        ctx.move_to( 20,40)
                        ctx.show_text("Please return when this asset is fully created.") 
                    
                    if percent > 0.98:
                        
                        ctx.set_font_size(15)
                        ctx.move_to( 20,20+self.scroll)
                        ctx.show_text("You are ready to create the /AST/ BLEND FILE") 
                        
                        ctx.set_font_size(15)
                        ctx.move_to( 20,40+self.scroll)
                        ctx.show_text("If changes will be nessesary you will need")
                        
                        ctx.set_font_size(15)
                        ctx.move_to( 20,60+self.scroll)
                        ctx.show_text("to edit /ast/"+self.path+".blend manually.")
                        
                        xgc.set_rgb_fg_color(gtk.gdk.color_parse("#222222")) ## CHOSE COLOR
                        widget.window.draw_rectangle(xgc, True, 0, 80+self.scroll,  w/3*2, h-self.scroll)
                        #self.itemblends
                        #self.itemblendsselect
                        
                        for n, i in enumerate(self.itemblends):
                            
                            # IF THIS BLENDFILE SELECTED
                            if n == self.itemblendsselect:
                                xgc.set_rgb_fg_color(gtk.gdk.color_parse("#395384")) ## CHOSE COLOR
                                widget.window.draw_rectangle(xgc, True, 0, 100+self.scroll+n*20-18,  w/3*2, 20)
                                
                                #mouse over blendfile
                                if my in range(100+self.scroll+n*20-18, 100+self.scroll+n*20-18+20) and my in range(0, h) and mx in range(w/3*2, w):
                                    xgc.set_rgb_fg_color(gtk.gdk.color_parse("#3f3f3f")) ## CHOSE COLOR
                                    widget.window.draw_rectangle(xgc, True, w/3*2, 100+self.scroll+n*20-18,  w/3*2, 20)
                                    
                                    
                                    if "GDK_BUTTON1" in str(fx) and self.allowed and "GDK_BUTTON1" not in str(self.mpf) and win.is_active(): #IF CLICKED
                                        
                                        print "BEFORECHECK"
                                        checkframes = Popen([cblndr+"blender", "-b", self.pf+"/dev/"+self.path+"/"+i , "-P", self.pf+"/py_data/modules/makeast.py"],stdout=PIPE, universal_newlines=True)

                                        checkframes.wait()
                                        checkstring = checkframes.stdout.read()
                                        print checkstring, "CHECKSTRING"
                                
                                
                                
                                widget.window.draw_pixbuf(None, self.settingsicon, 0, 0, w/3*2+2, 100+self.scroll+n*20-18, -1, -1, gtk.gdk.RGB_DITHER_NONE, 0, 0) 
                                ctx.set_font_size(15)
                                ctx.move_to( w/3*2+30,100+self.scroll+n*20)
                                ctx.show_text("Make /AST/")
                                
                            #mouse over blendfile
                            if my in range(100+self.scroll+n*20-18, 100+self.scroll+n*20-18+20) and my in range(0, h) and mx in range(0,w/3*2):
                                xgc.set_rgb_fg_color(gtk.gdk.color_parse("#3f3f3f")) ## CHOSE COLOR
                                widget.window.draw_rectangle(xgc, True, 0, 100+self.scroll+n*20-18,  w/3*2, 20)
                                
                                
                                if "GDK_BUTTON1" in str(fx) and self.allowed and "GDK_BUTTON1" not in str(self.mpf) and win.is_active(): #IF CLICKED
                                    self.itemblendsselect = n
                                        
                            
                            ctx.set_font_size(15)
                            ctx.move_to( 30,100+self.scroll+n*20)
                            ctx.show_text(i)
                            
                            widget.window.draw_pixbuf(None, self.blendericon, 0, 0, 2, 100+self.scroll+n*20-18, -1, -1, gtk.gdk.RGB_DITHER_NONE, 0, 0) 
                            
                            
                        
                
                
                # SCROLLING IT SELF
                # the scroll is done with the middle mouse button
                if self.mpy > my and "GDK_BUTTON2" in str(fx) and "GDK_BUTTON2" in str(self.mpf) and mx in range(0, w):
                    self.scroll = self.scroll + (my-self.mpy)
                    
                if self.mpy < my and "GDK_BUTTON2" in str(fx) and "GDK_BUTTON2" in str(self.mpf) and mx in range(0, w):
                    self.scroll = self.scroll - (self.mpy-my)
                
                
                #if self.scroll < 0-((n+al)*20)+h-33:  #THOSE VALUES HAVE TO BE REDONE
                #    self.scroll = 0-((n+al)*20)+h-33
                    
                if self.scroll > 0:
                    self.scroll = 0
                
                
            
                # TESTING SOMETHING
                ctx.set_font_size(20)
                ctx.move_to( mx, my)
                #ctx.show_text(str(mx)+":"+str(my)+"  "+str(self.winactive)+"   "+str(fx)) 
                
                self.dW = w
                self.DH = h
                
                self.mpx = mx
                self.mpy = my
                self.mpf = fx
                
                
                def callback():
                    if self.allowed == True:
                        widget.queue_draw()
                        

                glib.timeout_add(1, callback)
                
                
                
                
            graph = gtk.DrawingArea()
            graph.set_size_request(400,400)

            self.box.pack_start(graph)
            graph.show()
            graph.connect("expose-event", framegraph)         
Пример #2
0
    def __init__(self, test_res, test_borders=None,
                 full_res=None,
                 localdir=None, remotedir=None,
                 secs=5,
                 rangefinder=None):
        self.test_res = test_res
        self.width = test_res[0]
        self.height = test_res[1]
        self.localdir = localdir
        self.remotedir = remotedir
        self.full_res = full_res
        self.millisecs = secs * 1000

        self.use_tmp_file = True

        self.win = gtk.Window()
        self.win.set_border_width(10)

        # Unfortunately delete and destroy events don't work on the RPi.
        # Not sure why, but most of the time the event never gets passed.
        # It works on other Linux platforms.
        self.win.connect("delete_event", self.quit)
        self.win.connect("destroy", self.quit)

        vbox = gtk.VBox(spacing=3)
        self.win.add(vbox)

        self.drawing_area = gtk.DrawingArea()
        self.drawing_area.set_size_request(self.width, self.height)
        #self.win.add(self.drawing_area)
        vbox.pack_start(self.drawing_area)

        self.drawing_area.set_events(gtk.gdk.EXPOSURE_MASK |
                                     # gtk.gdk.POINTER_MOTION_MASK |
                                     # gtk.gdk.POINTER_MOTION_HINT_MASK |
                                     gtk.gdk.BUTTON_PRESS_MASK |
                                     gtk.gdk.BUTTON_RELEASE_MASK )

        try:
            # GTK2:
            self.drawing_area.connect("expose-event", self.expose_handler)
        except TypeError:
            # Python3/GI GTK3:
            self.drawing_area.connect('size-allocate', self.on_size_allocate)
            self.width = self.height = 0
            self.drawing_area.connect('draw', self.expose3)

        self.drawing_area.connect("button_press_event", self.button_press)
        self.drawing_area.connect("button_release_event", self.button_release)
        self.drawing_area.connect("motion_notify_event", self.drag_handler)

        # Just for testing, temporarily
        self.num = 0

        glib.timeout_add(self.millisecs, self.idle_handler,
                         self.drawing_area)

        # GTK2: X GC
        self.gc = None

        self.redgc = None
        self.pixbuf = None
        self.imgwidth = None
        self.imgheight = None
        self.cur_img = None
        self.drag_start_x = None
        self.drag_start_y = None

        try:
            self.win.show_all()
        except:
            print("Couldn't show window: exiting")
            sys.exit(1)

        # And the motion detecting parts,
        # which are infinitely simpler than the GTK garbage:
        self.md = MotionDetector(test_res=test_res, test_borders=test_borders,
                                 full_res=self.full_res,
                                 sensitivity=400,
                                 threshold=30,
                                 localdir=self.localdir,
                                 remotedir=self.localdir,
                                 rangefinder=rangefinder,
                                 verbose=2)
        self.buf1 = None
        self.buf2 = None
Пример #3
0
    def create_labels(self):
        """Create the labels for the signal block."""
        Element.create_labels(self)
        self._bg_color = self.is_dummy_block() and Colors.MISSING_BLOCK_BACKGROUND_COLOR or \
                         self.get_bypassed() and Colors.BLOCK_BYPASSED_COLOR or \
                         self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR

        layouts = list()
        #create the main layout
        layout = gtk.DrawingArea().create_pango_layout('')
        layouts.append(layout)
        layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self, font=BLOCK_FONT))
        self.label_width, self.label_height = layout.get_pixel_size()
        #display the params
        if self.is_dummy_block():
            markups = [
                '<span foreground="black" font_desc="{font}"><b>key: </b>{key}</span>'.format(font=PARAM_FONT, key=self._key)
            ]
        else:
            markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')]
        if markups:
            layout = gtk.DrawingArea().create_pango_layout('')
            layout.set_spacing(LABEL_SEPARATION*pango.SCALE)
            layout.set_markup('\n'.join(markups))
            layouts.append(layout)
            w, h = layout.get_pixel_size()
            self.label_width = max(w, self.label_width)
            self.label_height += h + LABEL_SEPARATION
        width = self.label_width
        height = self.label_height
        #setup the pixmap
        pixmap = self.get_parent().new_pixmap(width, height)
        gc = pixmap.new_gc()
        gc.set_foreground(self._bg_color)
        pixmap.draw_rectangle(gc, True, 0, 0, width, height)
        #draw the layouts
        h_off = 0
        for i,layout in enumerate(layouts):
            w,h = layout.get_pixel_size()
            if i == 0: w_off = (width-w)/2
            else: w_off = 0
            pixmap.draw_layout(gc, w_off, h_off, layout)
            h_off = h + h_off + LABEL_SEPARATION
        #create vertical and horizontal pixmaps
        self.horizontal_label = pixmap
        if self.is_vertical():
            self.vertical_label = self.get_parent().new_pixmap(height, width)
            Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
        #calculate width and height needed
        self.W = self.label_width + 2 * BLOCK_LABEL_PADDING

        def get_min_height_for_ports():
            visible_ports = filter(lambda p: not p.get_hide(), ports)
            H = 2*PORT_BORDER_SEPARATION + len(visible_ports) * PORT_SEPARATION
            if visible_ports: H -= ports[0].H
            return H
        self.H = max(
            [  # labels
                self.label_height + 2 * BLOCK_LABEL_PADDING
            ] +
            [  # ports
                get_min_height_for_ports() for ports in (self.get_sources_gui(), self.get_sinks_gui())
            ] +
            [  # bus ports only
                2 * PORT_BORDER_SEPARATION +
                sum([port.H + PORT_SPACING for port in ports if port.get_type() == 'bus']) - PORT_SPACING
                for ports in (self.get_sources_gui(), self.get_sinks_gui())
            ]
        )
        self.has_busses = [
            any(port.get_type() == 'bus' for port in ports)
            for ports in (self.get_sources_gui(), self.get_sinks_gui())
        ]
        self.create_comment_label()
Пример #4
0
def main():
    global loadSegy, buttonFilter

    window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    window.set_title("SEG-Y File Viewer by AJ OVALLES Seismic Processing Toys")

    main.hbox = gtk.HBox(False, 0)
    window.add(main.hbox)
    main.hbox.show()

    ##### CREATING LEFT MENU   ##########

    main.tablePar = gtk.Table(15, 4, False)
    main.tablePar.show()
    main.hbox.pack_start(main.tablePar)

    labelfile = gtk.Label("Input File: ")
    labelfile.show()
    main.tablePar.attach(labelfile, 0, 4, 1, 2)
    main.entryFileIn = gtk.Entry()
    main.entryFileIn.set_text("CDPSyn200t_801m.sgy")
    main.entryFileIn.show()
    main.tablePar.attach(main.entryFileIn, 0, 4, 2, 3)

    labelfold = gtk.Label("Fold: ")
    labelfold.show()
    main.entryFold = gtk.Entry()
    main.entryFold.set_text("200")
    main.entryFold.show()
    main.tablePar.attach(labelfold, 0, 2, 3, 4)
    main.tablePar.attach(main.entryFold, 2, 4, 3, 4)

    labelrecord = gtk.Label("CDP: ")
    labelrecord.show()
    main.entryRecord = gtk.Entry()
    main.entryRecord.set_text("1")
    main.entryRecord.show()
    main.tablePar.attach(labelrecord, 0, 2, 4, 5)
    main.tablePar.attach(main.entryRecord, 2, 4, 4, 5)

    loadSegy = gtk.Button(label="Load CDP")
    loadSegy.show()
    main.tablePar.attach(loadSegy, 0, 4, 5, 6)
    loadSegy.connect("clicked", on_loadSegy_clicked)

    labelIncrement = gtk.Label("CDP Increment: ")
    labelIncrement.show()
    main.entryIncrement = gtk.Entry()
    main.entryIncrement.set_text("1")
    main.entryIncrement.show()
    main.tablePar.attach(labelIncrement, 0, 3, 6, 7)
    main.tablePar.attach(main.entryIncrement, 3, 4, 6, 7)

    buttonNext = gtk.Button(label="Next CDP")
    buttonNext.show()
    main.tablePar.attach(buttonNext, 0, 4, 7, 8)
    buttonNext.connect("clicked", on_buttonNext_clicked)

    buttonSlantStack = gtk.Button(label="Show Slant Stack")
    #buttonSlantStack.show()
    main.tablePar.attach(buttonSlantStack, 0, 4, 9, 10)
    buttonSlantStack.connect("clicked", on_buttonSlantStack_clicked)

    buttonFilter = gtk.Button(label="Apply Filter")
    #buttonFilter.show()
    main.tablePar.attach(buttonFilter, 0, 4, 10, 11)
    buttonFilter.connect("clicked", on_buttonFilter_clicked)

    buttonExport = gtk.Button(label="Export Filtered SEGY")
    #buttonExport.show()
    main.tablePar.attach(buttonExport, 0, 4, 11, 12)
    buttonExport.connect("clicked", on_buttonExport_clicked)

    window.connect("destroy", lambda w: gtk.main_quit())

    ###### CREATING RIGHT DISPLAY   ########
    main.tableDis = gtk.Table(2, 3, False)
    main.tableDis.show()
    main.hbox.pack_start(main.tableDis)

    # Create the drawing area
    main.drawing_area = gtk.DrawingArea()
    main.drawing_area.set_size_request(300, 500)

    window.show()

    gtk.main()

    return 0
Пример #5
0
 def __init__(self, page, cfg):
     gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
     self.w_cfg = w_cfg = cfg.window
     self.set_title(APPLICATION_NAME)
     ## Header
     box = gtk.EventBox()
     box.modify_bg(gtk.STATE_NORMAL, w_cfg.header_bg_color)
     self.header = gtk.Label()
     header_font = pango.FontDescription(w_cfg.header_font)
     self.header.modify_font(header_font)
     self.header.modify_fg(gtk.STATE_NORMAL, w_cfg.header_fg_color)
     self.header.set_padding(
         0, int((header_font.get_size() / pango.SCALE) * 0.2))
     box.add(self.header)
     ## Separator
     separator = gtk.HSeparator()
     separator.set_size_request(-1, 0)
     separator.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#000000'))
     ## Text area
     self.drawingarea = gtk.DrawingArea()
     self.drawingarea.modify_bg(gtk.STATE_NORMAL, w_cfg.background_color)
     ## Layout
     self.vbox = gtk.VBox()
     self.vbox.pack_start(box, expand=False, fill=False)
     self.vbox.pack_start(separator, expand=False, fill=False)
     self.vbox.pack_start(self.drawingarea)
     self.add(self.vbox)
     ## Resize
     line_1 = w_cfg.text_font_size + w_cfg.line_gap
     char_1 = w_cfg.text_font_size + w_cfg.char_gap
     ## Decide window size
     self.win_width = (page.lpp * line_1 - w_cfg.line_gap +
                       w_cfg.left_margin + w_cfg.right_margin)
     ## 禁則処理用に一列追加
     self.win_height = ((page.cpl + 1) * char_1 - w_cfg.char_gap +
                        w_cfg.top_margin + w_cfg.bottom_margin)
     ## 描画開始位置
     self.draw_start_positon = (self.win_width -
                                (w_cfg.text_font_size + w_cfg.right_margin),
                                w_cfg.top_margin + w_cfg.text_font_size)
     ## Resize hints
     base_width = w_cfg.left_margin + w_cfg.right_margin - w_cfg.line_gap
     base_height = w_cfg.top_margin + w_cfg.bottom_margin - w_cfg.char_gap
     screen = gtk.gdk.Screen()
     max_width = screen.get_width()
     max_height = screen.get_height() - self.header.size_request()[1]
     max_lpp = int(
         (max_width -
          (w_cfg.left_margin + w_cfg.right_margin) + w_cfg.line_gap) /
         line_1)
     max_cpl = int(
         (max_height -
          (w_cfg.top_margin + w_cfg.bottom_margin) + w_cfg.char_gap) /
         char_1) - 1
     self.max_width = max_lpp * line_1 + base_width
     self.max_height = max_cpl * char_1 + base_height
     self.min_width = int(max_lpp * 0.25) * line_1 + base_width
     self.min_height = int(max_cpl * 0.25) * char_1 + base_height
     self.set_geometry_hints(self.drawingarea, self.min_width,
                             self.min_height, self.max_width,
                             self.max_height, base_width, base_height,
                             line_1, char_1)
     self.drawingarea.set_size_request(self.win_width, self.win_height)
     ## Event handler
     EventHandler(self, page, cfg)
     ## Show all
     self.show_all()
     self.move(w_cfg.win_x, w_cfg.win_y)
Пример #6
0
    def __init__(self, uid, panel_id):
        """Creating the applets core"""
        awn.AppletSimple.__init__(self, "media-player", uid, panel_id)
        self.set_tooltip_text(MediaPlayerApplet.APPLET_NAME)
        self.set_icon_name('media-player')
        self.bind_keys()

        # some initialization stuff
        self.isVideo = False
        self.size = self.get_size()
        self.full_window = None
        self.dialog = awn.Dialog(self)
        self.play_icon = awn.OverlayThemedIcon("media-playback-start")
        self.play_icon.props.scale = 0.4
        self.play_icon.props.active = False
        self.play_icon.props.gravity = gtk.gdk.GRAVITY_SOUTH_EAST
        self.add_overlay(self.play_icon)

        # Recent items menu
        self.recent_items_menu = gtk.Menu()
        for item in self.recentItems:
            menu_item = gtk.MenuItem(item)
            menu_item.connect("activate", self.playItem)
            self.recent_items_menu.append(menu_item)
        self.recent_items_menu.show_all()
        # Popup menu
        self.recent = gtk.MenuItem(_("Recent items"))
        self.recent.set_submenu(self.recent_items_menu)
        self.prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        self.prefs.connect("activate", self.show_prefs)
        self.about = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
        self.about.connect("activate", self.show_about)

        self.popup_menu = self.create_default_menu()
        self.popup_menu.append(self.recent)
        self.popup_menu.append(self.prefs)

        item = gtk.SeparatorMenuItem()
        item.show()
        self.popup_menu.append(item)

        self.popup_menu.append(self.about)
        self.popup_menu.show_all()

        # gstreamer stuff
        self.viSink = gst.element_factory_make(self.video_sink, "viSink")
        self.auSink = gst.element_factory_make(self.audio_sink, "auSink")
        # Set up our playbin
        self.playbin = gst.element_factory_make("playbin", "pbin")
        self.playbin.set_property("video-sink", self.viSink)
        self.playbin.set_property("audio-sink", self.auSink)

        bus = self.playbin.get_bus()
        bus.enable_sync_message_emission()
        bus.add_watch(self.OnGstMessage)
        bus.connect("sync-message::element", self.OnGstSyncMessage)

        # Defining Widgets
        self.vbox = gtk.VBox(spacing=6)
        self.da = gtk.DrawingArea()
        self.da.set_size_request(self.video_width, self.video_height)
        self.da.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000"))
        self.da.set_events(gtk.gdk.ALL_EVENTS_MASK)
        self.mouse_handler_id = self.da.connect("button-press-event",
                                                self.video_clicked)
        self.vbox.pack_start(self.da)
        # Buttons
        self.button_play = gtk.Button(stock='gtk-media-play')
        self.button_stop = gtk.Button(stock='gtk-media-stop')
        self.button_play.connect("clicked", self.button_play_pause_cb)
        self.button_stop.connect("clicked", self.button_stop_cb)
        # Packing Widgets
        self.hbbox = gtk.HButtonBox()
        self.hbbox.set_spacing(2)
        self.hbbox.pack_start(self.button_play)
        self.hbbox.pack_start(self.button_stop)
        self.vbox.add(self.hbbox)
        self.dialog.add(self.vbox)
        # Video can't be played into RGBA widget
        rgbColormap = self.vbox.get_screen().get_rgb_colormap()
        self.da.set_colormap(rgbColormap)
        self.da.realize()

        # Standard AWN Connects
        self.connect("clicked", self.icon_clicked)
        self.connect("context-menu-popup", self.menu_popup)
        self.connect("button-press-event", self.button_press)
        self.dialog.props.hide_on_unfocus = True
        # Drag&drop support
        self.get_icon().drag_dest_set(
            gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION,
            [("text/uri-list", 0, 0),
             ("text/plain", 0, 1)], gtk.gdk.ACTION_COPY)

        self.get_icon().connect("drag-data-received", self.applet_drop_cb)
        self.get_icon().connect("drag-motion", self.applet_drag_motion_cb)
        self.get_icon().connect("drag-leave", self.applet_drag_leave_cb)
Пример #7
0
                                 pixelsize, pixelsize)

    # restarting

    def refresh():

        widget.queue_draw()

    global tickspeed

    if dead == False:

        glib.timeout_add(tickspeed, refresh)


graphics = gtk.DrawingArea()
mainbox.pack_start(graphics)
graphics.connect("expose-event", snake_graphics, snakewindow)

# KEYBORAD SENSORING


def sens(widget, key):

    global direction
    if key.string == "w" and direction != "d":

        direction = "u"
    if key.string == "s" and direction != "u":

        direction = "d"
Пример #8
0
    def __init__(self):
        # Create backing pixmap of the appropriate size
        def configure_event(widget, event):
            x, y, w, h = widget.get_allocation()
            self.pix_map = gtk.gdk.Pixmap(widget.window, w, h)

            # make colors
            self.gc = dict()
            for name, color in (('black', (0, 0, 0)), ('red', (32000, 0, 0)),
                                ('blue', (0, 0, 32000)), ('green', (0, 32000,
                                                                    0))):
                self.gc[name] = self.pix_map.new_gc()
                self.gc[name].set_rgb_fg_color(
                    gtk.gdk.Color(red=color[0], green=color[1], blue=color[2]))
            self.layout = pango.Layout(widget.create_pango_context())
            self.canvas_width = w
            self.canvas_height = h
            self.x_max = eval(x_max, {"__builtins__": {}}, safe_dict)
            self.x_min = eval(x_min, {"__builtins__": {}}, safe_dict)
            self.x_scale = eval(x_scale, {"__builtins__": {}}, safe_dict)
            self.y_max = eval(y_max, {"__builtins__": {}}, safe_dict)
            self.y_min = eval(y_min, {"__builtins__": {}}, safe_dict)
            self.y_scale = eval(y_scale, {"__builtins__": {}}, safe_dict)
            self.previousMouseX = 0
            self.previousMouseY = 0
            self.plot()
            return True

        # Redraw the screen from the backing pixmap
        def expose_event(widget, event):
            x, y, w, h = event.area
            widget.window.draw_drawable(
                widget.get_style().fg_gc[gtk.STATE_NORMAL], self.pix_map, x, y,
                x, y, w, h)
            return False

        # Start marking selection
        def button_press_event(widget, event):
            global x_sel, y_sel

            if event.button == 1:
                self.selection[0][0], self.selection[0][1] = int(event.x), int(
                    event.y)
                self.selection[1][0], self.selection[1][1] = None, None

        # End of selection
        def button_release_event(widget, event):

            if event.button == 1 and event.x != self.selection[0][
                    0] and event.y != self.selection[0][1]:
                xmi, ymi = min(self.graph_x(self.selection[0][0]),
                               self.graph_x(event.x)), min(
                                   self.graph_y(self.selection[0][1]),
                                   self.graph_y(event.y))
                xma, yma = max(self.graph_x(self.selection[0][0]),
                               self.graph_x(event.x)), max(
                                   self.graph_y(self.selection[0][1]),
                                   self.graph_y(event.y))
                self.x_min, self.y_min, self.x_max, self.y_max = xmi, ymi, xma, yma
                parameter_entries_repopulate()
                graph.plot()
                self.selection[1][0] = None
                self.selection[0][0] = None

        # Draw rectangle during mouse movement
        def motion_notify_event(widget, event):

            if event.is_hint:
                x, y, state = event.window.get_pointer()
            else:
                x = event.x
                y = event.y
                state = event.state

            if state & gtk.gdk.BUTTON1_MASK and self.selection[0][
                    0] is not None:
                gc = self.drawing_area.get_style().black_gc
                gc.set_function(gtk.gdk.INVERT)
                if self.selection[1][0] is not None:
                    x0 = min(self.selection[1][0], self.selection[0][0])
                    y0 = min(self.selection[1][1], self.selection[0][1])
                    w = abs(self.selection[1][0] - self.selection[0][0])
                    h = abs(self.selection[1][1] - self.selection[0][1])
                    self.pix_map.draw_rectangle(gc, False, x0, y0, w, h)
                x0 = min(self.selection[0][0], int(x))
                y0 = min(self.selection[0][1], int(y))
                w = abs(int(x) - self.selection[0][0])
                h = abs(int(y) - self.selection[0][1])
                self.pix_map.draw_rectangle(gc, False, x0, y0, w, h)
                self.selection[1][0], self.selection[1][1] = int(x), int(y)
                self.draw_drawable()
            elif state & gtk.gdk.BUTTON2_MASK:
                dx = event.x - self.previousMouseX
                dy = event.y - self.previousMouseY
                dx = dx / self.canvas_width * (self.x_max - self.x_min)
                dy = dy / self.canvas_height * (self.y_max - self.y_min)
                self.x_min -= dx
                self.x_max -= dx
                self.y_min += dy
                self.y_max += dy
                parameter_entries_repopulate()
                graph.plot()

            self.previousMouseX = event.x
            self.previousMouseY = event.y

        def scroll_event(widget, event):
            if event.direction == gtk.gdk.SCROLL_UP:
                zoom_in(None)
            elif event.direction == gtk.gdk.SCROLL_DOWN:
                zoom_out(None)

        self.prev_y = [None, None, None]

        # Marked area point[0, 1][x, y]
        self.selection = [[None, None], [None, None]]

        self.drawing_area = gtk.DrawingArea()
        self.drawing_area.connect("expose_event", expose_event)
        self.drawing_area.connect("configure_event", configure_event)
        self.drawing_area.connect("button_press_event", button_press_event)
        self.drawing_area.connect("button_release_event", button_release_event)
        self.drawing_area.connect("motion_notify_event", motion_notify_event)
        self.drawing_area.connect("scroll_event", scroll_event)
        self.drawing_area.set_events(gtk.gdk.EXPOSURE_MASK
                                     | gtk.gdk.LEAVE_NOTIFY_MASK
                                     | gtk.gdk.BUTTON_PRESS_MASK
                                     | gtk.gdk.BUTTON_RELEASE_MASK
                                     | gtk.gdk.POINTER_MOTION_MASK
                                     | gtk.gdk.POINTER_MOTION_HINT_MASK)
        self.scale_style = "dec"
Пример #9
0
    def __init__(self,
                 size=None,
                 view_port_center=(0, 0),
                 view_port_width=None,
                 view_port_height=None,
                 recording=True,
                 max_num_frames=None,
                 flip_y=False,
                 title='Euv',
                 time_step=0.1):
        gobject.threads_init()
        gtk.gdk.threads_init()

        if size is None:
            size = (800, 600)
        self.view_port_center = view_port_center
        if view_port_width == None and view_port_height == None:
            raise Exception(
                "Either view_port_width or view_port_height must be set!")
        self.view_port_width = view_port_width
        self.view_port_height = view_port_height

        super(App, self).__init__(gtk.WINDOW_TOPLEVEL)
        self.set_title(title)

        settings = gtk.settings_get_default()
        settings.set_long_property("gtk-button-images", 1, '*')

        self.set_resizable(True)
        self.vbox = gtk.VBox(False, 0)
        self.add(self.vbox)
        self.canvas = gtk.DrawingArea()
        self.set_default_size(size[0], size[1])
        self.canvas.connect("expose_event", self.on_canvas_expose)
        self.vbox.pack_start(self.canvas, True, True, 0)
        hbox = gtk.HBox(False, 0)
        self.vbox.pack_start(hbox, False, True, 0)
        self.recording = recording
        self.flip_y = flip_y
        self.time_step = time_step
        if recording:
            self.buttonbox = gtk.HBox(False, 0)
            hbox.pack_start(self.buttonbox, True, False, 0)
            self.button_previous = image_button(stock=gtk.STOCK_MEDIA_REWIND)
            self.button_previous.connect("clicked",
                                         self.on_button_previous_clicked)
            self.buttonbox.pack_start(self.button_previous, False, False, 0)

            self.button_pause = image_button(stock=gtk.STOCK_MEDIA_PAUSE)
            self.button_pause.connect("clicked", self.on_button_pause_clicked)
            self.buttonbox.pack_start(self.button_pause, False, False, 0)

            self.button_next = image_button(stock=gtk.STOCK_MEDIA_FORWARD)
            self.button_next.connect("clicked", self.on_button_next_clicked)
            self.buttonbox.pack_start(self.button_next, False, False, 0)

            self.frame_scale = gtk.HScale()
            self.frame_adjustment = self.frame_scale.get_adjustment()
            self.frame_scale.set_digits(0)
            self.frame_adjustment.connect(
                "value-changed", self.on_frame_adjustment_value_changed)
            self.frame_scale.set_size_request(400, -1)
            self.buttonbox.pack_start(self.frame_scale, True, True, 0)
            if not max_num_frames is None:
                self.set_max_num_frames(max_num_frames)

        self.connect("delete_event", self.on_delete_event)
        self._user_break = False
        self.frames = []
        self.current_frame = -1
        self.pause = False
        gobject.timeout_add(int(self.time_step * 1000), self.play)
Пример #10
0
    def __init__(self):

        self.window = window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.ex = 0
        self.ey = 0
        self.maxx = 0
        self.maxy = 0
        self.minx = 0
        self.miny = 0
        self.coords = []
        self.coords2 = []
        self.coords3 = []

        window.set_title("PyNeural")
        window.set_position(gtk.WIN_POS_CENTER)

        #ic = gtk.Image(); ic.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
        #window.set_icon(ic.get_pixbuf())

        www = gtk.gdk.screen_width()
        hhh = gtk.gdk.screen_height()
        window.set_default_size(www / 2, hhh / 2)

        window.set_flags(gtk.CAN_FOCUS | gtk.SENSITIVE)

        window.set_events(gtk.gdk.ALL_EVENTS_MASK)

        window.connect("destroy", self.OnExit)
        window.connect("key-press-event", self.key_press_event)
        window.connect("button-press-event", self.button_press_event)

        self.setfont()

        try:
            window.set_icon_from_file("icon.png")
        except:
            pass

        hbox2 = gtk.HBox()
        area = gtk.DrawingArea()
        hbox2.pack_start(area)
        area.set_events(gtk.gdk.ALL_EVENTS_MASK)
        area.connect("expose-event", self.area_expose_cb)
        area.connect("motion-notify-event", self.area_motion)

        vbox = gtk.VBox()
        vbox.pack_start(hbox2, True)
        hbox = gtk.HBox()
        lab1 = gtk.Label("")
        hbox.pack_start(lab1)
        #butt1 = gtk.Button(" _New ")
        #butt1.connect("clicked", self.show_new, window)
        #hbox.pack_start(butt1, False)

        butt2 = gtk.Button(" E_xit ")
        butt2.connect("clicked", self.OnExit, window)
        hbox.pack_start(butt2, False)

        lab2 = gtk.Label("")
        hbox.pack_start(lab2)
        vbox.pack_start(hbox, False)

        window.add(vbox)
        window.show_all()
Пример #11
0
    def __init__(self):
        window = gtk.Window()
        hbox = gtk.HBox()
        vbox = gtk.VBox()

        #se usaran para el marcador
        self.label = gtk.Label()
        self.label.modify_font(pango.FontDescription("Purisa 14"))
        frame = gtk.Frame("Marcador")

        #asignacion de variables a widgest de gtk
        self.vadjustment = gtk.Adjustment()
        self.hadjustment = gtk.Adjustment()

        #asignacion de valores por defecto del adjustment
        self.vadjustment.set_upper(100)
        self.vadjustment.set_value(0)
        self.hadjustment.set_upper(100)
        self.hadjustment.set_value(0)

        #asignacion de propiedades de widgets
        self.vslide = gtk.VScale(self.vadjustment)
        self.hslide = gtk.HScale(self.hadjustment)
        #propiedad para que no se muestre valor del slide
        self.vslide.set_draw_value(False)
        self.hslide.set_draw_value(False)

        #variables globales que se utilizan en los slides
        self.increment_x = self.increment_y = 1
        self.indicator_x = self.indicator_y = -1
        self.goles = 0
        self.atajadas = 0

        #asignacion de variables de widgets
        self.drawing_area = gtk.DrawingArea()
        self.drawing_area.set_size_request(WIDTH, HEIGHT)

        #asignando cancha y arquero
        self.cancha = gtk.gdk.pixbuf_new_from_file('images/arco.jpg')
        self.portero = gtk.gdk.pixbuf_new_from_file(
            'images/goalkeeper_downcenter.png')

        window.connect("destroy", lambda w: gtk.main_quit())

        #callbacks al invocar el area de dibujo
        self.drawing_area.connect('configure_event', self.__configure_cb)
        self.drawing_area.connect('expose-event', self.__expose_cb)

        #evento que invoca funcion al presionar cualquier tecla
        window.connect('key-press-event', self.__key_press_event_cb)

        #anhadiendo widgets dentro del contenedor principal
        window.add(hbox)
        hbox.add(vbox)
        frame.add(self.label)
        vbox.add(frame)
        vbox.add(self.drawing_area)
        vbox.add(self.hslide)
        hbox.add(self.vslide)

        #mostrando los widgets
        window.show_all()

        #invocacion de la funcion que realiza loop del slider horizontal
        gobject.timeout_add(DELAY, self.__hslider_move_cb)
Пример #12
0
    def __init__(self, controller):
        self.logger = logging.getLogger('photobooth.gui')

        self.controller = controller

        self.in_progress = False

        # create window
        self.logger.debug('creating window')
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_title("Photobooth")
        window.set_default_size(800, 600)
        window.connect("destroy", self.exit, "Photobooth destroy")

        # add key listener
        window.connect('key_press_event', self._on_key_press_event)

        # vertical container to hold everything
        vbox = gtk.VBox()
        window.add(vbox)

        # create tools menu
        self.logger.debug('creating menu')
        tools_menu_item = gtk.MenuItem("_Tools")

        tools_menu = gtk.Menu()
        tools_menu_item_camera_toggle = gtk.MenuItem('_Toggle Camera')
        tools_menu_item_camera_toggle.connect("activate", self.start_stop,
                                              'toggle-camera')
        tools_menu_item_camera_toggle.show()
        tools_menu.append(tools_menu_item_camera_toggle)

        tools_menu_item.set_submenu(tools_menu)
        tools_menu_item.show()

        menu_bar = gtk.MenuBar()
        menu_bar.append(tools_menu_item)
        menu_bar.show()

        #FIXME doesn't always render
        vbox.pack_start(menu_bar, False, False, 2)

        self.logger.debug('creating drawing area')
        self.movie_window = gtk.DrawingArea()
        vbox.add(self.movie_window)

        hbox = gtk.HBox()
        vbox.pack_start(hbox, False)
        hbox.set_border_width(10)
        hbox.pack_start(gtk.Label())

        # create take picture button
        self.logger.debug('creating takePictureButton')
        self.takePictureButton = gtk.Button("Take Picture")
        self.takePictureButton.set_sensitive(False)
        self.takePictureButton.connect("clicked", self.take_picture)
        buttonText = self.takePictureButton.get_children()[0]
        buttonFont = pango.FontDescription("Georgia 32")
        buttonText.modify_font(buttonFont)
        hbox.pack_start(self.takePictureButton, False)

        hbox.add(gtk.Label())

        inprogressBox = gtk.HBox()
        vbox.pack_start(inprogressBox, False)
        inprogressBox.set_border_width(10)
        inprogressBox.pack_start(gtk.Label())
        self.countDownLabel = gtk.Label()
        countDownLabelFont = pango.FontDescription("Georgia 28")
        self.countDownLabel.modify_font(countDownLabelFont)
        inprogressBox.add(self.countDownLabel)
        inprogressBox.pack_start(gtk.Label())

        window.show_all()

        # link to controller
        self.controller.setViewFinder(self.movie_window)
Пример #13
0
    def __init__(self, gladefile, structure, global_vars, callback):

        self.global_vars = global_vars
        self.gladefile = gladefile
        self.structure = structure
        self.callback = callback

        self.tree = devede_other.create_tree(self, "wmenu_properties",
                                             self.gladefile)
        self.window = self.tree.get_object("wmenu_properties")

        menu_filename = global_vars["menu_bg"]
        if menu_filename == None:
            menu_filename = os.path.join(global_vars["path"], "backgrounds",
                                         "default_bg.png")
        w = self.tree.get_object("menu_bg_file")
        w.set_filename(menu_filename)
        filter = gtk.FileFilter()
        filter.add_mime_type("image/*")
        filter.set_name("Pictures")
        w.add_filter(filter)

        self.preview_x = 200
        self.preview_y = 200
        self.sf_final = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.preview_x,
                                           self.preview_y)
        self.preview = gtk.DrawingArea()
        self.preview.set_size_request(self.preview_x, self.preview_y)
        self.preview.connect("expose-event", self.repaint_preview)
        w.set_preview_widget(self.preview)

        self.on_menu_bg_file_update_preview(w, menu_filename)

        self.adding_sound = True
        w = self.tree.get_object("menu_sound")
        print "filtro"
        filter2 = gtk.FileFilter()
        filter2.add_mime_type("audio/mpeg")
        filter2.add_mime_type("audio/x-wav")
        filter2.add_mime_type("application/ogg")
        filter2.add_mime_type("audio/ogg")
        filter2.set_name("Audio files")
        w.add_filter(filter2)
        print "filtrado"
        w.set_filename(global_vars["menu_sound"])
        print "Añado"

        w = self.tree.get_object("menufont")
        w.set_font_name(global_vars["fontname"])

        w = self.tree.get_object("unselected_color")
        color = global_vars["menu_font_color"]
        c1 = gtk.gdk.Color(color[0], color[1], color[2])
        w.set_color(c1)
        w.set_alpha(color[3])

        w = self.tree.get_object("selected_color")
        color = global_vars["menu_selc_color"]
        c1 = gtk.gdk.Color(color[0], color[1], color[2])
        w.set_color(c1)

        w = self.tree.get_object("shadow_color")
        color = global_vars["menu_shadow_color"]
        c1 = gtk.gdk.Color(color[0], color[1], color[2])
        w.set_color(c1)
        w.set_alpha(color[3])

        w = self.tree.get_object("bg_color")
        color = global_vars["menu_bgcolor"]
        c1 = gtk.gdk.Color(color[0], color[1], color[2])
        w.set_color(c1)
        w.set_alpha(color[3])

        if global_vars["menu_alignment"] == 0:
            w = self.tree.get_object("menutop")
        elif global_vars["menu_alignment"] == 1:
            w = self.tree.get_object("menubottom")
        else:
            w = self.tree.get_object("menumiddle")
        w.set_active(True)

        if global_vars["menu_halignment"] == 0:
            w = self.tree.get_object("menuleft")
        elif global_vars["menu_halignment"] == 1:
            w = self.tree.get_object("menuright")
        else:
            w = self.tree.get_object("menucenter")
        w.set_active(True)

        if global_vars["do_menu"]:
            w = self.tree.get_object("domenu")
        else:
            w = self.tree.get_object("notmenu")
        w.set_active(True)

        w = self.tree.get_object("menu_title_text")
        w.set_text(global_vars["menu_title_text"])

        w = self.tree.get_object("menu_title_color")
        color = global_vars["menu_title_color"]
        c1 = gtk.gdk.Color(color[0], color[1], color[2])
        w.set_color(c1)
        w.set_alpha(color[3])

        w = self.tree.get_object("menu_title_shadow")
        color = global_vars["menu_title_shadow"]
        c1 = gtk.gdk.Color(color[0], color[1], color[2])
        w.set_color(c1)
        w.set_alpha(color[3])

        w = self.tree.get_object("menu_title_font")
        w.set_font_name(global_vars["menu_title_fontname"])

        w = self.tree.get_object("margin_top_adj")
        w.set_value(100.0 * global_vars["menu_top_margin"])
        w = self.tree.get_object("margin_bottom_adj")
        w.set_value(100.0 * global_vars["menu_bottom_margin"])
        w = self.tree.get_object("margin_left_adj")
        w.set_value(100.0 * global_vars["menu_left_margin"])
        w = self.tree.get_object("margin_right_adj")
        w.set_value(100.0 * global_vars["menu_right_margin"])

        self.window.show()
    def __init__(self, handle):
        super(VisualMatchActivity, self).__init__(handle)

        try:
            # Use 0.86 toolbar design
            toolbar_box = ToolbarBox()

            # Buttons added to the Activity toolbar
            activity_button = ActivityToolbarButton(self)
            toolbar_box.toolbar.insert(activity_button, 0)
            activity_button.show()

            # New-game Button
            self.button1 = ToolButton("new-game")
            self.button1.set_tooltip(_('New game'))
            self.button1.props.sensitive = True
            self.button1.connect('clicked', self._button1_cb, self)
            toolbar_box.toolbar.insert(self.button1, -1)
            self.button1.show()

            # Help Button
            self.button3 = ToolButton("search")
            self.button3.set_tooltip(_('Is there a match?'))
            self.button3.props.sensitive = True
            self.button3.connect('clicked', self._button3_cb, self)
            toolbar_box.toolbar.insert(self.button3, -1)
            self.button3.show()

            separator = gtk.SeparatorToolItem()
            separator.show()
            toolbar_box.toolbar.insert(separator, -1)

            # Label for showing deck status
            self.deck_label = gtk.Label(_("%d cards remaining") % (96))
            self.deck_label.show()
            deck_toolitem = gtk.ToolItem()
            deck_toolitem.add(self.deck_label)
            toolbar_box.toolbar.insert(deck_toolitem, -1)

            separator = gtk.SeparatorToolItem()
            separator.show()
            toolbar_box.toolbar.insert(separator, -1)

            # Label for showing match status
            self.match_label = gtk.Label(_("%d matches") % (0))
            self.match_label.show()
            match_toolitem = gtk.ToolItem()
            match_toolitem.add(self.match_label)
            toolbar_box.toolbar.insert(match_toolitem, -1)

            separator = gtk.SeparatorToolItem()
            separator.show()
            toolbar_box.toolbar.insert(separator, -1)

            # Label for showing counter
            self.clock_label = gtk.Label(_("-"))
            self.clock_label.show()
            clock_toolitem = gtk.ToolItem()
            clock_toolitem.add(self.clock_label)
            toolbar_box.toolbar.insert(clock_toolitem, -1)

            separator = gtk.SeparatorToolItem()
            separator.show()
            toolbar_box.toolbar.insert(separator, -1)

            # Label for showing play status
            self.status_label = gtk.Label(_("Find a match."))
            self.status_label.show()
            status_toolitem = gtk.ToolItem()
            status_toolitem.add(self.status_label)
            toolbar_box.toolbar.insert(status_toolitem, -1)

            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            separator.show()
            toolbar_box.toolbar.insert(separator, -1)

            # Write in the Journal
            journal_button = ToolButton("journal-write")
            journal_button.set_tooltip(_('Write in Journal'))
            journal_button.props.accelerator = '<Ctrl>j'
            journal_button.connect('clicked', self._journal_cb,
                                   activity.get_bundle_path())
            toolbar_box.toolbar.insert(journal_button, -1)
            journal_button.show()

            # The ever-present Stop Button
            stop_button = StopButton(self)
            stop_button.props.accelerator = '<Ctrl>q'
            toolbar_box.toolbar.insert(stop_button, -1)
            stop_button.show()

            self.set_toolbar_box(toolbar_box)
            toolbar_box.show()

        except NameError:
            # Use pre-0.86 toolbar design
            self.toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(self.toolbox)

            self.projectToolbar = ProjectToolbar(self)
            self.toolbox.add_toolbar(_('Project'), self.projectToolbar)

            self.toolbox.show()

        # Create a canvas
        canvas = gtk.DrawingArea()
        canvas.set_size_request(gtk.gdk.screen_width(), \
                                gtk.gdk.screen_height())
        self.set_canvas(canvas)
        canvas.show()
        self.show_all()

        # Initialize the canvas
        self.tw = window.new_window(canvas, \
                                    os.path.join(activity.get_bundle_path(), \
                                                 'images/card-'), \
                                    self)
Пример #15
0
    def __init__(self):
        if VERBOSE > 0:
            print 'Platform:', sys.platform

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect('destroy', lambda w: gtk.main_quit())
        self.window.set_title('pyTesseractTrainer - Tesseract Box '
                              + 'Editor version %s'
                              % (VERSION))        
        self.window.set_size_request(900, 600)

        vbox = gtk.VBox(False, 2)
        self.window.add(vbox)
        vbox.show()

        menuBar = self.makeMenu()
        vbox.pack_start(menuBar, False)

        self.scrolledWindow = gtk.ScrolledWindow()
        self.scrolledWindow.set_policy(gtk.POLICY_AUTOMATIC,
                gtk.POLICY_AUTOMATIC)
        vbox.pack_start(self.scrolledWindow, True, True, 2)
        self.scrolledWindow.show()

        self.drawingArea = gtk.DrawingArea()
        self.drawingArea.connect('expose-event', self.redrawArea)
        self.scrolledWindow.add_with_viewport(self.drawingArea)
        self.drawingArea.show()

        self.textScroll = gtk.ScrolledWindow()
        self.textScroll.set_policy(gtk.POLICY_AUTOMATIC,
                                   gtk.POLICY_AUTOMATIC)
        vbox.pack_start(self.textScroll, True, True, 2)
        self.textScroll.show()

        self.textVBox = gtk.VBox()
        self.textScroll.add_with_viewport(self.textVBox)
        self.textVBox.show()

        self.buttonBox = gtk.HBox(False, 0)
        vbox.pack_start(self.buttonBox, False, False, 2)
        self.buttonBox.show()

        b = gtk.CheckButton('_Bold', True)
        self.buttonBox.pack_start(b, False, False, 10)
        b.connect('toggled', self.onCheckButtonToggled, ATTR_BOLD)
        b.add_accelerator('activate', self.accelGroup, ord('B'),
                          gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        b.show()
        self.boldButton = b

        b = gtk.CheckButton('_Italic', True)
        self.buttonBox.pack_start(b, False, False, 10)
        b.connect('toggled', self.onCheckButtonToggled, ATTR_ITALIC)
        b.add_accelerator('activate', self.accelGroup, ord('I'),
                          gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        b.show()
        self.italicButton = b

        b = gtk.CheckButton('_Underline', True)
        self.buttonBox.pack_start(b, False, False, 10)
        b.connect('toggled', self.onCheckButtonToggled, ATTR_UNDERLINE)
        b.add_accelerator('activate', self.accelGroup, ord('U'),
                          gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        b.show()
        self.underlineButton = b

        self.spinBottom = gtk.SpinButton()
        self.spinBottom.set_wrap(True)
        self.spinBottom.connect("value_changed", self.onSpinButtonChanged,
                                DIR_BOTTOM)
        self.buttonBox.pack_end(self.spinBottom, False, False, 0)
        self.spinBottom.show()
        l = gtk.Label(' Bottom:')
        self.buttonBox.pack_end(l, False, False, 0)
        l.show()

        self.spinTop = gtk.SpinButton()
        self.spinTop.connect('value_changed', self.onSpinButtonChanged,
                             DIR_TOP)
        self.buttonBox.pack_end(self.spinTop, False, False, 0)
        self.spinTop.show()
        l = gtk.Label(' Top:')
        self.buttonBox.pack_end(l, False, False, 0)
        l.show()

        self.spinRUp = gtk.SpinButton()
        self.spinRUp.connect("value_changed", self.onSpinButtonChanged,
                             DIR_RUP)
        self.buttonBox.pack_end(self.spinRUp, False, False, 0)
        self.spinRUp.show()
        lru = gtk.Label(' r-up:')
        self.buttonBox.pack_end(lru, False, False, 0)
        lru.show()

        self.spinRight = gtk.SpinButton()
        self.spinRight.connect('value_changed', self.onSpinButtonChanged,
                               DIR_RIGHT)
        self.buttonBox.pack_end(self.spinRight, False, False, 0)
        self.spinRight.show()
        l = gtk.Label(' Right:')
        self.buttonBox.pack_end(l, False, False, 0)
        l.show()

        self.spinLDown = gtk.SpinButton()
        self.spinLDown.connect('value_changed', self.onSpinButtonChanged,
                               DIR_LDOWN)
        self.buttonBox.pack_end(self.spinLDown, False, False, 0)
        self.spinLDown.show()
        lld = gtk.Label(' l-down:')
        self.buttonBox.pack_end(lld, False, False, 0)
        lld.show()

        self.spinLeft = gtk.SpinButton()
        self.spinLeft.connect('value_changed', self.onSpinButtonChanged,
                              DIR_LEFT)
        self.buttonBox.pack_end(self.spinLeft, False, False, 0)
        self.spinLeft.show()
        l = gtk.Label('Left:')
        self.buttonBox.pack_end(l, False, False, 0)
        l.show()

        self.setImageControlSensitivity(False)
        self.setSymbolControlSensitivity(False)
        self.window.show_all() #.show()

        if len(sys.argv) >= 2 and sys.argv[1] != "":
            argfilename = sys.argv[1]
            self.loadImageAndBoxes(argfilename, self.window)
        else:
            argfilename = None
        self.isPaused = False
Пример #16
0
    def __init__(self, parent=None):
        gtk.Window.__init__(self)
        try:
            self.set_screen(parent.get_screen())
        except AttributeError:
            self.connect('destroy', lambda *w: gtk.main_quit())
        self.set_title(self.__class__.__name__)

        self.set_border_width(10)

        box = gtk.VBox(False, 3)
        self.add(box)

        # A check button using the tooltip-markup property
        button = gtk.CheckButton("This one uses the tooltip-markup property")
        button.set_tooltip_text("Hello, I am a static tooltip.")
        box.pack_start(button, False, False, 0)

        # A check button using the query-tooltip signal
        button = gtk.CheckButton("I use the query-tooltip signal")
        button.props.has_tooltip = True
        button.connect("query-tooltip", self.query_tooltip_cb)
        box.pack_start(button, False, False, 0)

        # A label
        label = gtk.Label("I am just a label")
        label.set_selectable(False)
        label.set_tooltip_text("Label & and tooltip")
        box.pack_start(label, False, False, 0)

        # A selectable label
        label = gtk.Label("I am a selectable label")
        label.set_selectable(True)
        label.set_tooltip_markup("<b>Another</b> Label tooltip")
        box.pack_start(label, False, False, 0)

        # Another one, with a custom tooltip window
        button = gtk.CheckButton("This one has a custom tooltip window!")
        box.pack_start(button, False, False, 0)

        tooltip_window = gtk.Window(gtk.WINDOW_POPUP)
        tooltip_button = gtk.Label("blaat!")
        tooltip_window.add(tooltip_button)
        tooltip_button.show()

        button.set_tooltip_window(tooltip_window)
        button.connect("query-tooltip", self.query_tooltip_custom_cb)
        button.props.has_tooltip = True

        # An insensitive button
        button = gtk.Button("This one is insensitive")
        button.set_sensitive(False)
        button.props.tooltip_text = "Insensitive!"
        box.pack_start(button, False, False, 0)

        # Testcases from Kris without a tree view don't exist
        tree_view = gtk.TreeView(self.create_model())
        tree_view.set_size_request(200, 240)

        tree_view.insert_column_with_attributes(0,
                                                "Test",
                                                gtk.CellRendererText(),
                                                text=0)

        tree_view.props.has_tooltip = True
        tree_view.connect("query-tooltip", self.query_tooltip_tree_view_cb)
        tree_view.get_selection().connect("changed", self.selection_changed_cb,
                                          tree_view)

        # We cannot get the button on the treeview column directly
        # so we have to use a ugly hack to get it.
        column = tree_view.get_column(0)
        column.set_clickable(True)
        label = gtk.Label("Test")
        column.set_widget(label)
        label.show()
        button = label.get_parent()
        button.props.tooltip_text = "Header"

        box.pack_start(tree_view, False, False, 2)

        # Add an IconView for some more testing
        iconview = gtk.IconView()
        iconview.props.has_tooltip = True
        iconview.connect("query-tooltip", self.query_tooltip_icon_view_cb)

        model = gtk.ListStore(str, gtk.gdk.Pixbuf)
        iconview.set_model(model)
        iconview.set_text_column(0)
        iconview.set_pixbuf_column(1)

        pixbuf1 = iconview.render_icon(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
        model.append(['Apply', pixbuf1])

        pixbuf2 = iconview.render_icon(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON)
        model.append(['Cancel', pixbuf2])

        box.pack_start(iconview, False, False, 2)

        # And a text view for Matthias
        buffer = gtk.TextBuffer()

        iter = buffer.get_end_iter()
        buffer.insert(iter, "Hello, the text ", -1)

        tag = buffer.create_tag("bold")
        tag.props.weight = pango.WEIGHT_BOLD

        iter = buffer.get_end_iter()
        buffer.insert_with_tags(iter, "in bold", tag)

        iter = buffer.get_end_iter()
        buffer.insert(iter, " has a tooltip!", -1)

        text_view = gtk.TextView(buffer)
        text_view.set_size_request(200, 50)

        text_view.props.has_tooltip = True
        text_view.connect("query-tooltip", self.query_tooltip_text_view_cb,
                          tag)

        box.pack_start(text_view, False, False, 2)

        # Drawing area
        drawing_area = gtk.DrawingArea()
        drawing_area.set_size_request(320, 240)
        drawing_area.props.has_tooltip = True
        drawing_area.connect("expose_event", self.drawing_area_expose)
        drawing_area.connect("query-tooltip",
                             self.query_tooltip_drawing_area_cb)
        box.pack_start(drawing_area, False, False, 2)

        # Done!
        self.show_all()
Пример #17
0
def GLDrawingArea(glconfig):
    glarea = gtk.DrawingArea()
    # Set OpenGL-capability to the widget
    gtkgl.widget_set_gl_capability(glarea, glconfig, None, True, RGBA_TYPE)
    return glarea
    def __init__(self, handle):
        """ Initiate activity. """
        super(AbacusActivity, self).__init__(handle)

        if _new_sugar_system:
            # Use 0.86 toolbar design
            toolbar_box = ToolbarBox()

            # Buttons added to the Activity toolbar
            activity_button = ActivityToolbarButton(self)
            toolbar_box.toolbar.insert(activity_button, 0)
            activity_button.show()

            # Suanpan (Chinese abacus) 2:5
            self.chinese = ToolButton("Con")
            self.chinese.set_tooltip(_('Suanpan'))
            self.chinese.props.sensitive = True
            self.chinese.connect('clicked', self._chinese_cb)
            toolbar_box.toolbar.insert(self.chinese, -1)
            self.chinese.show()

            # Soroban (Japanese abacus) 1:4
            self.japanese = ToolButton("Joff")
            self.japanese.set_tooltip(_('Soroban'))
            self.japanese.props.sensitive = True
            self.japanese.connect('clicked', self._japanese_cb)
            toolbar_box.toolbar.insert(self.japanese, -1)
            self.japanese.show()

            # Schety (Russian abacus) 0:10
            self.russian = ToolButton("Roff")
            self.russian.set_tooltip(_('Schety'))
            self.russian.props.sensitive = True
            self.russian.connect('clicked', self._russian_cb)
            toolbar_box.toolbar.insert(self.russian, -1)
            self.russian.show()

            # Nepohualtzintzin (Mayan abacus) 3:4 (base 20)
            self.mayan = ToolButton("Moff")
            self.mayan.set_tooltip(_('Nepohualtzintzin'))
            self.mayan.props.sensitive = True
            self.mayan.connect('clicked', self._mayan_cb)
            toolbar_box.toolbar.insert(self.mayan, -1)
            self.mayan.show()

            # Binary (base 2)
            self.binary = ToolButton("Boff")
            self.binary.set_tooltip(_('Binary'))
            self.binary.props.sensitive = True
            self.binary.connect('clicked', self._binary_cb)
            toolbar_box.toolbar.insert(self.binary, -1)
            self.binary.show()

            # Hexadecimal (base 16)
            self.hex = ToolButton("Hoff")
            self.hex.set_tooltip(_('Hexadecimal'))
            self.hex.props.sensitive = True
            self.hex.connect('clicked', self._hex_cb)
            toolbar_box.toolbar.insert(self.hex, -1)
            self.hex.show()

            # Fractions (1/2, 1/3, 1/4, 1/5, 1/6, 1/8, 1/9, 1/10, 1/12)
            self.fraction = ToolButton("Foff")
            self.fraction.set_tooltip(_('Fraction'))
            self.fraction.props.sensitive = True
            self.fraction.connect('clicked', self._fraction_cb)
            toolbar_box.toolbar.insert(self.fraction, -1)
            self.fraction.show()

            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(False)
            separator.show()
            toolbar_box.toolbar.insert(separator, -1)

            # The Customization submenu (roll your own)
            custom_toolbar = gtk.Toolbar()

            self._rods_label = gtk.Label(_("Rods:") + " ")
            self._rods_label.set_line_wrap(True)
            self._rods_label.show()
            self._rods_toolitem = gtk.ToolItem()
            self._rods_toolitem.add(self._rods_label)
            custom_toolbar.insert(self._rods_toolitem, -1)
            self._rods_toolitem.show()

            self._rods_spin_adj = gtk.Adjustment(15, 1, 20, 1, 32, 0)
            self._rods_spin = gtk.SpinButton(self._rods_spin_adj, 0, 0)
            self._rods_spin_id = self._rods_spin.connect(
                'value-changed', self._rods_spin_cb)
            self._rods_spin.set_numeric(True)
            self._rods_spin.show()
            self.tool_item_rods = gtk.ToolItem()
            self.tool_item_rods.add(self._rods_spin)
            custom_toolbar.insert(self.tool_item_rods, -1)
            self.tool_item_rods.show()

            self._top_label = gtk.Label(" " + _("Top:") + " ")
            self._top_label.set_line_wrap(True)
            self._top_label.show()
            self._top_toolitem = gtk.ToolItem()
            self._top_toolitem.add(self._top_label)
            custom_toolbar.insert(self._top_toolitem, -1)
            self._top_toolitem.show()

            self._top_spin_adj = gtk.Adjustment(2, 0, 4, 1, 32, 0)
            self._top_spin = gtk.SpinButton(self._top_spin_adj, 0, 0)
            self._top_spin_id = self._top_spin.connect('value-changed',
                                                       self._top_spin_cb)
            self._top_spin.set_numeric(True)
            self._top_spin.show()
            self.tool_item_top = gtk.ToolItem()
            self.tool_item_top.add(self._top_spin)
            custom_toolbar.insert(self.tool_item_top, -1)
            self.tool_item_top.show()

            self._bottom_label = gtk.Label(" " + _("Bottom:") + " ")
            self._bottom_label.set_line_wrap(True)
            self._bottom_label.show()
            self._bottom_toolitem = gtk.ToolItem()
            self._bottom_toolitem.add(self._bottom_label)
            custom_toolbar.insert(self._bottom_toolitem, -1)
            self._bottom_toolitem.show()

            self._bottom_spin_adj = gtk.Adjustment(5, 1, 15, 1, 32, 0)
            self._bottom_spin = gtk.SpinButton(self._bottom_spin_adj, 0, 0)
            self._bottom_spin_id = self._bottom_spin.connect(
                'value-changed', self._bottom_spin_cb)
            self._bottom_spin.set_numeric(True)
            self._bottom_spin.show()
            self.tool_item_bottom = gtk.ToolItem()
            self.tool_item_bottom.add(self._bottom_spin)
            custom_toolbar.insert(self.tool_item_bottom, -1)
            self.tool_item_bottom.show()

            self._value_label = gtk.Label(" " + _("Factor:") + " ")
            self._value_label.set_line_wrap(True)
            self._value_label.show()
            self._value_toolitem = gtk.ToolItem()
            self._value_toolitem.add(self._value_label)
            custom_toolbar.insert(self._value_toolitem, -1)
            self._value_toolitem.show()

            self._value_spin_adj = gtk.Adjustment(5, 1, 20, 1, 32, 0)
            self._value_spin = gtk.SpinButton(self._value_spin_adj, 0, 0)
            self._value_spin_id = self._value_spin.connect(
                'value-changed', self._value_spin_cb)
            self._value_spin.set_numeric(True)
            self._value_spin.show()
            self.tool_item_value = gtk.ToolItem()
            self.tool_item_value.add(self._value_spin)
            custom_toolbar.insert(self.tool_item_value, -1)
            self.tool_item_value.show()

            self._base_label = gtk.Label(" " + _("Base:") + " ")
            self._base_label.set_line_wrap(True)
            self._base_label.show()
            self._base_toolitem = gtk.ToolItem()
            self._base_toolitem.add(self._base_label)
            custom_toolbar.insert(self._base_toolitem, -1)
            self._base_toolitem.show()

            self._base_spin_adj = gtk.Adjustment(10, 1, 20, 1, 32, 0)
            self._base_spin = gtk.SpinButton(self._base_spin_adj, 0, 0)
            self._base_spin_id = self._base_spin.connect(
                'value-changed', self._base_spin_cb)
            self._base_spin.set_numeric(True)
            self._base_spin.show()
            self.tool_item_base = gtk.ToolItem()
            self.tool_item_base.add(self._base_spin)
            custom_toolbar.insert(self.tool_item_base, -1)
            self.tool_item_base.show()

            # Custom
            self._custom = ToolButton("new-game")
            self._custom.set_tooltip(_('Custom'))
            self._custom.props.sensitive = True
            self._custom.connect('clicked', self._custom_cb)
            custom_toolbar.insert(self._custom, -1)
            self._custom.show()

            custom_toolbar_button = ToolbarButton(page=custom_toolbar,
                                                  icon_name='view-source')
            custom_toolbar.show()
            toolbar_box.toolbar.insert(custom_toolbar_button, -1)
            custom_toolbar_button.show()

            separator = gtk.SeparatorToolItem()
            separator.props.draw = False
            separator.set_expand(True)
            separator.show()
            toolbar_box.toolbar.insert(separator, -1)

            # The ever-present Stop Button
            stop_button = StopButton(self)
            stop_button.props.accelerator = _('<Ctrl>Q')
            toolbar_box.toolbar.insert(stop_button, -1)
            stop_button.show()

            self.set_toolbar_box(toolbar_box)
            toolbar_box.show()

        else:
            # Use pre-0.86 toolbar design
            self.toolbox = activity.ActivityToolbox(self)
            self.set_toolbox(self.toolbox)

            self.projectToolbar = ProjectToolbar(self)
            self.toolbox.add_toolbar(_('Project'), self.projectToolbar)

            self.customToolbar = CustomToolbar(self)
            self.toolbox.add_toolbar(_('Custom'), self.customToolbar)

            self.toolbox.show()

        # Create a canvas
        canvas = gtk.DrawingArea()
        canvas.set_size_request(gtk.gdk.screen_width(),
                                gtk.gdk.screen_height())
        self.set_canvas(canvas)
        canvas.show()
        self.show_all()

        # Initialize the canvas
        self.abacus = Abacus(canvas, self)

        # Read the current mode from the Journal
        try:
            if self.metadata['abacus'] == 'suanpan':
                self._chinese_cb(None)
            elif self.metadata['abacus'] == 'soroban':
                self._japanese_cb(None)
            elif self.metadata['abacus'] == 'schety':
                self._russian_cb(None)
            elif self.metadata['abacus'] == 'nepohualtzintzin':
                self._mayan_cb(None)
            elif self.metadata['abacus'] == 'binary':
                self._binary_cb(None)
            elif self.metadata['abacus'] == 'hexadecimal':
                self._hex_cb(None)
            elif self.metadata['abacus'] == 'fraction':
                self._fraction_cb(None)
            else:
                self._chinese_cb(None)
        except:
            pass
        try:
            self.abacus.mode.set_value(self.metadata['value'])
            self.abacus.mode.label(self.abacus.mode.value())
        except:
            pass
Пример #19
0
	def __init__(self, lines, title = "", sec = 1, width = 10, remove_first = False, button_each_line = 4):
		"""lines: the line class list to show.
		title: the window title.
		sec: the load new entry wait second.
		width: the width of each entry.
		remove_first :true then remove the first entry because it already record a big value.
		button_each_line: the number of button of each line.
		"""
		super(gtpwin, self).__init__()

		self.entry_width = width

		self.max_value = 0
		self.prev_width = 0
		self.prev_height = 0
		self.y_ratio = 0
		self.logfd = False

		#Setup lines
		color_limit = (0xffb0ff, 0x006000)
		num = len(lines)
		block = (color_limit[0] - color_limit[1]) / float(num)
		color = color_limit[1]
		for e in lines:
			e.bcolor = gtk.gdk.Color("#"+ "%06x" % int(color))
			e.lcolor = ((((int(color) >> 16) / float(0xff) * 1), ((int(color) >> 8 & 0xff) / float(0xff) * 1), ((int(color) & 0xff) / float(0xff) * 1)))
			color += block
		self.lines = lines

		#Set window
		self.set_title(title)
		self.connect("destroy", gtk.main_quit)

		#Create button
		bhbox = gtk.HBox(False, 0)
		self.button_hboxes = [bhbox]
		num = 0
		for line in self.lines:
			line.button = gtk.ToggleButton(line.name)
			self.set_button_color(line.button, line.bcolor)
			line.button.line = line
			line.button.connect("clicked", self.button_click)
			line.entry = gtk.Entry()
			line.entry.set_editable(False)
			hbox = gtk.HBox(False, 0)
			hbox.pack_start(line.button, False, False, 0)
			hbox.pack_start(line.entry, False, False, 0)
			bhbox.pack_start(hbox, True, False, 0)
			num += 1
			if num >= button_each_line:
				bhbox = gtk.HBox(False, 0)
				self.button_hboxes.append(bhbox)
				num = 0

		#Create self.darea
		self.darea = gtk.DrawingArea()
		self.darea.connect("expose-event", self.expose)
		self.darea.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color("#FFFFFF"))

		#menubar
		mb = gtk.MenuBar()
		#file
		filemenu = gtk.Menu()
		filem = gtk.MenuItem("File")
		filem.set_submenu(filemenu)
		save = gtk.CheckMenuItem("Save log to a CSV file")
		save.connect("activate", self.mb_save)
		save.set_active(False)
		clean = gtk.MenuItem("Clean")
		clean.connect("activate", self.mb_clean)
		exit = gtk.MenuItem("Exit")
		exit.connect("activate", gtk.main_quit)
		filemenu.append(save)
		filemenu.append(clean)
		filemenu.append(gtk.SeparatorMenuItem())
		filemenu.append(exit)
		mb.append(filem)
		#set
		setmenu = gtk.Menu()
		setm = gtk.MenuItem("Settings")
		setm.set_submenu(setmenu)
		show_buttons = gtk.CheckMenuItem("Show buttons")
		show_buttons.set_active(True)
		show_buttons.connect("activate", self.show_buttons)
		setmenu.append(show_buttons)
		mb.append(setm)

		#Put widgets to window
		vbox = gtk.VBox(False, 0)
		vbox.pack_start(mb, False, False, 0)
		vbox.pack_start(self.darea, True, True, 0)
		for e in self.button_hboxes:
			vbox.pack_start(e, False, False, 0)
		self.add(vbox)

		self.show_all()
		gtk.Window.maximize(self)

		#Set each button to same width
		button_size_max = 0
		entry_size_max = 0
		for line in self.lines:
			if line.button.allocation.width > button_size_max:
				button_size_max = line.button.allocation.width
			if line.entry.allocation.width > entry_size_max:
				entry_size_max = line.entry.allocation.width
		for line in self.lines:
			line.button.set_size_request(button_size_max, -1)
			line.entry.set_size_request(entry_size_max, -1)

		#Add timer
		glib.timeout_add(int(sec * 1000), self.timer_cb)
		if remove_first:
			glib.timeout_add(int(sec * 1100), self.timer_remove_first_record)
Пример #20
0
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("Tesseract Box Editor")
        self.window.connect('destroy', lambda w: gtk.main_quit())
        self.window.set_size_request(800, 600)

        vbox = gtk.VBox(False, 2)
        self.window.add(vbox)
        vbox.show()

        menuBar = self.makeMenu()
        vbox.pack_start(menuBar, False)

        self.scrolledWindow = gtk.ScrolledWindow()
        self.scrolledWindow.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
        vbox.pack_start(self.scrolledWindow, True, True, 2)
        self.scrolledWindow.show()

        self.drawingArea = gtk.DrawingArea()
        self.drawingArea.connect("expose-event", self.redrawArea)
        self.scrolledWindow.add_with_viewport(self.drawingArea)
        self.drawingArea.show()

        self.textScroll = gtk.ScrolledWindow()
        self.textScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        vbox.pack_start(self.textScroll, True, True, 2)
        self.textScroll.show()

        self.textVBox = gtk.VBox()
        self.textScroll.add_with_viewport(self.textVBox)
        self.textVBox.show()

        self.buttonBox = gtk.HBox(False, 0)
        vbox.pack_start(self.buttonBox, False, False, 2)
        self.buttonBox.show()

        b = gtk.CheckButton("_Bold", True)
        self.buttonBox.pack_start(b, False, False, 10)
        b.connect("toggled", self.onCheckButtonToggled, ATTR_BOLD)
        b.add_accelerator("activate", self.accelGroup, ord('B'),
                          gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        b.show()
        self.boldButton = b

        b = gtk.CheckButton("_Italic", True)
        self.buttonBox.pack_start(b, False, False, 10)
        b.connect("toggled", self.onCheckButtonToggled, ATTR_ITALIC)
        b.add_accelerator("activate", self.accelGroup, ord('I'),
                          gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        b.show()
        self.italicButton = b

        b = gtk.CheckButton("_Underline", True)
        self.buttonBox.pack_start(b, False, False, 10)
        b.connect("toggled", self.onCheckButtonToggled, ATTR_UNDERLINE)
        b.add_accelerator("activate", self.accelGroup, ord('U'),
                          gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
        b.show()
        self.underlineButton = b

        self.spinBottom = gtk.SpinButton()
        self.spinBottom.connect("changed", self.onSpinButtonChanged,
                                DIR_BOTTOM)
        self.buttonBox.pack_end(self.spinBottom, False, False, 0)
        self.spinBottom.show()
        l = gtk.Label("     Bottom:")
        self.buttonBox.pack_end(l, False, False, 0)
        l.show()

        self.spinTop = gtk.SpinButton()
        self.spinTop.connect("changed", self.onSpinButtonChanged, DIR_TOP)
        self.buttonBox.pack_end(self.spinTop, False, False, 0)
        self.spinTop.show()
        l = gtk.Label("     Top:")
        self.buttonBox.pack_end(l, False, False, 0)
        l.show()

        self.spinRight = gtk.SpinButton()
        self.spinRight.connect("changed", self.onSpinButtonChanged, DIR_RIGHT)
        self.buttonBox.pack_end(self.spinRight, False, False, 0)
        self.spinRight.show()
        l = gtk.Label("     Right:")
        self.buttonBox.pack_end(l, False, False, 0)
        l.show()

        self.spinLeft = gtk.SpinButton()
        self.spinLeft.connect("changed", self.onSpinButtonChanged, DIR_LEFT)
        self.buttonBox.pack_end(self.spinLeft, False, False, 0)
        self.spinLeft.show()
        l = gtk.Label("Left:")
        self.buttonBox.pack_end(l, False, False, 0)
        l.show()

        self.setImageControlSensitivity(False)
        self.setSymbolControlSensitivity(False)
        self.window.show()
Пример #21
0
    def __init__(self, handle):
        """Set up the Chutar activity."""
        activity.Activity.__init__(self, handle)

        # we do not have collaboration features
        # make the share option insensitive
        self.max_participants = 1

        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

        share_button = ShareButton(self)
        toolbar_box.toolbar.insert(share_button, -1)
        share_button.show()

        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        hbox = gtk.HBox()
        vbox = gtk.VBox()

        #se usaran para el marcador
        self.label = gtk.Label()
        self.label.modify_font(pango.FontDescription("Purisa 14"))
        frame = gtk.Frame("Marcador")

        #asignacion de variables a widgest de gtk
        self.vadjustment = gtk.Adjustment()
        self.hadjustment = gtk.Adjustment()

        #asignacion de valores por defecto del adjustment
        self.vadjustment.set_upper(100)
        self.vadjustment.set_value(0)
        self.hadjustment.set_upper(100)
        self.hadjustment.set_value(0)

        #asignacion de propiedades de widgets
        self.vslide = gtk.VScale(self.vadjustment)
        self.hslide = gtk.HScale(self.hadjustment)

        #propiedad para que no se muestre valor del slide
        self.vslide.set_draw_value(False)
        self.hslide.set_draw_value(False)

        #variables globales que se utilizan en los slides
        self.increment_x = self.increment_y = 1
        self.indicator_x = self.indicator_y = -1
        self.goles = 0

        #asignacion de variables de widgets
        self.drawing_area = gtk.DrawingArea()
        self.drawing_area.set_size_request(WIDTH, HEIGHT)

        #asignando cancha y arquero
        self.cancha = gtk.gdk.pixbuf_new_from_file('images/arcosugar.jpg')
        self.portero = gtk.gdk.pixbuf_new_from_file(
            'images/goalkeeper_downcenter.png')

        #window.connect("destroy", lambda w: gtk.main_quit())

        #callbacks al invocar el area de dibujo
        self.drawing_area.connect('configure_event', self.__configure_cb)
        self.drawing_area.connect('expose-event', self.__expose_cb)

        #evento que invoca funcion al presionar cualquier tecla
        self.connect('key-press-event', self.__key_press_event_cb)

        #anhadiendo widgets dentro del contenedor principal
        self.set_canvas(hbox)
        hbox.add(vbox)
        frame.add(self.label)
        vbox.add(frame)
        vbox.add(self.drawing_area)
        vbox.add(self.hslide)
        hbox.add(self.vslide)

        #mostrando los widgets
        self.show_all()

        #invocacion de la funcion que realiza loop del slider horizontal
        gobject.timeout_add(DELAY, self.__hslider_move_cb)
Пример #22
0
    def __init__(self):
        '''application.'''
        self.__init_values()
        self.app = Application(False)
        # application set.
        app_w, app_h = 800, 570  # 初始化宽,高.
        min_app_w, min_app_h = 480, 300  # 防止超过,界面布局被破坏.
        self.app.set_default_size(min_app_w, min_app_h)
        self.app.window.set_default_size(app_w, app_h)
        # self.app.window.resize
        image_dir = os.path.join(get_parent_dir(__file__, 2), "image")
        self.app.set_icon(os.path.join(image_dir, "icon.ico"))
        self.app.set_skin_preview(
            os.path.join(os.path.join(image_dir, "frame.png")))
        # set titlebar.
        self.app.add_titlebar(
            ["theme", "menu", "max", "min", "close"],
            os.path.join(os.path.join(image_dir, "logo.png")),
            _("DPlayer"),
            " ",
            add_separator=False,
        )
        self.app.titlebar.set_size_request(-1, 30)

        #
        self.play_menus = PlayMenus()
        # 设置主题菜单.
        self.app.set_menu_callback(
            lambda button: self.play_menus.show_theme_menu(button))
        #
        self.main_ali = gtk.Alignment()
        self.main_vbox = gtk.VBox()
        self.main_ali.add(self.main_vbox)
        self.main_ali.set(0, 0, 1.0, 1.0)
        self.main_ali.set_padding(0, 2, 2, 2)
        #
        self.mid_combo_event = gtk.EventBox()
        self.mid_combo_event.connect("expose-event",
                                     self.mid_combo_event_expose_event)
        self.screen_mid_combo = ScreenMidCombo()
        self.mid_combo_event.set_visible_window(True)
        self.mid_combo_event.add(self.screen_mid_combo)
        '''movie screen. 电影播放屏幕.'''
        # 播放屏幕和播放列表的HBOX.
        self.play_list_view = PlayListView()
        self.screen_paned = Paned()
        self.screen_paned.paint_bottom_window = self.__paint_bottom_toolbar_background
        self.screen_frame = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
        self.screen = gtk.DrawingArea()
        self.screen_frame.add(self.screen)
        self.top_toolbar = ToolBar()
        self.bottom_toolbar = BottomToolBar()
        # BUG: 当显示上部工具条的时候,画面抖动.
        self.screen_paned.add_top_widget(self.top_toolbar.hbox_hframe)
        self.screen_paned.add_bottom_widget(self.bottom_toolbar.vbox)
        #self.screen_paned.add_mid_widget(self.screen_mid_combo)
        self.screen_paned.add_mid_widget(self.mid_combo_event)
        #
        self.screen_frame_event = self.screen_paned
        self.screen_paned.screen = self.screen
        #
        self.screen_paned.add1(self.screen_frame)
        self.screen_paned.add2(self.play_list_view.play_list_vbox)
        #
        self.play_control_panel = BottomToolBar(False)
        #
        self.main_vbox.pack_start(self.screen_paned, True, True)
        self.main_vbox.pack_start(self.play_control_panel.vbox, False, False)
        #
        self.app.main_box.pack_start(self.main_ali, True, True)
Пример #23
0
import gtk

import kaa
import kaa.imlib2
import kaa.display

window = gtk.Window()
window.set_size_request(1024, 768)

da = gtk.DrawingArea()
da.set_size_request(800, 600)

window.add(da)
window.connect("destroy", gtk.main_quit)
window.show_all()

image = kaa.imlib2.open("data/background.jpg")

# print da.window.xid

sock = gtk.Socket()
sock.add_id(da.window.xid)

x11win = kaa.display.X11Window(window=sock.get_id())
# x11win.render_imlib2_image(da.image)

kaa.main.run()
Пример #24
0
    def __init__(self):

        ###############################################
        #   el orden de los contenedores de la ventana
        #        ventana
        #        |
        #         ->box1
        #           |
        #            -> menu_bar
        #           |
        #            -> toolbar
        #           |
        #            -> box2
        #               |
        #                -> scrolled_window
        #               |
        #                -> scrolled_window2
        ################################################
        #esta es la lista de donde se sacan los valores para los botones
        #icaro
        arch=open(sys.path[0] + "/version", "r")
        a=arch.readline()
        creditos.Info.version= a
        self.carga_dicc()
        self.tooltip=tooltips.dicc
        self.lista=self.diccionario.keys()
        self.lista.sort()
        self.carga_paleta()
        # cargo la configuracion de icaro
        conf=open(sys.path[0] +"/config.dat","r")
        dat=conf.readlines()
        for txt in dat:
            self.config.append(txt)
        conf.close()

        #declaro la ventana principal
        self.window1 = gtk.Window()
        self.window1.connect('delete-event', gtk.main_quit)
        self.window1.set_icon_from_file(
                                        sys.path[0] +
                                         "/imagenes/icaro.png"
                                         )
        #~ self.window1.fullscreen()
        #self.window1.fullscreen()
        # declaro el drawing area donde va a estar pygame
        # y los eventos del mouse y teclado
        self.area = gtk.DrawingArea()
        self.area.set_app_paintable(True)
        self.area.set_size_request(3000, 3000)
        # declaro los botones del menu 'menu' y 'edicion'
        menu = gtk.Menu()
        # buf es donde se crgan todos los botones del menu
        buf=(
                _("New"),
                _("Open"),
                _("Save"),
                _("Save as"),
                _("Save as function"),
                _("Examples"),
                _("Exit")
            )
        for i in buf:
            menu_items = gtk.MenuItem(i)
            menu.append(menu_items)
            menu_items.connect("activate", self.menuitem_response, i)
            menu_items.show()


        menu2 = gtk.Menu()
        # buf es donde se crgan todos los botones del menu
        buf2=(_("Background"),_("Color"),_("About"), _("Config"))
        for i in buf2:
            menu_items2 = gtk.MenuItem(i)
            menu2.append(menu_items2)
            menu_items2.connect("activate", self.menuitem_response, i)
            menu_items2.show()


        # los menus del toolbar se agrupan en estos dos "menus raices"
        root_menu = gtk.MenuItem(_("File"))
        root_menu.show()
        root_menu.set_submenu(menu)

        root_menu2 = gtk.MenuItem(_("Edit"))
        root_menu2.show()
        root_menu2.set_submenu(menu2)
        #los dos menus_root quedan dentro de la barra de menu
        menu_bar = gtk.MenuBar()
        menu_bar.show()
        menu_bar.append (root_menu)
        menu_bar.append (root_menu2)
        # esta es la toolbar donde van los botones para cargar los datos
        # y compilar
        toolbar = gtk.Toolbar()
        toolbar.append_item
        toolbar.set_style(gtk.TOOLBAR_BOTH)
        toolbar.show()
        # creo los botones de la toolbar
        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_NEW,30)
        tool_button = toolbar.append_item(
                        _("New"),
                        self.tooltip["nuevo"],
                        "Private",
                        iconw,
                        self.nuevo)

        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_OPEN,30)
        tool_button = toolbar.append_item(
                        _("Open"),
                        self.tooltip["abrir"],
                        "Private",
                        iconw,
                        self.abrir)
        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_SAVE,30)
        tool_button = toolbar.append_item(
                        _("Save"),
                        self.tooltip["guardar"],
                        "Private",
                        iconw,
                        self.guardar)
        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_QUIT,30)
        tool_button = toolbar.append_item(
                        _("Exit"),
                        self.tooltip["salir"],
                        "Private",
                        iconw,
                        self.salir)

        toolbar.append_space()



        iconw = gtk.Image()
        iconw.set_from_file(sys.path[0] + "/imagenes/icaro.png")
        tool_button = toolbar.append_item(
                        _("Compile"),
                        self.tooltip["compilar"],
                        "Private",
                        iconw,
                        self.compilar)

        iconw = gtk.Image()
        iconw.set_from_file(sys.path[0] + "/imagenes/compilar.png")
        tool_button = toolbar.append_item(
                        _("Load"),
                        self.tooltip["cargar"],
                        "Private",
                        iconw,
                        self.upload)

        iconw = gtk.Image()
        iconw.set_from_file(sys.path[0] + "/imagenes/tortucaro.png")
        tool_button = toolbar.append_item(
                        _("Tortucaro"),
                        self.tooltip["tortucaro"],
                        "Private",
                        iconw,
                        self.tortucaro)
        toolbar.append_space()

        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_HELP,30)
        tool_button = toolbar.append_item(
                        _("Help"),
                        self.tooltip["ayuda"],
                        "Private",
                        iconw,
                        self.ayuda)
        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_PROPERTIES,30)
        tool_button = toolbar.append_item(
                        _("View source"),
                        self.tooltip["ver_codigo"],
                        "Private",
                        iconw,
                        self.ver)


        # un espacio en blanco para separar
        toolbar.append_space()
        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_EDIT,30)
        dibujar_button = toolbar.append_element(
                        gtk.TOOLBAR_CHILD_BUTTON,None,
                        _("Pen"),
                        self.tooltip["lapiz"],
                        "Private",
                        iconw,
                        self.dibujo,1)
        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_SELECT_COLOR,30)
        mover_button = toolbar.append_element(
                        gtk.TOOLBAR_CHILD_BUTTON,None,
                        _("Move"),
                        self.tooltip["mover"],
                        "Private",
                        iconw,
                        self.dibujo,2)

        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_DELETE,30)
        tool_button = toolbar.append_element(
                        gtk.TOOLBAR_CHILD_BUTTON,None,
                        _("Erase"),
                        self.tooltip["borrar"],
                        "Private",
                        iconw,
                        self.dibujo,3)

        iconw = gtk.Image()
        iconw.set_from_stock(gtk.STOCK_ZOOM_FIT,30)
        mover_button = toolbar.append_element(
                        gtk.TOOLBAR_CHILD_BUTTON,None,
                        _("Edit"),
                        self.tooltip["mover"],
                        "Private",
                        iconw,
                        self.dibujo,4)


        #declaro el scroll_window donde esta inserto el drawing area
        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_size_request(500, 600)
        scrolled_window.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
        scrolled_window.show()
        scrolled_window.add_with_viewport(self.area)
        #declaro el scroll window donde va la toolbar de los bloques
        scrolled_window2 = gtk.ScrolledWindow()
        scrolled_window2.set_border_width(1)
        scrolled_window2.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
        scrolled_window2.show()
        #declaro la tabla  donde van los botones para el menu de bloques

        table=gtk.VBox(False, len(self.lista))
        notebook = gtk.Notebook()
        notebook.set_tab_pos(gtk.POS_RIGHT)
#        notebook.show()
        
#
        scrolled_window2.add_with_viewport(notebook)

        label = gtk.Label(self.diccionario[self.lista[0]][1])
        notebook.append_page(table,label)
        # box1 es el contenedor principal despues de la ventana
        box1 = gtk.VBox(False, 3)
        # box2 es el segundo en importancia
        box2 = gtk.HBox(False, 2)
        buffer = self.diccionario[self.lista[1]][0]
        caja = self.imagen_boton(
                                self.diccionario[self.lista[1]][0],
                                self.diccionario[self.lista[1]][0]
                                )
        button = gtk.RadioButton()
        if self.tooltip.has_key(self.diccionario[self.lista[1]][0]):
            val=self.tooltip[self.diccionario[self.lista[1]][0]]
            button.set_tooltip_text(val)
        # bucle principal donde se cargan los RAdioButton donde se cargan
        # los componentes del diccionario


        button.add(caja)
        button.connect("clicked", self.botones,self.lista[1])#buffer

        button.show()
        table.pack_start(button, False, True, 0)

        for i in range(2,len(self.lista)):
            if self.diccionario[self.lista[i]][0]=="notebook":
                table=gtk.VBox(False, len(self.lista))
                label = gtk.Label(self.diccionario[self.lista[i]][1])
                notebook.append_page(table,label)
            else:
                buffer = self.diccionario[self.lista[i]][0]
                caja = self.imagen_boton(
                                    self.diccionario[self.lista[i]][0],
                                    self.diccionario[self.lista[i]][0]
                                        )
                button = gtk.RadioButton(button)
                if self.tooltip.has_key(
                                self.diccionario[self.lista[i]][0]
                                        ):
                    tool=self.tooltip   [
                                self.diccionario[self.lista[i]][0]
                                        ]
                    button.set_tooltip_text(tool)
                button.add(caja)
                button.connect("clicked", self.botones,self.lista[i])
                table.pack_start(button, False, True, 0)
                button.show()
            #empaqueto todo

        box2.pack_start(scrolled_window, True, True, 1)
        box2.pack_start(scrolled_window2,False, False, 1)
        box1.pack_start(menu_bar, False, True, 1)
        box1.pack_start(toolbar, False, True, 1)
        box1.pack_start(box2, True, True, 1)
        self.window1.add(box1)

        # capturo los eventos del drawing area
        # menos el teclado que lo capturo desde la ventana principal
        self.area.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.area.add_events(gtk.gdk.BUTTON_RELEASE_MASK)
        self.area.add_events(gtk.gdk.POINTER_MOTION_MASK)
        self.window1.add_events(gtk.gdk.KEY_PRESS_MASK)
        self.window1.add_events(gtk.gdk.KEY_RELEASE_MASK)
        self.area.connect("button-press-event", self.buttonpress_cb)
        self.area.connect("button-release-event", self.buttonrelease_cb)
        self.area.connect("motion-notify-event", self.move_cb)
        self.window1.connect("key_press_event", self.keypress_cb)
        self.window1.connect("key_release_event", self.keyrelease_cb)
        self.area.realize()
Пример #25
0
    def __init__(self, handle):
        "Set up the activity."

        # Sugar init
        activity.Activity.__init__(self, handle)

        # Create toolbox
        toolbox = activity.ActivityToolbox(self)
        toolbarview = Toolbar()
        tool = ToolButton('zoom-out')
        tool.set_tooltip(_('Zoom out'))
        tool.set_accelerator(_('<ctrl>minus'))
        tool.connect('clicked', self.zoom_out)
        toolbarview.insert(tool, -1)
        tool = ToolButton('zoom-in')
        tool.set_tooltip(_('Zoom in'))
        tool.set_accelerator(_('<ctrl>equal'))
        tool.connect('clicked', self.zoom_in)
        toolbarview.insert(tool, -1)
        toolbox.add_toolbar(_('View'), toolbarview)
        toolbarsample = Toolbar()
        tool = ToolButton('emptytree')
        tool.set_tooltip(_('Empty tree'))
        tool.connect('clicked', self.emptytree)
        toolbarsample.insert(tool, -1)
        tool = ToolButton('sample1')
        tool.set_tooltip(_('Test'))
        tool.connect('clicked', self.sample1)
        toolbarsample.insert(tool, -1)
        tool = ToolButton('sample2')
        tool.set_tooltip(_('Napoléon'))
        tool.connect('clicked', self.sample2)
        toolbarsample.insert(tool, -1)
        toolbox.add_toolbar(_('Samples'), toolbarsample)
        self.set_toolbox(toolbox)
        toolbox.show()

        # Create drawing area
        self.zoomlevel = 0
        self.area = gtk.DrawingArea()
        self.area.set_size_request(875, 780)
        self.area.set_events(gtk.gdk.BUTTON_PRESS_MASK
                             | gtk.gdk.BUTTON_RELEASE_MASK
                             | gtk.gdk.BUTTON_MOTION_MASK
                             | gtk.gdk.POINTER_MOTION_MASK)
        self.area.connect("expose_event", self.area_expose_cb)
        self.area.connect("button_press_event", self.press_button)
        self.area.connect("button_release_event", self.release_button)
        self.area.connect("motion_notify_event", self.mouse_move)
        self.moving = False

        # Create detail view
        self.fixed = VBoxColor(const.bg_color)
        self.fixed.set_size_request(325, 780)
        self.imagezone = gtk.DrawingArea()
        self.imagezone.set_size_request(325, 240)
        self.imagezone.set_events(gtk.gdk.BUTTON_PRESS_MASK
                                  | gtk.gdk.BUTTON_RELEASE_MASK)
        self.imagezone.connect("expose_event", self.image_expose)
        self.imagezone.connect("button_press_event", self.image_release_button)
        self.image_paste = gtk.gdk.pixbuf_new_from_file(
            "images/edit-paste.svg")
        self.image_hand1 = gtk.gdk.pixbuf_new_from_file("images/hand1.png")
        self.fixed.pack_start(self.imagezone, False, False, 0)
        self.detail_name = gtk.Entry()
        self.detail_name.connect("changed", self.detail_changed)
        self.fixed.pack_start(self.detail_name, False, False, 0)
        radiocontainer = gtk.HBox()
        self.detail_chkmale = gtk.RadioButton(None, _("Male"))
        self.detail_chkmale.connect("toggled", self.sexradio_checked, 'M')
        radiocontainer.pack_start(self.detail_chkmale, True, True, 0)
        self.detail_chkfemale = gtk.RadioButton(self.detail_chkmale,
                                                _("Female"))
        self.detail_chkfemale.connect("toggled", self.sexradio_checked, 'F')
        radiocontainer.pack_start(self.detail_chkfemale, True, True, 0)
        self.fixed.pack_start(radiocontainer, False, False, 0)
        scrolled = gtk.ScrolledWindow()
        scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolled.set_border_width(2)
        self.detail_description = gtk.TextView()
        self.detail_description.set_wrap_mode(gtk.WRAP_WORD)
        self.detail_description.set_size_request(200, 100)
        self.detail_description.set_cursor_visible(True)
        self.detail_description.get_buffer().connect("changed",
                                                     self.description_changed)
        scrolled.add(self.detail_description)
        self.fixed.pack_start(scrolled, False, False, 5)
        self.detail_btnaddparent = self.create_button(_("Add parents"),
                                                      "images/addparent.svg",
                                                      self.addparent_clicked)
        self.detail_btnaddbrother = self.create_button(
            _("Add brother/sister"), "images/addbrother.svg",
            self.addbrother_clicked)
        self.detail_btnaddunion = self.create_button(_("Add union"),
                                                     "images/addunion.svg",
                                                     self.addunion_clicked)
        self.detail_btnaddchild = self.create_button(_("Add child"),
                                                     "images/addchild.svg",
                                                     self.addchild_clicked)
        self.detail_btndelete = self.create_button(_("Delete"),
                                                   "images/delete.svg",
                                                   self.delete_clicked)
        self.fixed.pack_start(self.detail_btnaddparent, False, False, 2)
        self.fixed.pack_start(self.detail_btnaddunion, False, False, 2)
        self.fixed.pack_start(self.detail_btnaddbrother, False, False, 2)
        self.fixed.pack_start(self.detail_btnaddchild, False, False, 2)
        self.fixed.pack_start(self.detail_btndelete, False, False, 0)
        self.box = gtk.HBox(False)
        self.box.pack_start(self.fixed, True, True, 0)
        self.box.pack_start(self.area, True, True, 0)
        self.set_canvas(self.box)

        # Create empty tree
        self.tree = None
        self.selected = None
        self.init_tree(empty_tree(buddyName))

        # Show all
        self.show_all()
        self.area.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.ARROW))
Пример #26
0
    def __init__(self):
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_title("Drawing Area Example")
        window.connect("destroy", lambda w: gtk.main_quit())
        self.area = gtk.DrawingArea()
        self.area.set_size_request(400, 300)
        self.pangolayout = self.area.create_pango_layout("")
        self.sw = gtk.ScrolledWindow()
        self.sw.add_with_viewport(self.area)
        self.table = gtk.Table(2, 2)
        self.hruler = gtk.HRuler()
        self.vruler = gtk.VRuler()
        self.hruler.set_range(0, 400, 0, 400)
        self.vruler.set_range(0, 300, 0, 300)
        self.table.attach(self.hruler, 1, 2, 0, 1, yoptions=0)
        self.table.attach(self.vruler, 0, 1, 1, 2, xoptions=0)
        self.table.attach(self.sw, 1, 2, 1, 2)
        window.add(self.table)
        self.area.set_events(gtk.gdk.POINTER_MOTION_MASK
                             | gtk.gdk.POINTER_MOTION_HINT_MASK)
        self.area.connect("expose-event", self.area_expose_cb)

        def motion_notify(ruler, event):
            return ruler.emit("motion_notify_event", event)

        self.area.connect_object("motion_notify_event", motion_notify,
                                 self.hruler)
        self.area.connect_object("motion_notify_event", motion_notify,
                                 self.vruler)
        self.hadj = self.sw.get_hadjustment()
        self.vadj = self.sw.get_vadjustment()

        def val_cb(adj, ruler, horiz):
            if horiz:
                span = self.sw.get_allocation()[3]
            else:
                span = self.sw.get_allocation()[2]
            l, u, p, m = ruler.get_range()
            v = adj.value
            ruler.set_range(v, v + span, p, m)
            while gtk.events_pending():
                gtk.main_iteration()

        self.hadj.connect('value-changed', val_cb, self.hruler, True)
        self.vadj.connect('value-changed', val_cb, self.vruler, False)

        def size_allocate_cb(wid, allocation):
            x, y, w, h = allocation
            l, u, p, m = self.hruler.get_range()
            m = max(m, w)
            self.hruler.set_range(l, l + w, p, m)
            l, u, p, m = self.vruler.get_range()
            m = max(m, h)
            self.vruler.set_range(l, l + h, p, m)

        self.sw.connect('size-allocate', size_allocate_cb)
        self.area.show()
        self.hruler.show()
        self.vruler.show()
        self.sw.show()
        self.table.show()
        window.show()
Пример #27
0
    def __init__(self, directoryname="/tmp"):

        self.savePid()

        self.blocksize = WIDTH * HEIGHT * 4

        self.dir = directoryname
        self.compost_init()
        ## liste mit verfuegbaren chunks
        # self.compost._chunkss
        self.chunkindex = 0
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_title("Video-Player")
        window.set_default_size(500, 400)
        window.fullscreen()
        # make the cursor disappear on realize
        window.connect("realize", self.realize_cb)
        window.connect("destroy", gtk.main_quit, "WM destroy")
        vbox = gtk.VBox()
        window.add(vbox)
        self.movie_window = gtk.DrawingArea()
        vbox.add(self.movie_window)
        window.show_all()

        self.pipeline = gst.Pipeline()

        # open a file
        self.fileplayer = gst.element_factory_make("filesrc")
        self.pipeline.add(self.fileplayer)

        self.fileplayer.set_property("blocksize", self.blocksize)

        # force caps
        self.capsstring = "video/x-raw-rgb, bpp=(int)32, endianness=(int)4321, depth=(int)32, red_mask=(int)16711680, green_mask=(int)65280, blue_mask=(int)255, alpha_mask=(int)-16777216, width=(int)%d, height=(int)%d, framerate=%s, pixel-aspect-ratio=(fraction)1/1" % (
            WIDTH, HEIGHT, FRAMERATE)
        caps = gst.Caps(self.capsstring)
        self.capsfilter = gst.element_factory_make("capsfilter")
        self.pipeline.add(self.capsfilter)
        self.capsfilter.set_property("caps", caps)

        # colorspace converter
        self.colorspace = gst.element_factory_make("ffmpegcolorspace")
        self.pipeline.add(self.colorspace)

        # videorate converter
        self.videorate = gst.element_factory_make("videorate")
        self.pipeline.add(self.videorate)

        # output window
        self.sink = gst.element_factory_make("xvimagesink")
        self.pipeline.add(self.sink)

        self.sink.set_xwindow_id(self.movie_window.window.xid)

        gst.element_link_many(self.fileplayer, self.capsfilter,
                              self.colorspace, self.videorate, self.sink)

        # bus magic
        bus = self.pipeline.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect("message", self.on_message)
        bus.connect("sync-message::element", self.on_sync_message)

        self.fileplayer.set_property("location", self.get_next_file())
        self.pipeline.set_state(gst.STATE_PLAYING)
Пример #28
0

def pack(w, row, col):
    table.attach(w, col, col + 1, row, row + 1, gtk.EXPAND | gtk.FILL,
                 gtk.EXPAND | gtk.FILL, 0, 0)


win = gtk.Window()
win.connect("destroy", gtk.main_quit)

table = gtk.Table()
win.add(table)

row, col = 0, 0

drawing_area = gtk.DrawingArea()
# drawing_area.set_size_request(100, 100)
pack(drawing_area, row, col)
row += 1

vscroll = gtk.VScrollbar()
pack(vscroll, 0, 1)

hscroll = gtk.HScrollbar()
pack(hscroll, row, col)
row += 1

notebook = gtk.Notebook()
label = gtk.Label("Label")
notebook.append_page(label)
label = gtk.Label("Label")
Пример #29
0
 def _renderer_init(self):
     self._renderer = RendererGDK(gtk.DrawingArea(), self.figure.dpi)
Пример #30
0
    def __init__(self):

        # Init WIndow
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_default_size(800, 500)
        self.window.set_resizable(True)
        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)

        # Focus Check
        self.window.set_events(gtk.gdk.FOCUS_CHANGE_MASK)
        self.window.connect("focus_in_event", self.infocus)
        self.window.connect("focus_out_event", self.notinfocus)
        self.window.set_border_width(10)
        self.window.set_title("Sost-Sat Data Logger")

        # Init Quit Button
        self.button_quit = gtk.Button("Quit")
        self.button_quit.connect_object("clicked", gtk.Widget.destroy,
                                        self.window)

        self.button_view = gtk.Button("Connect")
        self.button_view.connect("clicked", self.connect, None)

        self.button_clear = gtk.Button("Clear")
        self.button_clear.connect("clicked", self.clear_text, None)

        # Init Text View
        self.textview = gtk.TextView()
        self.textview.set_editable(True)
        self.textbuffer = self.textview.get_buffer()
        self.textview.set_overwrite(False)
        self.textview.set_wrap_mode(gtk.WRAP_WORD)

        # Init ScrollWindow
        self.scrolledwindow = gtk.ScrolledWindow(hadjustment=None,
                                                 vadjustment=None)
        self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
        self.scrolledwindow.add(self.textview)

        # Init Label
        self.label_baud = gtk.Label("Baud Rate : ")
        self.label_port = gtk.Label("Port : ")
        self.label_input = gtk.Label("Input : ")
        self.label_about = gtk.Label(
            " Nano-Sat Serial Data Logger\n \n Version :7.1.0 \n Designed @ SOST Lab \n Designed By Priyashraba Misra\n International Instiute of Information Technology\n Pune "
        )
        self.label_about.set_justify(gtk.JUSTIFY_CENTER)

        # Combo for Baud, Port
        self.combobox_baud = gtk.combo_box_new_text()
        for i in self.baud_rates:
            self.combobox_baud.append_text(i)
        self.combobox_baud.set_active(0)

        self.combobox_port = gtk.combo_box_new_text()
        for i in self.port:
            self.combobox_port.append_text(i)
        self.combobox_port.set_active(1)

        #Text entru for USART write
        self.entry_usart = gtk.Entry(max=0)
        self.entry_usart.connect("changed", self.transmitUSART)
        self.entry_usart.set_sensitive(False)

        #HBox for Text
        self.hbox1 = gtk.HBox(False, 0)
        self.hbox1.pack_start(self.scrolledwindow,
                              expand=True,
                              fill=True,
                              padding=0)

        #HBox for Text
        self.hbox2 = gtk.HBox(False, 0)
        self.hbox2.pack_start(self.label_input,
                              expand=False,
                              fill=False,
                              padding=0)
        self.hbox2.pack_start(self.entry_usart,
                              expand=True,
                              fill=True,
                              padding=0)

        #HBox for Menus
        self.hbox3 = gtk.HBox(False, 0)
        self.hbox3.pack_start(self.label_baud,
                              expand=False,
                              fill=False,
                              padding=0)
        self.hbox3.pack_start(self.combobox_baud,
                              expand=True,
                              fill=False,
                              padding=0)
        self.hbox3.pack_start(self.label_port,
                              expand=False,
                              fill=False,
                              padding=5)
        self.hbox3.pack_start(self.combobox_port,
                              expand=True,
                              fill=False,
                              padding=5)
        self.hbox3.pack_start(self.button_view,
                              expand=True,
                              fill=False,
                              padding=5)
        self.hbox3.pack_start(self.button_clear,
                              expand=True,
                              fill=False,
                              padding=5)
        self.hbox3.pack_start(self.button_quit,
                              expand=True,
                              fill=False,
                              padding=5)

        #Vbox for stacking HBox(s)
        self.vbox1 = gtk.VBox(False, 10)
        self.vbox1.pack_start(self.hbox1, expand=True, fill=True, padding=5)
        self.vbox1.pack_start(self.hbox2, expand=False, fill=False, padding=5)
        self.vbox1.pack_start(self.hbox3, expand=False, fill=False, padding=5)

        #Drawing area for graph
        self.area = gtk.DrawingArea()
        self.area.set_size_request(600, 300)
        self.area.connect("expose-event", self.area_expose_cb)
        #self.area_expose_cb(self.area)
        self.area.show()

        #button for drawing area
        self.button_plottemp = gtk.Button("Start Plot")
        self.button_plottemp.connect("clicked", self.plotTemp, None)

        self.button_plotclear = gtk.Button("Clear Plot")
        self.button_plotclear.connect("clicked", self.plotClear, None)

        #hbox and vbox for drawing area
        self.hbox4 = gtk.HBox()
        self.hbox4.pack_start(self.area, expand=False, fill=False, padding=5)

        self.hbox5 = gtk.HBox()
        self.hbox5.pack_start(self.button_plottemp,
                              expand=False,
                              fill=False,
                              padding=5)
        self.hbox5.pack_start(self.button_plotclear,
                              expand=False,
                              fill=False,
                              padding=5)

        self.vbox2 = gtk.VBox()
        self.vbox2.pack_start(self.hbox4, expand=True, fill=True, padding=5)
        self.vbox2.pack_start(self.hbox5, expand=True, fill=True, padding=5)

        # Notebook for Tabs
        self.label_notepage1 = gtk.Label("Terminal")
        self.label_notepage2 = gtk.Label("Plot")
        self.label_notepage3 = gtk.Label("About")
        self.notebook = gtk.Notebook()
        self.notebook.set_tab_pos(gtk.POS_TOP)
        self.notebook.append_page(self.vbox1, self.label_notepage1)
        self.notebook.append_page(self.vbox2, self.label_notepage2)
        self.notebook.append_page(self.label_about, self.label_notepage3)
        self.notebook.show()

        # add to window
        self.window.add(self.notebook)

        # add accelerators
        self.accel_group = gtk.AccelGroup()
        self.window.add_accel_group(self.accel_group)
        self.button_view.add_accelerator("clicked", self.accel_group, ord('c'),
                                         gtk.gdk.CONTROL_MASK,
                                         gtk.ACCEL_VISIBLE)
        self.button_quit.add_accelerator("clicked", self.accel_group, ord('x'),
                                         gtk.gdk.CONTROL_MASK,
                                         gtk.ACCEL_VISIBLE)

        #show all
        self.button_view.show()
        self.button_quit.show()
        self.button_clear.show()
        self.button_plottemp.show()
        self.button_plotclear.show()
        self.scrolledwindow.show()
        self.textview.show()
        self.hbox1.show()
        self.hbox2.show()
        self.hbox3.show()
        self.hbox4.show()
        self.hbox5.show()
        self.vbox1.show()
        self.vbox2.show()
        self.window.show()
        self.label_baud.show()
        self.label_port.show()
        self.label_input.show()
        self.label_about.show()
        self.label_notepage1.show()
        self.label_notepage2.show()
        self.label_notepage3.show()
        self.combobox_baud.show()
        self.combobox_port.show()
        self.entry_usart.show()

        # Init Timeout
        #timer = gobject.timeout_add(100,self.display)
        idle1 = gobject.idle_add(self.display)