예제 #1
0
    def initUI(self):

        self.parent.title("Listbox + Scale + ChkBtn")
        self.pack(fill=BOTH, expand=1)
        acts = ['Scarlett Johansson', 'Rachel Weiss',
            'Natalie Portman', 'Jessica Alba']

        lb = Listbox(self)
        for i in acts:
            lb.insert(END, i)

        lb.bind("<<ListboxSelect>>", self.onSelect)
        lb.place(x=20, y=20)

        self.var = StringVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.place(x=20, y=190)

        scale = Scale(self, from_=0, to=100, command=self.onScale)
        scale.place(x=20, y=220)

        self.var_scale = IntVar()
        self.label_scale = Label(self, text=0, textvariable=self.var_scale)
        self.label_scale.place(x=180, y=220)

        self.var_chk = IntVar()
        cb = Checkbutton(self, text="Test", variable=self.var_chk,
                command=self.onClick)
        cb.select()
        cb.place(x=220, y=60)
예제 #2
0
 def initUI(self):
     self.parent.title("CheckButton")
     self.pack(fill=BOTH,expand=True)
     self.var = BooleanVar()
     self.var.set(False)
     
     chbt = Checkbutton(self,text="Show Title",
                        variable=self.var,command=self.onClick)
     #chbt.select()
     chbt.place(x=50,y=50)
예제 #3
0
    def initUI(self):
      
        self.parent.title("Checkbutton")

        self.pack(fill=BOTH, expand=1)
        self.var = IntVar()
        
        cb = Checkbutton(self, text="Show title",
            variable=self.var, command=self.onClick)
        cb.select()
        cb.place(x=50, y=50)
예제 #4
0
    def initUI(self):
      
        self.parent.title("Checkbutton")

        self.pack(fill=BOTH, expand=1)
        self.var = IntVar()
        
        cb = Checkbutton(self, text="Show title",
            variable=self.var, command=self.onClick)
        cb.select()
        cb.place(x=50, y=50)
예제 #5
0
    def initUI(self):
      
        self.parent.title("Checkbutton")

        self.pack(fill=BOTH, expand=True)
        self.var = BooleanVar()
        submit = Submitbutton(self)
        cb = Checkbutton(self, text="Show title",
            variable=self.var, command=self.onClick)
        cb.select()
        cb.place(x=50, y=50)
        submit.place(x=5, y=5)
예제 #6
0
    def initUI(self):
      
        self.parent.title("Checkbutton")

        self.pack(fill=BOTH, expand=1)
        self.var = IntVar()
        #We create an IntVar object. 
        #It is a value holder for integer values for widgets in Tkinter.
        
        cb = Checkbutton(self, text="Show title",
            variable=self.var, command=self.onClick)
        #An instance of the Checkbutton is created. 
        #The value holder is connected to the widget via the variable parameter. 
        #When we click on the check button, the onClick() method is called. 
        #This is done with the command parameter.
        cb.select()
        #Initially, the title is shown in the titlebar. 
        #So at the start, we make it checked with the select() method.
        cb.place(x=50, y=50)
class GraphCheckButton(object):
	def __init__(self, window, graphProgramInstance, mainProgramInstance):
		self.window = window
		self.mainProgramInstance = mainProgramInstance
		self.graphProgramInstance = graphProgramInstance
		self.interfaceColor = self.graphProgramInstance.lineColor

	def makeCheckBoxes(self):
		#this creates a 'status' for the check box. So if it is on, it's status
		#is 1. If it is off, then it is 0. The status stores these values 
		self.derivativeStatus = IntVar() 
		self.derivativeToggle = Checkbutton(self.window, 
			                           bg = self.interfaceColor, 
			                           text = 'Derivative (Green)', 
			                           variable = self.derivativeStatus, 
			                           onvalue = 1, offvalue = 0, 
			         command = self.graphProgramInstance.updateToggleParameters,
			         fg = 'red')
		self.functionStatus = IntVar()
		self.functionToggle = Checkbutton(self.window, bg = self.interfaceColor, 
			                         text = 'Function (Yellow)',
			                         variable = self.functionStatus, 
			                         onvalue = 1, offvalue = 0,
			         command = self.graphProgramInstance.updateToggleParameters,
			         fg = 'red')
		self.integralStatus = IntVar()
		self.integralToggle = Checkbutton(self.window, bg = self.interfaceColor, 
			                              text = 'Integral (Red)', 
			                              variable = self.integralStatus, 
			                              onvalue = 1, offvalue = 0, 
			         command = self.graphProgramInstance.updateToggleParameters,
			         fg = 'red')
		self.derivativeToggle.place(x = 450, y = 560)
		self.functionToggle.place(x = 450, y = 590)
		self.integralToggle.place(x = 450, y = 620)
def FileInfo():
    top = tk.Tk()
    top.title("File and Device Info")
    checkCmd1 = IntVar()
    checkCmd2 = IntVar()
    checkCmd3 = IntVar()
    checkCmd4 = IntVar()
    checkCmd5 = IntVar()
    checkCmd6 = IntVar()
    checkCmd7 = IntVar()
    checkCmd8 = IntVar()
    checkCmd9 = IntVar()
    w = 1050
    h = 320
    x = 10
    y = 50

    def cbcommand1():
        checkCmd1.set(not checkCmd1.get())

    def cbcommand2():
        checkCmd2.set(not checkCmd2.get())

    def cbcommand3():
        checkCmd3.set(not checkCmd3.get())

    def cbcommand4():
        checkCmd4.set(not checkCmd4.get())

    def cbcommand5():
        checkCmd5.set(not checkCmd5.get())

    def cbcommand6():
        checkCmd6.set(not checkCmd6.get())

    def cbcommand7():
        checkCmd7.set(not checkCmd7.get())

    def cbcommand8():
        checkCmd8.set(not checkCmd8.get())

    def cbcommand9():
        checkCmd9.set(not checkCmd9.get())

    def ADD_PDOCallBack():
        if ((TPDO.get() == '') or (RPDO.get() == '')):
            tkMessageBox.showinfo("Info", "Invalid PDO information !!")
        elif ((int(TPDO.get()) < 4) or (int(RPDO.get()) < 4)):
            tkMessageBox.showinfo("Info", "Minimum of 4 PDOs should be added")
        elif ((int(TPDO.get()) > 15) or (int(RPDO.get()) > 15)):
            tkMessageBox.showinfo(
                "Info", "Maximum of 15 PDOs only supported by this tool")
        else:
            for i in range(0, int(TPDO.get())):
                selected_index.append('180' +
                                      str(hex(i).split('x')[1]).upper())
                lb1.insert(
                    "end", '180' + str(hex(i).split('x')[1]).upper() +
                    '  Transmit PDO Communication Parameter ' + str(i))
            for i in range(0, int(TPDO.get())):
                selected_index.append('1A0' +
                                      str(hex(i).split('x')[1]).upper())
                lb1.insert(
                    "end", '1A0' + str(hex(i).split('x')[1]).upper() +
                    '  Transmit PDO Mapping Parameter ' + str(i))
            for i in range(0, int(RPDO.get())):
                selected_index.append('140' +
                                      str(hex(i).split('x')[1]).upper())
                lb1.insert(
                    "end", '140' + str(hex(i).split('x')[1]).upper() +
                    '  Receive PDO Communication Parameter ' + str(i))
            for i in range(0, int(RPDO.get())):
                selected_index.append('160' +
                                      str(hex(i).split('x')[1]).upper())
                lb1.insert(
                    "end", '160' + str(hex(i).split('x')[1]).upper() +
                    '  Receive PDO Mapping Parameter ' + str(i))
            tkMessageBox.showinfo("Info", "PDOs Added")

    top.geometry("%dx%d+%d+%d" % (w, h, x, y))
    group1 = tk.LabelFrame(top, text="File Information").grid(row=0,
                                                              columnspan=7,
                                                              sticky='W',
                                                              padx=5,
                                                              pady=5,
                                                              ipadx=140,
                                                              ipady=120)
    Label(top, text="File Name : ").place(x=20, y=70)
    FileName = tk.Entry(top, width=25)
    FileName.pack()
    FileName.place(x=110, y=70)
    FileName.insert(0, "CANopen.eds")
    Label(top, text="File Version : ").place(x=20, y=100)
    FileVersion = tk.Entry(top, width=25)
    FileVersion.pack()
    FileVersion.place(x=110, y=100)
    Label(top, text="File Revision : ").place(x=20, y=130)
    FileRevision = tk.Entry(top, width=25)
    FileRevision.pack()
    FileRevision.place(x=110, y=130)
    Label(top, text="Description : ").place(x=20, y=160)
    Description = tk.Entry(top, width=25)
    Description.pack()
    Description.place(x=110, y=160)
    Label(top, text="Author : ").place(x=20, y=190)
    Author = tk.Entry(top, width=25)
    Author.pack()
    Author.place(x=110, y=190)

    group2 = tk.LabelFrame(top, text="Device Information").grid(row=0,
                                                                columnspan=7,
                                                                sticky='W',
                                                                padx=305,
                                                                pady=5,
                                                                ipadx=150,
                                                                ipady=120)
    Label(top, text="Vendor Name : ").place(x=320, y=70)
    VendorName = tk.Entry(top, width=25)
    VendorName.pack()
    VendorName.place(x=430, y=70)
    Label(top, text="Vendor Number : ").place(x=320, y=100)
    VendorNumber = tk.Entry(top, width=25)
    VendorNumber.pack()
    VendorNumber.place(x=430, y=100)
    Label(top, text="Product Name : ").place(x=320, y=130)
    ProductName = tk.Entry(top, width=25)
    ProductName.pack()
    ProductName.place(x=430, y=130)
    Label(top, text="Product Number : ").place(x=320, y=160)
    ProductNumber = tk.Entry(top, width=25)
    ProductNumber.pack()
    ProductNumber.place(x=430, y=160)
    Label(top, text="Revision Number : ").place(x=320, y=190)
    RevisionNumber = tk.Entry(top, width=25)
    RevisionNumber.pack()
    RevisionNumber.place(x=430, y=190)
    Label(top, text="Order Code : ").place(x=320, y=220)
    OrderCode = tk.Entry(top, width=25)
    OrderCode.pack()
    OrderCode.place(x=430, y=220)

    group3 = tk.LabelFrame(top, text="Supported Bit Rate").grid(row=0,
                                                                columnspan=7,
                                                                sticky='W',
                                                                padx=650,
                                                                pady=5,
                                                                ipadx=80,
                                                                ipady=150)
    checkBox1 = Checkbutton(top,
                            variable=checkCmd1,
                            text="10k Bit/Sec",
                            command=cbcommand1)
    checkBox1.pack()
    checkBox1.place(x=700, y=20)
    checkBox2 = Checkbutton(top,
                            variable=checkCmd2,
                            text="20k Bit/Sec",
                            command=cbcommand2)
    checkBox2.pack()
    checkBox2.place(x=700, y=50)
    checkBox3 = Checkbutton(top,
                            variable=checkCmd3,
                            text="50k Bit/Sec",
                            command=cbcommand3)
    checkBox3.pack()
    checkBox3.place(x=700, y=80)
    checkBox4 = Checkbutton(top,
                            variable=checkCmd4,
                            text="100k Bit/Sec",
                            command=cbcommand4)
    checkBox4.pack()
    checkBox4.place(x=700, y=110)
    checkBox5 = Checkbutton(top,
                            variable=checkCmd5,
                            text="125k Bit/Sec",
                            command=cbcommand5)
    checkBox5.pack()
    checkBox5.place(x=700, y=140)
    checkBox6 = Checkbutton(top,
                            variable=checkCmd6,
                            text="250k Bit/Sec",
                            command=cbcommand6)
    checkBox6.pack()
    checkBox6.place(x=700, y=170)
    checkBox7 = Checkbutton(top,
                            variable=checkCmd7,
                            text="500k Bit/Sec",
                            command=cbcommand7)
    checkBox7.pack()
    checkBox7.place(x=700, y=200)
    checkBox8 = Checkbutton(top,
                            variable=checkCmd8,
                            text="800k Bit/Sec",
                            command=cbcommand8)
    checkBox8.pack()
    checkBox8.place(x=700, y=230)
    checkBox9 = Checkbutton(top,
                            variable=checkCmd9,
                            text="1000k Bit/Sec",
                            command=cbcommand9)
    checkBox9.pack()
    checkBox9.place(x=700, y=260)

    group4 = tk.LabelFrame(top, text="Number of PDOs").grid(row=0,
                                                            columnspan=7,
                                                            sticky='W',
                                                            padx=850,
                                                            pady=5,
                                                            ipadx=80,
                                                            ipady=80)
    Label(top, text="Transmit PDOs").place(x=890, y=100)
    TPDO = tk.Entry(top, width=10)
    TPDO.pack()
    TPDO.place(x=900, y=120)
    Label(top, text="Receive PDOs").place(x=890, y=170)
    RPDO = tk.Entry(top, width=10)
    RPDO.pack()
    RPDO.place(x=900, y=190)

    ADD = tk.Button(top, text="Add PDOs", command=ADD_PDOCallBack)
    ADD.pack()
    ADD.place(x=900, y=250)

    def SaveClose():
        FILE_info[0] = (FileName.get())
        FILE_info[1] = (FileVersion.get())
        FILE_info[2] = (FileRevision.get())
        FILE_info[3] = (Description.get())
        FILE_info[4] = (Author.get())
        DEVICE_info[0] = (VendorName.get())
        DEVICE_info[1] = (VendorNumber.get())
        DEVICE_info[2] = (ProductName.get())
        DEVICE_info[3] = (ProductNumber.get())
        DEVICE_info[4] = (RevisionNumber.get())
        DEVICE_info[5] = (OrderCode.get())
        PDO_info[0] = TPDO.get()
        PDO_info[1] = RPDO.get()
        BAUD_info[0] = str(checkCmd1.get())
        BAUD_info[1] = str(checkCmd2.get())
        BAUD_info[2] = str(checkCmd3.get())
        BAUD_info[3] = str(checkCmd4.get())
        BAUD_info[4] = str(checkCmd5.get())
        BAUD_info[5] = str(checkCmd6.get())
        BAUD_info[6] = str(checkCmd7.get())
        BAUD_info[7] = str(checkCmd8.get())
        BAUD_info[8] = str(checkCmd9.get())
        tkMessageBox.showinfo("Info", "Closing File and Device Info Window")
        top.destroy()

    SaveButton = tk.Button(top, text="Save & Close", command=SaveClose)
    SaveButton.place(x=330, y=280)
    top.mainloop()
