Example #1
0
File: pySAD.py Project: AlbMA/PySAD
    def initUI(self):

        self.initText()

        self.parent.title("PySAD")
        self.style = Style()
        self.style.theme_use("clam")

        self.pack(fill=BOTH, expand=1)

        barraLateral = Frame(self, borderwidth=1)
        barraLateral.pack(side=RIGHT, padx=5, pady=5)

        idiomaFrame = Frame(barraLateral, relief=FLAT)
        idiomaFrame.pack(side=TOP)

        self.espButton = Button(idiomaFrame,
                                text="es",
                                width=0,
                                command=lambda: self.updateText(0))
        self.espButton.grid(row=0, column=0)
        self.engButton = Button(idiomaFrame,
                                text="en",
                                width=0,
                                command=lambda: self.updateText(1))
        self.engButton.grid(row=0, column=1)

        self.updateText(0)

        editarFrame = Frame(barraLateral,
                            relief=RAISED,
                            borderwidth=1,
                            width=1000)
        editarFrame.pack(fill=BOTH, expand=1, side=TOP, padx=5, pady=5)

        self.tipoCurva = IntVar()

        tituloSelector = Label(editarFrame, textvariable=self.curTip)
        tituloSelector.grid(row=0, columnspan=2, padx=2, pady=4)
        Radiobutton(editarFrame,
                    textvariable=self.ArcSpi,
                    variable=self.tipoCurva,
                    value=1,
                    command=self.cambiaFormula,
                    width=17).grid(row=1, columnspan=2, sticky=W, padx=4)
        Radiobutton(editarFrame,
                    textvariable=self.LogSpi,
                    variable=self.tipoCurva,
                    value=2,
                    command=self.cambiaFormula).grid(row=2,
                                                     columnspan=2,
                                                     sticky=W,
                                                     padx=4)

        self.formulaLabel = Label(editarFrame)
        self.formulaLabel.grid(row=4, columnspan=2, pady=4)

        Label(editarFrame, textvariable=self.aaa).grid(row=5, column=0, pady=2)
        Label(editarFrame, textvariable=self.bbb).grid(row=6, column=0, pady=2)
        self.labelC = Label(editarFrame, textvariable=self.ccc)
        self.labelC.grid(row=7, column=0, pady=2)
        self.labelC.config(state=DISABLED)
        Label(editarFrame, textvariable=self.Lma).grid(row=8, column=0, pady=2)
        Label(editarFrame, textvariable=self.fre).grid(row=9, column=0, pady=2)

        parA = Entry(editarFrame, width=4, textvariable=self.a)
        parA.grid(row=5, column=1, sticky=W)

        parB = Entry(editarFrame, width=4, textvariable=self.b)
        parB.grid(row=6, column=1, sticky=W)

        self.parC = Entry(editarFrame, width=4, textvariable=self.c)
        self.parC.grid(row=7, column=1, sticky=W)
        self.parC.config(state=DISABLED)

        lMax = Entry(editarFrame, width=4, textvariable=self.lMax)
        lMax.grid(row=8, column=1, sticky=W)
        self.createToolTip(lMax, self.stringText['LmaToo'])

        frec = Entry(editarFrame, width=4, textvariable=self.frec)
        frec.grid(row=9, column=1, sticky=W)
        self.createToolTip(frec, self.stringText['FreToo'])

        self.espejar = IntVar()
        checkEspejar = Checkbutton(editarFrame,
                                   textvariable=self.Mir,
                                   variable=self.espejar,
                                   command=self.activarFuente)
        checkEspejar.grid(row=10, columnspan=2, pady=2, sticky=W, padx=4)
        self.createToolTip(checkEspejar, self.stringText['MirToo'])

        self.fuente = IntVar()
        self.checkFuente = Checkbutton(editarFrame,
                                       textvariable=self.Sou,
                                       state=DISABLED,
                                       variable=self.fuente)
        self.checkFuente.grid(row=11, columnspan=2, pady=2, sticky=W, padx=4)
        self.createToolTip(self.checkFuente, self.stringText['SouToo'])

        okButton = Button(editarFrame,
                          textvariable=self.Gen,
                          command=self.regraficar)
        okButton.grid(row=12, columnspan=2, pady=5)
        self.createToolTip(okButton, self.stringText['GenToo'])

        self.frame2 = Frame(self, borderwidth=1)
        self.frame2.pack(fill=BOTH, expand=1, side=LEFT, padx=5, pady=5)

        self.canvas = FigureCanvasTkAgg(self.f, master=self.frame2)
        self.canvas.get_tk_widget().pack(side=TOP,
                                         fill=BOTH,
                                         expand=1,
                                         padx=10,
                                         pady=10)

        frameGuardar = Frame(barraLateral, relief=FLAT, borderwidth=1)
        frameGuardar.pack(fill=BOTH, expand=1, side=BOTTOM, padx=5, pady=5)

        icGuardar = PhotoImage(
            data=
            '''R0lGODlhEAAQAIABADMzM////yH5BAEKAAEALAAAAAAQABAAAAIlDI55wchvQJQOxontUktTbkHcSJZkGCao161N5U5SLNM1vZlOAQA7'''
        )
        saveButtonNEC = Button(frameGuardar,
                               text=self.stringText['NEC'][0],
                               image=icGuardar,
                               compound=LEFT,
                               command=self.escribirFichero,
                               width=3)
        saveButtonNEC.image = icGuardar
        saveButtonNEC.grid(row=0, column=0, pady=2, padx=2, sticky=W)
        self.createToolTip(saveButtonNEC, self.stringText['NECToo'])

        saveButtonPDF = Button(frameGuardar,
                               text=self.stringText['PDF'][0],
                               image=icGuardar,
                               compound=LEFT,
                               command=self.escribirPDF,
                               width=3)
        saveButtonPDF.image = icGuardar
        saveButtonPDF.grid(row=0, column=2, pady=2, padx=2, sticky=E)
        self.createToolTip(saveButtonPDF, self.stringText['PDFToo'])

        self.helpButton = Button(frameGuardar,
                                 text="?",
                                 command=self.mostrarAyuda,
                                 width=2)
        self.helpButton.grid(row=0, column=3, pady=2, padx=2, sticky=E)

        frame3 = Frame(barraLateral, relief=RAISED, borderwidth=1)
        frame3.pack(fill=BOTH, expand=1, side=BOTTOM, padx=5, pady=5)

        Label(frame3, textvariable=self.lenlen).grid(row=1,
                                                     column=0,
                                                     pady=4,
                                                     padx=12)
        Label(frame3, textvariable=self.radrad).grid(row=2,
                                                     column=0,
                                                     pady=4,
                                                     padx=12)
        Label(frame3, textvariable=self.StringLongitud).grid(row=1,
                                                             column=1,
                                                             pady=4)
        Label(frame3, textvariable=self.StringRadio).grid(row=2,
                                                          column=1,
                                                          pady=4)
