Exemple #1
0
    def startVid(self):
        gobject.threads_init()
        video = Frame(self, background='black')
        video.grid(row=0, column=0, columnspan=8, rowspan=4, padx=2, sticky=E+W+S+N)
        window_id = video.winfo_id()
     
        self.buf = gst.Buffer()

        self.bin = gst.Bin("my-bin")
        timeoverlay = gst.element_factory_make("timeoverlay", "overlay")
        self.bin.add(timeoverlay)
        pad = timeoverlay.get_pad("video_sink")
        ghostpad = gst.GhostPad("sink", pad)
        self.bin.add_pad(ghostpad)
        videosink = gst.element_factory_make("ximagesink")
        self.bin.add(videosink)
        gst.element_link_many(timeoverlay, videosink)
    
        self.player.set_property('video-sink', self.bin)
        self.player.set_property('uri', 'file://%s' % (os.path.abspath(self.project.videoPath)))

        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()

        bus.connect("message", self.on_message, window_id)
        bus.connect('sync-message::element', self.on_sync_message, window_id)

        self.play.configure(command=lambda: self.play_video())

        self.back.configure(command=self.play_back)
Exemple #2
0
    def startVid(self):
        gobject.threads_init()
        video = Frame(self, background='black')
        video.grid(row=0, column=0, columnspan=8, rowspan=4, padx=2, sticky=E+W+S+N)
        window_id = video.winfo_id()
     
        self.buf = gst.Buffer()

        self.bin = gst.Bin("my-bin")
        timeoverlay = gst.element_factory_make("timeoverlay", "overlay")
        self.bin.add(timeoverlay)
        pad = timeoverlay.get_pad("video_sink")
        ghostpad = gst.GhostPad("sink", pad)
        self.bin.add_pad(ghostpad)
        videosink = gst.element_factory_make("ximagesink")
        self.bin.add(videosink)
        gst.element_link_many(timeoverlay, videosink)
    
        self.player.set_property('video-sink', self.bin)
        self.player.set_property('uri', 'file://%s' % (os.path.abspath(self.project.videoPath)))

        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()

        bus.connect("message", self.on_message, window_id)
        bus.connect('sync-message::element', self.on_sync_message, window_id)

        self.play.configure(command=lambda: self.play_video())

        self.back.configure(command=self.play_back)
	def initUI(self):
		
		self.parent.title("Simple FTP-Client")
		self.pack(fill=BOTH, expand=True)
	
		# self.parent.title("Buttons") 
				
		#frame2 = Frame(self)
		#frame2.pack(anchor=W,side=LEFT)
		#lbl2 = Label(frame2, text="Command Line", width=6)
		#lbl2.pack(fill=X,anchor=W,expand=True,padx=5, pady=5)        
		#txt2 = Text(frame2)
		#txt2.pack(fill=X,side=BOTTOM,pady=5, padx=5)           

		frame3 = Frame(self, width=400, height=500)
		frame3.pack(side=BOTTOM,anchor=NW)
		lbl3 = Label(frame3, text="Command Line", width=6)
		lbl3.pack(fill=X,anchor=NE,expand=True,padx=5, pady=5)        
		txt = Text(frame3)
		txt.pack(fill=BOTH,pady=5, padx=5)
	        wid = frame3.winfo_id()
		os.system('xterm -into %d -geometry 400x400 -sb &' % wid)
		
		     
		
		f1 = Frame(self)
		f1.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10)
		lb=Label(f1, text="Host:").grid(row=0, column=0)
		e1 = Entry(f1)
		e1.grid(row=0, column=1, padx=1)
		
		f2 = Frame(self)
		f2.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10)
		lb2=Label(f2, text="Username:"******"Password:"******"Port:").grid(row=0, column=2)
		e4 = Entry(f4)
		e4.grid(row=0, column=3, padx=5)

		connectButton = Button(self, text="Connect", command=callback)
		connectButton.pack(expand=True,fill=X,side=LEFT, anchor=NW, padx=10, pady=10)