예제 #9
0
class EMNN():
    def __init__(self, conn):
        conn.gui = True
        queue = self.queue = Queue.Queue()
        conn.queue = queue
        self.conn = conn

    def startgui(self):
        self.root = root = Tk()
        root.title('SIMAPSE - Simulation Maps for Ecological Niche Modelling')
        root.geometry('695x445+375+115')
        root.tk.call('encoding', 'system', 'utf-8')
        root.configure(bg='#d9d9d9')
        root.resizable(width='false', height='false')
        self.gui()
        self.root.after(100, self.periodicUpdate)
        root.mainloop()

    def gui(self):
        from Tkinter import Button, Entry, Frame, Label, Checkbutton, \
                            Scrollbar, Text, IntVar, StringVar, OptionMenu

        self.dir_project = ''
        self.folds = 0
        self.func = ""
        self.aucfilter = IntVar()

        self.lightgray = '#d9d9d9'
        self.darkgray = '#d3d3d3'

        self.normaltext = ("Helvetica", -10)
        self.boldtext = ("Helvetica", -10, "bold")
        self.bigtext = ("Helvetica", -12, "bold")
        self.smalltext = ("Helvetica", -9)

        self.butData = Button(self.root)
        self.butData.place(in_=self.root, x=5, y=5)
        self.butData.configure(height=1,
                               width=10,
                               text="Data File",
                               font=self.normaltext,
                               highlightbackground=self.lightgray,
                               command=self.dataOpen)

        self.butRasterFolder = Button(self.root)
        self.butRasterFolder.place(in_=self.root, x=5, y=35)
        self.butRasterFolder.configure(height=1,
                                       width=10,
                                       text="Raster Folder",
                                       font=self.normaltext,
                                       highlightbackground=self.lightgray,
                                       command=self.rasterOpen)

        self.butOutFolder = Button(self.root)
        self.butOutFolder.place(in_=self.root, x=5, y=65)
        self.butOutFolder.configure(height=1,
                                    width=10,
                                    text="Out Folder",
                                    font=self.normaltext,
                                    highlightbackground=self.lightgray,
                                    command=self.outOpen)

        self.entData = Entry(self.root)
        self.entData.place(in_=self.root, x=100, y=9)
        self.entData.configure(textvariable="file_data",
                               font=self.normaltext,
                               width=97,
                               background=self.darkgray,
                               relief="flat",
                               highlightbackground=self.lightgray)
        self.entData.insert(0, '')

        self.entOutFolder = Entry(self.root)
        self.entOutFolder.place(in_=self.root, x=100, y=69)
        self.entOutFolder.configure(textvariable="out_dir",
                                    font=self.normaltext,
                                    width=97,
                                    background=self.darkgray,
                                    relief="flat",
                                    highlightbackground=self.lightgray)
        self.entOutFolder.insert(0, '')

        self.entRasterFolder = Entry(self.root)
        self.entRasterFolder.place(in_=self.root, x=100, y=39)
        self.entRasterFolder.configure(textvariable="dir_rasters",
                                       font=self.normaltext,
                                       width=97,
                                       background=self.darkgray,
                                       relief="flat",
                                       highlightbackground=self.lightgray)
        self.entRasterFolder.insert(0, '')

        self.activeMethod = StringVar(self.root)
        self.activeMethod.set("Random repetition")
        self.butMETHOD = OptionMenu(
            self.root,
            self.activeMethod,
            "Random repetition",
            "Cross validation",
            "Bootstrapping",
            command=lambda x: self.displayMethodFrame(x))
        self.butMETHOD.place(in_=self.root,
                             x=4,
                             y=97,
                             height="25",
                             width="120")
        self.butMETHOD.configure(font=self.smalltext,
                                 background=self.lightgray)
        self.displayMethodFrame(self.activeMethod.get())

        self.activeOption = StringVar(self.root)
        self.activeOption.set("Network structure")
        self.butOPTION = OptionMenu(
            self.root,
            self.activeOption,
            "Network structure",
            "Options",
            command=lambda x: self.displayOptionFrame(x))
        self.butOPTION.place(in_=self.root,
                             x=4,
                             y=182,
                             height="25",
                             width="120")
        self.butOPTION.configure(font=self.smalltext,
                                 background=self.lightgray)
        self.displayOptionFrame(self.activeOption.get())

        self.Progress_frame = Frame(self.root)
        self.Progress_frame.place(in_=self.root, x=5, y=423)
        self.Progress_frame.configure(borderwidth="2",
                                      relief='sunken',
                                      height="20",
                                      width="105",
                                      bg='white')

        self.Progress_bar = Label(self.Progress_frame)
        self.Progress_bar.place(x=0, y=0)
        self.Progress_bar.configure(font=self.smalltext)

        self.Progress_info = Label(self.root)
        self.Progress_info.place(x=110, y=425)
        self.Progress_info.configure(font=self.smalltext, bg=self.lightgray)

        self.frameButtons = Frame(self.root)
        self.frameButtons.place(in_=self.root, x=5, y=336)
        self.frameButtons.configure(borderwidth="2",
                                    bg=self.lightgray,
                                    relief="raise",
                                    height="84",
                                    width="260")

        self.butREAD = Button(self.root)
        self.butREAD.place(in_=self.frameButtons, x=5, y=5, width=70)
        self.butREAD.configure(font=self.bigtext,
                               highlightbackground=self.lightgray,
                               text="READ",
                               command=self.read)

        self.butRUN = Button(self.root)
        self.butRUN.place(in_=self.frameButtons, x=80, y=5, width=70)
        self.butRUN.configure(font=self.bigtext,
                              highlightbackground=self.lightgray,
                              text="RUN",
                              command=self.returnVar,
                              state='disabled')

        self.butRESULTS = Button(self.root)
        self.butRESULTS.place(in_=self.frameButtons, x=155, y=5, width=80)
        self.butRESULTS.configure(font=self.bigtext,
                                  highlightbackground=self.lightgray,
                                  text="RESULTS",
                                  command=self.returnResults,
                                  state='disabled')

        self.butPROJECT = Button(self.root)
        self.butPROJECT.place(in_=self.frameButtons, x=5, y=45, width=70)
        self.butPROJECT.configure(font=self.boldtext,
                                  highlightbackground=self.lightgray,
                                  text="PROJECT",
                                  command=self.project,
                                  state='disabled')

        self.frameText = Frame(self.root)
        self.frameText.place(in_=self.root, x=270, y=100)
        self.frameText.configure(height=320, width=400)

        self.scrollbar = Scrollbar(self.root)

        self.textFrame = Text(self.frameText, wrap='word')
        self.textFrame.configure(font=self.normaltext, height="24", width="65")
        self.textFrame.place(x=0, y=0)
        self.textFrame.configure(yscrollcommand=self.scrollbar.set)

        self.scrollbar.configure(command=self.textFrame.yview,
                                 highlightbackground=self.lightgray)
        self.scrollbar.place(x=675, y=100, height=320)

    def displayMethodFrame(self, method):
        ''' Displays individual frames for the subsetting method'''
        from Tkinter import Button, Entry, Frame, Label

        if self.__dict__.has_key('frameMethodSelection'):
            self.frameMethodSelection.destroy()

        self.varupdate()
        c = self.conn.simargs

        self.frameMethodSelection = Frame(self.root)
        self.frameMethodSelection.place(in_=self.root, x=5, y=122)
        self.frameMethodSelection.configure(borderwidth="2",
                                            relief="raise",
                                            height="60",
                                            width="260",
                                            bg=self.lightgray)

        if method == "Random repetition":
            self.labRepetitions = Label(self.root)
            self.labRepetitions.place(in_=self.frameMethodSelection, x=2, y=10)
            self.labRepetitions.configure(font=self.normaltext,
                                          borderwidth="1",
                                          justify='left',
                                          anchor='e',
                                          bg=self.lightgray,
                                          text="Number of repetitions:")

            self.entRepetitions = Entry(self.root)
            self.entRepetitions.place(in_=self.frameMethodSelection,
                                      x=125,
                                      y=10)
            self.entRepetitions.configure(textvariable="repetitions",
                                          width="7",
                                          font=self.normaltext,
                                          highlightbackground=self.lightgray)
            self.entRepetitions.delete(0, 'end')
            self.entRepetitions.insert('end', c['repetitions'])

        elif method == "Cross validation":
            self.labRepetitions = Label(self.root)
            self.labRepetitions.place(in_=self.frameMethodSelection, x=2, y=10)
            self.labRepetitions.configure(font=self.normaltext,
                                          bg=self.lightgray,
                                          text="Number of folds:")

            self.entRepetitions = Entry(self.root)
            self.entRepetitions.place(in_=self.frameMethodSelection,
                                      x=100,
                                      y=10)
            self.entRepetitions.configure(textvariable="repetitions",
                                          width="7",
                                          highlightbackground=self.lightgray,
                                          font=self.normaltext)
            self.entRepetitions.delete(0, 'end')
            self.entRepetitions.insert('end', c['repetitions'])

        elif method == "Bootstrapping":
            self.labRepetition = Label(self.root)
            self.labRepetition.place(in_=self.frameMethodSelection, x=2, y=5)
            self.labRepetition.configure(borderwidth="1",
                                         text="Number of Bootstraps:",
                                         bg=self.lightgray,
                                         font=self.normaltext)

            self.entRepetitions = Entry(self.root)
            self.entRepetitions.place(in_=self.frameMethodSelection,
                                      x=125,
                                      y=5)
            self.entRepetitions.configure(textvariable="repetitions",
                                          width="7",
                                          highlightbackground=self.lightgray,
                                          font=self.normaltext)
            self.entRepetitions.delete(0, 'end')
            self.entRepetitions.insert('end', c['repetitions'])

            self.labBsize = Label(self.root)
            self.labBsize.place(in_=self.frameMethodSelection, x=2, y=30)
            self.labBsize.configure(borderwidth="1",
                                    text="Bootstraps Sample Size:",
                                    bg=self.lightgray,
                                    font=self.normaltext)

            self.entBsize = Entry(self.root)
            self.entBsize.place(in_=self.frameMethodSelection, x=125, y=30)
            self.entBsize.configure(textvariable="Bsize",
                                    width="7",
                                    highlightbackground=self.lightgray,
                                    font=self.normaltext)
            self.entBsize.delete(0, 'end')
            self.entBsize.insert('end', c['bsize'])

    def displayOptionFrame(self, option):
        ''' Displays individual frames for the subsetting method'''
        from Tkinter import Button, Entry, Frame, Label, Checkbutton

        if self.__dict__.has_key('frameOptionSelection'):
            self.frameOptionSelection.destroy()

        self.varupdate()
        c = self.conn.simargs

        self.frameOptionSelection = Frame(self.root)
        self.frameOptionSelection.place(in_=self.root, x=5, y=207)
        self.frameOptionSelection.configure(borderwidth="2",
                                            relief="raise",
                                            height="125",
                                            width="260",
                                            bg=self.lightgray)

        if option == "Network structure":
            self.labMaxiter = Label(self.root)
            self.labMaxiter.place(in_=self.frameOptionSelection, x=190, y=5)
            self.labMaxiter.configure(borderwidth="1",
                                      font=self.normaltext,
                                      text="Internal",
                                      bg=self.lightgray)

            self.labNNN = Label(self.root)
            self.labNNN.place(in_=self.frameOptionSelection, x=95, y=5)
            self.labNNN.configure(borderwidth="1",
                                  font=self.normaltext,
                                  text="Reported",
                                  bg=self.lightgray)

            self.labTI = Label(self.root)
            self.labTI.place(in_=self.frameOptionSelection, x=5, y=25)
            self.labTI.configure(borderwidth="1",
                                 font=self.normaltext,
                                 text="Total iterations =",
                                 bg=self.lightgray)

            self.entITERReport = Entry(self.root)
            self.entITERReport.place(in_=self.frameOptionSelection, x=88, y=25)
            self.entITERReport.configure(textvariable="AUCReport",
                                         width="10",
                                         font=self.normaltext,
                                         highlightbackground=self.lightgray)
            self.entITERReport.delete(0, 'end')
            self.entITERReport.insert('end', c['iterreport'])

            self.times = Label(self.root)
            self.times.place(in_=self.frameOptionSelection, x=160, y=25)
            self.times.configure(text="x",
                                 font=self.normaltext,
                                 bg=self.lightgray)

            self.entITERInter = Entry(self.root)
            self.entITERInter.place(in_=self.frameOptionSelection, x=180, y=25)
            self.entITERInter.configure(textvariable="maxiter",
                                        width="10",
                                        font=self.normaltext,
                                        highlightbackground=self.lightgray)
            self.entITERInter.delete(0, 'end')
            self.entITERInter.insert('end', c['iterinter'])

            self.labEta = Label(self.root)
            self.labEta.place(in_=self.frameOptionSelection, x=5, y=55)
            self.labEta.configure(borderwidth="1",
                                  font=self.normaltext,
                                  text="Learning Rate",
                                  bg=self.lightgray)

            self.butHINT = Button(self.root)
            self.butHINT.place(in_=self.frameOptionSelection,
                               x=65,
                               y=75,
                               height=23,
                               width=20)
            self.butHINT.configure(font=self.smalltext,
                                   text="H",
                                   command=self.hint,
                                   state='disabled',
                                   highlightbackground=self.lightgray)

            self.labMomentum = Label(self.root)
            self.labMomentum.place(in_=self.frameOptionSelection, x=88, y=55)
            self.labMomentum.configure(borderwidth="1",
                                       font=self.normaltext,
                                       text="Momentum",
                                       bg=self.lightgray)

            self.entLRATE = Entry(self.root)
            self.entLRATE.place(in_=self.frameOptionSelection, x=5, y=75)
            self.entLRATE.configure(textvariable="eta",
                                    width="8",
                                    font=self.normaltext,
                                    highlightbackground=self.lightgray)
            self.entLRATE.delete(0, 'end')
            self.entLRATE.insert('end', c['lrate'])

            self.entMomentum = Entry(self.root)
            self.entMomentum.place(in_=self.frameOptionSelection, x=90, y=75)
            self.entMomentum.configure(textvariable="momentum",
                                       width="8",
                                       font=self.normaltext,
                                       highlightbackground=self.lightgray)
            self.entMomentum.delete(0, 'end')
            self.entMomentum.insert('end', c['momentum'])

            self.labNNS = Label(self.root)
            self.labNNS.place(in_=self.frameOptionSelection, x=165, y=55)
            self.labNNS.configure(borderwidth="1",
                                  font=self.normaltext,
                                  text="Hidden Layers",
                                  bg=self.lightgray)

            self.entNNShape = Entry(self.root)
            self.entNNShape.place(in_=self.frameOptionSelection, x=160, y=75)
            self.entNNShape.configure(textvariable="HiddenLyr",
                                      width="14",
                                      font=self.normaltext,
                                      highlightbackground=self.lightgray)
            self.entNNShape.delete(0, 'end')
            self.entNNShape.insert('end', c['hiddenlyrs'])

        elif option == "Options":

            self.labPercentage = Label(self.root)
            self.labPercentage.place(in_=self.frameOptionSelection, x=2, y=5)
            self.labPercentage.configure(borderwidth="1",
                                         text="Test %:",
                                         font=self.normaltext,
                                         bg=self.lightgray)

            self.entPercentage = Entry(self.root)
            self.entPercentage.place(in_=self.frameOptionSelection,
                                     x=45,
                                     y=5,
                                     width=30)
            self.entPercentage.configure(textvariable="Percentage",
                                         font=self.normaltext,
                                         highlightbackground=self.lightgray)
            self.entPercentage.delete(0, 'end')
            self.entPercentage.insert('end', c['percentage'])

            self.labAPRatio = Label(self.root)
            self.labAPRatio.place(in_=self.frameOptionSelection, x=80, y=5)
            self.labAPRatio.configure(borderwidth="1",
                                      text="Pseudoabsences/Presences:",
                                      font=self.normaltext,
                                      bg=self.lightgray)

            self.entAPRatio = Entry(self.root)
            self.entAPRatio.place(in_=self.frameOptionSelection, x=220, y=5)
            self.entAPRatio.configure(textvariable="apratio",
                                      width="4",
                                      font=self.normaltext,
                                      highlightbackground=self.lightgray)
            self.entAPRatio.delete(0, 'end')
            self.entAPRatio.insert('end', c['apratio'])

            self.labBurnin = Label(self.root)
            self.labBurnin.place(in_=self.frameOptionSelection, x=2, y=30)
            self.labBurnin.configure(borderwidth="1",
                                     text="Burn-in iterations:",
                                     font=self.normaltext,
                                     bg=self.lightgray)

            self.entBurnin = Entry(self.root)
            self.entBurnin.place(in_=self.frameOptionSelection, x=90, y=30)
            self.entBurnin.configure(textvariable="burnin",
                                     width="8",
                                     font=self.normaltext,
                                     highlightbackground=self.lightgray)
            self.entBurnin.delete(0, 'end')
            self.entBurnin.insert('end', c['burnin'])

            self.chkAucFilter = Checkbutton(self.root)
            self.chkAucFilter.place(in_=self.frameOptionSelection, x=2, y=60)
            self.chkAucFilter.configure(font=self.normaltext,
                                        text="Filter with AUC threshold",
                                        variable=self.aucfilter,
                                        bg=self.lightgray,
                                        command=self.aucstate)

            self.labAUCTrain = Label(self.root)
            self.labAUCTrain.place(in_=self.frameOptionSelection, x=5, y=85)
            self.labAUCTrain.configure(borderwidth="1",
                                       font=self.normaltext,
                                       text="training data",
                                       bg=self.lightgray)

            self.entAUCTrain = Entry(self.root)
            self.entAUCTrain.place(in_=self.frameOptionSelection, x=70, y=85)
            self.entAUCTrain.configure(textvariable="valueAuc",
                                       width="8",
                                       font=self.normaltext,
                                       highlightbackground=self.lightgray)
            self.entAUCTrain.delete(0, 'end')
            self.entAUCTrain.insert('end', c['auctrain'])

            self.labAUCTest = Label(self.root)
            self.labAUCTest.place(in_=self.frameOptionSelection, x=130, y=85)
            self.labAUCTest.configure(borderwidth="1",
                                      font=self.normaltext,
                                      text="testing data",
                                      bg=self.lightgray)

            self.entAUCTest = Entry(self.root)
            self.entAUCTest.place(in_=self.frameOptionSelection, x=195, y=85)
            self.entAUCTest.configure(textvariable="valueAucTest",
                                      width="8",
                                      font=self.normaltext,
                                      highlightbackground=self.lightgray)
            self.entAUCTest.delete(0, 'end')
            self.entAUCTest.insert('end', c['auctest'])

            self.aucstate()

    def varupdate(self):
        extract = self.extract
        c = self.conn.simargs

        c['file_data'] = extract('entData', c['file_data'])
        c['dir_rasters'] = extract('entRasterFolder', c['dir_rasters'])
        c['out_dir'] = extract('entOutFolder', c['out_dir'])
        c['method'] = extract('activeMethod', c['method'])
        c['iterreport'] = int(extract('entITERReport', c['iterreport']))
        c['iterinter'] = int(extract('entITERInter', c['iterinter']))
        c['lrate'] = float(extract('entLRATE', c['lrate']))
        c['momentum'] = float(extract('entMomentum', c['momentum']))
        c['hiddenlyrs'] = extract('entNNShape', c['hiddenlyrs'])
        c['apratio'] = float(extract('entAPRatio', c['apratio']))
        c['percentage'] = int(extract('entPercentage', c['percentage']))
        c['burnin'] = int(extract('entBurnin', c['burnin']))
        c['auctrain'] = float(extract('entAUCTrain', c['auctrain']))
        c['auctest'] = float(extract('entAUCTest', c['auctest']))
        c['repetitions'] = int(extract('entRepetitions', c['repetitions']))
        c['bsize'] = int(extract('entBsize', c['bsize']))
        c['aucfilter'] = bool(extract('aucfilter', int(c['aucfilter'])))

    def extract(self, test, default):
        if test in self.__dict__.keys():
            value = self.__dict__[test].get()
        else:
            value = default
        return value

    def read(self):
        import time
        self.varupdate()
        self.conn.processor(self.conn.manager.read_all, 'read')

    def returnVar(self):
        # Updates variables
        self.varupdate()
        self.conn.processor(self.conn.manager.model, 'run')

    def returnResults(self):
        self.varupdate()
        self.conn.processor(self.conn.manager.results, 'results')

    def project(self):
        self.varupdate()
        project_dir = askdirectory()
        self.conn.simargs['project_dir'] = project_dir
        self.conn.processor(self.conn.manager.project, 'project')

    def hint(self):
        self.varupdate()
        self.conn.processor(self.conn.manager.hint, 'hint')

    def dataOpen(self):
        self.entData.delete(0, 'end')
        file_data = askopenfilename(filetypes=[("text files",
                                                "*.txt"), ("allfiles", "*")])
        self.entData.insert('end', file_data)

    def rasterOpen(self):
        self.entRasterFolder.delete(0, 'end')
        dir_rasters = askdirectory()
        self.entRasterFolder.insert('end', dir_rasters)

    def outOpen(self):
        self.entOutFolder.delete(0, 'end')
        out_dir = askdirectory()
        self.entOutFolder.insert('end', out_dir)

    def update_text(self, string_txt):
        txt = string_txt + " \n"
        self.textFrame.insert('end', txt)
        self.textFrame.yview('end')

    def processGraph(self, graph_object):
        '''Just a wraper to call the graphics creation object'''
        graph_object()

    def periodicUpdate(self):
        """Executes periodic checks to GUI:
            - if there are new messages and displays when true"""
        try:
            while 1:
                code, args, kwargs = self.queue.get_nowait()
                if code == Connector.CODE_TEXT:
                    self.update_text(*args)
                elif code == Connector.CODE_PROGRESS:
                    self.progress(*args, **kwargs)
                elif code == Connector.CODE_MODIFY_BUTTON:
                    self.modify_but(*args)
                elif code == Connector.CODE_SHOWRESULTS:
                    self.showResults(*args)
                elif code == Connector.CODE_GRAPHS:
                    self.processGraph(args)
                else:
                    self.update_text('Unknown message...')
                self.queue.task_done()
                self.root.update()
        except Queue.Empty:
            pass
        self.root.after(100, self.periodicUpdate)

    def modify_but(self, state, buttonlist):
        if buttonlist == 'all':
            buttonlist = [
                'READ', 'RUN', 'RESULTS', 'PROJECT', 'HINT', 'METHOD', 'OPTION'
            ]
        for button in buttonlist:
            but = "self.but%s.configure(state=\'%s\')" % (button, state)
            exec(but)

    def abundance(self):
        self.entAUCTrain.configure(state='disabled')
        self.entAUCTest.configure(state='disabled')

    def aucstate(self):
        if self.aucfilter.get(): state = 'normal'
        else: state = 'disabled'
        self.entAUCTrain.configure(state=state)
        self.entAUCTest.configure(state=state)

    def progress(self, value, maxvalue, **kwargs):
        '''Shows the progress bar in GUI
           args are:
            Value    - Value of the current progress
            MaxValue - Value where progress terminates
           kwargs are
            color    - Color for the progess bar
            msg      - message to display'''
        color = 'blue'
        if 'color' in kwargs: color = kwargs['color']
        percent = (value * 100) / maxvalue
        self.Progress_bar.configure(font=self.smalltext,
                                    foreground="white",
                                    background=color)  #"#0000ff"
        if percent <> 100:
            width = int((percent / 100.000) * 20)
            text = '%s%%' % percent
            self.Progress_bar.configure(text=text, width=width)
            if 'msg' in kwargs:
                self.Progress_info.configure(text=kwargs['msg'])
        elif percent == 100:
            self.Progress_bar.configure(text="",
                                        width=0,
                                        relief="flat",
                                        background="#ece9d8")
            self.Progress_info.configure(text="")

    def showResults(self, figures):
        from Tkinter import Button
        figures = [self.entOutFolder.get() + "/" + x for x in figures]
        ResultsWindow = mytoplevel(self.root, figures, self)
        ResultsWindow.title('Results')
        butRW = Button(ResultsWindow,
                       text='CLOSE',
                       command=ResultsWindow.destroy)
        butRW.pack()

    def update_queue(self):
        try:
            while self.queue.qsize():
                msg = '%s\n' % self.queue.get(0)
                self.textFrame.insert('end', msg)
                self.textFrame.yview('end')
        except Queue.Empty:
            pass