Example #2
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)
Example #3
0
File: pySAD.py Project: AlbMA/PySAD
	def initUI(self):

		self.initText()

		self.parent.title("PySAD")
		self.style = Style()
		self.style.theme_use("clam")

		self.pack(fill=BOTH, expand=1)

		barraLateral = Frame(self, borderwidth=1)
		barraLateral.pack(side=RIGHT, padx=5, pady=5)

		idiomaFrame = Frame(barraLateral, relief=FLAT)
		idiomaFrame.pack(side=TOP)

		self.espButton = Button(idiomaFrame, text="es", width=0, command=lambda: self.updateText(0))
		self.espButton.grid(row=0, column=0)
		self.engButton = Button(idiomaFrame, text="en", width=0, command=lambda: self.updateText(1))
		self.engButton.grid(row=0, column=1)

		self.updateText(0)

		editarFrame = Frame(barraLateral, relief=RAISED, borderwidth=1, width=1000)
		editarFrame.pack(fill=BOTH, expand=1, side=TOP, padx=5, pady=5)

		self.tipoCurva = IntVar()

		tituloSelector = Label(editarFrame, textvariable=self.curTip)
		tituloSelector.grid(row=0,columnspan=2, padx=2, pady=4)	
		Radiobutton(editarFrame, textvariable=self.ArcSpi, variable=self.tipoCurva , value=1, command=self.cambiaFormula, width=17).grid(row=1,columnspan=2,sticky=W,padx=4)
		Radiobutton(editarFrame, textvariable=self.LogSpi, variable=self.tipoCurva , value=2, command=self.cambiaFormula).grid(row=2,columnspan=2,sticky=W,padx=4)

		self.formulaLabel = Label(editarFrame)
		self.formulaLabel.grid(row=4, columnspan=2, pady=4)

		Label(editarFrame,textvariable=self.aaa).grid(row=5, column=0,pady=2)
		Label(editarFrame,textvariable=self.bbb).grid(row=6, column=0,pady=2)
		self.labelC = Label(editarFrame,textvariable=self.ccc)
		self.labelC.grid(row=7, column=0,pady=2)
		self.labelC.config(state=DISABLED)
		Label(editarFrame,textvariable=self.Lma).grid(row=8, column=0,pady=2)
		Label(editarFrame,textvariable=self.fre).grid(row=9, column=0,pady=2)

		parA = Entry(editarFrame,width=4,textvariable=self.a)
		parA.grid(row=5, column=1, sticky=W)

		parB = Entry(editarFrame,width=4,textvariable=self.b)
		parB.grid(row=6, column=1, sticky=W)

		self.parC = Entry(editarFrame,width=4,textvariable=self.c)
		self.parC.grid(row=7, column=1, sticky=W)
		self.parC.config(state=DISABLED)

		lMax = Entry(editarFrame,width=4,textvariable=self.lMax)
		lMax.grid(row=8, column=1, sticky=W)
		self.createToolTip(lMax, self.stringText['LmaToo'])	

		frec = Entry(editarFrame,width=4,textvariable=self.frec)
		frec.grid(row=9, column=1, sticky=W)
		self.createToolTip(frec, self.stringText['FreToo'])	

		self.espejar = IntVar()
		checkEspejar = Checkbutton(editarFrame, textvariable=self.Mir, variable=self.espejar, command=self.activarFuente)
		checkEspejar.grid(row=10, columnspan=2, pady=2, sticky=W, padx=4)
		self.createToolTip(checkEspejar, self.stringText['MirToo'])

		self.fuente = IntVar()
		self.checkFuente = Checkbutton(editarFrame, textvariable=self.Sou, state=DISABLED, variable=self.fuente)
		self.checkFuente.grid(row=11, columnspan=2, pady=2, sticky=W, padx=4)
		self.createToolTip(self.checkFuente, self.stringText['SouToo'])
		
		okButton = Button(editarFrame, textvariable=self.Gen, command=self.regraficar)
		okButton.grid(row=12, columnspan=2, pady=5)
		self.createToolTip(okButton, self.stringText['GenToo'])

		self.frame2 = Frame(self, borderwidth=1)
		self.frame2.pack(fill=BOTH, expand=1, side=LEFT, padx=5, pady=5)

		self.canvas = FigureCanvasTkAgg(self.f, master=self.frame2)
		self.canvas.get_tk_widget().pack(side=TOP,fill=BOTH, expand=1, padx=10, pady=10)

		frameGuardar = Frame(barraLateral, relief=FLAT, borderwidth=1)
		frameGuardar.pack(fill=BOTH, expand=1, side=BOTTOM, padx=5, pady=5)

		icGuardar = PhotoImage(data='''R0lGODlhEAAQAIABADMzM////yH5BAEKAAEALAAAAAAQABAAAAIlDI55wchvQJQOxontUktTbkHcSJZkGCao161N5U5SLNM1vZlOAQA7''')
		saveButtonNEC = Button(frameGuardar, text=self.stringText['NEC'][0], image=icGuardar, compound=LEFT, command=self.escribirFichero, width=3)
		saveButtonNEC.image = icGuardar
		saveButtonNEC.grid(row=0, column=0, pady=2, padx=2, sticky=W)
		self.createToolTip(saveButtonNEC, self.stringText['NECToo'])

		saveButtonPDF = Button(frameGuardar, text=self.stringText['PDF'][0], image=icGuardar, compound=LEFT, command=self.escribirPDF, width=3)
		saveButtonPDF.image = icGuardar
		saveButtonPDF.grid(row=0, column=2, pady=2, padx=2, sticky=E)
		self.createToolTip(saveButtonPDF, self.stringText['PDFToo'])

		self.helpButton = Button(frameGuardar, text="?", command=self.mostrarAyuda, width=2)
		self.helpButton.grid(row=0, column=3, pady=2, padx=2, sticky=E)

		frame3 = Frame(barraLateral, relief=RAISED, borderwidth=1)
		frame3.pack(fill=BOTH, expand=1, side=BOTTOM, padx=5, pady=5)

		Label(frame3,textvariable=self.lenlen).grid(row=1, column=0,pady=4,padx=12)
		Label(frame3,textvariable=self.radrad).grid(row=2, column=0,pady=4,padx=12)
		Label(frame3,textvariable=self.StringLongitud).grid(row=1, column=1,pady=4)
		Label(frame3,textvariable=self.StringRadio).grid(row=2, column=1,pady=4)