Exemple #4
0
    def initUI(self):
      
        self.parent.title("Windows")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        self.columnconfigure(1, weight=1)
        self.columnconfigure(15, pad=7)
        self.rowconfigure(3, weight=1)
        self.rowconfigure(9, pad=7)
        
        def hello():
            print "hello!"

        #Menubar--------------------------------------------------------------
        menubar = tkinter.Menu(self)
        
        filemenu = tkinter.Menu(menubar, tearoff=0)
        filemenu.add_command(label="New", command=hello)
        filemenu.add_command(label="Open", command=hello)
        filemenu.add_command(label="Save", command=hello)
        filemenu.add_command(label="Save As", command=hello)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.parent.quit)
        menubar.add_cascade(label="File", menu=filemenu)
       
        editmenu = tkinter.Menu(menubar, tearoff=0)
        editmenu.add_command(label="Copy", command=hello)
        editmenu.add_command(label="Paste", command=hello)
        editmenu.add_command(label="SelectAll", command=hello)
        editmenu.add_command(label="Undo", command=hello)
        editmenu.add_command(label="Redo", command=hello)
        menubar.add_cascade(label="Edit", menu=editmenu)
        
        #Create analysis window here
        def do_popup_analysis():
            new_frame = Tk()
            
        menubar.add_command(label="Analysis", command=do_popup_analysis)

        def do_popup_plot():
            new_frame = Tk()
            
        menubar.add_command(label="Plot", command=do_popup_plot)
        menubar.add_command(label="Help", command=hello)

        self.parent.config(menu=menubar)
        #Menubar done----------------------------------------------------------

        #Video embedding part--------------------------------------------------
        gobject.threads_init()
        video = Frame(self)
        video.grid(row=0, column=0, columnspan=8, rowspan=4, 
            padx=2, sticky=E+W+S+N)
        window_id = video.winfo_id()
 
        
        self.buf = gst.Buffer()


        self.bin = gst.Bin("my-bin")
        timeoverlay = gst.element_factory_make("timeoverlay", "overlay")
        self.bin.add(timeoverlay)
        pad = timeoverlay.get_pad("video_sink")
        ghostpad = gst.GhostPad("sink", pad)
        self.bin.add_pad(ghostpad)
        videosink = gst.element_factory_make("autovideosink")
        self.bin.add(videosink)
        gst.element_link_many(timeoverlay, videosink)
        
        self.player = gst.element_factory_make('playbin2', 'player')
        self.player.set_property('video-sink', self.bin)
        self.player.set_property('uri', 'file://%s' % (os.path.abspath(sys.argv[1])))
       
        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect("message", self.on_message, window_id)
        bus.connect('sync-message::element', self.on_sync_message, window_id)


        def play_video():
            if self.play["text"] == "Play":
                self.player.set_state(gst.STATE_PLAYING)
                self.play["text"] = "Pause"
            else:
                self.player.set_state(gst.STATE_PAUSED)
                self.play["text"] = "Play"

        
        self.play = Button(self, text="Play", command=play_video, width=50)
        self.play.grid(row=5,column=0)

        self.entry = tkinter.Entry(self, width=50)
        self.entry.grid(row=5, column=1)

        def play_back():
            pos_int = self.player.query_position(gst.FORMAT_TIME, None)[0]
            text = self.entry.get()
            diff = 0
            if text=="":
                diff = pos_int - (3*(10**9))
            else:
                val = float(self.entry.get())
                diff = pos_int - (val*(10**9))
            
            if diff>0:
                self.player.seek_simple(gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, diff)
            else:
                self.player.seek_simple(gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, 0)
 

        self.back = Button(self, text="Playback", command=play_back, width=50)
        self.back.grid(row=5, column=2)

        #Video embedding done---------------------------------------------------

        #Display of symbols
        self.display = Text(self, height=2, wrap=tkinter.NONE)
        self.display.grid(row=6, column=0, rowspan=3, columnspan=3, sticky=E+W)

        scrollbar = tkinter.Scrollbar(self, orient=tkinter.HORIZONTAL, command=self.display.xview)
        scrollbar.grid(row=9,column=0, columnspan=3, sticky=N+S+E+W)
        self.display['xscrollcommand'] = scrollbar.set
        #Display done
       
        
        #Buttons for symbols----------------------------------------------------
        buttongrid = Frame(self)
        buttongrid.grid(row=0, column=8, rowspan=7, columnspan=4)

        #Speakers
        alpha = ['A','B','C','D','E','F','G','H','I','J']
        s = []
        self.checkvars = []
        for i in range(self.NUM_SPEAKERS):
            s.append(alpha[i])
            self.checkvars.append(tkinter.IntVar())
        
        i=0
        self.speakers = []
        colors = ["blue", "green", "yellow", "orange", "pink"]
        for text in s:
            if i<3:
                b = tkinter.Checkbutton(buttongrid, text=text, variable=self.checkvars[i], onvalue = 1, offvalue = 0)
                self.speakers.append((b, colors[i]))
                b.grid(row=0, column=(i%3)+3)
            else:
                b = tkinter.Checkbutton(buttongrid, text=text, variable=self.checkvars[i], onvalue = 1, offvalue = 0)
                self.speakers.append((b, colors[i]))
                b.grid(row=1, column=(i%3)+3)
            i += 1
        #Done with speakers



        deflect_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/deflection.gif", height=30, width=50)
        question_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/question.gif", height=30, width=50)
        hesitation_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/hesitation.gif", height=30, width=50)
        interrupt_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/interrupt.gif", height=30, width=50)
        overcoming_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/overcoming.gif", height=30, width=50)
        support_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/support.gif", height=30, width=50)
        yesand_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/yesand.gif", height=30, width=50)
        humour_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/humour.gif", height=30, width=50)
        move_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/move.gif", height=30, width=50)
        block_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/block.gif", height=30, width=50)
        deviation_image = tkinter.PhotoImage(file="/home/aparna/RA/Framework/symbols/deviation.gif", height=30, width=50)

        self.idea_var = tkinter.IntVar()

        def update_symbols(text):
            
            
            #self.display.edit_separator()
            #Stores timestamp
            timestamp = self.player.query_position(gst.FORMAT_TIME, None)[0]
            print timestamp

            #Stores current speakers
            current_speakers = []
            for i in range(len(self.speakers)):
                if self.checkvars[i].get() == 1:
                    current_speakers.append((self.speakers[i][0]['text'], self.speakers[i][1]))

            if text=="deflection":
                self.display.image_create(tkinter.END, image= deflect_image)
            elif text=="question":
                self.display.image_create(tkinter.END, image= question_image)
            elif text=="hesitation":
                self.display.image_create(tkinter.END, image= hesitation_image)
            elif text=="interrupt":
                self.display.image_create(tkinter.END, image= interrupt_image)
            elif text=="overcoming":
                self.display.image_create(tkinter.END, image= overcoming_image)
            elif text=="support":
                self.display.image_create(tkinter.END, image= support_image)
            elif text=="yesand":
                self.display.image_create(tkinter.END, image= yesand_image)
            elif text=="humour":
                self.display.image_create(tkinter.END, image= humour_image)
            elif text=="move":
                self.display.image_create(tkinter.END, image= move_image)
            elif text=="block":
                self.display.image_create(tkinter.END, image= block_image)
            elif text=="deviation":
                self.display.image_create(tkinter.END, image= deviation_image)

            ct= 1
            for sp in current_speakers:
                ct+= 1
                self.display.tag_config(sp[0], foreground=sp[1])
                if self.idea_var.get()==1:
                    self.display.tag_config("is_idea", background="yellow")
                    self.display.insert(tkinter.END, sp[0], (sp[0], "is_idea"))
                else:
                    self.display.tag_config("not_idea", background="white")
                    self.display.insert(tkinter.END, sp[0], (sp[0], "not_idea"))
            self.num_inserted.append(ct)
            self.display.see(tkinter.END)

       
        idea = tkinter.Checkbutton(buttongrid, text="Idea", variable=self.idea_var, onvalue = 1, offvalue = 0, indicatoron=0, width=15, height=1)
        #idea = Button(buttongrid, text="Idea", width=14, command=idea)
        idea.grid(row=2, column=3, columnspan=2)

        topic = tkinter.Button(buttongrid, text="Topic", width=13, height=1)
        topic.grid(row=2, column=5, columnspan=2)

        b1 = Button(buttongrid, image=move_image, command=lambda: update_symbols("move"))
        b1.image = move_image
        b1.grid(row=3, column=3)

        b2 = Button(buttongrid, image=block_image, command=lambda: update_symbols("block"))
        b2.image = block_image
        b2.grid(row=3, column=4)

        b3 = Button(buttongrid, image=deflect_image, command=lambda: update_symbols("deflection"))
        b3.image = deflect_image
        b3.grid(row=3, column=5)

        b4 = Button(buttongrid, image=interrupt_image, command=lambda: update_symbols("interrupt"))
        b4.image = interrupt_image
        b4.grid(row=3, column=6)

        b5 = Button(buttongrid, image=humour_image, command=lambda: update_symbols("humour"))
        b5.image = humour_image
        b5.grid(row=4, column=3)

        b6 = Button(buttongrid, image=question_image, command=lambda: update_symbols("question"))
        b6.image = question_image
        b6.grid(row=4, column=4)

        b7 = Button(buttongrid, image=hesitation_image, command=lambda: update_symbols("hesitation"))
        b7.image = hesitation_image
        b7.grid(row=4, column=5)

        b8 = Button(buttongrid, image=support_image, command=lambda: update_symbols("support"))
        b8.image = support_image
        b8.grid(row=4, column=6)

        b9 = Button(buttongrid, image=overcoming_image, command=lambda: update_symbols("overcoming"))
        b9.image = overcoming_image
        b9.grid(row=5, column=3)

        b10 = Button(buttongrid, image=yesand_image, command=lambda: update_symbols("yesand"))
        b10.image = yesand_image
        b10.grid(row=5, column=4)

        b11 = Button(buttongrid, image=deviation_image, command=lambda: update_symbols("deviation"))
        b11.image = deviation_image
        b11.grid(row=5, column=5)

        def undo():
            val = self.num_inserted[-1]
            for i in range(val):
                self.display.delete("end-2c")
            self.display.see(tkinter.END)
            del self.num_inserted[-1]
        
        undo = tkinter.Button(buttongrid, text="Undo", command=undo, width=5)
        undo.grid(row=5, column=6)
