def addListBox(self, ax=600, ay=52, x=0, y=0, bg="#B4045F"):

        scrolly = Scrollbar(self,
                            activebackground="#171212",
                            bg="#171212",
                            orient=VERTICAL,
                            troughcolor="#171212")

        listbox = Listbox(self,
                          height=ay,
                          width=ax,
                          background=bg,
                          borderwidth=0,
                          highlightcolor="#4d86a1",
                          selectbackground="#4d86a1",
                          activestyle=NONE,
                          highlightbackground="#4a4a4a",
                          yscrollcommand=scrolly.set)
        listbox.config(font=("", 10), fg="#FFFFFF")
        listbox.place(x=0, y=0)
        scrolly.place(x=651, y=0, height=387)
        self.__list_listbox.append(listbox)
        self.__list_scrollbar.append(scrolly)
        for x in self.__list_listbox:
            x.configure(yscrollcommand=scrolly.set)
        scrolly.configure(command=self.__yview)
Exemplo n.º 2
0
    def __init__(self, root):
        self.root = root
        self.columns = 26
        
        button_play = Button(self.root, 
                             text="Play", 
                             command=self.callback_play)
        
        button_stop = Button(self.root, 
                             text="Stop", 
                             command=self.callback_stop)

        button_shutdown = Button(self.root, 
                                 text="Shut down", 
                                 command=self.callback_shutdown)

        button_close = Button(self.root, 
                              text="Close", 
                              command=self.callback_close)

        self.text = Text(self.root, height=1)
        
        scrollbar = Scrollbar(self.root, width=30)
        font = tkFont.Font(size=15)
        self.listbox = Listbox(self.root, 
                               yscrollcommand=scrollbar.set,
                               selectmode=SINGLE,
                               font=font)
        self.listbox.bind("<<ListboxSelect>>", self.callback_stream_selected)
        
        scrollbar.config(command=self.listbox.yview)
        
        button_stop.place(relx=0, rely=0)
        button_play.place(relx=0.18, rely=0)
        button_close.place(relx=0.5, rely=0)
        button_shutdown.place(relx=0.7, rely=0)
        
        scrollbar.place(relx=0.9, rely=0.2, relheight=0.7)
        
        self.listbox.place(relx=0, rely=0.2, relwidth=0.9, relheight=0.7)
        self.text.place(relx=0, rely=0.9)
        self.root.protocol("WM_DELETE_WINDOW", self.callback_close)