예제 #10
0
    def initUI(self):
        """
        Initializes the user interface

        Setting up the entry widgets for:
        - Experiment_ID
        - Participant Name
        - Session Day
        - Pupil Size
        - Practice
        - Stereo
        """
        # Set the title
        self.parent.title(EXP_NAME)

        # Create the label for Experiment_ID and set location
        label_id = Label(text='Participant ID:')
        label_id.place(x=20, y=20)

        # Check the DATA_DIR directory for previous participants
        # and choose the next Experiment_ID in line
        self.folders = listdir(DATA_DIR)
        # Initiate Tkinter's StringVar
        self.value_id = StringVar()
        # Set the default value
        self.value_id.set('001')
        # Going in reverse order of the participants' directories in
        # DATA_DIR, find the last participant's Experiment_ID and opt
        # for the next one in line
        for folder in reversed(self.folders):
            try:
                # Check if the value of the first 3 digits of the
                # directory name is greater than the default value
                if int(folder[:3]) >= int(self.value_id.get()):
                    # Get the next Experiment_ID in integer form and
                    # convert to string format
                    num = str(int(folder[:3]) + 1)
                    # Actions to perform in case scenarios for each
                    # of the possibilites of num_length
                    num_length = {3: num, 2: '0%s' % num, 1: '00%s' % num}
                    # Set the value accordingly to the StringVar,
                    # replacing the default
                    self.value_id.set(num_length[len(num)])
            # In case there are other folders in DATA_DIR, for which
            # the first 3 characters are not digits, we must cater
            # for when an exception is thrown up
            except ValueError:
                pass
        # Create the entry widget for Experiment_ID with the preset
        # value and state disabled
        self.input_id = Entry(self.parent,
                              width=5,
                              state=DISABLED,
                              textvariable=self.value_id)
        self.input_id.place(x=150, y=20)

        # Create the label for Participant Name and set location
        label_name = Label(text='Participant Name:')
        label_name.place(x=20, y=50)

        # Initiate Tkinter's StringVar
        self.value_name = StringVar()
        # Set the default value
        self.value_name.set('')
        # Create the entry for Participant Name and set location
        self.input_name = Entry(self.parent,
                                width=35,
                                textvariable=self.value_name)
        self.input_name.place(x=150, y=50)
        self.input_name.focus()

        # Create the label for Session Day and set location
        label_day = Label(text='Session Day:')
        label_day.place(x=20, y=80)

        # Create value holder for Session Day as IntVar and set default
        # value to 1
        self.value_day = IntVar()
        self.value_day.set(1)
        # Create the radiobuttons as required
        for day in range(1, TOTAL_SESSIONS + 1):
            input_day = Radiobutton(self.parent,
                                    text=str(day),
                                    variable=self.value_day,
                                    value=day)
            # Anchor them to the West (W)
            input_day.pack(anchor=W)
            # Choose location for the radiobuttons
            input_day.place(x=150, y=(50 + (day * 25)))

        # Create the label for Pupil Size and set location
        label_pupilsize = Label(text='Pupil Size:')
        label_pupilsize.place(x=20, y=140)

        self.value_pupilsize = StringVar()
        self.value_pupilsize.set('')
        # Create the MaxLengthEntry for Pupil Size and set location
        # The maximum length is set to 3 characters and a float must be
        # provided
        self.input_pupilsize = MaxLengthEntry(self.parent,
                                              width=5,
                                              maxlength=3,
                                              required_type=float)
        self.input_pupilsize.config(textvariable=self.value_pupilsize)
        self.input_pupilsize.place(x=150, y=140)

        # Create value folder for Practice as IntVar
        self.value_practice = IntVar()
        # Create the checkbutton for Practice and set location
        input_practice = Checkbutton(self.parent,
                                     text='Practice',
                                     variable=self.value_practice,
                                     onvalue=1,
                                     offvalue=0)
        input_practice.place(x=150, y=170)

        # Create value holder for Stereo as IntVar
        self.value_stereo = IntVar()
        # Create the checkbutton for Stereo and set location
        input_stereo = Checkbutton(self.parent,
                                   text='Stereo',
                                   variable=self.value_stereo,
                                   onvalue=1,
                                   offvalue=0)
        input_stereo.place(x=150, y=200)

        # Create the label for Previous Subjects and set location
        label_previous = Label(text='Previous Subjects:')
        label_previous.place(x=20, y=250)

        # Create the Listboc containing all the previous participants
        self.input_previous = Listbox(self.parent, width=35, height=10)
        for identifier in self.folders:
            self.input_previous.insert(END, identifier)
        self.input_previous.place(x=150, y=250)
        self.input_previous.bind('<<ListboxSelect>>', self.__select_previous)

        # Create the submit button, give command upon pressing and set
        # location
        submit = Button(text='Submit', width=47, command=self.gather_input)
        submit.pack(padx=8, pady=8)
        submit.place(x=20, y=425)
예제 #11
0
파일: gui.py 프로젝트: OzTamir/oZip
class MainWindow(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent, background="white")   
        self.parent = parent
        self.files = []
        self.lb = None
        self.should_decompress = False
        self.initUI()
        self.update_idletasks()
    
    def initUI(self):
        ''' Create the UI '''
        # Name the window
        self.parent.title("oZip")
        self.pack(fill=BOTH, expand=1)
        
        # 'Add File' button
        addFileButton = Button(self, text="Add File",
            command=self.onOpen)
        addFileButton.place(x=225, y=30)
        
        # 'Go' button
        goButton = Button(self, text="Go",
            command=self.onClick)
        goButton.place(x=225, y=100)
        
        # 'Quit' button
        quitButton = Button(self, text="Quit",
            command=self.quit)
        quitButton.place(x=225, y=160)
        
        # Decompression checkbox
        self.cb = Checkbutton(self, text="Should decompress",
            command=self.checkboxClick)
        self.cb.place(x=20, y=195)
        
        # Selected files list
        lb = Listbox(self)
        self.lb = lb   
        lb.place(x=20, y=20)

    def checkboxClick(self):
        ''' Update the variable that stores the action that will be done on the files '''
        # Update the GUI
        self.cb.update_idletasks()
        # Update the backend
        self.should_decompress = not self.should_decompress

    def onClick(self):
        ''' 'Go' button pressed '''
        # Create a queue for any error messages that may rise
        err_q = Queue()
        # Run the processing on another thread and use the current thread to display errors if occured
        worker = Thread(target=runPool, args=(self.files, err_q, self.should_decompress))
        worker.setDaemon(True)
        worker.start()

        # Display error messages if needed
        while True:
            # Get the next error message
            var = err_q.get()
            # If it's a tuple, display the error from the tuple
            if isinstance(var, tuple):
                self.showError(var[0], var[1])
            # If it's a string it means that the processing is done
            elif isinstance(var, str):
                break
            # Remove the error from the queue
            err_q.task_done()
        # When all the files are done, inform the user
        box.showinfo("Done", 'Processing completed.')
        # Quit
        self.quit()

    def showError(self, filename, error_msg):
        ''' Show an error msg if needed '''
        box.showerror("Error on file %s" % filename, error_msg)

    def onOpen(self):
        ''' 'Add File' button was clicked '''
        # Get a tuple with the user's selected files
        selected_files = tkFileDialog.askopenfilenames()
        for path in selected_files:
            # Append the selected files to the list and to the list view (filename only in the GUI, path in backend)
            self.files.append(path)
            self.lb.insert(END, ntpath.split(path)[-1])
            # Update the GUI
            self.lb.update_idletasks()