Exemple #5
0
class mainframe(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.filenm=None
        self.streamnm = None
        self.pack(fill=BOTH, expand=1)
        self.parent = parent
        self.initplayer()
        self.player_process = None
        self.seekthread = None
        self.fstate = False
        self.paused = True
        self.trackmouse = True
        self.stdout_thread = None
        self.stream = False
        self.inhibit_slider_trigger = False
        self.q = LifoQueue()
        self.currtime = 0
        self.endtime = -1

    def initplayer(self):
        self.parentframe = Frame(self)
        self.parentframe.pack(fill=BOTH, expand=True)
        self.videoFrame = Frame(self.parentframe, width=800, height=480)
        self.videoFrame.pack(side="top", fill="both", expand=True)
        self.buttonframe = Frame(self.parentframe, padding="2 2 1 1")
        self.buttonframe.pack(side="bottom", fill="x", expand=False)

        self.seekbar = Scale(self.buttonframe, from_= 0, to=100, orient=HORIZONTAL)
        self.seekbar.grid(column=0, columnspan=4, row=0, sticky=[N, E, S, W])
        self.seekbar.configure(command=self.seeked)

        self.selectbutton = Button(self.buttonframe, text="Select File")
        self.selectbutton.grid(column=0, row=1, sticky=[E,W])
        self.streambutton = Button(self.buttonframe, text="Open HTTP", command=self.streamopen)
        self.streambutton.grid(column=1, row=1, sticky=[E,W])
        self.playbutton = Button(self.buttonframe, text="Play")
        self.playbutton.config(command=self.playpause)
        self.playbutton.grid(column=2, row=1, sticky=[E,W])
        self.fullscreenbutton = Button(self.buttonframe, text="Fullscreen", command=self.togglefullscreen)
        self.fullscreenbutton.grid(column=3, row=1, sticky=[E,W])
        for child in self.buttonframe.winfo_children(): child.grid_configure(padx=5, pady=5)
        self.buttonframe.rowconfigure(0, weight=1)
        self.buttonframe.rowconfigure(1, weight=1)
        self.buttonframe.columnconfigure(0, weight=1)
        self.buttonframe.columnconfigure(1, weight=1)
        self.buttonframe.columnconfigure(2, weight=1)
        self.buttonframe.columnconfigure(3, weight=1)

        self.selectbutton.configure(command=self.fileopen)
        self.videoFrame.bind("<Button-1>",self.playpause)
        self.parent.bind("<F11>", self.togglefullscreen)
        self.parent.bind("<Motion>",self.mouseops)

    def mouseops(self,event=None):
        self.videoFrame.config(cursor="")
        self.videoFrame.after(5000,self.cursorhandler)
        if self.trackmouse:
            x, y = self.parent.winfo_pointerx(), self.parent.winfo_pointery()
            windowx, windowy = self.parent.winfo_width(), self.parent.winfo_height()
            if windowy - 30 <= y:
                if self.fstate:
                    self.buttonframe.pack(side="bottom", fill="x", expand=False)
                    self.trackmouse = False
                    self.parent.after(5000, self.mousetracker)
                self.inhibit_slider_trigger = False
            elif self.fstate:
                self.buttonframe.pack_forget()
                self.inhibit_slider_trigger = True
            else:
                self.inhibit_slider_trigger = True

    def mousetracker(self):
        print 'Mouse Tracker'
        self.trackmouse = True
        self.videoFrame.after(0,self.mouseops)

    def cursorhandler(self):
        self.videoFrame.config(cursor="none")

    def togglefullscreen(self, event=None):
        self.fstate = not self.fstate
        self.parent.attributes("-fullscreen",self.fstate)
        if self.fstate:
            self.fullscreenbutton.config(text="Exit Fullscreen")
            self.buttonframe.pack_forget()
            self.videoFrame.config(cursor="none")
        else:
            self.fullscreenbutton.config(text="Fullscreen")
            self.buttonframe.pack(side="bottom", fill="x", expand=False)
            self.videoFrame.after(5000, self.cursorhandler)

    def fileopen(self):
        self.filenm = askopenfilename(filetypes=[("Supported Files","*.mp4;*.mkv;*.mpg;*.avi;*.mov"),("All Files","*.*")])
        self.stream = False
        self.play()

    def streamopen(self):
        self.streamnm = Dlog(self.parent)
        if self.streamnm.result is not None:
            s = str(self.streamnm)
        else:
            return
        if s.startswith('http'):
            self.stream = True
            self.play()
        else:
            self.stream = False
            showerror("Error","Incorrect Entry")

    def play(self):
        global fifofilename
        if self.filenm is not None and self.filenm != "":
            winid = self.videoFrame.winfo_id()
            if self.mplayer_isrunning():
                self.stop()
            try:
                self.paused = False
                self.playbutton.configure(text="Pause")
                if not self.stream:
                    self.player_process = Popen(["mplayer","-fs","-slave","-quiet","-wid",str(winid),self.filenm],stdin=PIPE, stdout=PIPE)
                else:
                    self.player_process = Popen(["mplayer","-fs","-slave","-quiet","-wid",str(winid),self.streamnm], stdin=PIPE, stdout=PIPE)
                self.stdout_thread = Thread(target=self.enqueue_pipe, args=(self.player_process.stdout, self.q))
                self.stdout_thread.daemon = True
                self.stdout_thread.start()
                self.emptypipe()
                self.seekthread = Thread(target=self.seekbar_setup, args=())
                self.seekthread.daemon = True
                self.seekthread.start()
            except:
                showerror("Error","".join(["Couldn't play video:\n",str(sys.exc_info()[:])]))

    def getvidtime(self):
        if self.mplayer_isrunning():
            self.command_player("get_time_length")
            output = self.readpipe()
            while "ANS_LENGTH" not in output:
                output = self.readpipe()
            if "ANS_LENGTH" in output:
                return output.split('ANS_LENGTH=')[1]
            else:
                return 0

    def playpause(self, event=None):
        if self.player_process is None:
            return
        self.paused = not self.paused
        if self.paused:
            print "VIDEO IS PAUSED /B/RO"
            self.playbutton.configure(text="Play")
        else:
            self.playbutton.configure(text="Pause")
        self.command_player("pause")

    def setwh(self,w,h):
        self.videoFrame.configure(width=w, height=h)

    def quit(self):
        print "QUIT CALLED"
        self.destroy()

    def mplayer_isrunning(self):
        if self.player_process is not None:
            return (self.player_process.poll() is None)
        else:
            return False

    def command_player(self, comd):
        global fifofilename
        if self.mplayer_isrunning():
            try:
                self.player_process.stdin.flush()
                self.player_process.stdin.write("\r\n%s\r\n"%comd)
                # for _ in itertools.repeat(None,8192):
                #     self.player_process.stdin.write("\n")
                self.player_process.stdin.flush()
            except:
                showerror("Error","Error passing command to mplayer\n%s"%sys.exc_info()[1])

    def enqueue_pipe(self, out, q):
        print 'Working on reading mplayer pipe output...'
        for line in iter(out.readline, b''):
            q.put(line)
        out.close()

    def seekbar_setup(self):
        pos = '0'
        trial = 0
        while float(pos)<1:
            trial += 1
            pos = self.getvidtime()
        self.seekbar.config(to=int(float(pos)))
        self.endtime = int(float(pos))
        Timer(1, self.seekbar_updater).start()

    def seekbar_updater(self):
        if not self.paused and self.inhibit_slider_trigger:
            self.currtime += 1
            self.seekbar.set(self.currtime)
        else:
            self.currtime = self.seekbar.get()
        Timer(1, self.seekbar_updater).start()

    def seeked(self,e):
        pos = self.seekbar.get()
        print "We changed pos to :%d"% pos

        x, y = self.parent.winfo_pointerx(), self.parent.winfo_pointery()
        windowx, windowy = self.parent.winfo_width(), self.parent.winfo_height()
        if not self.inhibit_slider_trigger and windowy - 30 <= y:
            self.command_player("seek %d 2"%pos)
            if self.paused:
                self.command_player("pause")

    def startmousetrack(self):
        self.trackmouse = True

    def readpipe(self):
        line = ""
        try:
            line = self.q.get_nowait()
        except Empty:
            print "Empty PIPE"
        finally:
            return line

    def emptypipe(self):
        str = ''
        try:
            while not self.q.empty():
                str += self.q.get_nowait()
        except Empty:
            print "Empty Pipe"
        finally:
            return str

    def stop(self):
        if self.mplayer_isrunning():
            self.player_process.stdin.write("quit\n")
            self.player_process.stdin.flush()
            print self.emptypipe()
        self.player_process = None