Example #4
0
    def initUI(self):
        self.parent.title("Main")
        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(10, pad=7)
        
        def hello():
            print "hello!"

        #Menubar--------------------------------------------------------------
        menubar = Tkinter.Menu(self)
        
        filemenu = Tkinter.Menu(menubar, tearoff=0)
        filemenu.add_command(label="New", command=lambda: NewProjectDialog(self))
        filemenu.add_command(label="Open", command=lambda: OldProjectDialog(self))
        filemenu.add_command(label="Save", command=lambda: self.project.saveProject())
        filemenu.add_command(label="Save As", command=lambda: SaveAsDialog(self, self.project))
        filemenu.add_command(label="Save and Export Image", command=lambda: self.project.saveAndExportImage())
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.parent.quit)
        menubar.add_cascade(label="File", menu=filemenu)
       
        
        #Create analysis window here
        #def do_popup_analysis():
        #    new_frame = Tkinter.Tk()
            
        #menubar.add_command(label="Analysis", command=do_popup_analysis)

        #def do_popup_plot():
        #    new_frame = Tkinter.Tk()
            
        #menubar.add_command(label="Plot", command=do_popup_plot)
        
            
        menubar.add_command(label="Help", command=lambda: helpDialog(self))
        
        self.parent.config(menu=menubar)
        #Menubar done----------------------------------------------------------
    
    
        #Choose Project part---------------------------------------------------
        self.box = Frame(self)
        self.box.grid(row=0, column=0, columnspan=8, rowspan=4, padx=2)
        btn = Button(self.box, text="New Project", command=lambda: NewProjectDialog(self), default=ACTIVE)
        btn.grid(row=0, column=0, columnspan = 4, rowspan=4, padx=2)
        btn2 = Button(self.box, text="Open Project", command=lambda: OldProjectDialog(self), default=ACTIVE)
        btn2.grid(row=0, column=4, columnspan = 4, rowspan=4,padx=2)
        #Project done----------------------------------------------------------

        #Display of symbols
        self.display = Text(self, height=4, wrap=NONE)
        self.display.grid(row=7, column=0, rowspan=3, columnspan=3, sticky=E+W)
        
        
        #scrollbar = Scrollbar(self, orient=HORIZONTAL, command=self.display.xview) #remove seekbar
        #scrollbar.grid(row=10,column=0, columnspan=3, sticky=N+S+E+W)
        #self.display['xscrollcommand'] = scrollbar.set
        
        #Adding time dependent display
        self.t = threading.Thread(target=self.update_display)
        self.t.daemon = True
        self.t.start()
        #Display done
       
        #Slider
        self.slider = Scale(self, orient=HORIZONTAL, variable = self.var)
        self.slider.grid(row=6, column=0, columnspan=3, sticky=N+S+E+W)
        #Done with slider

        #Buttons for symbols----------------------------------------------------
        buttongrid = Frame(self)
        self.buttongrid = buttongrid
        buttongrid.grid(row=0, column=8, rowspan=10, columnspan=5)


    #Topic implementation    
        self.idea_var = IntVar()
        self.topic_var = IntVar()
        idea = Checkbutton(buttongrid, text="Idea", variable=self.idea_var, onvalue = 1, offvalue = 0, indicatoron=0, height=2, width=16)
        idea.grid(row=11, column=0, columnspan=2)
        self.buttonmap['\r'] = idea
        
        def delTopic(event):
            line = self.topic_display.index(CURRENT).split(".")[0]
            self.topic_display.config(state=NORMAL)
            self.topic_display.delete(""+line+".0", ""+str(int(line)+1)+".0")
            self.topic_display.config(state=DISABLED)
        topic = Checkbutton(buttongrid, text="Topic", variable=self.topic_var, onvalue = 1, offvalue = 0, indicatoron=0, width=16, height=2)
        topic.grid(row=11, column=2, columnspan=2)
        topic_indicator = Label(buttongrid, width=33, height=2, bg="gray")
        topic_indicator.grid(row=10, column=0, columnspan=4)
        self.topic_change_var = 0
        self.topic_display = Text(buttongrid, wrap=NONE, state=DISABLED)
        self.topic_display.grid(row=15, column=0, columnspan=4, sticky=N+S+W)
        self.topic_display.configure(height=10, width=36)
        self.topic_display.bind("<Button-3>", delTopic)

        scrollbar2 = Scrollbar(buttongrid, orient=VERTICAL, command=self.topic_display.yview)
        scrollbar2.grid(row=15,column=3, sticky=N+S+E)
        self.display['yscrollcommand'] = scrollbar2.set
        
        self.topics = []
        def change_color():
            self.topic_change_var = self.topic_change_var %4
            col_map = {0 : "red", 1 : "blue", 2 : "green", 3 : "yellow"}
            if self.topic_var.get():
                #Get timestamp
                self.timest = pos_int = self.player.query_position(gst.FORMAT_TIME, None)[0]
                topic_indicator.configure(bg=col_map[self.topic_change_var])
                self.topic_change_var += 1
            else:
                self.topic_display.config(state=NORMAL)
                topic_col = col_map[(self.topic_change_var-1)%4]
                self.topic_display.tag_config(str(self.topic_change_var), background=topic_col)
                insert = bisect_right(self.topics, self.timest/1000000000.0)
                self.topics.insert(insert, self.timest/1000000000.0)
                self.topic_display.insert("%d.0" % (insert+1), str(self.timest/1000000000.0)+"-"+str(self.player.query_position(gst.FORMAT_TIME, None)[0]/1000000000.0)+"\n", (str(self.timest/1000000000.0), str(self.topic_change_var)))
                self.topic_display.see("%d.0" % (insert+1))
                topic_indicator.configure(bg="gray")
                self.topic_display.config(state=DISABLED)
        
        topic.configure(command=change_color)
        #topic.bind("<Shift_L>", change_color())
        
        
        #def update_topInd(): #TODO: change colors on playback
        #    while True:
        #        if self.play["text"] == "Pause":
        #            try:
        #                timestamp = self.player.query_position(gst.FORMAT_TIME, None)[0]/1000000000.0
        #                insert = bisect_right(self.topics, timestamp)
        #                if insert > 0 and float(self.topic_display.get("%d.0" % (insert), "%d.end" % (insert)).split('-')[1]) >= timestamp:
        #                    #topic_indicator.configure(bg= #get color in self.topic_display at line insert
        #                    pass
        #                time.sleep(.1)
        #            except:
        #                continue
        #        else:
        #            time.sleep(.2)
        #self.tt = threading.Thread(target=update_topInd)
        #self.tt.daemon = True
        #self.tt.start()
        
    #Done with topic

        
        h = '44'
        w = '40'
        c = "top"
        codemap = {
            'a':'yesandquestion',
            's':'interrupt',
            'd':'block',
            'f':'overcoming',
            'q':'move',
            'w':'question',
            'e':'support',
            'r':'yesand',
            'z':'deflection',
            'x':'humour',
            'c':'block-support',
            'v':'hesitation',
        }
        firstrow = 12
        b1 = Button(buttongrid, image=self.imagemap[codemap['a']], command=lambda: self.update_symbols(codemap['a']), background="white", height=h, width=w, compound=c, text="A")
        b1.image = self.imagemap[codemap['a']]
        b1.grid(row=firstrow, column=0)
        self.buttonmap['a'] = b1
        
        b2 = Button(buttongrid, image=self.imagemap[codemap['s']], command=lambda: self.update_symbols(codemap['s']), background="white", height=h, width=w, compound=c, text="S")
        b2.image = self.imagemap[codemap['s']]
        b2.grid(row=firstrow, column=1)
        self.buttonmap['s'] = b2
        
        b3 = Button(buttongrid, image=self.imagemap[codemap['d']], command=lambda: self.update_symbols(codemap['d']), background="white", height=h, width=w, compound=c, text="D")
        b3.image = self.imagemap[codemap['d']]
        b3.grid(row=firstrow, column=2)
        self.buttonmap['d'] = b3
        
        b4 = Button(buttongrid, image=self.imagemap[codemap['f']], command=lambda: self.update_symbols(codemap['f']), background="white", height=h, width=w, compound=c, text="F")
        b4.image = self.imagemap[codemap['f']]
        b4.grid(row=firstrow, column=3)
        self.buttonmap['f'] = b4
        
        b5 = Button(buttongrid, image=self.imagemap[codemap['q']], command=lambda: self.update_symbols(codemap['q']), background="white", height=h, width=w, compound=c, text="Q")
        b5.image = self.imagemap[codemap['q']]
        b5.grid(row=firstrow+1, column=0)
        self.buttonmap['q'] = b5
        
        b6 = Button(buttongrid, image=self.imagemap[codemap['w']], command=lambda: self.update_symbols(codemap['w']), background="white", height=h, width=w, compound=c, text="W")
        b6.image = self.imagemap[codemap['w']]
        b6.grid(row=firstrow+1, column=1)
        self.buttonmap['w'] = b6
        
        b7 = Button(buttongrid, image=self.imagemap[codemap['e']], command=lambda: self.update_symbols(codemap['e']), background="white", height=h, width=w, compound=c, text="E")
        b7.image = self.imagemap[codemap['e']]
        b7.grid(row=firstrow+1, column=2)
        self.buttonmap['e'] = b7
        
        b8 = Button(buttongrid, image=self.imagemap[codemap['r']], command=lambda: self.update_symbols(codemap['r']), background="white", height=h, width=w, compound=c, text="R", font=100)
        b8.image = self.imagemap[codemap['r']]
        b8.grid(row=firstrow+1, column=3)
        self.buttonmap['r'] = b8
        
        b9 = Button(buttongrid, image=self.imagemap[codemap['z']], command=lambda: self.update_symbols(codemap['z']), background="white", height=h, width=w, compound=c, text="Z")
        b9.image = self.imagemap[codemap['z']]
        b9.grid(row=firstrow+2, column=0)
        self.buttonmap['z'] = b9
        
        b10 = Button(buttongrid, image=self.imagemap[codemap['x']], command=lambda: self.update_symbols(codemap['x']), background="white", height=h, width=w, compound=c, text="X", font=100)
        b10.image = self.imagemap[codemap['x']]
        b10.grid(row=firstrow+2, column=1)
        self.buttonmap['x'] = b10
        
        b11 = Button(buttongrid, image=self.imagemap[codemap['c']], command=lambda: self.update_symbols(codemap['c']), background="white", height=h, width=w, compound=c, text="C", font=100)
        b11.image = self.imagemap[codemap['c']]
        b11.grid(row=firstrow+2, column=2)
        self.buttonmap['c'] = b11
        
        b12 = Button(buttongrid, image=self.imagemap[codemap['v']], command=lambda: self.update_symbols(codemap['v']), background="white", height=h, width=w, compound=c, text="V", font=100)
        b12.image = self.imagemap[codemap['v']]
        b12.grid(row=firstrow+2, column=3)
        self.buttonmap['v'] = b12