Exemplo n.º 3
0
    def __init__(self, master=None):
        self.new = False

        Tk.__init__(self, master)
        ScreenManipulation.checkPlatform(self)
        screensize = self.screensize

        self.seeding = False
        '''Setting the Window Size'''
        self.minsize(screensize[0], screensize[1])
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        '''Setting the Window Size'''
        '''Menu Bar'''
        menubar = Menu(self)
        self.filemenu = Menu(menubar, tearoff=0)
        self.suggestionmenu = Menu(menubar, tearoff=0)
        self.helpmenu = Menu(menubar, tearoff=0)
        tabbedPane = ttk.Notebook(self)
        t1 = ttk.Frame(tabbedPane)
        self.t2 = ttk.Frame(tabbedPane)
        self.tree = ttk.Treeview(t1,
                                 columns=("fullpath"),
                                 displaycolumns=(0),
                                 yscrollcommand=lambda f, l: ScreenManipulation
                                 .autoscroll(vsb, f, l))
        self.config(menu=menubar)
        '''FILE MENU'''
        self.filemenu.add_command(label="Create", command=self.createFile)
        self.filemenu.add_command(label="Load Dataset",
                                  command=self.askToOpenDirectory)
        self.filemenu.add_command(label="Seed", command=self.seedFile)
        self.filemenu.add_command(label="Test", command=self.clickTestFile)
        self.filemenu.add_command(label="Exit", command=lambda: self.destroy())
        menubar.add_cascade(label="Experimentation", menu=self.filemenu)
        '''HELP MENU'''
        self.helpmenu.add_command(label="About Us", command=aboutUs)
        self.helpmenu.add_command(label="User's Manual")
        menubar.add_cascade(label="Help", menu=self.helpmenu)
        '''Menu Bar'''
        '''Setting the Tabbed Pane'''
        tabbedPane.add(t1, text="Project")
        tabbedPane.add(self.t2, text="Results")
        tabbedPane.grid(row=0, column=0, sticky=(N, W, S, E))
        '''Setting the Tabbed Pane'''
        '''Widgets'''
        '''File Text Box'''
        txtWidth = screensize[0] * .5
        txtHeight = screensize[1] * .5
        txtPosX = screensize[0] * .36
        txtPosY = screensize[1] * .06
        self.text = Text(t1,
                         state='disabled',
                         bg='gray',
                         yscrollcommand=lambda f, l: ScreenManipulation.
                         autoscroll(vsb1, f, l))
        self.text.place(width=txtWidth, height=txtHeight, x=txtPosX, y=txtPosY)
        self.text.tag_configure("error", foreground="red", underline=True)
        vsb1 = Scrollbar(t1, orient="vertical")
        vsb1['command'] = self.text.yview
        vsb1Width = screensize[0] * .010
        vsb1Height = screensize[1] * .5
        vsb1PosX = screensize[0] * .86
        vsb1PosY = screensize[1] * .061
        vsb1.place(width=vsb1Width, height=vsb1Height, x=vsb1PosX, y=vsb1PosY)
        '''line numbering'''
        txtWidth = screensize[0] * .0225
        txtHeight = screensize[1] * .5
        txtPosX = screensize[0] * .34
        txtPosY = screensize[1] * .06
        self.lineNumbering = Text(t1,
                                  state='disabled',
                                  bg='gray',
                                  yscrollcommand=lambda f, l:
                                  ScreenManipulation.autoscroll(vsb1, f, l))
        self.lineNumbering.place(width=txtWidth,
                                 height=txtHeight,
                                 x=txtPosX,
                                 y=txtPosY)
        vsb1['command'] = self.lineNumbering.yview
        '''File List Box'''
        fileWidth = screensize[0] * .30
        fileHeight = screensize[1] * .5
        filePosX = screensize[0] * .025
        filePosY = screensize[1] * .06

        self.tree.heading("#0", text="Directory Structure", anchor='w')
        self.tree.column("#0", stretch=0, width=500)

        populate_roots(self.tree, self.path)
        vsb = Scrollbar(t1, orient="vertical")
        vsb['command'] = self.tree.yview
        vsbWidth = screensize[0] * .010
        vsbHeight = screensize[1] * .5
        vsbPosX = screensize[0] * .325
        vsbPosY = screensize[1] * .061
        vsb.place(width=vsbWidth, height=vsbHeight, x=vsbPosX, y=vsbPosY)
        self.tree.place(width=fileWidth,
                        height=fileHeight,
                        x=filePosX,
                        y=filePosY)

        fileLX = screensize[0] * .025
        fileLY = screensize[1] * .025
        fileLabel = Label(t1, text="Files:")
        fileLabel.place(x=fileLX, y=fileLY)
        '''File List Box'''
        '''Error Table w/ Label'''
        errLX = screensize[0] * .35
        errLY = screensize[1] * .57
        self.errLabel = Label(t1, text="Error:")
        self.errLabel.place(x=errLX, y=errLY)

        errListWidth = screensize[0] * .6
        errListHeight = screensize[1] * .27
        errListPosX = screensize[0] * .35
        errListPosY = screensize[1] * .60

        self.var = tktable.ArrayVar(t1)
        self.var["%i,%i" % (0, 0)] = 'Line'
        self.var["%i,%i" % (0, 1)] = 'Column'
        self.var["%i,%i" % (0, 2)] = 'Description'

        self.ErrorsTable = tktable.Table(
            t1,
            rows=9,
            cols=3,
            state='disabled',
            titlerows=1,
            selectmode='browse',
            selecttype='row',
            colstretch='last',
            resizeborders='none',
            flashmode='on',
            bg='white',
            variable=self.var,
            yscrollcommand=lambda x, v: ScreenManipulation.autoscroll(
                vsb2, x, v))
        vsb2 = ttk.Scrollbar(t1, orient="vertical")
        self.ErrorsTable.tag_configure('flash', background='')
        vsb2['command'] = self.ErrorsTable.yview
        vsb2Width = screensize[0] * .010
        vsb2Height = screensize[1] * .27
        vsb2PosX = screensize[0] * .945
        vsb2PosY = screensize[1] * .60
        vsb2.place(width=vsb2Width, height=vsb2Height, x=vsb2PosX, y=vsb2PosY)
        self.ErrorsTable.place(width=errListWidth,
                               height=errListHeight,
                               x=errListPosX,
                               y=errListPosY)
        '''Error Table w/ Label'''
        '''Results Table'''
        self.varRes = tktable.ArrayVar(self.t2)
        self.varRes["%i,%i" % (0, 0)] = 'FileName'
        self.varRes["%i,%i" % (0, 1)] = 'Errors Seeded'
        self.varRes["%i,%i" % (0, 2)] = 'Errors Detected'
        self.varRes["%i,%i" % (0, 3)] = 'Previous Errors Detected'
        self.varRes["%i,%i" % (0, 4)] = 'Effectiveness'
        self.varRes["%i,%i" % (0, 5)] = 'Count'

        self.resTb = tktable.Table(self.t2,
                                   rows=30,
                                   cols=6,
                                   state='disabled',
                                   titlerows=1,
                                   colwidth=05,
                                   selectmode='browse',
                                   selecttype='row',
                                   colstretch='all',
                                   variable=self.varRes,
                                   resizeborders='none',
                                   bg='white',
                                   yscrollcommand=lambda x, v:
                                   ScreenManipulation.autoscroll(vsb5, x, v))

        resWidth = self.screensize[0] * .9
        resHeight = self.screensize[1] * .85
        resPosX = (self.screensize[0] * .5) - (self.screensize[0] * .45)
        resPosY = (self.screensize[1] * .5) - (self.screensize[1] * .425)
        self.resTb.place(width=resWidth,
                         height=resHeight,
                         x=resPosX,
                         y=resPosY)

        vsb5 = Scrollbar(self.t2, orient="vertical")
        vsb5['command'] = self.resTb.yview
        vsb5Width = screensize[0] * .010
        vsb5Height = screensize[1] * .85
        vsb5PosX = (self.screensize[0] * .5) + (self.screensize[0] * .45)
        vsb5PosY = (self.screensize[1] * .5) - (self.screensize[1] * .425)
        vsb5.place(width=vsb5Width, height=vsb5Height, x=vsb5PosX, y=vsb5PosY)
        '''Results Table'''
        '''Suggestion Box'''
        sugLX = screensize[0] * .025
        sugLY = screensize[1] * .57
        self.sugLabel = Label(t1, text="Suggestion:")
        self.sugLabel.place(x=sugLX, y=sugLY)
        exactLX = screensize[0] * .025
        exactLY = screensize[1] * .87
        self.exacMatchLabel = Label(t1, text="Exact Match: None")
        self.exacMatchLabel.place(x=exactLX, y=exactLY)
        sugWidth = screensize[0] * .31
        sugHeight = screensize[1] * .27
        sugPosX = screensize[0] * .025
        sugPosY = screensize[1] * .60

        self.var2 = tktable.ArrayVar(t1)
        self.var2["%i,%i" % (0, 0)] = 'Tag'
        self.var2["%i,%i" % (0, 1)] = 'Value'

        suggestion = tktable.Table(t1,
                                   rows=10,
                                   cols=2,
                                   state='disabled',
                                   titlerows=1,
                                   colwidth=30,
                                   selectmode='browse',
                                   selecttype='row',
                                   colstretch='last',
                                   variable=self.var2,
                                   resizeborders='none',
                                   bg='white',
                                   yscrollcommand=lambda x, v:
                                   ScreenManipulation.autoscroll(vsb3, x, v))
        vsb3 = ttk.Scrollbar(t1, orient="vertical")
        vsb3['command'] = suggestion.yview
        vsb3Width = screensize[0] * .010
        vsb3Height = screensize[1] * .27
        vsb3PosX = screensize[0] * .325
        vsb3PosY = screensize[1] * .60
        vsb3.place(width=vsb3Width, height=vsb3Height, x=vsb3PosX, y=vsb3PosY)

        suggestion.place(width=sugWidth,
                         height=sugHeight,
                         x=sugPosX,
                         y=sugPosY)
        '''Suggestion Box'''
        '''Button'''
        brws = Button(t1, text='Browser', command=self.toBrowser)
        bWidth = screensize[0] * .1
        bHeight = screensize[1] * .05
        bPosX = screensize[0] * .875
        bPosY = screensize[1] * .1
        brws.place(width=bWidth, height=bHeight, x=bPosX, y=bPosY)

        Save = Button(t1, text='Save', command=self.toSave)
        SWidth = screensize[0] * .1
        SHeight = screensize[1] * .05
        SPosX = screensize[0] * .875
        SPosY = screensize[1] * .15
        Save.place(width=SWidth, height=SHeight, x=SPosX, y=SPosY)

        perfCorr = Button(t1, text='Edit', command=self.enableText)
        SWidth = screensize[0] * .1
        SHeight = screensize[1] * .05
        SPosX = screensize[0] * .875
        SPosY = screensize[1] * .20
        perfCorr.place(width=SWidth, height=SHeight, x=SPosX, y=SPosY)

        Val = Button(t1, text='Validate', command=self.validateFile)
        VWidth = screensize[0] * .1
        VHeight = screensize[1] * .05
        VPosX = screensize[0] * .875
        VPosY = screensize[1] * .25
        Val.place(width=VWidth, height=VHeight, x=VPosX, y=VPosY)

        suggest = Button(t1,
                         text='View Suggestion',
                         command=self.clickSuggestion)
        SWidth = screensize[0] * .1
        SHeight = screensize[1] * .05
        SPosX = screensize[0] * .35
        SPosY = screensize[1] * .875
        suggest.place(width=SWidth, height=SHeight, x=SPosX, y=SPosY)
        '''Button'''

        self.LLine = Label(t1, text='Line: \n')
        LLWidth = screensize[0] * .1
        LLHeight = screensize[1] * .05
        LLPosX = screensize[0] * .875
        LLPosY = screensize[1] * .4
        self.LLine.place(width=LLWidth, height=LLHeight, x=LLPosX, y=LLPosY)

        self.LColumn = Label(t1, text='Column: \n')
        LCWidth = screensize[0] * .1
        LCHeight = screensize[1] * .05
        LCPosX = screensize[0] * .875
        LCPosY = screensize[1] * .45
        self.LColumn.place(width=LCWidth, height=LCHeight, x=LCPosX, y=LCPosY)
        '''Status Bar'''
        errDetWidth = screensize[0] * .25
        errDetHeight = screensize[1] * .03
        errDetPosX = screensize[0] * .0
        errDetPosY = screensize[1] * .93
        self.errDetected = Label(t1, text="Errors Seeded: N/A", relief=SUNKEN)
        self.errDetected.place(width=errDetWidth,
                               height=errDetHeight,
                               x=errDetPosX,
                               y=errDetPosY)

        totErrWidth = screensize[0] * .25
        totErrHeight = screensize[1] * .03
        totErrPosX = screensize[0] * .25
        totErrPosY = screensize[1] * .93
        self.totErrDetected = Label(t1,
                                    text="Total Errors Detected: N/A",
                                    relief=SUNKEN)
        self.totErrDetected.place(width=totErrWidth,
                                  height=totErrHeight,
                                  x=totErrPosX,
                                  y=totErrPosY)

        effWidth = screensize[0] * .25
        effHeight = screensize[1] * .03
        effPosX = screensize[0] * .50
        effPosY = screensize[1] * .93
        self.effectiveness = Label(t1,
                                   text="Effectiveness: N/A",
                                   relief=SUNKEN)
        self.effectiveness.place(width=effWidth,
                                 height=effHeight,
                                 x=effPosX,
                                 y=effPosY)

        ptotErrWidth = screensize[0] * .25
        ptotErrHeight = screensize[1] * .03
        ptotErrPosX = screensize[0] * .75
        ptotErrPosY = screensize[1] * .93
        self.ptotErrDetected = Label(t1,
                                     text="Previous Errors Detected: N/A",
                                     relief=SUNKEN)
        self.ptotErrDetected.place(width=ptotErrWidth,
                                   height=ptotErrHeight,
                                   x=ptotErrPosX,
                                   y=ptotErrPosY)
        '''Status Bar'''

        self.tree.bind('<<TreeviewOpen>>', update_tree)
        self.tree.bind('<<TreeviewSelect>>', self.readAndCreateRecord)
        tabbedPane.bind('<<NotebookTabChanged>>', self.results)

        self.text.bind('<Button-1>', self.key)