예제 #12
0
파일: gui.py 프로젝트: cyphyhouse/UI-
class MapUI:
    def __init__(self, master):
        def center(win):
            win.update_idletasks()
            width = win.winfo_width()
            height = win.winfo_height()
            x = (win.winfo_screenwidth() // 4) - (width // 2) + 40
            y = (win.winfo_screenheight() // 4) - (height // 2) + 40
            win.geometry('{}x{}+{}+{}'.format(width, height, x, y))

        def callback(event):
            event.widget.focus_set()
            print "clicked at", event.x, event.y

            if self.add_tasks_flg.get() == 1:
                # Select number of robots
                # Define elements of pop up window
                self.top = Toplevel()

                self.num_robots = StringVar(self.top)
                self.num_robots.set("1")  # default value
                w = OptionMenu(self.top, self.num_robots, '1', '2', '3',
                               '4').grid(row=0, column=1)
                text1 = Message(self.top, text="Number of robots:",
                                width=150).grid(row=0, column=0)

                self.e = Entry(self.top, width=10)
                self.e.grid(row=1, column=1)
                text2 = Message(self.top, text="Task duration:",
                                width=150).grid(row=1, column=0)
                text3 = Message(self.top, text="(s)", width=60).grid(row=1,
                                                                     column=2)

                newline = Message(self.top, text=" ").grid(row=2)

                button = Button(self.top,
                                text='Enter',
                                command=lambda: self.enter_task(event)).grid(
                                    row=3, column=1)
                button_cancel = Button(self.top,
                                       text='Cancel',
                                       command=self.cancel_task).grid(row=3,
                                                                      column=2)

                center(self.top)

        master.title("Map Interface")
        master.minsize(width=1000, height=750)
        master.maxsize(width=1000, height=750)
        master.config(bg=BKG_COLOUR)
        self.master = master

        # Canvas for overlaying map
        self.map_canvas = Canvas(master,
                                 width=CANVAS_W,
                                 height=CANVAS_H,
                                 bg='gray85',
                                 highlightthickness=0)
        self.map_canvas.pack(side='right', padx=50)
        self.map_canvas.bind("<Button-1>", callback)
        global CANVAS_PTR
        CANVAS_PTR = self.map_canvas
        self.master.update()
        w = self.map_canvas.winfo_width()
        h = self.map_canvas.winfo_height()
        # Overlay a grid
        for i in range(0, w, SQ_SIZE):
            if i != 0:
                self.map_canvas.create_line(i, 0, i, h, dash=1)
        for i in range(0, h, SQ_SIZE):
            if i != 0:
                self.map_canvas.create_line(0, i, w, i, dash=1)

        # Load in flame icon from flame.gif
        self.flame_icon = PhotoImage(file="flame.gif")
        # Load in the drone icon from drone.gif
        global DRONE_ICON
        DRONE_ICON = PhotoImage(file="drone.gif")

        buttons_frame = Canvas(master,
                               width=163,
                               height=230,
                               bg=BUTTONS_BKG_COLOUR,
                               highlightthickness=1,
                               highlightbackground='dim grey')
        buttons_frame.place(x=40, y=200)

        # Define UI buttons
        self.add_tasks_flg = IntVar()
        self.add_tasks_b = Checkbutton(master,
                                       text="Add Tasks",
                                       variable=self.add_tasks_flg,
                                       highlightbackground=BUTTONS_BKG_COLOUR,
                                       background=BUTTONS_BKG_COLOUR)
        self.add_tasks_b.place(x=77, y=240)

        self.clear_wp_b = Button(master,
                                 text='Clear Tasks',
                                 command=self.clear_wp,
                                 highlightbackground=BUTTONS_BKG_COLOUR)
        self.clear_wp_b.config(width=10)
        self.clear_wp_b.place(x=65, y=270)
        '''
        self.gen_wp_file_b = Button(master, text='Generate Waypoints File', command=self.gen_wp_file, highlightbackground=BKG_COLOUR)
        self.gen_wp_file_b.config(width=20)
        self.gen_wp_file_b.place(x=20, y=250)
        '''

        self.land_b = Button(master,
                             text='Land',
                             command=self.land,
                             highlightbackground=BUTTONS_BKG_COLOUR)
        self.land_b.config(width=10)
        self.land_b.place(x=65, y=350)

        # Set up coordinate system conversion and display corners of room:
        file_obj = open('antenna_locations.txt', 'r')
        anchors = []
        for line in file_obj:
            cur_anchors = map(float, line.split())
            anchors.append(cur_anchors)
        file_obj.close()
        anchors = (np.array(anchors)).T

        # Find largest (abs) x and y values to use a reference for conversion ratio
        x_vals = anchors[0]
        largest_x_val = x_vals[np.argmax(abs(x_vals))]
        y_vals = anchors[1]
        largest_y_val = y_vals[np.argmax(abs(y_vals))]

        if largest_x_val > largest_y_val:
            largest_y_val = largest_x_val
        else:
            largest_x_val = largest_y_val

        global m_per_pixel_x
        m_per_pixel_x = float(largest_x_val / (CANVAS_W / 2))
        global m_per_pixel_y
        m_per_pixel_y = float(largest_y_val / (CANVAS_H / 2))

        # Place antenna (anchors) on UI
        anchors = anchors.T
        for cur_anchor in anchors:
            x_pixel_loc = cur_anchor[0] / m_per_pixel_x + CANVAS_W / 2
            y_pixel_loc = -1 * (cur_anchor[1] / m_per_pixel_y) + CANVAS_H / 2

            # Draw antenna @ location
            global ANTENNA_LIST
            antenna_id = self.map_canvas.create_oval(x_pixel_loc - 15,
                                                     y_pixel_loc - 15,
                                                     x_pixel_loc + 15,
                                                     y_pixel_loc + 15,
                                                     fill='red')

        self.master.update()

    global SQ_SIZE
    SQ_SIZE = 20
    global BKG_COLOUR
    BKG_COLOUR = 'gray95'
    global BUTTONS_BKG_COLOUR
    BUTTONS_BKG_COLOUR = 'grey66'
    global CANVAS_W
    CANVAS_W = 700
    global CANVAS_H
    CANVAS_H = 700
    global TASK_LIST
    TASK_LIST = None
    global m_per_pixel_x
    m_per_pixel_x = None
    global m_per_pixel_y
    m_per_pixel_y = None
    global NEW_TASK_FLAG
    NEW_TASK_FLAG = False
    global ANTENNA_LIST
    ANTENNA_LIST = None
    global DRONE_ICON
    DRONE_ICON = None

    flame_icon = None
    ui_wp_list = None
    #task_list = None
    add_wp_flag = False
    task_id = 0
    add_tasks_flg = None

    def add_tasks(self):
        print "adding tasks"
        # function imp here
        self.add_wp_flag = True
        self.map_canvas.config(cursor='pencil')

    def clear_wp(self):
        print "clear tasks"
        global TASK_LIST
        TASK_LIST = None
        for element_id in self.ui_wp_list:
            self.map_canvas.delete(element_id[0])
        self.ui_wp_list = None

    '''
    def gen_wp_file(self):
        print "generate wp file"
        # function imp here
    '''

    def land(self):
        # Send a new task with position (0,0,0) z=0 tells drone to land
        print("land")

    def enter_task(self, event):
        # Determine square (top left corner coords):
        w_start = event.x - event.x % SQ_SIZE
        h_start = event.y - event.y % SQ_SIZE

        #Translate pixel location to physical location
        x_pixel = event.x
        y_pixel = event.y
        # Find out how many pixels from center:
        x_pixel = x_pixel - CANVAS_W / 2
        x_physical = x_pixel * m_per_pixel_x

        #vertical case, note this is flipped
        y_pixel = y_pixel - CANVAS_W / 2
        y_pixel = -1 * y_pixel
        y_physical = y_pixel * m_per_pixel_y

        try:
            # Add to task list
            global TASK_LIST
            if TASK_LIST == None:
                TASK_LIST = [[
                    self.task_id,
                    int(self.num_robots.get()),
                    float(self.e.get()), x_physical, y_physical
                ]]
                global NEW_TASK_FLAG
                NEW_TASK_FLAG = True
            else:
                TASK_LIST.append([
                    self.task_id,
                    int(self.num_robots.get()),
                    float(self.e.get()), x_physical, y_physical
                ])
                global NEW_TASK_FLAG
                NEW_TASK_FLAG = True

            # Indicate task in UI
            element_id = self.map_canvas.create_image(event.x,
                                                      event.y,
                                                      image=self.flame_icon)
            if self.ui_wp_list == None:
                self.ui_wp_list = [[element_id]]
            else:
                self.ui_wp_list.append([element_id])
        except:
            print("Invalid Task Entry")

        self.map_canvas.config(cursor='arrow')
        self.add_wp_flag = False

        print(TASK_LIST)

        self.task_id = self.task_id + 1
        self.top.destroy()

    def cancel_task(self):
        self.top.destroy()
예제 #13
0
    def initUI(self):
        """
        Initializes the user interface

        Setting up the entry widgets for:
        - Experiment_ID
        - Participant Name
        - Session Day
        - Pupil Size
        - Practice
        - Stereo
        """
        # Set the title
        self.parent.title(EXP_NAME)

        # Create the label for Experiment_ID and set location
        label_id = Label(text='Participant ID:')
        label_id.place(x=20, y=20)

        # Check the DATA_DIR directory for previous participants
        # and choose the next Experiment_ID in line
        self.folders = listdir(DATA_DIR)
        # Initiate Tkinter's StringVar
        self.value_id = StringVar()
        # Set the default value
        self.value_id.set('001')
        # Going in reverse order of the participants' directories in
        # DATA_DIR, find the last participant's Experiment_ID and opt
        # for the next one in line
        for folder in reversed(self.folders):
            try:
                # Check if the value of the first 3 digits of the
                # directory name is greater than the default value
                if int(folder[:3]) >= int(self.value_id.get()):
                    # Get the next Experiment_ID in integer form and
                    # convert to string format
                    num = str(int(folder[:3]) + 1)
                    # Actions to perform in case scenarios for each
                    # of the possibilites of num_length
                    num_length = {
                                  3: num,
                                  2: '0%s' % num,
                                  1: '00%s' % num
                    }
                    # Set the value accordingly to the StringVar,
                    # replacing the default
                    self.value_id.set(num_length[len(num)])
            # In case there are other folders in DATA_DIR, for which
            # the first 3 characters are not digits, we must cater
            # for when an exception is thrown up
            except ValueError:
                pass
        # Create the entry widget for Experiment_ID with the preset
        # value and state disabled
        self.input_id = Entry(self.parent, width=5, state=DISABLED,
                              textvariable=self.value_id)
        self.input_id.place(x=150, y=20)

        # Create the label for Participant Name and set location
        label_name = Label(text='Participant Name:')
        label_name.place(x=20, y=50)

        # Initiate Tkinter's StringVar
        self.value_name = StringVar()
        # Set the default value
        self.value_name.set('')
        # Create the entry for Participant Name and set location
        self.input_name = Entry(self.parent, width=35,
                                textvariable=self.value_name)
        self.input_name.place(x=150, y=50)
        self.input_name.focus()

        # Create the label for Session Day and set location
        label_day = Label(text='Session Day:')
        label_day.place(x=20, y=80)

        # Create value holder for Session Day as IntVar and set default
        # value to 1
        self.value_day = IntVar()
        self.value_day.set(1)
        # Create the radiobuttons as required
        for day in range(1, TOTAL_SESSIONS + 1):
            input_day = Radiobutton(self.parent, text=str(day),
                                    variable=self.value_day, value=day)
            # Anchor them to the West (W)
            input_day.pack(anchor=W)
            # Choose location for the radiobuttons
            input_day.place(x=150, y=(50 + (day * 25)))

        # Create the label for Pupil Size and set location
        label_pupilsize = Label(text='Pupil Size:')
        label_pupilsize.place(x=20, y=140)

        self.value_pupilsize = StringVar()
        self.value_pupilsize.set('')
        # Create the MaxLengthEntry for Pupil Size and set location
        # The maximum length is set to 3 characters and a float must be
        # provided
        self.input_pupilsize = MaxLengthEntry(self.parent, width=5,
                                              maxlength=3,
                                              required_type=float)
        self.input_pupilsize.config(textvariable=self.value_pupilsize)
        self.input_pupilsize.place(x=150, y=140)

        # Create value folder for Practice as IntVar
        self.value_practice = IntVar()
        # Create the checkbutton for Practice and set location
        input_practice = Checkbutton(self.parent, text='Practice',
                                     variable=self.value_practice, onvalue=1,
                                     offvalue=0)
        input_practice.place(x=150, y=170)

        # Create value holder for Stereo as IntVar
        self.value_stereo = IntVar()
        # Create the checkbutton for Stereo and set location
        input_stereo = Checkbutton(self.parent, text='Stereo',
                                   variable=self.value_stereo, onvalue=1,
                                   offvalue=0)
        input_stereo.place(x=150, y=200)

        # Create the label for Previous Subjects and set location
        label_previous = Label(text='Previous Subjects:')
        label_previous.place(x=20, y=250)

        # Create the Listboc containing all the previous participants
        self.input_previous = Listbox(self.parent, width=35, height=10)
        for identifier in self.folders:
            self.input_previous.insert(END, identifier)
        self.input_previous.place(x=150, y=250)
        self.input_previous.bind('<<ListboxSelect>>', self.__select_previous)

        # Create the submit button, give command upon pressing and set
        # location
        submit = Button(text='Submit', width=47, command=self.gather_input)
        submit.pack(padx=8, pady=8)
        submit.place(x=20, y=425)
예제 #14
0
class setup():
	def __init__(self):
		self.pid1=0
		self.playing1=0
		self.paused1=0
		self.pid2=0
		self.playing2=0
		self.paused2=0
		self.pid3=0
		self.playing3=0
		self.paused3=0
		self.file1=''
		self.root=Tkinter.Tk()
		RWidth=self.root.winfo_screenwidth()
		RHeight=self.root.winfo_screenheight()
		self.root.geometry(("%dx%d")%(RWidth,RHeight))


		self.title=Label(self.root)
		self.title.pack()
		self.title.place(x=500,y=30)
		self.title.config(text ="WAVE MIXER")

		self.buttonbrl = Button(self.root, text="Select File", command=self.showl1)
		self.buttonbrl.pack()
		self.buttonbrl.place(x=120,y=170)
		self.browsel1=Label(self.root)
		self.browsel1.pack()
		self.browsel1.place(x=210,y=170)

		self.wave1=Label(self.root)
		self.wave1.pack()
		self.wave1.place(x=120,y=120)
		self.wave1.config(text ="WAVE 1")


		self.labelampl=Label(self.root)
		self.labelampl.pack()
		self.labelampl.place(x=120,y=220)
		self.labelampl.config(text ="Amplitude")
		self.l1=1
		
		self.scalel1=Scale(self.root,orient='horizontal',command=self.print_valuel1,from_=0,to=5)
		self.scalel1.pack()
		self.scalel1.place(x=210,y=220)

		self.timeshiftl2=Label(self.root)
		self.timeshiftl2.pack()
		self.timeshiftl2.place(x=120,y=270)
		self.timeshiftl2.config(text ="Time Shift")

		self.selectionl2=''
		self.l2=0
		self.scalel2=Scale(self.root,orient='horizontal',length=200,command=self.print_valuel2,from_=-1.0,to=1.0,tickinterval=0.5,resolution=0.5)
		self.scalel2.pack()
		self.scalel2.place(x=210,y=260)

		self.timescalel3=Label(self.root)
		self.timescalel3.pack()
		self.timescalel3.place(x=120,y=320)
		self.timescalel3.config(text ="Time Scale")

		self.selectionl3=''
		self.l3=0
		self.scalel3=Scale(self.root,orient='horizontal',command=self.print_valuel3,from_=0,to=8,length=300,tickinterval=0.125,resolution=0.125)
		self.scalel3.pack()
		self.scalel3.place(x=210,y=320)

		self.var1= IntVar()
		self.sl1=0
		self.var1.trace_variable('w', self.show1)
		self.Cl1 = Checkbutton(self.root, text = "time reversal",onvalue=1,offvalue=0, variable =self.var1)
		self.Cl1.pack()
		self.Cl1.place(x=150,y=375)

		self.var2= IntVar()
		self.sl2=0
		self.var2.trace_variable('w', self.show2)
		self.Cl2 = Checkbutton(self.root, text = "select for modulation",onvalue=1,offvalue=0, variable =self.var2)
		self.Cl2.pack()
		self.Cl2.place(x=150,y=420)


		self.var3= IntVar()
		self.sl3=0
		self.var3.trace_variable('w', self.show3)
		self.Cl3 = Checkbutton(self.root, text = "select for mixing",onvalue=1,offvalue=0, variable =self.var3)
		self.Cl3.pack()
		self.Cl3.place(x=150,y=470)

###################################


		self.buttonbrm = Button(self.root, text="Select File", command=self.showm1)
		self.buttonbrm.pack()
		self.buttonbrm.place(x=470,y=170)
		self.browsem1=Label(self.root)
		self.browsem1.pack()
		self.browsem1.place(x=570,y=170)

		self.wave2=Label(self.root)
		self.wave2.pack()
		self.wave2.place(x=470,y=120)
		self.wave2.config(text ="WAVE 2")

		self.labelampm=Label(self.root)
		self.labelampm.pack()
		self.labelampm.place(x=470,y=220)
		self.labelampm.config(text ="Amplitude")
		self.selectionm1=''
		self.m1=1
		self.scalem1=Scale(self.root,orient='horizontal',command=self.print_valuem1,from_=0,to=5)
		self.scalem1.pack()
		self.scalem1.place(x=570,y=220)

		self.timeshiftm2=Label(self.root)
		self.timeshiftm2.pack()
		self.timeshiftm2.place(x=470,y=270)
		self.timeshiftm2.config(text ="Time Shift")
		self.selectionm2=''
		self.m2=0
		self.scalem2=Scale(self.root,orient='horizontal',command=self.print_valuem2,length=200,from_=-1.0,to=1.0,tickinterval=0.5,     resolution=0.5)
		self.scalem2.pack()
		self.scalem2.place(x=570,y=260)

		self.timescalem3=Label(self.root)
		self.timescalem3.pack()
		self.timescalem3.place(x=470,y=320)
		self.timescalem3.config(text ="Time Scale")
		self.selectionm3=''
		self.m3=0
		self.scalem3=Scale(self.root,orient='horizontal',command=self.print_valuem3,from_=0.0,to=8.0,length=300,tickinterval=0.125,resolution=0.125)
		self.scalem3.pack()
		self.scalem3.place(x=570,y=320)

		self.var4= IntVar()
		self.sm1=0
		self.var4.trace_variable('w',self.show4)
		self.Cl4 = Checkbutton(self.root, text = "time reversal",onvalue=1,offvalue=0, variable =self.var4)
		self.Cl4.pack()
		self.Cl4.place(x=470,y=375)

		self.var5= IntVar()
		self.sm2=0
		self.var5.trace_variable('w', self.show5)
		self.Cl5 = Checkbutton(self.root, text = "select for modulation",onvalue=1,offvalue=0, variable =self.var5)
		self.Cl5.pack()
		self.Cl5.place(x=470,y=420)


		self.var6= IntVar()
		self.sm3=0
		self.var6.trace_variable('w', self.show6)
		self.Cl6 = Checkbutton(self.root, text = "select for mixing",onvalue=1,offvalue=0, variable =self.var6)
		self.Cl6.pack()
		self.Cl6.place(x=470,y=470)

		self.f2=0


#################################################



		self.buttonbrr = Button(self.root, text="Select File", command=self.showr1)
		self.buttonbrr.pack()
		self.buttonbrr.place(x=820,y=170)
		self.browser1=Label(self.root)
		self.browser1.pack()
		self.browser1.place(x=920,y=170)

		self.wave3=Label(self.root)
		self.wave3.pack()
		self.wave3.place(x=820,y=120)
		self.wave3.config(text ="WAVE 3")

		self.labelampr=Label(self.root)
		self.labelampr.pack()
		self.labelampr.place(x=820,y=220)
		self.labelampr.config(text ="Amplitude")
		self.selectionr1=''
		self.r1=1
		self.scaler1=Scale(self.root,orient='horizontal',command=self.print_valuer1,from_=0,to=5)
		self.scaler1.pack()
		self.scaler1.place(x=910,y=220)

		self.timeshiftr2=Label(self.root)
		self.timeshiftr2.pack()
		self.timeshiftr2.place(x=820,y=270)
		self.timeshiftr2.config(text ="Time Shift")
		self.selectionr2=''
		self.r2=0
		self.scaler2=Scale(self.root,orient='horizontal',command=self.print_valuer2,length=200,from_=-1.0,to=1.0,tickinterval=0.5,     resolution=0.51)
		self.scaler2.pack()
		self.scaler2.place(x=910,y=260)

		self.timescaler3=Label(self.root)
		self.timescaler3.pack()
		self.timescaler3.place(x=820,y=320)
		self.timescaler3.config(text ="Time Scale")
		self.selectionr3=''
		self.r3=0
		self.scaler3=Scale(self.root,orient='horizontal',command=self.print_valuer3,from_=0,to=8,length=300,tickinterval=0.5,resolution=0.5)
		self.scaler3.pack()
		self.scaler3.place(x=910,y=320)

		self.var7= IntVar()
		self.sr1=0
		self.var7.trace_variable('w', self.show7)
		self.Cr1 = Checkbutton(self.root, text = "time reversal",onvalue=1,offvalue=0, variable =self.var7)
		self.Cr1.pack()
		self.Cr1.place(x=820,y=375)

		self.var8= IntVar()
		self.sr2=0
		self.var8.trace_variable('w', self.show8)
		self.Cr2 = Checkbutton(self.root, text = "select for modulation",onvalue=1,offvalue=0, variable =self.var8)
		self.Cr2.pack()
		self.Cr2.place(x=820,y=420)


		self.var9= IntVar()
		self.sr3=0
		self.var9.trace_variable('w', self.show9)
		self.Cr3 = Checkbutton(self.root, text = "select for mixing",onvalue=1,offvalue=0, variable =self.var9)
		self.Cr3.pack()
		self.Cr3.place(x=820,y=470)





		self.f1=0



		self.buttonl5 = Button(self.root, text="Play", command=self.getvalue1)
		self.buttonl5.pack()
		self.buttonl5.place(x=120,y=520)
		self.buttonl6 = Button(self.root, text="Pause", command=self.getpausevalue1)
		self.buttonl6.pack()
		self.buttonl6.place(x=220,y=520)
		self.buttonl7 = Button(self.root, text="Stop", command=self.getstopvalue1)
		self.buttonl7.pack()
		self.buttonl7.place(x=320,y=520)
		
		self.buttonm5 = Button(self.root, text="Play", command=self.getvalue2)
		self.buttonm5.pack()
		self.buttonm5.place(x=470,y=520)
		self.buttonm6 = Button(self.root, text="Pause", command=self.getpausevalue2)
		self.buttonm6.pack()
		self.buttonm6.place(x=570,y=520)
		self.buttonm7 = Button(self.root, text="Stop", command=self.getstopvalue2)
		self.buttonm7.pack()
		self.buttonm7.place(x=670,y=520)


		self.buttonr5 = Button(self.root, text="Play", command=self.getvalue3)
		self.buttonr5.pack()
		self.buttonr5.place(x=820,y=520)
		self.buttonr6 = Button(self.root, text="Pause", command=self.getpausevalue3)
		self.buttonr6.pack()
		self.buttonr6.place(x=920,y=520)
		self.buttonr7 = Button(self.root, text="Stop", command=self.getstopvalue3)
		self.buttonr7.pack()
		self.buttonr7.place(x=1020,y=520)

		self.buttonmodulate = Button(self.root, text="Modulate & Play", command=self.modulate)
		self.buttonmodulate.pack()
		self.buttonmodulate.place(x=220,y=670)

		self.buttonmix = Button(self.root, text="Mix & Play", command=self.mix)
		self.buttonmix.pack()
		self.buttonmix.place(x=520,y=670)
		self.value=0
		
		self.rec = Button(self.root, text="Record", command=self.readytorecord)
		self.rec.pack()
		self.rec.place(x=820,y=670)

		
		
		self.pausevalue=' '

		self.pausevalue1=0
		self.pausevalue2=0
		self.pausevalue3=0
		self.stopvalue1=0
		self.stopvalue2=0
		self.stopvalue3=0


	def readytorecord(self):
		r=RECORD()
		r.record_to_file("recorded.wav")

	def modulate(self):
		global mod
		mod=[None]*3
		f1=0
		f2=0
		f3=0
		if self.sl2:
			if len(mod)>0:
				for i in range(len(mod)):
					if mod[i]==filename1:
						f1=1
				if f1==0:
					mod[0]=filename1
					a[0]=float(self.l1)
					tsc[0]=float(self.l2)
					tsh[0]=float(self.l3)
					r[0]=float(self.sl1)
			else:
				mod[0]=(filename1)
				a[0]=float(self.l1)
				tsc[0]=float(self.l2)
				tsh[0]=float(self.l3)
				r[0]=float(self.sl1)

		if self.sm2:
			if len(mod)>0:
				for i in range(len(mod)):
					if mod[i]==filename2:
						f2=1
				if f2==0:
					mod[1]=(filename2)
					a[1]=float(self.m1)
					tsc[1]=float(self.m2)
					tsh[1]=float(self.m3)
					r[1]=float(self.sm1)

			else:
				mod[1]=filename2
				a[1]=float(self.m1)
				tsc[1]=float(self.m2)
				tsh[1]=float(self.m3)
				r[1]=float(self.sm1)
		if self.sr2:
			if len(mod)>0:
				for i in range(len(mod)):
					if mod[i]==filename3:
						f3=1
				if f3==0:
					mod[2]=(filename3)
					a[2]=float(self.r1)
					tsc[2]=float(self.r2)
					tsh[2]=float(self.r3)
					r[2]=float(self.sr1)
			else:
				mod[2]=(filename1)
				a[2]=float(self.r1)
				tsc[2]=float(self.r2)
				tsh[2]=float(self.r3)
				r[2]=float(self.sr1)
		modfunc()
	def mix(self):
		global mix
		mix=[None]*3
		f1=0
		f2=0
		f3=0

		if self.sl3:
			if len(mix)>0:
				for i in range(len(mix)):
					if mix[i]==filename1:
						f1=1
				if f1==0:
					mix[0]=filename1
					a[0]=float(self.l1)
					tsc[0]=float(self.l2)
					tsh[0]=float(self.l3)
					r[0]=float(self.sl1)
			else:
				mix[0]=(filename1)
				a[0]=float(self.l1)
				tsc[0]=float(self.l2)
				tsh[0]=float(self.l3)
				r[0]=float(self.sl1)

		if self.sm3:
			if len(mix)>0:
				for i in range(len(mix)):
					if mix[i]==filename2:
						f2=1
				if f2==0:
					mix[1]=filename2
					a[1]=float(self.m1)
					tsc[1]=float(self.m2)
					tsh[1]=float(self.m3)
					r[1]=float(self.sm1)

			else:
				mix[1]=filename2
				a[1]=float(self.m1)
				tsc[1]=float(self.m2)
				tsh[1]=float(self.m3)
				r[1]=float(self.sm1)
		if self.sr3:
			if len(mix)>0:
				for i in range(len(mix)):
					if mix[i]==filename3:
						f3=1
				if f3==0:
					mix[2]=(filename3)
					a[2]=float(self.r1)
					tsc[2]=float(self.r2)
					tsh[2]=float(self.r3)
					r[2]=float(self.sr1)
			else:
				mix[2]=(filename3)
				a[2]=float(self.r1)
				tsc[2]=float(self.r2)
				tsh[2]=float(self.r3)
				r[2]=float(self.sr1)
		mixfunc()

	def showl1(self):
		global filename1
		filename1 = tkFileDialog.askopenfilename(filetypes = [('wave files', '*.wav'), ('text files', '.txt')])
		self.browsel1.config(text=filename1)
		selected[0]=filename1
		return filename1
	def print_valuel1(self,val):
		self.l1=val
	def print_valuel2(self,val):
		self.l2=val
	def print_valuel3(self,val):
		self.l3=val
	def show1(self,*args):
		self.sl1=self.var1.get()
	def show2(self,*args):
		self.sl2=self.var2.get()
	def show3(self,*args):
		self.sl3=self.var3.get()
	def showm1(self):
		global filename2
		filename2 = tkFileDialog.askopenfilename()
		selected[1]=filename2
		self.browsem1.config(text=filename2)
		return filename2
	def print_valuem2(self,val):
		self.m2=val
	def print_valuem1(self,val):
		self.m1=val
	def print_valuem3(self,val):
		self.m3=val
	def show4(self,*args):
		self.sm1=self.var4.get()
	def show5(self,*args):
		self.sm2=self.var5.get()
	def show6(self,*args):
		self.sm3=self.var6.get()
	def showr1(self):
		global filename3
		filename3 = tkFileDialog.askopenfilename()
		selected[2]=filename3
		self.browser1.config(text=filename3)
		return filename3
	def print_valuer2(self,val):
		self.r2=val
	def print_valuer1(self,val):
		self.r1=val
	def show7(self,*args):
		self.sr1=self.var7.get()
	def print_valuer3(self,val):
		self.r3=val
	def show8(self,*args):
		self.sr2=self.var8.get()
	def show9(self,*args):
		self.sr3=self.var9.get()
	def getvalue1(self):
		self.value=0
		self.play1(self.value)
	def getpausevalue1(self):
		self.pausevalue=0
		self.pause1(self.pausevalue)
	def getpausevalue2(self):
		self.pausevalue=1
		self.pause1(self.pausevalue)
	def getpausevalue3(self):
		self.pausevalue=2
		self.pause1(self.pausevalue)
	def getstopvalue1(self):
		self.stopvalue=0
		self.stop1(self.stopvalue)
	def getstopvalue2(self):
		self.stopvalue=1
		self.stop1(self.stopvalue)
	def getstopvalue3(self):
		self.stopvalue=2
		self.stop1(self.stopvalue)
	def getvalue2(self):
		self.value=1
		self.play1(self.value)
	def getvalue3(self):
		self.value=2
		self.play1(self.value)

	def play1(self,value):
		s2=float(self.l2)
		s3=float(self.l3)
		mix=[]
		modulate=[]
		if value==0:
			file1=mixer(selected[value])

			amp=float(self.l1)

			file1.amp1(amp)

			timeshiftby=s2

			file1.shift(timeshiftby)
			self.pausevalue=0
			self.stopvalue=0
			scaleby=s3
			file1.scale(scaleby)
			if self.sl1:
				file1.reverse1()

			file1.write1('output1.wav')
			self.playf('output1.wav')

		elif value==1:
			file2=mixer(selected[value])
			amp=float(self.m1)
			file2.amp1(amp)
			s5=float(self.m2)
			timeshiftby=s5
			file2.shift(timeshiftby)
			self.pausevalue=1
			self.stopvalue=1
			s6=float(self.m3)
			scaleby=s6
			file2.scale(scaleby)
			if self.sm1:
				file2.reverse1()

			file2.write1('output2.wav')
			self.playf('output2.wav')

		if value==2:
			file3=mixer(selected[value])
			amp=float(self.r1)
			file3.amp1(amp)
			s8=float(self.r2)	
			timeshiftby=s8
			file3.shift(timeshiftby)
			self.pausevalue=2
			self.stopvalue=2
			s9=float(self.r3)
			scaleby=s9
			file3.scale(scaleby)
			if self.sr1:
				file3.reverse1()

			file3.write1('output3.wav')
			self.playf('output3.wav')

	def stop1(self,value):
		if value==0:
			if self.playing1==1 or self.pausevalue==0:
				os.kill(self.pid1,9)
		if value==1:
			if self.playing2==1 or self.pausevalue==1:
				os.kill(self.pid2,9)
		if value==2:
			if self.playing3==1 or self.pausevalue==2:
				os.kill(self.pid3,9)

	def pause1(self,value):
		if value==0:
			if self.playing1==1:
				os.kill(self.pid1,signal.SIGSTOP)
				self.paused1=1
				self.playing1=0
		if value==1:
			if self.playing2==1:
				os.kill(self.pid2,signal.SIGSTOP)
				self.paused2=1
				self.playing2=0
		if value==2:
			if self.playing3==1:
				os.kill(self.pid3,signal.SIGSTOP)
				self.paused3=1
				self.playing3=0



	def playf(self,out):
		played=0.0
		if self.pausevalue==0:
			if self.paused1==1:
				os.kill(self.pid1,signal.SIGCONT)
				self.playing1=1
				self.paused1=0
			else:
				self.playing1=1
				Chunk=1024
				self.pid1=os.fork()
				if self.pid1==0:
					f = wave.open(out,'rb')  
					pl = pyaudio.PyAudio()  
					stream = pl.open(format = pl.get_format_from_width(f.getsampwidth()),channels = f.getnchannels(),rate = f.getframerate(), output = True)  
					data = f.readframes(Chunk)  
					while data != '':  
						stream.write(data)  
						data = f.readframes(Chunk)  
					stream.stop_stream()  
					stream.close()  
					pl.terminate()
					exit(0)
		if self.pausevalue==1:
			if self.paused2==1:
				os.kill(self.pid2,signal.SIGCONT)
				self.playing2=1
				self.paused2=0
			else:
				self.playing2=1
				Chunk=1024
				self.pid2=os.fork()
				if self.pid2==0:
					f = wave.open(out,'rb')  
					pl = pyaudio.PyAudio()  
					stream = pl.open(format = pl.get_format_from_width(f.getsampwidth()),channels = f.getnchannels(),rate = f.getframerate(), output = True)  
					data = f.readframes(Chunk)  
		
					while data != '':  
						stream.write(data)  
						data = f.readframes(Chunk)  
					stream.stop_stream()  
					stream.close()  
					pl.terminate()
					exit(0)
		if self.pausevalue==2:
			if self.paused3==1:
				os.kill(self.pid3,signal.SIGCONT)
				self.playing3=1
				self.paused3=0
			else:
				self.playing3=1
				Chunk=1024
				self.pid3=os.fork()
				if self.pid3==0:
					f = wave.open(out,'rb')  
					pl = pyaudio.PyAudio()  
					stream = pl.open(format = pl.get_format_from_width(f.getsampwidth()),channels = f.getnchannels(),rate = f.getframerate(), output = True)  
					data = f.readframes(Chunk)  
		
					while data != '':  
						stream.write(data)  
						data = f.readframes(Chunk)  
					stream.stop_stream()  
					stream.close()  
					pl.terminate()
					exit(0)



	def main(self):
		self.root.mainloop()
def FileInfo():
   top = tk.Tk()
   top.title("File and Device Info")
   checkCmd1 = IntVar()
   checkCmd2 = IntVar()
   checkCmd3 = IntVar()
   checkCmd4 = IntVar()
   checkCmd5 = IntVar()
   checkCmd6 = IntVar()
   checkCmd7 = IntVar()
   checkCmd8 = IntVar()
   checkCmd9 = IntVar()
   w = 1050
   h = 320
   x = 10
   y = 50
   
   def cbcommand1():
      checkCmd1.set(not checkCmd1.get())
   def cbcommand2():
      checkCmd2.set(not checkCmd2.get())
   def cbcommand3():
      checkCmd3.set(not checkCmd3.get())
   def cbcommand4():
      checkCmd4.set(not checkCmd4.get())
   def cbcommand5():
      checkCmd5.set(not checkCmd5.get())
   def cbcommand6():
      checkCmd6.set(not checkCmd6.get())
   def cbcommand7():
      checkCmd7.set(not checkCmd7.get())
   def cbcommand8():
      checkCmd8.set(not checkCmd8.get())
   def cbcommand9():
      checkCmd9.set(not checkCmd9.get())

   def ADD_PDOCallBack():
      if((TPDO.get() == '') or (RPDO.get() == '')):
         tkMessageBox.showinfo("Info", "Invalid PDO information !!")
      elif((int(TPDO.get()) < 4) or (int(RPDO.get()) < 4)):
         tkMessageBox.showinfo("Info", "Minimum of 4 PDOs should be added")
      elif( (int(TPDO.get()) > 15) or (int(RPDO.get()) > 15) ):
         tkMessageBox.showinfo("Info", "Maximum of 15 PDOs only supported by this tool")
      else:
         for i in range(0,int(TPDO.get())):
            selected_index.append('180'+str(hex(i).split('x')[1]).upper())
            lb1.insert("end", '180'+str(hex(i).split('x')[1]).upper()+'  Transmit PDO Communication Parameter '+str(i))
         for i in range(0,int(TPDO.get())):
            selected_index.append('1A0'+str(hex(i).split('x')[1]).upper())
            lb1.insert("end", '1A0'+str(hex(i).split('x')[1]).upper()+'  Transmit PDO Mapping Parameter '+str(i))
         for i in range(0,int(RPDO.get())):
            selected_index.append('140'+str(hex(i).split('x')[1]).upper())
            lb1.insert("end", '140'+str(hex(i).split('x')[1]).upper()+'  Receive PDO Communication Parameter '+str(i))
         for i in range(0,int(RPDO.get())):
            selected_index.append('160'+str(hex(i).split('x')[1]).upper())
            lb1.insert("end", '160'+str(hex(i).split('x')[1]).upper()+'  Receive PDO Mapping Parameter '+str(i))
         tkMessageBox.showinfo("Info", "PDOs Added")
      
   top.geometry("%dx%d+%d+%d" % (w, h, x, y))
   group1 = tk.LabelFrame(top, text="File Information").grid(row=0, columnspan=7, sticky='W',padx=5, pady=5, ipadx=140, ipady=120)
   Label(top,text="File Name : ").place(x=20,y=70)
   FileName = tk.Entry(top, width=25)
   FileName.pack()
   FileName.place(x=110,y=70)
   FileName.insert(0,"CANopen.eds")
   Label(top,text="File Version : ").place(x=20,y=100)
   FileVersion = tk.Entry(top, width=25)
   FileVersion.pack()
   FileVersion.place(x=110,y=100)
   Label(top,text="File Revision : ").place(x=20,y=130)
   FileRevision = tk.Entry(top, width=25)
   FileRevision.pack()
   FileRevision.place(x=110,y=130)
   Label(top,text="Description : ").place(x=20,y=160)
   Description = tk.Entry(top, width=25)
   Description.pack()
   Description.place(x=110,y=160)
   Label(top,text="Author : ").place(x=20,y=190)
   Author = tk.Entry(top, width=25)
   Author.pack()
   Author.place(x=110,y=190)

   group2 = tk.LabelFrame(top, text="Device Information").grid(row=0, columnspan=7, sticky='W',padx=305, pady=5, ipadx=150, ipady=120)
   Label(top,text="Vendor Name : ").place(x=320,y=70)
   VendorName = tk.Entry(top, width=25)
   VendorName.pack()
   VendorName.place(x=430,y=70)
   Label(top,text="Vendor Number : ").place(x=320,y=100)
   VendorNumber = tk.Entry(top, width=25)
   VendorNumber.pack()
   VendorNumber.place(x=430,y=100)
   Label(top,text="Product Name : ").place(x=320,y=130)
   ProductName = tk.Entry(top, width=25)
   ProductName.pack()
   ProductName.place(x=430,y=130)
   Label(top,text="Product Number : ").place(x=320,y=160)
   ProductNumber = tk.Entry(top, width=25)
   ProductNumber.pack()
   ProductNumber.place(x=430,y=160)
   Label(top,text="Revision Number : ").place(x=320,y=190)
   RevisionNumber = tk.Entry(top, width=25)
   RevisionNumber.pack()
   RevisionNumber.place(x=430,y=190)
   Label(top,text="Order Code : ").place(x=320,y=220)
   OrderCode = tk.Entry(top, width=25)
   OrderCode.pack()
   OrderCode.place(x=430,y=220)

   group3 = tk.LabelFrame(top, text="Supported Bit Rate").grid(row=0, columnspan=7, sticky='W',padx=650, pady=5, ipadx=80, ipady=150)
   checkBox1 = Checkbutton(top, variable=checkCmd1, text="10k Bit/Sec", command=cbcommand1)
   checkBox1.pack()
   checkBox1.place(x=700,y=20)
   checkBox2 = Checkbutton(top, variable=checkCmd2, text="20k Bit/Sec", command=cbcommand2)
   checkBox2.pack()
   checkBox2.place(x=700,y=50)
   checkBox3 = Checkbutton(top, variable=checkCmd3, text="50k Bit/Sec", command=cbcommand3)
   checkBox3.pack()
   checkBox3.place(x=700,y=80)
   checkBox4 = Checkbutton(top, variable=checkCmd4, text="100k Bit/Sec", command=cbcommand4)
   checkBox4.pack()
   checkBox4.place(x=700,y=110)
   checkBox5 = Checkbutton(top, variable=checkCmd5, text="125k Bit/Sec", command=cbcommand5)
   checkBox5.pack()
   checkBox5.place(x=700,y=140)
   checkBox6 = Checkbutton(top, variable=checkCmd6, text="250k Bit/Sec", command=cbcommand6)
   checkBox6.pack()
   checkBox6.place(x=700,y=170)
   checkBox7 = Checkbutton(top, variable=checkCmd7, text="500k Bit/Sec", command=cbcommand7)
   checkBox7.pack()
   checkBox7.place(x=700,y=200)
   checkBox8 = Checkbutton(top, variable=checkCmd8, text="800k Bit/Sec", command=cbcommand8)
   checkBox8.pack()
   checkBox8.place(x=700,y=230)
   checkBox9 = Checkbutton(top, variable=checkCmd9, text="1000k Bit/Sec", command=cbcommand9)
   checkBox9.pack()
   checkBox9.place(x=700,y=260)

   group4 = tk.LabelFrame(top, text="Number of PDOs").grid(row=0, columnspan=7, sticky='W',padx=850, pady=5, ipadx=80, ipady=80)
   Label(top,text="Transmit PDOs").place(x=890,y=100)
   TPDO = tk.Entry(top, width=10)
   TPDO.pack()
   TPDO.place(x=900,y=120)
   Label(top,text="Receive PDOs").place(x=890,y=170)
   RPDO = tk.Entry(top, width=10)
   RPDO.pack()
   RPDO.place(x=900,y=190)

   ADD = tk.Button(top, text ="Add PDOs", command = ADD_PDOCallBack)
   ADD.pack()
   ADD.place(x=900,y=250)

   def SaveClose():
      FILE_info[0] = (FileName.get())
      FILE_info[1] = (FileVersion.get())
      FILE_info[2] = (FileRevision.get())
      FILE_info[3] = (Description.get())
      FILE_info[4] = (Author.get())
      DEVICE_info[0] = (VendorName.get())
      DEVICE_info[1] = (VendorNumber.get())
      DEVICE_info[2] = (ProductName.get())
      DEVICE_info[3] = (ProductNumber.get())
      DEVICE_info[4] = (RevisionNumber.get())
      DEVICE_info[5] = (OrderCode.get())
      PDO_info[0] = TPDO.get()
      PDO_info[1] = RPDO.get()
      BAUD_info[0] = str(checkCmd1.get())
      BAUD_info[1] = str(checkCmd2.get())
      BAUD_info[2] = str(checkCmd3.get())
      BAUD_info[3] = str(checkCmd4.get())
      BAUD_info[4] = str(checkCmd5.get())
      BAUD_info[5] = str(checkCmd6.get())
      BAUD_info[6] = str(checkCmd7.get())
      BAUD_info[7] = str(checkCmd8.get())
      BAUD_info[8] = str(checkCmd9.get())
      tkMessageBox.showinfo("Info", "Closing File and Device Info Window")
      top.destroy()
   
   SaveButton = tk.Button(top, text="Save & Close", command=SaveClose)
   SaveButton.place(x=330,y=280)
   top.mainloop()      
예제 #16
0
    def initUI(self):
        self.parent.title("Cravis_ver1")
        self.pack(fill=BOTH, expand=1)
        frame = Frame(self,
                      width=1500,
                      height=200,
                      relief=RAISED,
                      borderwidth=1)
        frame.pack(expand=False)
        #frame.config(bg="blue")
        self.pack(expand=False)
        #####

        #####

        frame2 = Frame(self,
                       width=1500,
                       height=300,
                       relief=RAISED,
                       borderwidth=1)
        frame2.pack(expand=False)
        self.pack(expand=False)

        self.var0 = BooleanVar()
        self.var1 = BooleanVar()
        self.var2 = BooleanVar()
        self.var3 = BooleanVar()
        self.var4 = BooleanVar()
        self.var5 = BooleanVar()
        self.content = IntVar()

        reset_Area_Button = Button(self,
                                   width=10,
                                   text="reset_Area",
                                   command=self.reset_Area)
        reset_Area_Button.place(x=610, y=400)

        set_Area_Button = Button(self,
                                 width=10,
                                 text="set_Area",
                                 command=self.set_Area)
        set_Area_Button.place(x=610, y=430)

        show_Area_Button = Button(self,
                                  width=10,
                                  text="show_Area",
                                  command=self.show_Area)
        show_Area_Button.place(x=610, y=460)

        quitButton = Button(self, text="Quit", command=self.off_video)
        quitButton.place(x=50, y=20)

        startButton = Button(self, text="Video", command=self.on_start)
        startButton.place(x=100, y=20)

        TakePicButton = Button(self, text="TakePic", command=self.Takepic)
        TakePicButton.place(x=150, y=20)

        LoadDataButton = Button(self,
                                text="Load_Data",
                                bg="green",
                                command=self.confirm_LoadData)
        LoadDataButton.place(x=550, y=90)

        SaveDataButton = Button(self,
                                text="Save_Data",
                                bg="green",
                                command=self.confirm_SaveData)
        SaveDataButton.place(x=550, y=120)
        ######

        cb1 = Checkbutton(self,
                          text="Binary",
                          variable=self.var1,
                          command=self.on_Binary)
        cb1.place(x=80, y=50)

        cb2 = Checkbutton(self,
                          text="Partical",
                          variable=self.var2,
                          command=self.on_Partical)
        cb2.place(x=80, y=80)

        cb3 = Checkbutton(self,
                          text="Sobel",
                          variable=self.var3,
                          command=self.on_Sobel)
        cb3.place(x=80, y=110)

        cb4 = Checkbutton(self,
                          text="Median",
                          variable=self.var4,
                          command=self.on_Median)
        cb4.place(x=80, y=140)

        cb5 = Checkbutton(self,
                          text="Level_Adjust",
                          variable=self.var5,
                          command=self.on_LevelAdjust)
        cb5.place(x=80, y=170)

        cb5 = Checkbutton(self, text="SaveImage", variable=self.var0)
        cb5.place(x=550, y=20)
        #####

        ###################################

        AdjustBinaryButton = Button(self,
                                    text="Adjust_Binary",
                                    command=self.AdjustBinary)
        AdjustBinaryButton.place(x=340, y=50)

        AdjustExtractButton = Button(self,
                                     text="Adjust_Extract",
                                     command=self.AdjustExtract)
        AdjustExtractButton.place(x=340, y=80)

        AdjustBinaryButton = Button(self,
                                    text="Adjust_3",
                                    command=self.AdjustBinary)
        AdjustBinaryButton.place(x=340, y=110)

        AdjustExtractButton = Button(self,
                                     text="Adjust_4",
                                     command=self.AdjustExtract)
        AdjustExtractButton.place(x=340, y=140)

        AdjustExtractButton = Button(self,
                                     text="Adjust_5",
                                     command=self.AdjustExtract)
        AdjustExtractButton.place(x=340, y=170)

        ########
        self.infor_Alg1 = Text(self, width=40, height=1)
        #self.infor_Alg1.pack(side=LEFT)
        self.infor_Alg1.place(x=130, y=250)
        #thongtin_Alg1="Binary : "
        #self.infor_Alg1.insert(END,thongtin_Alg1)
        self.label_Alg1 = Label(self, text="Binary: ")
        self.label_Alg1.place(x=50, y=250)
        ##
        self.infor_Alg2 = Text(self, width=40, height=1)
        #self.infor_Alg2.pack(side=LEFT)
        self.infor_Alg2.place(x=130, y=270)

        #thongtin_Alg2="Extract : "
        #self.infor_Alg2.insert(END,thongtin_Alg2)
        self.label_Alg2 = Label(self, text="Extract: ")
        self.label_Alg2.place(x=50, y=270)
        ##
        self.infor_Alg3 = Text(self, width=40, height=1)
        #self.infor_Alg3.pack()
        self.infor_Alg3.place(x=130, y=290)
        #thongtin_Alg3="Alg_3 : "
        #self.infor_Alg3.insert(END,thongtin_Alg3)
        self.label_Alg3 = Label(self, text="Alg3: ")
        self.label_Alg3.place(x=50, y=290)
        ##
        self.infor_Alg4 = Text(self, width=40, height=1)
        #self.infor_Alg4.pack(side=LEFT)
        self.infor_Alg4.place(x=130, y=310)
        #thongtin_Alg4="Alg_4 : "
        #self.infor_Alg4.insert(END,thongtin_Alg4)
        self.label_Alg4 = Label(self, text="Alg4: ")
        self.label_Alg4.place(x=50, y=310)
        ##
        self.infor_Alg5 = Text(self, width=40, height=1)
        #self.infor_Alg5.pack()
        self.infor_Alg5.place(x=130, y=330)
        #thongtin_Alg5="Alg_5 : "
        #self.infor_Alg5.insert(END,thongtin_Alg5)
        self.label_Alg5 = Label(self, text="Alg5: ")
        self.label_Alg5.place(x=50, y=330)
        ##

        self.infor_Area1 = Text(self, width=20, height=1)
        self.infor_Area1.place(x=100, y=400)
        #thongtin_Area1="Area1:"
        #self.infor_Area1.insert(END,thongtin_Area1)
        self.label_Area1 = Label(self, text="Area1: ")
        self.label_Area1.place(x=50, y=400)

        ##
        self.infor_Area2 = Text(self, width=20, height=1)
        self.infor_Area2.place(x=350, y=400)
        #thongtin_Area2="Area2:"
        #self.infor_Area2.insert(END,thongtin_Area2)
        self.label_Area2 = Label(self, text="Area2: ")
        self.label_Area2.place(x=300, y=400)
        ##
        self.infor_Area3 = Text(self, width=20, height=1)
        self.infor_Area3.place(x=100, y=450)
        #thongtin_Area3="Area3:"
        #self.infor_Area3.insert(END,thongtin_Area3)
        self.label_Area3 = Label(self, text="Area3: ")
        self.label_Area3.place(x=50, y=450)
        ##
        self.infor_Area4 = Text(self, width=20, height=1)
        self.infor_Area4.place(x=350, y=450)
        #thongtin_Area4="Area4:"
        #self.infor_Area4.insert(END,thongtin_Area4)
        self.label_Area4 = Label(self, text="Area4: ")
        self.label_Area4.place(x=300, y=450)
        #####

        ################################
        self.infor = Text(self, width=50, height=2)
        self.infor.pack()
        thongtin = "CHAO MUNG DEN VOI CHUONG TRINH CRAVIS_V1  \n DESIGN BY VISUAL GROUP"
        self.infor.insert(END, thongtin)

        ###################################

        menuBar = Menu(self.parent)
        self.parent.config(menu=menuBar)

        fileMenu1 = Menu(menuBar)
        fileMenu2 = Menu(menuBar)
        fileMenu3 = Menu(menuBar)

        fileMenu1.add_command(label="zoom", command=self.zoom)
        fileMenu1.add_command(label="password", command=self.zoom)
        fileMenu1.add_command(label="2", command=self.onExit)
        fileMenu1.add_command(label="3", command=self.onExit)

        fileMenu2.add_command(label="Exit", command=self.onExit)
        fileMenu2.add_command(label="1", command=self.onExit)
        fileMenu2.add_command(label="2", command=self.onExit)
        fileMenu2.add_command(label="3", command=self.onExit)

        fileMenu3.add_command(label="help", command=self.file_help)
        fileMenu3.add_command(label="1", command=self.onExit)
        fileMenu3.add_command(label="2", command=self.onExit)
        fileMenu3.add_command(label="3", command=self.onExit)

        menuBar.add_cascade(label="File", menu=fileMenu1)
        menuBar.add_cascade(label="Infor", menu=fileMenu2)
        menuBar.add_cascade(label="Help", menu=fileMenu3)
예제 #17
0
class SkyglowEstimationToolbox:
    """Main class that establishes GUI."""
    def __init__(self, root):
        self.root = root

        # Radio action buttons
        self.action = None
        self.sgmap_single_btn, self.krn_lib_btn, self.multi_map_btn = None, None, None

        self.file_log_var = StringVar()
        self.csv_file_var = StringVar()
        self.krn_folder_var = StringVar()
        self.output_folder_var = StringVar()
        self.sgmap_folder_var = StringVar()

        self.krn_ent_var = StringVar()
        self.krn_var, self.hem_var = IntVar(), IntVar()
        self.img, self.cdiag = None, None
        self.lat_lbl, self.lat_entry = None, None
        self.k_lbl, self.k_entry = None, None
        self.zen_lbl, self.zen_entry = None, None
        self.azi_lbl, self.azi_entry = None, None
        self.krn_lvl, self.krn_entry, self.krn_btn = None, None, None
        self.txt_redir, self.prg_log = None, None
        self.map_btn, self.gen_krn_btn = None, None

        # Sets window title, size, and icon on screen.
        self.root.title("Skyglow Estimation Toolbox (SET)")
        self.root.geometry('%dx%d+%d+%d' %
                           (constants.SW * 0.75, constants.SH * 0.75, 25, 25))
        self.root.iconbitmap(os.path.join(os.getcwd(), constants.ICO))
        self.root.resizable(False, False)
        self.root.update_idletasks()

        # Creates three paned windows for the main screen.
        base = PanedWindow()
        base.pack(fill=BOTH, expand=1)
        sub1 = PanedWindow(base,
                           orient=VERTICAL,
                           height=self.root.winfo_height() * 3 / 4)
        base.add(sub1)
        sub2 = PanedWindow(sub1,
                           orient=HORIZONTAL,
                           height=self.root.winfo_height() / 5)
        sub1.add(sub2)

        # Creates frame for holding inputs.
        self.input_frame = Frame(sub2)
        sub2.add(self.input_frame)

        # Creates frame for bottom half of main screen.
        self.img_frame = Frame(sub1, bd=2, bg='white', relief="sunken")
        sub1.add(self.img_frame)

        # Creates canvas for displaying images.
        self.img_canvas = Canvas(self.img_frame,
                                 bd=2,
                                 relief="groove",
                                 width=constants.SW * 0.6,
                                 height=self.root.winfo_height() * 3 / 4 * 0.9)
        self.img_canvas.place(relx=.5, rely=.5, anchor=CENTER)

        # Creates help button for link to documentation, instructions, and about.
        self.help_btn = Menubutton(self.input_frame,
                                   text="Help",
                                   relief="raised",
                                   bd=2,
                                   width=8,
                                   pady=1)
        #self.help_btn.place(relx=1, rely=0, anchor=NE)
        self.help_btn.grid(column=4, columnspan=1, row=0)
        self.help_btn_menu = Menu(self.help_btn, tearoff=0)
        doc = 'https://github.com/NASA-DEVELOP'
        self.help_btn_menu.add_command(label="Documentation",
                                       command=lambda: self.open_url(doc))
        self.help_btn_menu.add_command(label="Instructions",
                                       command=self.instructions)
        self.help_btn_menu.add_separator()
        self.help_btn_menu.add_command(label="About", command=self.about)
        self.help_btn["menu"] = self.help_btn_menu

    def main_screen(self):
        """Set up input GUI and image display screen."""
        self.action = IntVar()

        btn_width = int(constants.SW / 60)
        file_width = int(constants.SW / 18)
        lbl_width = int(constants.SW / 60)
        gen_width = int(constants.SW / 42)
        radio_font = Font(family='TkDefaultFont', size=12)
        self.sgmap_single_btn = Radiobutton(
            self.input_frame,
            text="Generate Artificial Skyglow Map",
            font=radio_font,
            width=btn_width,
            variable=self.action,
            value='sng',
            command=self.sng_popup)
        self.krn_lib_btn = Radiobutton(self.input_frame,
                                       text="Generate Kernel Library",
                                       font=radio_font,
                                       width=btn_width,
                                       variable=self.action,
                                       value='krn',
                                       command=self.krn_popup)
        self.multi_map_btn = Radiobutton(
            self.input_frame,
            text="Generate Maps from Multiple Kernels",
            font=radio_font,
            width=btn_width,
            variable=self.action,
            value='mul',
            command=self.mul_popup)
        self.hem_map_btn = Radiobutton(
            self.input_frame,
            text="Generate Hemispherical Visualization",
            font=radio_font,
            width=btn_width,
            variable=self.action,
            value='hem',
            command=self.hem_popup)
        #Place widget
        self.sgmap_single_btn.grid(column=0, columnspan=1, row=0)
        self.krn_lib_btn.grid(column=1, columnspan=1, row=0)
        self.multi_map_btn.grid(column=2, columnspan=1, row=0)
        self.hem_map_btn.grid(column=3, columnspan=1, row=0)

        # VIIRS Image Reference File
        self.file_lbl = Label(self.input_frame,
                              text="Image File:",
                              width=lbl_width,
                              anchor=E)
        self.file_log = Entry(self.input_frame,
                              width=file_width,
                              bd=2,
                              relief="sunken",
                              textvariable=self.file_log_var)
        self.browse_btn = Button(self.input_frame,
                                 text="Browse",
                                 command=self.import_viirs)

        # Angles CSV File
        self.csv_file_lbl = Label(self.input_frame,
                                  text="Angles CSV File:",
                                  width=lbl_width,
                                  anchor=E)
        self.csv_file_log = Entry(self.input_frame,
                                  width=file_width,
                                  bd=2,
                                  relief="sunken",
                                  textvariable=self.csv_file_var)
        self.csv_browse_btn = Button(self.input_frame,
                                     text="Browse",
                                     command=self.import_csv)

        # Multiple Maps form Kernel library
        self.mul_file_lbl = Label(self.input_frame,
                                  text="Kernel Folder:",
                                  width=lbl_width,
                                  anchor=E)
        self.mul_file_log = Entry(self.input_frame,
                                  width=file_width,
                                  bd=2,
                                  relief="sunken",
                                  textvariable=self.krn_folder_var)
        self.mul_browse_btn = Button(self.input_frame,
                                     text="Browse",
                                     command=self.import_krn_folder)

        # MultiKrn Map Output Location
        self.output_lbl = Label(self.input_frame,
                                text="Output Location:",
                                width=lbl_width,
                                anchor=E)
        self.output_log = Entry(self.input_frame,
                                width=file_width,
                                bd=2,
                                relief="sunken",
                                textvariable=self.output_folder_var)
        self.output_btn = Button(self.input_frame,
                                 text="Browse",
                                 command=self.import_out_folder)

        # Hemisphere Output Location
        self.sgmap_folder_lbl = Label(self.input_frame,
                                      text="Skyglow Map Location:",
                                      width=lbl_width,
                                      anchor=E)
        self.sgmap_folder_log = Entry(self.input_frame,
                                      width=file_width,
                                      bd=2,
                                      relief="sunken",
                                      textvariable=self.sgmap_folder_var)
        self.sgmap_folder_btn = Button(self.input_frame,
                                       text="Browse",
                                       command=self.import_sgmap_folder)

        # Import Kernel Checkbutton
        self.check_lbl = Label(self.input_frame,
                               text="Import Kernel:",
                               width=lbl_width,
                               anchor=E)

        self.krn_chk = Checkbutton(self.input_frame,
                                   anchor=W,
                                   variable=self.krn_var,
                                   command=self.checkbtn_val)

        self.hem_chk_lbl = Label(self.input_frame,
                                 text="Generate kernels for hemisphere:",
                                 width=lbl_width,
                                 anchor=E)

        self.hem_chk = Checkbutton(self.input_frame,
                                   anchor=W,
                                   variable=self.hem_var)

        # Region Latitude (deg), Grand Teton National park = 43.7904 degrees N
        self.lat_lbl = Label(self.input_frame,
                             text="Latitude (deg):",
                             width=lbl_width,
                             anchor=E)
        self.lat_entry = Entry(self.input_frame,
                               width=btn_width,
                               bd=2,
                               relief="sunken")
        self.lon_lbl = Label(self.input_frame,
                             text="Longitude (deg):",
                             width=lbl_width,
                             anchor=E)
        self.lon_entry = Entry(self.input_frame,
                               width=btn_width,
                               bd=2,
                               relief="sunken")

        # Atmospheric Clarity Parameter, REF 2, Eq. 12, p. 645
        self.k_lbl = Label(self.input_frame,
                           text="Atmospheric Clarity Parameter:",
                           width=btn_width,
                           anchor=E)
        self.k_entry = Entry(self.input_frame,
                             width=btn_width,
                             bd=2,
                             relief="sunken")

        # Zenith angle (deg), z, REF 2, Fig. 6, p.648
        self.zen_lbl = Label(self.input_frame,
                             text="Zenith Angle (deg):",
                             width=lbl_width,
                             anchor=E)
        self.zen_entry = Entry(self.input_frame,
                               width=btn_width,
                               bd=2,
                               relief="sunken")

        # Azimuth angle (deg)
        self.azi_lbl = Label(self.input_frame,
                             text="Azimuth Angle (deg):",
                             width=lbl_width,
                             anchor=E)
        self.azi_entry = Entry(self.input_frame,
                               width=btn_width,
                               bd=2,
                               relief="sunken")

        self.krn_lbl = Label(self.input_frame,
                             text="Kernel File:",
                             width=lbl_width,
                             anchor=E)
        self.krn_ent = Entry(self.input_frame,
                             width=file_width,
                             bd=2,
                             relief="sunken",
                             textvariable=self.krn_ent_var)
        self.krn_btn = Button(self.input_frame,
                              text="Browse",
                              command=self.import_krn)

        # Generate Artificial Skyglow Map Button
        self.map_btn = Button(self.input_frame,
                              text="Generate Artificial Skyglow Map",
                              width=gen_width,
                              command=self.generate_map)
        # Generate Kernal library button for SET
        self.gen_krn_btn = Button(self.input_frame,
                                  text="Generate Kernel Library",
                                  width=gen_width,
                                  command=self.generate_krn)
        # Generate Map of Multiple Kernals(word better later on)
        self.mul_map_btn = Button(self.input_frame,
                                  text="Generate Maps from Multiple Kernels",
                                  width=gen_width,
                                  command=self.generate_mmap)
        # Generate Hemispherical Visualization Display of Skyglow
        self.hem_gen_btn = Button(self.input_frame,
                                  text="Generate Hemisphere",
                                  width=gen_width,
                                  command=self.generate_hem)

    def import_viirs(self):
        """Import a VIIRS DNB file."""
        # Allows user to search through his directory for VIIRS Image file.
        file_types = [('TIFF Files', '*.tif'), ('All files', '*')]
        file_name = filedialog.askopenfilename(initialdir='/',
                                               title="Select file",
                                               filetypes=file_types)
        self.file_log_var.set(file_name)

        # Checks to see if file is empty. If not, displays image on canvas.
        if file_name != '':
            pilimg = Image.open(file_name)
            pilimg_width, pilimg_height = pilimg.size
            pilimg.tile = [
                t for t in pilimg.tile
                if t[1][2] < pilimg_width and t[1][3] < pilimg_height
            ]
            canvas_size = (self.img_canvas.winfo_width(),
                           self.img_canvas.winfo_height())
            pilimg_r = pilimg.resize(canvas_size, Image.ANTIALIAS)
            pilimg_col = ImageOps.colorize(ImageOps.grayscale(pilimg_r),
                                           (0, 0, 0), (255, 255, 255))
            pilimg_cont = ImageOps.autocontrast(pilimg_col,
                                                cutoff=.4,
                                                ignore=None)
            self.img = ImageTk.PhotoImage(pilimg_cont)
            self.img_canvas.create_image(canvas_size[0] / 2,
                                         canvas_size[1] / 2,
                                         image=self.img)
        else:
            print('File is empty.')

    def import_csv(self):
        """Import CSV file."""
        file_types = [('CSV Files', '*.csv'), ('All files', '*')]
        file_name = filedialog.askopenfilename(initialdir='/',
                                               title="Select file",
                                               filetypes=file_types)
        self.csv_file_var.set(file_name)

        if file_name is '':
            print('File is empty.')

    def import_krn_folder(self):
        """Import kernel folder."""
        krn_dir = filedialog.askdirectory(initialdir='/',
                                          title="Select kernel folder")
        self.krn_folder_var.set(krn_dir)

        if krn_dir is '':
            print('Directory is empty.')

    def import_out_folder(self):
        """Import skyglow output folder."""
        output_dir = filedialog.askdirectory(initialdir='/',
                                             title="Select output folder")
        self.output_folder_var.set(output_dir)

        if output_dir is '':
            print('Directory is empty.')

    def import_krn(self):
        """Import existing kernel tif."""
        file_types = [('TIFF Files', '*.tif'), ('All files', '*')]
        file_name = filedialog.askopenfilename(initialdir='/',
                                               title="Select file",
                                               filetypes=file_types)
        self.krn_ent_var.set(file_name)

    def import_sgmap_folder(self):
        """Import skyglow map folder for hemisphere building."""
        sgmap_dir = filedialog.askdirectory(initialdir='/',
                                            title="Select skyglow map folder")
        self.sgmap_folder_var.set(sgmap_dir)

        if sgmap_dir is '':
            print('Directory is empty.')

    def sng_popup(self):
        """Single map tab."""
        self.remove_all()

        self.check_lbl.grid(column=0, row=2)
        self.krn_chk.place(relx=.22, rely=.41, anchor=CENTER)

        self.file_lbl.grid(column=0, row=1)
        self.file_log.grid(column=1, columnspan=3, row=1)
        self.browse_btn.grid(column=4, row=1, sticky=W, padx=3)

        self.lat_lbl.grid(column=0, row=3)
        self.lat_entry.grid(column=1, row=3)

        self.k_lbl.grid(column=2, row=3)
        self.k_entry.grid(column=3, row=3)

        self.zen_lbl.grid(column=0, row=4)
        self.zen_entry.grid(column=1, row=4)

        self.azi_lbl.grid(column=2, row=4)
        self.azi_entry.grid(column=3, row=4)

        self.map_btn.grid(column=1, columnspan=3, row=5, sticky=N + S + E + W)

    def krn_popup(self):
        """Kernel lib tab."""
        self.remove_all()

        # latitude
        self.lat_lbl.grid(column=0, row=3)
        self.lat_entry.grid(column=1, row=3)

        # atmospheric clarity
        self.k_lbl.grid(column=2, row=3)
        self.k_entry.grid(column=3, row=3)

        # angles file
        self.csv_file_lbl.grid(column=0, row=1)
        self.csv_file_log.grid(column=1, columnspan=3, row=1)
        self.csv_browse_btn.grid(column=4, row=1, sticky=W, padx=3)

        # input VIIRS image
        self.file_lbl.grid(column=0, row=2)
        self.file_log.grid(column=1, columnspan=3, row=2)
        self.browse_btn.grid(column=4, row=2, sticky=W, padx=3)

        self.hem_chk_lbl.grid(column=0, row=4)
        self.hem_chk.place(relx=.21, rely=.69)

        self.gen_krn_btn.grid(column=1,
                              columnspan=3,
                              row=5,
                              sticky=N + S + E + W)

    def mul_popup(self):
        """Multiple maps tab."""
        self.remove_all()

        # Kernel folder location
        self.mul_file_lbl.grid(column=0, row=1)
        self.mul_file_log.grid(column=1, columnspan=3, row=1)
        self.mul_browse_btn.grid(column=4, row=1, sticky=W, padx=3)

        # input VIIRS image
        self.file_lbl.grid(column=0, row=2)
        self.file_log.grid(column=1, columnspan=3, row=2)
        self.browse_btn.grid(column=4, row=2, sticky=W, padx=3)

        # Choose output location
        self.output_lbl.grid(column=0, row=3)
        self.output_log.grid(column=1, columnspan=3, row=3)
        self.output_btn.grid(column=4, row=3, sticky=W, padx=3)

        # Generate map from kernel folder
        self.mul_map_btn.grid(column=1,
                              columnspan=3,
                              row=4,
                              sticky=N + S + E + W)

    def hem_popup(self):
        """Hemisphere tab."""
        self.remove_all()

        # Skyglow Map Folder
        self.sgmap_folder_lbl.grid(column=0, row=1)
        self.sgmap_folder_log.grid(column=1, columnspan=3, row=1)
        self.sgmap_folder_btn.grid(column=4, row=1, sticky=W, padx=3)

        # Latitude entry
        self.lat_lbl.grid(column=0, row=3)
        self.lat_entry.grid(column=1, row=3)

        # Longitude entry
        self.lon_lbl.grid(column=2, row=3)
        self.lon_entry.grid(column=3, row=3)

        # Generate Hemispherical Visualization button
        self.hem_gen_btn.grid(column=1,
                              columnspan=3,
                              row=4,
                              sticky=N + S + E + W)

    def remove_all(self):
        """Remove all existing GUI elements before opening new tab."""
        self.check_lbl.grid_remove()
        self.krn_chk.place_forget()
        self.hem_chk.place_forget()
        self.hem_chk_lbl.grid_remove()
        self.file_lbl.grid_remove()
        self.file_log.grid_remove()
        self.browse_btn.grid_remove()
        self.krn_lbl.grid_remove()
        self.krn_ent.grid_remove()
        self.krn_btn.grid_remove()
        self.lat_lbl.grid_remove()
        self.lat_entry.grid_remove()
        self.k_lbl.grid_remove()
        self.k_entry.grid_remove()
        self.zen_lbl.grid_remove()
        self.zen_entry.grid_remove()
        self.azi_lbl.grid_remove()
        self.azi_entry.grid_remove()
        self.map_btn.grid_remove()
        self.gen_krn_btn.grid_remove()
        self.mul_map_btn.grid_remove()
        self.csv_file_lbl.grid_remove()
        self.csv_file_log.grid_remove()
        self.csv_browse_btn.grid_remove()
        self.mul_file_lbl.grid_remove()
        self.mul_file_log.grid_remove()
        self.mul_browse_btn.grid_remove()
        self.output_lbl.grid_remove()
        self.output_log.grid_remove()
        self.output_btn.grid_remove()
        self.hem_gen_btn.grid_remove()
        self.lat_lbl.grid_remove()
        self.lat_entry.grid_remove()
        self.lon_lbl.grid_remove()
        self.lon_entry.grid_remove()
        self.sgmap_folder_lbl.grid_remove()
        self.sgmap_folder_log.grid_remove()
        self.sgmap_folder_btn.grid_remove()

    def checkbtn_val(self):
        """Change interface based on if Import Kernel button is checked."""
        # Import Kernel File widgets when Kernel Checkbutton is marked.
        if self.krn_var.get():
            self.lat_lbl.grid_remove()
            self.lat_entry.grid_remove()
            self.k_lbl.grid_remove()
            self.k_entry.grid_remove()
            self.zen_lbl.grid_remove()
            self.zen_entry.grid_remove()
            self.azi_lbl.grid_remove()
            self.azi_entry.grid_remove()
            self.krn_lbl.grid(column=0, row=2)
            self.krn_ent.grid(column=1, columnspan=3, row=2)
            self.krn_btn.grid(column=4, row=2, sticky=W, padx=3)
            self.krn_chk.place_forget()
            self.krn_chk.place(relx=0.19, rely=.5)
        # Input parameter widgets when Kernel Checkbuttton is unmarked
        else:
            self.krn_lbl.grid_remove()
            self.krn_ent.grid_remove()
            self.krn_btn.grid_remove()
            self.lat_lbl.grid(column=0, row=3)
            self.lat_entry.grid(column=1, row=3)
            self.k_lbl.grid(column=2, row=3)
            self.k_entry.grid(column=3, row=3)
            self.zen_lbl.grid(column=0, row=4)
            self.zen_entry.grid(column=1, row=4)
            self.azi_lbl.grid(column=2, row=4)
            self.azi_entry.grid(column=3, row=4)
            self.krn_chk.place_forget()
            self.krn_chk.place(relx=0.22, rely=.41, anchor=CENTER)

    @staticmethod
    def open_url(url):
        """"Open a url"""
        webbrowser.open_new(url)

    def instructions(self):
        """Open instructions window."""
        # Instantiates separate Toplevel instruction window.
        instr_window = Toplevel(self.root)
        instr_window.geometry('550x575+25+25')
        instr_window.title('Instructions')
        instr_window.wm_iconbitmap(constants.ICO)
        instr_window.resizable(False, False)

        # Creatse Scrollbar and Frame for containing other widgets.
        instr_scroll = Scrollbar(instr_window)
        instr_scroll.pack(fill=Y, side="right")
        instr_frame = Frame(instr_window, bg='white')
        instr_frame.pack(fill=BOTH, side="left")

        # Adds instruction text from constants and adds image of Cinzano's diagram.
        instr = Text(instr_frame,
                     width=65,
                     height=40,
                     padx=10,
                     pady=5,
                     bd=0,
                     wrap="word")
        instr.insert("end", constants.INSTR)
        cdiagram_file = Image.open("./static/cinzano_diagram.PNG")
        cdiagram_file = cdiagram_file.resize((500, 450), Image.ANTIALIAS)
        self.cdiag = ImageTk.PhotoImage(cdiagram_file)
        instr.image_create("end", image=self.cdiag)
        instr.tag_add("top", "1.0", "4.10")
        instr.tag_config("top", font='Times 12 bold')
        instr.tag_add("body", "5.0", "19.20")
        instr.tag_config("body", font='Times 12')
        instr.insert("end", constants.CDIAG)
        instr.pack()
        instr_scroll.config(command=instr.yview)

    def about(self):
        """Open an about window.

        Window gives authors, SET version number, and icon credit.
        """
        # Instantiates a new Toplevel about window.
        about_window = Toplevel(self.root)
        about_window.geometry('350x335+25+25')
        about_window.title('About')
        about_window.wm_iconbitmap(constants.ICO)
        about_window.resizable(False, False)

        # Adds text to about window.
        about = Text(about_window, width=50, height=30, padx=10, pady=3)
        about.insert("end", constants.ABOUT)
        about.tag_add("abt", "1.0", "21.30")
        about.tag_config("abt", font='Times 10 bold', justify=CENTER)
        about.pack()

    def progress(self):
        """Construct a progress window to monitor darksky."""
        # Instantiates a new Toplevel window and frame for progress bar and loading log.
        self.prg_window = Toplevel(self.root)
        self.prg_window.geometry('650x325+250+250')
        self.prg_window.title('Generating Artificial Skyglow Map...')
        self.prg_window.iconbitmap(constants.ICO)
        self.prg_window.resizable(False, False)
        prg_frame = Frame(self.prg_window)
        prg_frame.pack(fill=BOTH)

        # Creates Scrollbar, Progressbar, and Label for checking progress..
        prg_scroll = Scrollbar(prg_frame)
        prg_scroll.pack(fill=Y, side="right")
        self.prg_bar = ttk.Progressbar(prg_frame,
                                       orient=HORIZONTAL,
                                       length=750,
                                       mode='indeterminate')
        self.prg_bar.pack()
        self.prg_bar.start()
        prg_lbl_txt = StringVar()
        prg_lbl = Label(prg_frame, textvariable=prg_lbl_txt)
        prg_lbl.pack()

        # Displays message log that prints from log file and starts darkskypy.
        self.prg_log = Text(prg_frame,
                            width=90,
                            padx=5,
                            pady=5,
                            relief="sunken")
        self.prg_log.pack()
        self.prg_log.insert(
            "end", "*****Progress Log*****\n=======================\n")
        self.prg_log.tag_add("abt", "1.0", "3.0")
        self.prg_log.tag_config("abt", font='Courier 12 bold', justify=CENTER)
        self.txt_redir = LogRedirector(self.prg_log)
        logger.addHandler(self.txt_redir)
        sys.stderr = StderrRedirector(self.prg_log)
        prg_lbl_txt.set("Start time: " + str(time.asctime()))

        self.no_progress = 0

    def update_progress(self):
        """Update progress window to prevent it from freezing."""
        self.prg_log.update()
        # if only one thread exists, stop progress bar and close window
        if len(threading.enumerate()) == 1:
            self.prg_bar.stop()
            self.no_progress += 1
            if self.no_progress == 3:
                self.prg_window.withdraw()
        else:
            self.prg_bar.start()
        self.root.after(1000, self.update_progress)

    def generate_map(self):
        """Call darksky.sgmapper in background thread."""
        # Acquires input arguments.
        lat_in, k_in, zen_in, azi_in, file_in, krn_file_in = 0, 0, 0, 0, '', ''
        if self.krn_var.get():
            krn_file_in = self.krn_ent_var.get()
        else:
            lat_in = float(self.lat_entry.get())
            k_in = float(self.k_entry.get())
            zen_in = float(self.zen_entry.get())
            azi_in = float(self.azi_entry.get())
        file_in = self.file_log_var.get()

        self.progress()

        # Create new threads to run light propagation model simultaneously.
        p_thread = threading.Thread(target=self.update_progress())
        t_thread = threading.Thread(target=darksky.sgmapper,
                                    args=(lat_in, k_in, zen_in, azi_in,
                                          file_in, krn_file_in))
        t_thread.setDaemon(True)
        p_thread.start()
        t_thread.start()

    def generate_krn(self):
        """Start kernel generation in background threads."""
        # Acquires input arguments
        csv_in, file_in, lat_in, k_in, hem = '', '', 0, 0, False
        csv_in = self.csv_file_var.get()
        file_in = self.file_log_var.get()
        lat_in = float(self.lat_entry.get())
        k_in = float(self.k_entry.get())
        hem = self.hem_var.get()

        self.progress()

        # Create new threads to run light propagation model simultaneously.
        p_thread = threading.Thread(target=self.update_progress())
        with open(csv_in, "rb") as f:
            angle_list = loadtxt(f, delimiter=",", skiprows=1)
        p_thread.start()
        for angle_set in angle_list:
            t_thread = threading.Thread(target=darksky.generate_krn,
                                        args=(lat_in, k_in, angle_set[0],
                                              angle_set[1], file_in, hem))
            t_thread.setDaemon(True)

            t_thread.start()

    def generate_mmap(self):
        """Start brightness map creation from kernels."""
        # Acquires input arguments
        krn_folder_in, file_in, output_in, = '', '', ''
        krn_folder_in = self.krn_folder_var.get()
        file_in = self.file_log_var.get()
        output_in = self.output_folder_var.get()

        self.progress()

        # Create new threads to run light propagation model simultaneously.
        p_thread = threading.Thread(target=self.update_progress())
        t_thread = threading.Thread(target=darksky.multisgmapper,
                                    args=(file_in, krn_folder_in, output_in))
        t_thread.setDaemon(True)
        p_thread.start()
        t_thread.start()

    def generate_hem(self):
        """Generate hemisphere."""
        sgmap_folder_in, lat_in, lon_in, = '', 0, 0
        sgmap_folder_in = self.sgmap_folder_var.get()
        lat_in = float(self.lat_entry.get())
        lon_in = float(self.lon_entry.get())
        darksky.generate_hem(lat_in, lon_in, sgmap_folder_in)
예제 #18
0
    def initUI(self):
        self.parent.title("Cravis_ver1")
        self.pack(fill=BOTH, expand=1)
        frame = Frame(self,
                      width=750,
                      height=200,
                      relief=RAISED,
                      borderwidth=1)
        frame.pack(expand=True)
        #frame.config(bg="blue")
        self.pack(expand=False)
        #####

        #####

        frame2 = Frame(self,
                       width=750,
                       height=200,
                       relief=RAISED,
                       borderwidth=1)
        frame2.pack(expand=False)
        self.pack(expand=False)

        self.var1 = BooleanVar()
        self.var2 = BooleanVar()
        self.var3 = BooleanVar()
        self.var4 = BooleanVar()
        self.var5 = BooleanVar()
        self.content = IntVar()

        closeButton = Button(self,
                             text="Close",
                             background="green",
                             command=self.error)
        closeButton.pack(side=RIGHT, padx=5, pady=5)

        okButton = Button(self, text="OK", background="green")
        okButton.pack(side=RIGHT)

        quitButton = Button(self, text="Quit", command=self.off_video)
        quitButton.place(x=50, y=20)

        startButton = Button(self, text="Start", command=self.on_start)
        startButton.place(x=100, y=20)

        TakePicButton = Button(self, text="TakePic", command=self.Takepic)
        TakePicButton.place(x=150, y=20)

        ######

        cb1 = Checkbutton(self,
                          text="Binary",
                          variable=self.var1,
                          command=self.on_Binary)
        cb1.place(x=80, y=60)

        cb2 = Checkbutton(self,
                          text="Partical",
                          variable=self.var2,
                          command=self.on_Partical)
        cb2.place(x=80, y=80)

        cb3 = Checkbutton(self,
                          text="Sobel",
                          variable=self.var3,
                          command=self.on_Sobel)
        cb3.place(x=80, y=100)

        cb4 = Checkbutton(self,
                          text="Median",
                          variable=self.var4,
                          command=self.on_Median)
        cb4.place(x=80, y=120)

        cb5 = Checkbutton(self,
                          text="Level_Adjust",
                          variable=self.var5,
                          command=self.on_LevelAdjust)
        cb5.place(x=80, y=140)
        #####

        ###################################

        #infor=Text(self,state="disable",width=50,height=10,wrap='none')

        self.infor = Text(self, width=50, height=2)
        self.infor.pack()
        thongtin = "CHAO MUNG DEN VOI CHUONG TRINH CRAVIS_V1                 DESIGN BY VISUAL GROUP"
        self.infor.insert(END, thongtin)

        ################################

        menuBar = Menu(self.parent)
        self.parent.config(menu=menuBar)

        fileMenu1 = Menu(menuBar)
        fileMenu2 = Menu(menuBar)
        fileMenu3 = Menu(menuBar)

        fileMenu1.add_command(label="zoom", command=self.zoom)
        fileMenu1.add_command(label="password", command=self.password)
        fileMenu1.add_command(label="2", command=self.onExit)
        fileMenu1.add_command(label="3", command=self.onExit)

        fileMenu2.add_command(label="Exit", command=self.onExit)
        fileMenu2.add_command(label="1", command=self.onExit)
        fileMenu2.add_command(label="2", command=self.onExit)
        fileMenu2.add_command(label="3", command=self.onExit)

        fileMenu3.add_command(label="help", command=self.file_help)
        fileMenu3.add_command(label="1", command=self.onExit)
        fileMenu3.add_command(label="2", command=self.onExit)
        fileMenu3.add_command(label="3", command=self.onExit)

        menuBar.add_cascade(label="File", menu=fileMenu1)
        menuBar.add_cascade(label="Infor", menu=fileMenu2)
        menuBar.add_cascade(label="Help", menu=fileMenu3)