Example #5
0
    def initUI(self):
        self.parent.title("Main")
        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(10, pad=7)

        def hello():
            print "hello!"

        #Menubar--------------------------------------------------------------
        menubar = Tkinter.Menu(self)

        filemenu = Tkinter.Menu(menubar, tearoff=0)
        filemenu.add_command(label="New",
                             command=lambda: NewProjectDialog(self))
        filemenu.add_command(label="Open",
                             command=lambda: OldProjectDialog(self))
        filemenu.add_command(label="Save",
                             command=lambda: self.project.saveProject())
        filemenu.add_command(label="Save As",
                             command=lambda: SaveAsDialog(self, self.project))
        filemenu.add_command(label="Save and Export Image",
                             command=lambda: self.project.saveAndExportImage())
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.parent.quit)
        menubar.add_cascade(label="File", menu=filemenu)

        #Create analysis window here
        #def do_popup_analysis():
        #    new_frame = Tkinter.Tk()

        #menubar.add_command(label="Analysis", command=do_popup_analysis)

        #def do_popup_plot():
        #    new_frame = Tkinter.Tk()

        #menubar.add_command(label="Plot", command=do_popup_plot)

        menubar.add_command(label="Help", command=lambda: helpDialog(self))

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

        #Choose Project part---------------------------------------------------
        self.box = Frame(self)
        self.box.grid(row=0, column=0, columnspan=8, rowspan=4, padx=2)
        btn = Button(self.box,
                     text="New Project",
                     command=lambda: NewProjectDialog(self),
                     default=ACTIVE)
        btn.grid(row=0, column=0, columnspan=4, rowspan=4, padx=2)
        btn2 = Button(self.box,
                      text="Open Project",
                      command=lambda: OldProjectDialog(self),
                      default=ACTIVE)
        btn2.grid(row=0, column=4, columnspan=4, rowspan=4, padx=2)
        #Project done----------------------------------------------------------

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

        #scrollbar = Scrollbar(self, orient=HORIZONTAL, command=self.display.xview) #remove seekbar
        #scrollbar.grid(row=10,column=0, columnspan=3, sticky=N+S+E+W)
        #self.display['xscrollcommand'] = scrollbar.set

        #Adding time dependent display
        self.t = threading.Thread(target=self.update_display)
        self.t.daemon = True
        self.t.start()
        #Display done

        #Slider
        self.slider = Scale(self, orient=HORIZONTAL, variable=self.var)
        self.slider.grid(row=6, column=0, columnspan=3, sticky=N + S + E + W)
        #Done with slider

        #Buttons for symbols----------------------------------------------------
        buttongrid = Frame(self)
        self.buttongrid = buttongrid
        buttongrid.grid(row=0, column=8, rowspan=10, columnspan=5)

        #Topic implementation
        self.idea_var = IntVar()
        self.topic_var = IntVar()
        idea = Checkbutton(buttongrid,
                           text="Idea",
                           variable=self.idea_var,
                           onvalue=1,
                           offvalue=0,
                           indicatoron=0,
                           height=2,
                           width=16)
        idea.grid(row=11, column=0, columnspan=2)
        self.buttonmap['\r'] = idea

        def delTopic(event):
            line = self.topic_display.index(CURRENT).split(".")[0]
            self.topic_display.config(state=NORMAL)
            self.topic_display.delete("" + line + ".0",
                                      "" + str(int(line) + 1) + ".0")
            self.topic_display.config(state=DISABLED)

        topic = Checkbutton(buttongrid,
                            text="Topic",
                            variable=self.topic_var,
                            onvalue=1,
                            offvalue=0,
                            indicatoron=0,
                            width=16,
                            height=2)
        topic.grid(row=11, column=2, columnspan=2)
        topic_indicator = Label(buttongrid, width=33, height=2, bg="gray")
        topic_indicator.grid(row=10, column=0, columnspan=4)
        self.topic_change_var = 0
        self.topic_display = Text(buttongrid, wrap=NONE, state=DISABLED)
        self.topic_display.grid(row=15,
                                column=0,
                                columnspan=4,
                                sticky=N + S + W)
        self.topic_display.configure(height=10, width=36)
        self.topic_display.bind("<Button-3>", delTopic)

        scrollbar2 = Scrollbar(buttongrid,
                               orient=VERTICAL,
                               command=self.topic_display.yview)
        scrollbar2.grid(row=15, column=3, sticky=N + S + E)
        self.display['yscrollcommand'] = scrollbar2.set

        self.topics = []

        def change_color():
            self.topic_change_var = self.topic_change_var % 4
            col_map = {0: "red", 1: "blue", 2: "green", 3: "yellow"}
            if self.topic_var.get():
                #Get timestamp
                self.timest = pos_int = self.player.query_position(
                    gst.FORMAT_TIME, None)[0]
                topic_indicator.configure(bg=col_map[self.topic_change_var])
                self.topic_change_var += 1
            else:
                self.topic_display.config(state=NORMAL)
                topic_col = col_map[(self.topic_change_var - 1) % 4]
                self.topic_display.tag_config(str(self.topic_change_var),
                                              background=topic_col)
                insert = bisect_right(self.topics, self.timest / 1000000000.0)
                self.topics.insert(insert, self.timest / 1000000000.0)
                self.topic_display.insert(
                    "%d.0" % (insert + 1),
                    str(self.timest / 1000000000.0) + "-" + str(
                        self.player.query_position(gst.FORMAT_TIME, None)[0] /
                        1000000000.0) + "\n",
                    (str(self.timest / 1000000000.0), str(
                        self.topic_change_var)))
                self.topic_display.see("%d.0" % (insert + 1))
                topic_indicator.configure(bg="gray")
                self.topic_display.config(state=DISABLED)

        topic.configure(command=change_color)
        #topic.bind("<Shift_L>", change_color())

        #def update_topInd(): #TODO: change colors on playback
        #    while True:
        #        if self.play["text"] == "Pause":
        #            try:
        #                timestamp = self.player.query_position(gst.FORMAT_TIME, None)[0]/1000000000.0
        #                insert = bisect_right(self.topics, timestamp)
        #                if insert > 0 and float(self.topic_display.get("%d.0" % (insert), "%d.end" % (insert)).split('-')[1]) >= timestamp:
        #                    #topic_indicator.configure(bg= #get color in self.topic_display at line insert
        #                    pass
        #                time.sleep(.1)
        #            except:
        #                continue
        #        else:
        #            time.sleep(.2)
        #self.tt = threading.Thread(target=update_topInd)
        #self.tt.daemon = True
        #self.tt.start()

        #Done with topic

        h = '44'
        w = '40'
        c = "top"
        codemap = {
            'a': 'yesandquestion',
            's': 'interrupt',
            'd': 'block',
            'f': 'overcoming',
            'q': 'move',
            'w': 'question',
            'e': 'support',
            'r': 'yesand',
            'z': 'deflection',
            'x': 'humour',
            'c': 'block-support',
            'v': 'hesitation',
        }
        firstrow = 12
        b1 = Button(buttongrid,
                    image=self.imagemap[codemap['a']],
                    command=lambda: self.update_symbols(codemap['a']),
                    background="white",
                    height=h,
                    width=w,
                    compound=c,
                    text="A")
        b1.image = self.imagemap[codemap['a']]
        b1.grid(row=firstrow, column=0)
        self.buttonmap['a'] = b1

        b2 = Button(buttongrid,
                    image=self.imagemap[codemap['s']],
                    command=lambda: self.update_symbols(codemap['s']),
                    background="white",
                    height=h,
                    width=w,
                    compound=c,
                    text="S")
        b2.image = self.imagemap[codemap['s']]
        b2.grid(row=firstrow, column=1)
        self.buttonmap['s'] = b2

        b3 = Button(buttongrid,
                    image=self.imagemap[codemap['d']],
                    command=lambda: self.update_symbols(codemap['d']),
                    background="white",
                    height=h,
                    width=w,
                    compound=c,
                    text="D")
        b3.image = self.imagemap[codemap['d']]
        b3.grid(row=firstrow, column=2)
        self.buttonmap['d'] = b3

        b4 = Button(buttongrid,
                    image=self.imagemap[codemap['f']],
                    command=lambda: self.update_symbols(codemap['f']),
                    background="white",
                    height=h,
                    width=w,
                    compound=c,
                    text="F")
        b4.image = self.imagemap[codemap['f']]
        b4.grid(row=firstrow, column=3)
        self.buttonmap['f'] = b4

        b5 = Button(buttongrid,
                    image=self.imagemap[codemap['q']],
                    command=lambda: self.update_symbols(codemap['q']),
                    background="white",
                    height=h,
                    width=w,
                    compound=c,
                    text="Q")
        b5.image = self.imagemap[codemap['q']]
        b5.grid(row=firstrow + 1, column=0)
        self.buttonmap['q'] = b5

        b6 = Button(buttongrid,
                    image=self.imagemap[codemap['w']],
                    command=lambda: self.update_symbols(codemap['w']),
                    background="white",
                    height=h,
                    width=w,
                    compound=c,
                    text="W")
        b6.image = self.imagemap[codemap['w']]
        b6.grid(row=firstrow + 1, column=1)
        self.buttonmap['w'] = b6

        b7 = Button(buttongrid,
                    image=self.imagemap[codemap['e']],
                    command=lambda: self.update_symbols(codemap['e']),
                    background="white",
                    height=h,
                    width=w,
                    compound=c,
                    text="E")
        b7.image = self.imagemap[codemap['e']]
        b7.grid(row=firstrow + 1, column=2)
        self.buttonmap['e'] = b7

        b8 = Button(buttongrid,
                    image=self.imagemap[codemap['r']],
                    command=lambda: self.update_symbols(codemap['r']),
                    background="white",
                    height=h,
                    width=w,
                    compound=c,
                    text="R",
                    font=100)
        b8.image = self.imagemap[codemap['r']]
        b8.grid(row=firstrow + 1, column=3)
        self.buttonmap['r'] = b8

        b9 = Button(buttongrid,
                    image=self.imagemap[codemap['z']],
                    command=lambda: self.update_symbols(codemap['z']),
                    background="white",
                    height=h,
                    width=w,
                    compound=c,
                    text="Z")
        b9.image = self.imagemap[codemap['z']]
        b9.grid(row=firstrow + 2, column=0)
        self.buttonmap['z'] = b9

        b10 = Button(buttongrid,
                     image=self.imagemap[codemap['x']],
                     command=lambda: self.update_symbols(codemap['x']),
                     background="white",
                     height=h,
                     width=w,
                     compound=c,
                     text="X",
                     font=100)
        b10.image = self.imagemap[codemap['x']]
        b10.grid(row=firstrow + 2, column=1)
        self.buttonmap['x'] = b10

        b11 = Button(buttongrid,
                     image=self.imagemap[codemap['c']],
                     command=lambda: self.update_symbols(codemap['c']),
                     background="white",
                     height=h,
                     width=w,
                     compound=c,
                     text="C",
                     font=100)
        b11.image = self.imagemap[codemap['c']]
        b11.grid(row=firstrow + 2, column=2)
        self.buttonmap['c'] = b11

        b12 = Button(buttongrid,
                     image=self.imagemap[codemap['v']],
                     command=lambda: self.update_symbols(codemap['v']),
                     background="white",
                     height=h,
                     width=w,
                     compound=c,
                     text="V",
                     font=100)
        b12.image = self.imagemap[codemap['v']]
        b12.grid(row=firstrow + 2, column=3)
        self.buttonmap['v'] = b12