Exemplo n.º 4
0
class CenterFrame(BasePAFrame):
    """
    фрейм со списком файлов
    """

    def __init__(self, *args, **kwargs):
        self.w_frame_child = kwargs.pop('child_frame')

        BasePAFrame.__init__(self, *args, **kwargs)

        self.w_listbox_files = Listbox(self)
        self.w_scrollbar_files = Scrollbar(self)

        self.catalog = None
        self.catalog_files = []

    def _pa_configure(self):
        BasePAFrame._pa_configure(self)

        self.w_listbox_files.config(yscrollcommand=self.w_scrollbar_files.set)
        self.w_scrollbar_files.config(command=self.w_listbox_files.yview)

        self.w_listbox_files.bind(
            '<<ListboxSelect>>', self.select_listbox_file)

    def _pa_layout(self):
        BasePAFrame._pa_layout(self)

        w_listbox_files_width = 0.95
        self.w_listbox_files.place(
            relx=0,
            rely=0,
            relwidth=w_listbox_files_width,
            relheight=1)
        self.w_scrollbar_files.place(
            relx=w_listbox_files_width,
            rely=0,
            relwidth=1-w_listbox_files_width,
            relheight=1)

    def set_catalog(self, catalog=None):
        """
        задаем новый каталог для отображения

        :param catalog: словарь
            {
                'path': путь к каталогу
            }
        :return:
        """

        try:
            current_index = self.w_listbox_files.curselection()[0]
        except IndexError:
            current_index = 0

        if 0 < current_index < len(self.catalog_files):
            set_index = current_index + 1
        else:
            set_index = current_index

        self.catalog = catalog
        self.catalog_files = []
        self.w_listbox_files.delete(0, END)
        self.w_frame_child.set_file(None)

        if self.catalog is not None:
            catalog_path = self.catalog

            for file_name in os.listdir(catalog_path):
                file_path = os.path.join(catalog_path, file_name)
                if os.path.isfile(file_path):
                    self.catalog_files.append({
                        'name': file_name,
                        'path': file_path})
            self.catalog_files.sort(key=lambda x: x['name'])
            catalog_files = [catalog['name'] for catalog in self.catalog_files]
            self.w_listbox_files.insert(END, *catalog_files)

            self.w_listbox_files.selection_set(set_index)
            self.w_listbox_files.see(set_index)
            self.w_listbox_files.event_generate("<<ListboxSelect>>")

    def update_catalog(self):
        self.set_catalog(self.catalog)

    def select_listbox_file(self, event):
        """
        обработчик выбора файла в списке файлов

        :param event:
        :return:
        """
        try:
            index = self.w_listbox_files.curselection()[0]
            file_ = self.catalog_files[index]
        except IndexError:
            return
        else:
            self.w_frame_child.set_file(file_)
Exemplo n.º 5
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
Exemplo n.º 6
0
    def initUI(self):
        '''Sets up the GUI that is displayed to the user'''
        self.root.title("Network Generator")

        #figure containing the graph
        self.networkPlot = Figure(tight_layout=True)

        #plots-plots are the objects that are actually updated
        self.network = self.networkPlot.add_subplot(111)
        #enable autoscaling
        self.network.autoscale(enable=True)

        #set up canvas, which holds figure containinf the graph
        canvas1 = FigureCanvasTkAgg(self.networkPlot, master=self.root)
        canvas1.show()
        canvas1.get_tk_widget().place(x=0, y=0, height=400, width=800)

        #draw the empty graph (graph initially displayed as a white space
        #until nodes are added)
        nx.draw(self.networkGraph,
                pos=nx.spring_layout(self.networkGraph),
                ax=self.network,
                nodelist=self.networkGraph.nodes())
        #draw the network plot on the canvas
        self.networkPlot.canvas.draw()

        #labels and textfields for links:
        #buttons and textfields 1-5 are for links
        #buttons and textfields 6-9 are for entering flows
        #each number designating a label matches up with the
        #textfield it describes
        label1 = Label(self.root, text="Device 1")
        label1.place(x=100, y=450)
        textfield1 = Text(self.root)
        textfield1.config(width=10, height=1)
        textfield1.place(x=100, y=480)

        label2 = Label(self.root, text="Device 2")
        label2.place(x=200, y=450)
        textfield2 = Text(self.root)
        textfield2.config(width=10, height=1)
        textfield2.place(x=200, y=480)

        label3 = Label(self.root, text="Link Rate(Mbps)")
        label3.place(x=300, y=450)
        textfield3 = Text(self.root)
        textfield3.config(width=10, height=1)
        textfield3.place(x=300, y=480)

        label4 = Label(self.root, text="Link Delay(ms)")
        label4.place(x=400, y=450)
        textfield4 = Text(self.root)
        textfield4.config(width=10, height=1)
        textfield4.place(x=400, y=480)

        label5 = Label(self.root, text="Link Buffer(KB)")
        label5.place(x=500, y=450)
        textfield5 = Text(self.root)
        textfield5.config(width=10, height=1)
        textfield5.place(x=500, y=480)

        #labels for flows and corresponding textfields:
        #buttons and textfields 6-9 are for flows
        label6 = Label(self.root, text="Flow Source")
        label6.place(x=100, y=510)
        textfield6 = Text(self.root)
        textfield6.config(width=10, height=1)
        textfield6.place(x=100, y=530)

        label7 = Label(self.root, text="Flow Destination")
        label7.place(x=200, y=510)
        textfield7 = Text(self.root)
        textfield7.config(width=10, height=1)
        textfield7.place(x=200, y=530)

        label8 = Label(self.root, text="Data Amount(MB)")
        label8.place(x=300, y=510)
        textfield8 = Text(self.root)
        textfield8.config(width=10, height=1)
        textfield8.place(x=300, y=530)

        label9 = Label(self.root, text="Flow Start(s)")
        label9.place(x=400, y=510)
        textfield9 = Text(self.root)
        textfield9.config(width=10, height=1)
        textfield9.place(x=400, y=530)

        #put in buttons that call update functions when pressed
        button1 = Button(self.root,
                         text="Add Host",
                         width=10,
                         command=lambda: self.addHost())
        button1.place(x=0, y=420)
        button2 = Button(self.root,
                         text="Add Router",
                         width=10,
                         command=lambda: self.addRouter())
        button2.place(x=100, y=420)
        # the 1.0 means row 1 column 0
        # we take the text entered in the textfields and send that to the
        # update functions as parameters
        # you need the strip() function to get rid of the newline character
        # automatically place at the end of each text entry
        button3 = Button(
            self.root,
            text="Add Link",
            width=10,
            command=lambda: self.addEdge(
                (textfield1.get("1.0", END).strip(), textfield2.get(
                    "1.0", END).strip(), textfield3.get("1.0", END).strip(),
                 textfield4.get("1.0", END).strip(), textfield5.get(
                     "1.0", END).strip())))
        button3.place(x=0, y=480)
        button4 = Button(
            self.root,
            text="Add Flow",
            width=10,
            command=lambda: self.addFlow(
                (textfield6.get("1.0", END).strip(), textfield7.get(
                    "1.0", END).strip(), textfield8.get("1.0", END).strip(),
                 textfield9.get("1.0", END).strip())))
        button4.place(x=0, y=530)

        #list of flows entered:
        #whenever a new flow is entered (and is unique) it is
        #displayed in this pane
        self.flowlistgui = Text(self.root)
        self.flowlistgui.config(width=95, height=7)
        self.flowlistgui.place(x=0, y=590)

        #scrollbar for flow list
        scrollbar = Scrollbar(self.root)
        scrollbar.config(command=self.flowlistgui.yview)
        self.flowlistgui.config(yscrollcommand=scrollbar.set)
        scrollbar.place(x=750, y=590, height=120)

        #label that goes above flow list
        label10 = Label(self.root, text="Flow List")
        label10.place(x=370, y=565)

        #write to text file button: writing to the text file also
        #closes out the gui
        button5 = Button(self.root,
                         text="Write to File",
                         width=10,
                         command=lambda: self.writeToFile(self.fileOutpath))
        button5.place(x=370, y=720)
Exemplo n.º 7
0
 def initUI(self):
     '''Sets up the GUI that is displayed to the user'''
     self.root.title("Network Generator")     
     
     #figure containing the graph
     self.networkPlot = Figure(tight_layout=True)
     
     #plots-plots are the objects that are actually updated
     self.network = self.networkPlot.add_subplot(111)
     #enable autoscaling
     self.network.autoscale(enable=True) 
     
     #set up canvas, which holds figure containinf the graph
     canvas1 = FigureCanvasTkAgg(self.networkPlot, master=self.root)
     canvas1.show()
     canvas1.get_tk_widget().place(x=0, y=0, height=400, width=800)
     
     #draw the empty graph (graph initially displayed as a white space
     #until nodes are added)
     nx.draw(self.networkGraph,pos=nx.spring_layout(self.networkGraph),
             ax=self.network,nodelist=self.networkGraph.nodes())
     #draw the network plot on the canvas
     self.networkPlot.canvas.draw()
     
     #labels and textfields for links: 
     #buttons and textfields 1-5 are for links
     #buttons and textfields 6-9 are for entering flows
     #each number designating a label matches up with the 
     #textfield it describes
     label1 = Label(self.root, text="Device 1") 
     label1.place(x=100, y=450)   
     textfield1= Text(self.root)
     textfield1.config(width=10, height=1)
     textfield1.place(x=100, y=480)
     
     label2 = Label(self.root, text="Device 2") 
     label2.place(x=200, y=450)    
     textfield2= Text(self.root)
     textfield2.config(width=10, height=1)
     textfield2.place(x=200, y=480)       
     
     label3 = Label(self.root, text="Link Rate(Mbps)") 
     label3.place(x=300, y=450)    
     textfield3= Text(self.root)
     textfield3.config(width=10, height=1)
     textfield3.place(x=300, y=480)  
     
     label4 = Label(self.root, text="Link Delay(ms)") 
     label4.place(x=400, y=450)  
     textfield4= Text(self.root)
     textfield4.config(width=10, height=1)
     textfield4.place(x=400, y=480)  
     
     label5 = Label(self.root, text="Link Buffer(KB)") 
     label5.place(x=500, y=450)    
     textfield5= Text(self.root)
     textfield5.config(width=10, height=1)
     textfield5.place(x=500, y=480)  
     
     #labels for flows and corresponding textfields: 
     #buttons and textfields 6-9 are for flows
     label6 = Label(self.root, text="Flow Source") 
     label6.place(x=100, y=510)   
     textfield6= Text(self.root)
     textfield6.config(width=10, height=1)
     textfield6.place(x=100, y=530)  
     
     label7 = Label(self.root, text="Flow Destination") 
     label7.place(x=200, y=510)      
     textfield7= Text(self.root)
     textfield7.config(width=10, height=1)
     textfield7.place(x=200, y=530)  
     
     label8 = Label(self.root, text="Data Amount(MB)") 
     label8.place(x=300, y=510)      
     textfield8= Text(self.root)
     textfield8.config(width=10, height=1)
     textfield8.place(x=300, y=530)  
     
     label9 = Label(self.root, text="Flow Start(s)") 
     label9.place(x=400, y=510)     
     textfield9= Text(self.root)
     textfield9.config(width=10, height=1)
     textfield9.place(x=400, y=530)          
     
     #put in buttons that call update functions when pressed
     button1 = Button(self.root, text="Add Host", width=10, 
                      command= lambda: self.addHost())
     button1.place(x=0,y=420)
     button2 = Button(self.root, text="Add Router", width=10, 
                      command= lambda: self.addRouter())
     button2.place(x=100,y=420)
     # the 1.0 means row 1 column 0
     # we take the text entered in the textfields and send that to the 
     # update functions as parameters
     # you need the strip() function to get rid of the newline character
     # automatically place at the end of each text entry
     button3 = Button(self.root, text="Add Link", width=10, command= lambda: 
                      self.addEdge((textfield1.get("1.0", END).strip(),
                                    textfield2.get("1.0", END).strip(),
                                    textfield3.get("1.0", END).strip(),
                                    textfield4.get("1.0", END).strip(),
                                    textfield5.get("1.0", END).strip())))
     button3.place(x=0,y=480)
     button4 = Button(self.root, text="Add Flow", width=10, command= lambda: 
                      self.addFlow((textfield6.get("1.0", END).strip(),
                                    textfield7.get("1.0", END).strip(),
                                    textfield8.get("1.0", END).strip(),
                                    textfield9.get("1.0", END).strip())))
     button4.place(x=0,y=530)  
     
     #list of flows entered:
     #whenever a new flow is entered (and is unique) it is 
     #displayed in this pane
     self.flowlistgui = Text(self.root)
     self.flowlistgui.config(width=95, height=7)
     self.flowlistgui.place(x=0,y=590)
     
     #scrollbar for flow list
     scrollbar = Scrollbar(self.root)   
     scrollbar.config(command=self.flowlistgui.yview)
     self.flowlistgui.config(yscrollcommand=scrollbar.set)
     scrollbar.place(x=750,y=590, height=120)  
     
     #label that goes above flow list
     label10 = Label(self.root, text="Flow List") 
     label10.place(x=370, y=565)   
     
     #write to text file button: writing to the text file also
     #closes out the gui
     button5 = Button(self.root, text="Write to File", width=10, 
                     command= lambda: self.writeToFile(self.fileOutpath))
     button5.place(x=370,y=720)