Esempio n. 1
0
    def __init__(self, master):
        self.master = master
        self.dumps = []
        self.downloadpath = 'downloads'
        self.block = False

        # interface elements
        #progressbar
        #self.value = 0
        #self.progressbar = ttk.Progressbar(self.master, orient=HORIZONTAL, value=self.value, mode='determinate')
        #self.progressbar.grid(row=0, column=0, columnspan=1, sticky=W+E)
        #self.run()

        #description
        self.desc = Label(self.master, text="", anchor=W, font=("Arial", 10))
        self.desc.grid(row=0, column=0, columnspan=1)
        #self.footer = Label(self.master, text="%s (version %s). This program is free software (GPL v3 or higher)" % (NAME, VERSION), anchor=W, justify=LEFT, font=("Arial", 10))
        #self.footer.grid(row=2, column=0, columnspan=1)

        #begin tabs
        self.notebook = ttk.Notebook(self.master)
        self.notebook.grid(row=1, column=0, columnspan=1, sticky=W + E + N + S)
        self.frame1 = ttk.Frame(self.master)
        self.notebook.add(self.frame1, text='Dump generator')
        self.frame2 = ttk.Frame(self.master)
        self.notebook.add(self.frame2, text='Downloader')
        self.frame3 = ttk.Frame(self.master)
        self.notebook.add(self.frame3, text='Uploader')

        #dump generator tab (1)
        self.labelframe11 = LabelFrame(self.frame1, text="Single download")
        self.labelframe11.grid(row=0, column=0)
        self.labelframe12 = LabelFrame(self.frame1, text="Batch download")
        self.labelframe12.grid(row=1, column=0)
        #single download labelframe
        self.label11 = Label(self.labelframe11, text="Wiki URL:")
        self.label11.grid(row=0, column=0)
        self.entry11 = Entry(self.labelframe11, width=40)
        self.entry11.grid(row=0, column=1)
        self.entry11.bind('<Return>', (lambda event: self.checkURL()))
        self.optionmenu11var = StringVar(self.labelframe11)
        self.optionmenu11var.set("api.php")
        self.optionmenu11 = OptionMenu(self.labelframe11, self.optionmenu11var,
                                       self.optionmenu11var.get(), "index.php")
        self.optionmenu11.grid(row=0, column=2)
        self.button11 = Button(
            self.labelframe11,
            text="Check",
            command=lambda: thread.start_new_thread(self.checkURL, ()),
            width=5)
        self.button11.grid(row=0, column=3)
        #batch download labelframe
        self.label12 = Label(self.labelframe12, text="Wiki URLs:")
        self.label12.grid(row=0, column=0)
        self.text11 = Text(self.labelframe12, width=70, height=20)
        self.text11.grid(row=0, column=1)

        #downloader tab (2)
        self.label25var = StringVar(self.frame2)
        self.label25var.set("Available dumps: 0 (0.0 MB)")
        self.label25 = Label(self.frame2,
                             textvariable=self.label25var,
                             width=27,
                             anchor=W)
        self.label25.grid(row=0, column=0, columnspan=2)
        self.label26var = StringVar(self.frame2)
        self.label26var.set("Downloaded: 0 (0.0 MB)")
        self.label26 = Label(self.frame2,
                             textvariable=self.label26var,
                             background='lightgreen',
                             width=27,
                             anchor=W)
        self.label26.grid(row=0, column=2, columnspan=2)
        self.label27var = StringVar(self.frame2)
        self.label27var.set("Not downloaded: 0 (0.0 MB)")
        self.label27 = Label(self.frame2,
                             textvariable=self.label27var,
                             background='white',
                             width=27,
                             anchor=W)
        self.label27.grid(row=0, column=4, columnspan=2)

        self.label21 = Label(self.frame2,
                             text="Filter by wikifarm:",
                             width=15,
                             anchor=W)
        self.label21.grid(row=1, column=0)
        self.optionmenu21var = StringVar(self.frame2)
        self.optionmenu21var.set("all")
        self.optionmenu21 = OptionMenu(self.frame2, self.optionmenu21var,
                                       self.optionmenu21var.get(),
                                       "Gentoo Wiki", "OpenSuSE", "Referata",
                                       "ShoutWiki", "Unknown", "Wikanda",
                                       "WikiFur", "Wikimedia", "WikiTravel",
                                       "Wikkii")
        self.optionmenu21.grid(row=1, column=1)

        self.label22 = Label(self.frame2,
                             text="Filter by size:",
                             width=15,
                             anchor=W)
        self.label22.grid(row=1, column=2)
        self.optionmenu22var = StringVar(self.frame2)
        self.optionmenu22var.set("all")
        self.optionmenu22 = OptionMenu(self.frame2, self.optionmenu22var,
                                       self.optionmenu22var.get(), "KB", "MB",
                                       "GB", "TB")
        self.optionmenu22.grid(row=1, column=3)

        self.label23 = Label(self.frame2,
                             text="Filter by date:",
                             width=15,
                             anchor=W)
        self.label23.grid(row=1, column=4)
        self.optionmenu23var = StringVar(self.frame2)
        self.optionmenu23var.set("all")
        self.optionmenu23 = OptionMenu(self.frame2, self.optionmenu23var,
                                       self.optionmenu23var.get(), "2011",
                                       "2012")
        self.optionmenu23.grid(row=1, column=5)

        self.label24 = Label(self.frame2, text="Filter by mirror:")
        self.label24.grid(row=1, column=6)
        self.optionmenu24var = StringVar(self.frame2)
        self.optionmenu24var.set("all")
        self.optionmenu24 = OptionMenu(self.frame2, self.optionmenu24var,
                                       self.optionmenu24var.get(),
                                       "Google Code", "Internet Archive",
                                       "ScottDB")
        self.optionmenu24.grid(row=1, column=7)

        self.button23 = Button(self.frame2,
                               text="Filter!",
                               command=self.filterAvailableDumps,
                               width=7)
        self.button23.grid(row=1, column=8)

        self.treescrollbar = Scrollbar(self.frame2)
        self.treescrollbar.grid(row=2, column=9, sticky=W + E + N + S)
        columns = ('dump', 'wikifarm', 'size', 'date', 'mirror', 'status')
        self.tree = ttk.Treeview(self.frame2,
                                 height=20,
                                 columns=columns,
                                 show='headings',
                                 yscrollcommand=self.treescrollbar.set)
        self.treescrollbar.config(command=self.tree.yview)
        self.tree.column('dump', width=495, minwidth=200, anchor='center')
        self.tree.heading('dump', text='Dump')
        self.tree.column('wikifarm', width=100, minwidth=100, anchor='center')
        self.tree.heading('wikifarm', text='Wikifarm')
        self.tree.column('size', width=100, minwidth=100, anchor='center')
        self.tree.heading('size', text='Size')
        self.tree.column('date', width=100, minwidth=100, anchor='center')
        self.tree.heading('date', text='Date')
        self.tree.column('mirror', width=120, minwidth=120, anchor='center')
        self.tree.heading('mirror', text='Mirror')
        self.tree.column('status', width=120, minwidth=120, anchor='center')
        self.tree.heading('status', text='Status')
        self.tree.grid(row=2, column=0, columnspan=9, sticky=W + E + N + S)
        [
            self.tree.heading(column,
                              text=column,
                              command=lambda: self.treeSortColumn(
                                  column=column, reverse=False))
            for column in columns
        ]
        #self.tree.bind("<Double-1>", (lambda: thread.start_new_thread(self.downloadDump, ())))
        self.tree.tag_configure('downloaded', background='lightgreen')
        self.tree.tag_configure('nodownloaded', background='white')
        self.button21 = Button(
            self.frame2,
            text="Load available dumps",
            command=lambda: thread.start_new_thread(self.loadAvailableDumps,
                                                    ()),
            width=15)
        self.button21.grid(row=3, column=0)
        self.button23 = Button(
            self.frame2,
            text="Download selection",
            command=lambda: thread.start_new_thread(self.downloadDump, ()),
            width=15)
        self.button23.grid(row=3, column=4)
        self.button22 = Button(self.frame2,
                               text="Clear list",
                               command=self.deleteAvailableDumps,
                               width=10)
        self.button22.grid(row=3, column=8, columnspan=2)

        #uploader tab (3)
        self.label31 = Label(self.frame3, text="todo...")
        self.label31.grid(row=0, column=0)
        #end tabs

        #statusbar
        self.status = Label(
            self.master,
            text=
            "Welcome to WikiTeam tools. What wiki do you want to preserve today?",
            bd=1,
            background='grey',
            justify=LEFT,
            relief=SUNKEN)
        self.status.grid(row=4, column=0, columnspan=10, sticky=W + E)

        #begin menu
        menu = Menu(self.master)
        master.config(menu=menu)

        #file menu
        filemenu = Menu(menu)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="Preferences", command=self.callback)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=askclose)

        #help menu
        helpmenu = Menu(menu)
        menu.add_cascade(label="Help", menu=helpmenu)
        helpmenu.add_command(label="About", command=self.callback)
        helpmenu.add_command(label="Help index", command=self.callback)
        helpmenu.add_command(label="WikiTeam homepage",
                             command=lambda: webbrowser.open_new_tab(HOMEPAGE))
Esempio n. 2
0
# Add the scrollbar to the listbox frame
listTableScrollbar = Scrollbar(listFrame)
listTableScrollbar.pack(side=RIGHT, fill=Y)

# Add the listbox and bind doubleclicking on an entry to open that applicable entry
listTable = Listbox(listFrame, bd=0, yscrollcommand=listTableScrollbar.set)
listTable.pack(side="left", fill=BOTH, expand=True)
listTable.bind("<Double-Button-1>", SelectEntry)
listTableScrollbar.configure(command=listTable.yview)

# Pack the frame
listFrame.pack(side="left", fill=BOTH, expand=True)

# Add the tabs to the main window
tabs = ttk.Notebook(mainFrame)
viewEntries = ttk.Frame(tabs)
addEntries = ttk.Frame(tabs)
tabs.pack(side="right", fill=BOTH, expand=True)
tabs.add(viewEntries, text='View Entry')
tabs.add(addEntries, text='Add Entries')

################################################################################
# SETTING UP VIEWENTRIES
################################################################################

# Add the labels to the viewentries tabs
aliasViewLabel = Label(viewEntries,
                       text="Name/Alias: ",
                       padx=padding,
                       pady=padding,
def start():
    main_frame.pack_forget()

    # GUI Generate Tabs
    noteb = ttk.Notebook(main_window)
    noteb.pack(fill=BOTH, expand=1, padx=5, pady=5)
    noteb.pressed_index = None
    tab1 = Frame(noteb)
    tab1.pack(fill=BOTH, expand=1, padx=5, pady=5)
    noteb.add(tab1, text="Choose Files")

    # GUI Load your annotation
    def load_report():
        # Function for loading pwy-inference-report file by user in the GUI. The selected file path is displayed in the GUI.
        ld_report = str(
            tkFileDialog.askopenfilename(initialdir=os.getcwd,
                                         title="Select",
                                         filetypes=(("TXT files", "*.txt"),
                                                    ("all files", "*.*file"))))
        load_your_report_label.config(text=ld_report)
        select_report_button.config(state="normal")

    load_your_report_framelabel = LabelFrame(
        tab1,
        text="Load pwy-inference-report",
        relief=framelabel_relief,
        font=framelabel_font,
        borderwidth=framelabel_borderwidth)
    load_your_report_framelabel.pack(fill=X, padx=5, pady=10)
    load_your_report_label = Label(load_your_report_framelabel,
                                   text=ld_report,
                                   font=label_font,
                                   wraplength=label_wraplength)
    load_your_report_label.pack(fill=X, padx=5, pady=5)
    load_your_report_button = Button(load_your_report_framelabel,
                                     text="Load",
                                     command=load_report,
                                     font=button_font,
                                     cursor=button_cursor,
                                     overrelief=button_overrelief,
                                     bg=button_bg,
                                     borderwidth=button_borderwidth)
    load_your_report_button.pack(fill=X, padx=5, pady=5)

    # GUI Select report location
    def select_report():
        # Function to select and enter the report file name. The selected file path is displayed in the GUI.
        sel_report = str(
            tkFileDialog.asksaveasfilename(
                initialdir=os.getcwd,
                title=
                "Select the path for the storage and enter the filename (*.txt) of the report!",
                filetypes=(("txt files", "*.txt"), ("all files", "*.*"))))
        select_report_label.config(text=sel_report)
        get_pwys_button.config(state="normal")

    select_report_framelabel = LabelFrame(
        tab1,
        text="Select Location For Report File Storing",
        relief=framelabel_relief,
        font=framelabel_font,
        borderwidth=framelabel_borderwidth)
    select_report_framelabel.pack(fill=X, padx=5, pady=10)
    select_report_label = Label(select_report_framelabel,
                                text=sel_report,
                                font=label_font,
                                wraplength=label_wraplength)
    select_report_label.pack(fill=X, padx=5, pady=5)
    select_report_button = Button(select_report_framelabel,
                                  text="Select and enter name (.txt)!",
                                  state=DISABLED,
                                  command=select_report,
                                  font=button_font,
                                  cursor=button_cursor,
                                  overrelief=button_overrelief,
                                  bg=button_bg,
                                  borderwidth=button_borderwidth)
    select_report_button.pack(fill=X, padx=5, pady=5)

    def get_pwys():
        # Disable "Choose Files" Buttons
        load_your_report_button.config(state=DISABLED)
        select_report_button.config(state=DISABLED)
        get_pwys_button.config(state=DISABLED)

        tab2 = Frame(noteb)
        tab2.pack(fill=BOTH, expand=1, padx=5, pady=5)
        noteb.add(tab2, text="Results")
        noteb.select(tab2)
        # GUI add objects for a scrollable tab
        mycanvas = Canvas(tab2)
        mycanvas.pack(side="left", fill=BOTH, expand=1)

        unacc_frame = Frame(mycanvas)
        unacc_frame.pack(fill=BOTH, expand=1, padx=5, pady=5)
        mycanvas.create_window(0, 0, window=unacc_frame, anchor="nw")

        # Start filtering
        filer = open(load_your_report_label["text"], "r").read()
        if operating_system == "Windows":
            pwyblock = filer.split(
                "Here is the result of determine-pathways-with-cf:")[1].split(
                    "\nList of pathways pruned")[0]
            pwys = pwyblock.split("\n (")[1:]
        else:
            pwyblock = filer.split(
                "Here is the result of determine-pathways-with-cf:")[1].split(
                    "\r\nList of pathways pruned")[0]
            pwys = pwyblock.split("\r\n (")[1:]
        pwys_miss_reac = {}
        for i in range(len(pwys)):
            if operating_system == "Windows":
                pwys[i] = pwys[i].replace("\n", "")
            else:
                pwys[i] = pwys[i].replace("\r\n", "")

        for i in pwys:
            c = 0
            missingreac = []
            presentreac = []
            i = i.replace(" (", "-(")
            if "REACTIONS-MISSING" in i:
                c = 1
                pwy_name_reason = i.split(" ")[0] + "\t" + i.split("-(")[1]

                if "REACTIONS-PRESENT" in i:
                    o = i.split("REACTIONS-PRESENT")[1]
                    if " NIL)" not in o.split(") ")[0]:
                        oo = o.split("-(")[1].split(")")[0]
                        if " " in oo:
                            for tt in oo.split(" "):
                                if tt != "":
                                    presentreac.append(tt)
                        else:
                            presentreac.append(oo)
                z = i.split("REACTIONS-MISSING")[1]
                if " NIL)" not in z.split(") ")[0]:
                    r = z.split("-(")[1].split(")")[0]
                    if " " in r:
                        for t in r.split(" "):
                            if t != "":
                                missingreac.append(t)
                    else:
                        missingreac.append(r)
            if c == 1:
                react = (missingreac, presentreac)
                pwys_miss_reac[pwy_name_reason] = react
        out = open(select_report_label["text"], "w")
        out.write(
            "This file contains all PWYs with missing Reactions they are not added by PathoLogic:\n"
        )
        for l in pwys_miss_reac:
            if len(pwys_miss_reac[l][1]) > len(
                    pwys_miss_reac[l][0]) and "PASSING-SCORE" not in l:
                out.write(
                    l + "\t" + str(len(pwys_miss_reac[l][0])) + "\tof\t" +
                    str(len(pwys_miss_reac[l][1]) +
                        len(pwys_miss_reac[l][0])) + "\treactions missing!\n")
            if len(pwys_miss_reac[l][1]) == len(
                    pwys_miss_reac[l][0]) and "PASSING-SCORE" not in l:
                out.write(
                    l + "\t" + str(len(pwys_miss_reac[l][0])) + "\tof\t" +
                    str(len(pwys_miss_reac[l][1]) +
                        len(pwys_miss_reac[l][0])) + "\treactions missing!\n")
        out.close()

        result_framelabel = LabelFrame(unacc_frame,
                                       relief=framelabel_relief,
                                       borderwidth=framelabel_borderwidth)
        result_framelabel.pack(fill=X, padx=5, pady=5)
        result_label = Label(
            result_framelabel,
            text=
            "The pathways have been filtered and were listed below as well as in the report file.\n\nA possible strategy could be to add all filtered pathways to the PGDB and run Pathway Tools Pathway Hole Filler. All pathways that are complete after this step could be kept and the others should be searched for possible gene candidates in the report file of the pathway hole filler. If no gene could be assigned to the missing reaction, remove the pathway.",
            font=label_font,
            wraplength=label_wraplength)
        result_label.pack(fill=X, padx=5, pady=5)

        result2_framelabel = LabelFrame(unacc_frame,
                                        text="Filtered Pathways:",
                                        relief=framelabel_relief,
                                        font=framelabel_font,
                                        borderwidth=framelabel_borderwidth)
        result2_framelabel.pack(fill=X, padx=5, pady=5)
        read_report = open(select_report_label["text"], "r")
        header1_label = Label(result2_framelabel,
                              text="FRAME-ID",
                              font="Arial 10 bold",
                              wraplength=label_wraplength)
        header1_label.grid(row=0, column=0, padx=5, sticky=W + E + N + S)
        header2_label = Label(result2_framelabel,
                              text="REASON",
                              font="Arial 10 bold",
                              wraplength=label_wraplength)
        header2_label.grid(row=0, column=1, padx=5, sticky=W + E + N + S)
        header3_label = Label(result2_framelabel,
                              text="NUMBER OF MISSING REACTIONS",
                              font="Arial 10 bold",
                              wraplength=label_wraplength)
        header3_label.grid(row=0, column=2, padx=5, sticky=W + E + N + S)
        row_nr = 0
        for line in read_report:
            if "This file contains all PWYs with missing Reactions they are not added by PathoLogic:\n" not in line:
                row_nr = row_nr + 1
                result2_label = Label(result2_framelabel,
                                      text=line.split("\t")[0],
                                      font=label_font,
                                      wraplength=label_wraplength)
                result2_label.grid(row=row_nr,
                                   column=0,
                                   padx=5,
                                   sticky=W + E + N + S)
                result3_label = Label(result2_framelabel,
                                      text=line.split("\t")[1],
                                      font=label_font,
                                      wraplength=label_wraplength)
                result3_label.grid(row=row_nr,
                                   column=1,
                                   padx=5,
                                   sticky=W + E + N + S)
                result4_label = Label(result2_framelabel,
                                      text=line.split("\t")[2:-1],
                                      font=label_font,
                                      wraplength=label_wraplength)
                result4_label.grid(row=row_nr,
                                   column=2,
                                   padx=5,
                                   sticky=W + E + N + S)

        def open_report():
            if operating_system == "Windows":
                startfile(select_report_label["text"])
            else:
                subprocess.call(['xdg-open', select_report_label["text"]])

        open_report_button = Button(unacc_frame,
                                    text="Open report file!",
                                    command=open_report,
                                    font=button_font,
                                    cursor=button_cursor,
                                    overrelief=button_overrelief,
                                    bg=button_bg,
                                    borderwidth=button_borderwidth)
        open_report_button.pack(expand=1, fill=X, padx=5, pady=5)

        quit_button = Button(unacc_frame,
                             text="Quit",
                             command=close_program,
                             font=button_font,
                             cursor=button_cursor,
                             overrelief=button_overrelief,
                             bg=button_bg,
                             borderwidth=button_borderwidth)
        quit_button.pack(expand=1, fill=X, padx=5, pady=5)
        # If the content of the unacc_frame is to big for the window, than add a scrollbar
        mycanvas.update()
        main_window.update()
        if unacc_frame.winfo_height() > (main_window.winfo_height() - 50):
            myscrollbar = Scrollbar(tab2, command=mycanvas.yview)
            mycanvas.config(yscrollcommand=myscrollbar.set,
                            scrollregion=mycanvas.bbox("all"))
            myscrollbar.pack(side=RIGHT, fill=Y)

            def mousewheel(event):
                if operating_system == "Windows":
                    mycanvas.yview_scroll(int(-1 * (event.delta / 120)),
                                          "units")
                elif operating_system == "Linux":
                    if event.num == 4:
                        mycanvas.yview_scroll(-1, "units")
                    if event.num == 5:
                        mycanvas.yview_scroll(1, "units")
                elif operating_system == "Darwin":
                    mycanvas.yview_scroll((event.delta / 120), "units")

            if operating_system == "Linux":
                mycanvas.bind_all("<Button-4>", mousewheel)
                mycanvas.bind_all("<Button-5>", mousewheel)
            else:
                mycanvas.bind_all("<MouseWheel>", mousewheel)

    get_pwys_button = Button(tab1,
                             text="Get Pathways",
                             command=get_pwys,
                             state=DISABLED,
                             font=button_font,
                             cursor=button_cursor,
                             overrelief=button_overrelief,
                             bg=button_bg,
                             borderwidth=button_borderwidth)
    get_pwys_button.pack(expand=1, fill=BOTH, padx=5, pady=10)
Esempio n. 4
0
    def initialize_widgets(self):
        """Initializes all needed widgets for the page."""
        self.label_title = tk.Label(self, text="Parameter Configuration", font=("Arial", 20, 'bold'), fg="white",
                                    bg="#7695e3", )

        self.grid_top = tk.LabelFrame(self, text="Settings", font=("Arial", 16, 'bold'))
        self.grid_middle = tk.LabelFrame(self, text="Varying Parameter Configuration", font=("Arial", 16, 'bold'))
        self.grid_bottom = tk.LabelFrame(self, text="Fixed Parameter Configuration", font=("Arial", 16, 'bold'))

        #########################
        # Widgets for top grid
        #########################
        self.label_mode = tk.Label(self.grid_top, text='Mode')
        self.dropdown_mode = tk.OptionMenu(self.grid_top, self.mode, *self.model.mode_options, command=self.set_mode)
        self.label_sm = tk.Label(self.grid_top, text='Sky Brightness Distribution')
        self.dropdown_sm = tk.OptionMenu(self.grid_top, self.sm, *self.model.sm_options, command=self.set_skymodel)

        self.button_popup_help_settings = tk.Button(self.grid_top, text="?", command=self.popup.popup_window_settings,
                                                    width=4)

        self.label_telescope = tk.Label(self.grid_top, text='Telescope: ')
        self.dropdown_telescope = tk.OptionMenu(self.grid_top, self.telescope, *self.model.telescope_options,
                                                command=self.set_telescope)

        self.label_browse_antenna = tk.Label(self.grid_top, text="Choose antenna list")
        self.entry_browse_antenna = tk.Entry(self.grid_top, state="normal")
        self.entry_browse_antenna.insert(0, self.model.antennalist)
        self.button_browse_antenna = tk.Button(self.grid_top, text="Browse...", command=self.browse_antenna_file,
                                               state="normal")

        #########################
        # Widgets for middle grid
        #########################
        self.grid_var_params_radio = tk.Frame(self.grid_middle)
        self.radio_manual = tk.Radiobutton(self.grid_var_params_radio, text="Manual", variable=self.var_radio, value=1,
                                           command=self.toggle_browsing)
        self.radio_file = tk.Radiobutton(self.grid_var_params_radio, text="From file", variable=self.var_radio, value=2,
                                         command=self.toggle_browsing)

        self.button_popup_help_var_params = tk.Button(self.grid_var_params_radio, text="?",
                                                      command=self.popup.popup_window_var_param, width=4)

        self.label_browse = tk.Label(self.grid_var_params_radio, text="Csv-file path")
        self.entry_browse = tk.Entry(self.grid_var_params_radio, state="disabled")
        self.button_browse = tk.Button(self.grid_var_params_radio, text="Browse...", command=self.browse_file,
                                       state="disabled")

        self.grid_var_param_settings = tk.Frame(self.grid_middle)
        self.label_var_param_set = tk.Label(self.grid_var_param_settings, text="Varying Parameter Set")
        self.dropdown_var_param_set = tk.OptionMenu(self.grid_var_param_settings, self.var_param_set,
                                                    *self.model.var_param_set_options,
                                                    command=self.get_var_param_options)

        self.grid_var_param_checkboxes = tk.Frame(self.grid_middle)

        self.table_var_params_num = tk.Frame(self.grid_middle)
        self.label_name_num = tk.Label(self.table_var_params_num, text="Name", borderwidth=1, relief="solid")
        self.label_min_num = tk.Label(self.table_var_params_num, text="Min", borderwidth=1, relief="solid")
        self.label_max_num = tk.Label(self.table_var_params_num, text="Max", borderwidth=1, relief="solid")
        self.label_steps_num = tk.Label(self.table_var_params_num, text="Steps", borderwidth=1, relief="solid")
        self.label_units_num = tk.Label(self.table_var_params_num, text="Units", borderwidth=1, relief="solid")

        self.grid_var_params_str = tk.Frame(self.grid_middle)
        self.label_name_str = tk.Label(self.grid_var_params_str, text="Name", borderwidth=1, relief="solid")
        self.label_values_str = tk.Label(self.grid_var_params_str, text="Values", borderwidth=1, relief="solid")

        #########################
        # Widgets for bottom grid
        #########################
        self.note = ttk.Notebook(self.grid_bottom)
        self.tab1 = tk.Frame(self.note)
        self.tab2 = tk.Frame(self.note)
        self.tab3 = tk.Frame(self.note)
        self.note.add(self.tab1, text="Instrumental")
        self.note.add(self.tab2, text="Sky-model")
        self.note.add(self.tab3, text="Sources")

        # Widgets for grid_fixed_sim
        self.grid_browse_fixed_sim = tk.Frame(self.tab1)
        self.button_popup_help_fixed_params_tab1 = tk.Button(self.grid_browse_fixed_sim, text="?",
                                                             command=self.popup.popup_window_fixed_param, width=4)
        self.label_browse_fixed_sim = tk.Label(self.grid_browse_fixed_sim,
                                               text="Choose from file")
        self.entry_browse_fixed_sim = tk.Entry(self.grid_browse_fixed_sim, state="normal")
        self.button_browse_fixed_sim = tk.Button(self.grid_browse_fixed_sim, text="Browse...",
                                                 command=self.load_fixed_params_sim, state="normal")
        self.table_fixed_params_sim = tk.Frame(self.tab1)

        # Widgets for grid_fixed_sm
        self.grid_browse_fixed_sm = tk.Frame(self.tab2)
        self.button_popup_help_fixed_params_tab2 = tk.Button(self.grid_browse_fixed_sm, text="?",
                                                             command=self.popup.popup_window_fixed_param, width=4)
        self.label_browse_fixed_sm = tk.Label(self.grid_browse_fixed_sm,
                                              text="Choose from file")
        self.entry_browse_fixed_sm = tk.Entry(self.grid_browse_fixed_sm, state="normal")
        self.button_browse_fixed_sm = tk.Button(self.grid_browse_fixed_sm, text="Browse...",
                                                command=self.load_fixed_params_sm, state="normal")
        self.table_fixed_params_sm = tk.Frame(self.tab2)

        # Widgets for grid_fixed_sp
        self.grid_nsp = tk.Frame(self.tab3)
        self.button_popup_help_fixed_params_tab3 = tk.Button(self.grid_nsp, text="?",
                                                             command=self.popup.popup_window_fixed_param_sources,
                                                             width=4)
        self.label_nsp = tk.Label(self.grid_nsp, text="Number Of Sources")
        self.dropdown_nsp = tk.OptionMenu(self.grid_nsp, self.number_of_sources,
                                          *[1, 2, 3, 4, 5],
                                          command=self.create_entry_table_sources)

        self.table_sources = tk.Frame(self.tab3)
        self.label_sp_name = tk.Label(self.table_sources, text="Parameter", borderwidth=1, relief="solid")
        self.label_sp_flux = tk.Label(self.table_sources, text="sp_flux")
        self.label_sp_fluxunit = tk.Label(self.table_sources, text="sp_fluxunit")
        self.label_sp_direction_ra = tk.Label(self.table_sources, text="sp_direction_ra")
        self.label_sp_direction_dec = tk.Label(self.table_sources, text="sp_direction_dec")
        self.label_sp_shape = tk.Label(self.table_sources, text="sp_shape")
        self.label_sp_majoraxis = tk.Label(self.table_sources, text="sp_majoraxis")
        self.label_sp_minoraxis = tk.Label(self.table_sources, text="sp_minoraxis")
        self.label_sp_positionangle = tk.Label(self.table_sources, text="sp_positionangle")
        self.label_sp_frequency = tk.Label(self.table_sources, text="sp_frequency")
        self.label_sp_frequency_unit = tk.Label(self.table_sources, text="sp_frequency_unit")
Esempio n. 5
0
 def __init_notebook_container__(self):
     self.notebook = ttk.Notebook(self)
     self.notebook.pack(side=LEFT, fill=BOTH, expand=True, padx=10, pady=10)
Esempio n. 6
0
    def draw_config_window(self):
        global username, password, host, sip_username, sip_password, common_objects

        # Configuration instance
        elements = common_objects['myconf'].get_configuration()

        wwindow_conf = Toplevel(self.parent_win)
        wwindow_conf.title('Configuration')
        wwindow_conf.resizable(width=FALSE, height=FALSE)
        wnotebook = ttk.Notebook(wwindow_conf)
        wf1 = ttk.Frame(wnotebook, padding="20 20 20 20")
        wf2 = ttk.Frame(wnotebook, padding="20 20 20 20")
        wnotebook.add(wf1, text='Elastix Account')
        wnotebook.add(wf2, text='SIP Account')

        #Textfield Host
        wlabel_host = ttk.Label(wf1, text='Elastix Host: ')
        wlabel_host.grid(column=0, row=0, sticky=E)
        host = StringVar()
        wtext_host = ttk.Entry(wf1, textvariable=host)
        wtext_host.grid(column=1, row=0)
        if elements['elx_host']:
            wtext_host.delete(0, END)
            wtext_host.insert(0, elements['elx_host'])
        #Textfield Username
        wlabel_username = ttk.Label(wf1, text='Elastix Username: '******'http_user']:
            wtext_username.delete(0, END)
            wtext_username.insert(0, elements['http_user'])
        #Textfield Password
        wlabel_password = ttk.Label(wf1, text='Password: '******'http_pass']:
            wtext_password.delete(0, END)
            wtext_password.insert(0, elements['http_pass'])
        #Button
        wbutton_update_config = ttk.Button(
            wf1,
            text="Update Configuration",
            command=self.cb_update_configuration)
        wbutton_update_config.grid(column=1, row=3)

        #Textfield Username SIP
        wlabel_sip_username = ttk.Label(wf2, text='SIP Username: '******'sip_user']:
            wtext_sip_username.delete(0, END)
            wtext_sip_username.insert(0, elements['sip_user'])
        #Textfield Password SIP
        wlabel_sip_password = ttk.Label(wf2, text='SIP Password: '******'sip_pass']:
            wtext_sip_password.delete(0, END)
            wtext_sip_password.insert(0, elements['sip_pass'])
        #Button
        wbutton_update_sip_config = ttk.Button(
            wf2,
            text="Update Configuration",
            command=self.cb_update_configuration)
        wbutton_update_sip_config.grid(column=1, row=2)

        wnotebook.pack()
Esempio n. 7
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        top.geometry("1024x600+0+0")
        top.attributes("-fullscreen", True)
        top.title("Treadmill")
        top.configure(highlightcolor="black")

        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])
        self.TNotebook1 = ttk.Notebook(top)
        self.TNotebook1.place(relx=0.019,
                              rely=0.1,
                              relheight=0.887,
                              relwidth=0.967)
        self.TNotebook1.configure(width=1002)
        self.TNotebook1.configure(takefocus="")
        self.TNotebook1_t0 = Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t0, padding=3)
        self.TNotebook1.tab(
            0,
            text="Graph",
            compound="left",
            underline="-1",
        )
        self.TNotebook1_t1 = Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t1, padding=3)
        self.TNotebook1.tab(
            1,
            text="Recap",
            compound="left",
            underline="-1",
        )

        self.Canvas1 = Canvas(self.TNotebook1_t0)
        self.Canvas1.place(relx=0.08,
                           rely=0.118,
                           relheight=0.865,
                           relwidth=0.821)
        self.Canvas1.configure(borderwidth="2")
        self.Canvas1.configure(relief=RIDGE)
        self.Canvas1.configure(selectbackground="#c4c4c4")
        self.Canvas1.configure(width=821)

        self.Label1 = Label(self.TNotebook1_t0)
        self.Label1.place(relx=0.08, rely=0.059, height=17, width=84)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(text='''Heart Rate''')

        self.Label2 = Label(self.TNotebook1_t0)
        self.Label2.place(relx=0.21, rely=0.059, height=17, width=34)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(text='''Max :''')

        self.Label3 = Label(self.TNotebook1_t0)
        self.Label3.place(relx=0.27, rely=0.059, height=17, width=78)
        self.Label3.configure(activebackground="#f9f9f9")
        self.Label3.configure(text='''max_value''')

        self.Label4 = Label(self.TNotebook1_t0)
        self.Label4.place(relx=0.4, rely=0.059, height=17, width=58)
        self.Label4.configure(activebackground="#f9f9f9")
        self.Label4.configure(text='''Average :''')

        self.Label3 = Label(self.TNotebook1_t0)
        self.Label3.place(relx=0.48, rely=0.059, height=17, width=108)
        self.Label3.configure(activebackground="#f9f9f9")
        self.Label3.configure(text='''average_value''')

        self.Labelframe1 = LabelFrame(self.TNotebook1_t1)
        self.Labelframe1.place(relx=0.02,
                               rely=0.02,
                               relheight=0.951,
                               relwidth=0.96)
        self.Labelframe1.configure(relief=GROOVE)
        self.Labelframe1.configure(text='''Labelframe''')
        self.Labelframe1.configure(width=960)

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.229,
                               rely=0.247,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Average Heart Rate''')
        self.Labelframe2.configure(width=150)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.207,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Label''')

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''BPM''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.417,
                               rely=0.247,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Total Steps''')
        self.Labelframe2.configure(width=150)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.207,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Label''')

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Steps''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.604,
                               rely=0.247,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Burned Calories''')
        self.Labelframe2.configure(width=150)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.207,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Label''')

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Cal''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.229,
                               rely=0.557,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Maximum Heart Rate''')
        self.Labelframe2.configure(width=150)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.207,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Label''')

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''BPM''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.417,
                               rely=0.557,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Step Frequency''')
        self.Labelframe2.configure(width=150)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.207,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Label''')

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Steps''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.604,
                               rely=0.557,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Covered''')
        self.Labelframe2.configure(width=150)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.207,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Label''')

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Km''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.052,
                               rely=0.392,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Speed''')
        self.Labelframe2.configure(width=150)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.207,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Label''')

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.133,
                          rely=0.552,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Km/hr''')

        self.Labelframe2 = LabelFrame(self.Labelframe1)
        self.Labelframe2.place(relx=0.781,
                               rely=0.392,
                               relheight=0.299,
                               relwidth=0.156,
                               bordermode='ignore')
        self.Labelframe2.configure(relief=GROOVE)
        self.Labelframe2.configure(text='''Time''')
        self.Labelframe2.configure(width=150)

        self.Label5 = Label(self.Labelframe2)
        self.Label5.place(relx=0.067,
                          rely=0.345,
                          height=37,
                          width=114,
                          bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Label''')

        self.back = Button(top)
        self.back.place(relx=0.019, rely=0.017, height=35, width=62)
        self.back.configure(activebackground="#d9d9d9")
        self.back.configure(command=recap_support.destroy_window)
        self.back.configure(text='''Back''')
        self.back.configure(width=62)
			line="     "+line[:len(line)-4]
			List.insert(y,line)
			y=y+1
		f1.close()
	else:
		label.configure(text="All Available Options : ")
		f1=open('new3.txt','r+')
		y=0
		for line in f1:
			line="     "+line[:len(line)-4]
			List.insert(y,line)
			y=y+1
		f1.close()
main_window=Tkinter.Tk()
main_window.wm_title("                                                                       Unix Project")
tab1=ttk.Notebook(main_window)
tab1.pack()
frame1=Tkinter.Frame(main_window,width=730,height=630)
frame1.pack()
tab1.add(frame1,text="                                 Package Installer                                  ",state="normal")
frame2=Tkinter.Frame(main_window,width=600,height=600)
frame2.pack()
tab1.add(frame2,text="                                 Online Help                                   ",state="normal")
search=Tkinter.Entry(frame1,bd=5)
search.place(x=200,y=13)
search_but=Tkinter.Button(frame1,text="        Search        ",command=clicked)
search_but.place(x=400,y=10)
List=Tkinter.Listbox(frame1,width=50,height=33)
x=0
fo=open('new3.txt','r')
for line in fo:
Esempio n. 9
0
def gui():
    """""" """""" """""" """
     G  L  O  B  A  L  S
    """ """""" """""" """"""
    #    global dispInterf_state
    #    global stop_event

    global root, livefeed_canvas, imageplots_frame

    global slider_exposure, measurementfolder_name, calibrationfolder_name
    global button_initcamera, button_release, button_saveconfig
    global text_config, tbox, entry_measfolder, entry_calibfolder, piezosteps_var, CheckVar, output_text
    global a, colors, canvas_plot, line, ax

    global updateconfig_event

    global POI, ROI
    global displaymidline_state
    global piezo_dispaxis, calib_linear_region
    global toggle_selector_RS

    POI, ROI = [], []
    displaymidline_state = False
    measurementfolder_name = 'stack'
    calibrationfolder_name = 'stack'
    calib_linear_region = [19, None]

    #    dispInterf_state = 0

    q = Queue()
    stdout_queue = Queue()

    beginlive_event = Event()
    stoplive_event = Event()
    release_event = Event()
    #    stop_event = Event()
    piezostep_event = Event()
    updateconfig_event = Event()
    plotmidline_event = Event()
    """
    MAIN WINDOW
    """
    root = tk.Tk()
    root.iconbitmap('winicon.ico')
    #root.wm_attributes('-topmost', 1)
    #    w, h = root.winfo_screenwidth(), root.winfo_screenheight()
    #root.geometry("%dx%d+0+0" % (w, h))
    root.title('White light interferometry: Topography')
    root.configure(background='grey')
    """
    MENU
    """
    menubar = tk.Menu(root)
    filemenu = tk.Menu(menubar, tearoff=0)
    #filemenu.add_command(label = 'Load image', command=openimage)
    filemenu.add_command(label='Save displayed image')
    menubar.add_cascade(label='File', menu=filemenu)

    optionsmenu = tk.Menu(menubar, tearoff=0)
    optionsmenu.add_command(label='Configure camera')
    menubar.add_cascade(label='Options', menu=optionsmenu)

    menubar.add_command(label='Help')
    """""" """""" """""" """""" """""" """""" """""" """""" """""" """""" """""" """
            L        A        Y        O        U        T
    """ """""" """""" """""" """""" """""" """""" """""" """""" """""" """""" """"""
    """
    2 MAIN TABS
    """
    tabControl = ttk.Notebook(root)
    tab_ops = ttk.Frame(tabControl)
    tab_config = ttk.Frame(tabControl)
    tabControl.add(tab_ops, text='Operations')
    tabControl.add(tab_config, text='Camera configuration')
    tabControl.grid(row=0, sticky='we')
    """
    CAMERA CONFIGURATIONS FROM .INI FILE
    """
    text_config = tk.Text(tab_config, bg='gray18', fg='thistle1')
    text_config.grid(row=0, sticky='we')

    scrollb = tk.Scrollbar(tab_config, command=text_config.yview)
    scrollb.grid(row=0, column=1, sticky='nswe')
    text_config['yscrollcommand'] = scrollb.set

    root.config_ini = 'config.ini'
    file_contents = open(root.config_ini).read()
    text_config.insert('end', file_contents)

    tbox_contents = text_config.get('1.0', 'end')
    # c.char is a fixed array, so in case future editing needs more array space,
    # an expanded array is passed as an argument
    tbox = Array(ctypes.c_char, bytes(tbox_contents + '\n' * 10, 'utf8'))

    text_config.tag_config('section', foreground='khaki1')
    update_tboxEmbellishments()
    """
    SAVE CONFIGURATION CHANGES
    """
    button_saveconfig = tk.Button(tab_config,
                                  text="Save changes",
                                  bg="white",
                                  fg="black",
                                  command=update_config)

    button_saveconfig.grid(row=0, column=2, padx=10, pady=10)
    """
    CAMERA CONNECTION/DISCONNECTION FRAME
    """
    cameraonoff_frame = tk.Frame(tab_ops)
    cameraonoff_frame.grid(row=0, sticky='we')

    cameraonoff_frame.grid_rowconfigure(0, weight=1)
    cameraonoff_frame.grid_columnconfigure(0, weight=1)
    cameraonoff_frame.grid_columnconfigure(1, weight=1)
    """
    INITIALIZE CAMERA
    """
    button_initcamera = tk.Button(cameraonoff_frame,
                       text="INITIALIZE CAMERA",
                       bg="white",
                       fg="black",
                       command=lambda: create_cameraprocess(q, release_event, \
                            beginlive_event, stoplive_event, piezostep_event, \
                            updateconfig_event, plotmidline_event, stdout_queue))

    button_initcamera.grid(row=0, column=0, padx=10, pady=10)
    """
    RELEASE CAMERA
    """
    button_release = tk.Button(
        cameraonoff_frame,
        text="RELEASE CAMERA",
        bg="white",
        fg="black",
        command=lambda: notify_releasecamera(release_event))
    button_release.grid(row=0, column=1, padx=10, pady=10)

    #    """
    #    EXPOSURE TIME CONFIGURATION
    #    """
    #    label_exposure = tk.Label(cameraonoff_frame, text='Exposure time: ')
    #    label_exposure.grid(row=0,column=2,padx=10,pady=10,sticky='we')
    #
    #    slider_exposure = tk.Scale(cameraonoff_frame, from_=6, to=2000, orient='horizontal')
    #    slider_exposure.grid(row=0,column=3,padx=10,pady=10,sticky='we')
    #
    #    entry_exposure = tk.Entry(cameraonoff_frame)
    #    entry_exposure.grid(row=0,column=4,padx=10,pady=10,sticky='we')
    #    entry_exposure.delete(0, 'end')
    #    entry_exposure.insert(0, '')
    #    entry_exposure.bind("<Return>", get_exposure)
    #
    #    button_exposure = tk.Button(cameraonoff_frame,
    #                       text="Set",
    #                       bg="white",
    #                       fg="black",
    #                       command=set_exposure)
    #    button_exposure.grid(row=0,column=5,padx=10,pady=10,sticky='we')

    root.rowconfigure(0, weight=1)
    root.columnconfigure(0, weight=1)

    tab_ops.rowconfigure(0, weight=1)
    tab_ops.columnconfigure(0, weight=1)

    tab_config.rowconfigure(0, weight=1)
    tab_config.columnconfigure(0, weight=1)

    main_frame = tk.Frame(tab_ops)
    main_frame.grid(row=1, column=0, sticky='nswe')

    main_frame.grid_rowconfigure(0, weight=1)
    main_frame.grid_rowconfigure(1, weight=1)
    main_frame.grid_rowconfigure(2, weight=1)
    main_frame.grid_rowconfigure(3, weight=1)
    main_frame.grid_columnconfigure(0, weight=1)
    main_frame.grid_columnconfigure(1, weight=1)
    main_frame.grid_columnconfigure(2, weight=1)

    imageplots_frame = tk.Frame(main_frame)
    imageplots_frame.grid(row=0, column=0, sticky='nswe')

    imageplots_frame.grid_rowconfigure(0, weight=1)
    imageplots_frame.grid_columnconfigure(0, weight=1)

    oscillation_frame = tk.Frame(main_frame)
    oscillation_frame.grid(row=0, column=1, sticky='nswe')

    oscillation_frame.grid_rowconfigure(0, weight=1)
    oscillation_frame.grid_columnconfigure(0, weight=1)

    buttons_frame = tk.Frame(main_frame)
    buttons_frame.grid(row=0, column=2, sticky='nswe')

    buttons_frame.grid_rowconfigure(0, weight=1)
    buttons_frame.grid_columnconfigure(0, weight=1)

    piezosteps_frame = tk.Frame(buttons_frame)
    piezosteps_frame.grid(row=0, column=0, sticky='nswe')

    piezosteps_frame.grid_rowconfigure(0, weight=1)
    piezosteps_frame.grid_columnconfigure(0, weight=1)

    preperation_frame = tk.Frame(buttons_frame, borderwidth=1, relief='solid')
    preperation_frame.grid(row=1, column=0, sticky='nswe')

    preperation_frame.grid_rowconfigure(0, weight=1)
    preperation_frame.grid_columnconfigure(0, weight=1)

    measurement_frame = tk.Frame(buttons_frame, borderwidth=1, relief='solid')
    measurement_frame.grid(row=2, column=0, sticky='nswe', pady=10)

    measurement_frame.grid_rowconfigure(0, weight=1)
    measurement_frame.grid_columnconfigure(0, weight=1)

    selections_frame = tk.Frame(main_frame)
    selections_frame.grid(row=2, column=0, sticky='nswe')

    selections_frame.grid_rowconfigure(0, weight=1)
    selections_frame.grid_columnconfigure(0, weight=1)
    """
    CREATE CANVAS FOR IMAGE DISPLAY
    """
    #    sections = cfg.load_config_fromtkText('ALL', text_config.get('1.0', 'end'))
    #    h = eval(sections[2]['height'])
    #    w = eval(sections[2]['width'])
    dpi = 96.0
    #    f = Figure(figsize=(w/dpi,h/dpi))
    f = Figure(figsize=(500 / dpi, 500 / dpi), dpi=96)
    f.subplots_adjust(left=0.0, bottom=0.0, right=1.0, top=1.0)
    ax = f.add_subplot(111)
    ax.set_axis_off()
    img = Image.frombytes('L', (500, 500), b'\x00' * 250000)
    ax.imshow(img, cmap='gray', vmin=0, vmax=65535)
    livefeed_canvas = FigureCanvasTkAgg(f, master=imageplots_frame)
    livefeed_canvas.get_tk_widget().grid(row=0, column=0, sticky='nswe')
    livefeed_canvas.draw()
    """
    TOOLBAR - IMAGE SHOW
    """
    toolbarimshowFrame = tk.Frame(master=imageplots_frame)
    toolbarimshowFrame.grid(row=1, column=0)
    toolbarimshow = NavigationToolbar2Tk(livefeed_canvas, toolbarimshowFrame)
    toolbarimshow.update()

    # create global list of different plotting colors
    colors = lspec()
    """
    CREATE CANVAS FOR POI AND MIDLINE PLOTTING
    """
    #    dpi = 96
    #    fig = Figure(figsize=(imageplots_frame.winfo_height()/dpi, imageplots_frame.winfo_width()/3/dpi))
    fig = Figure(tight_layout=True)
    a = fig.add_subplot(111)
    canvas_plot = FigureCanvasTkAgg(fig, master=imageplots_frame)
    canvas_plot.get_tk_widget().grid(row=0, column=1, sticky='nswe')
    """
    TOOLBAR - LINE PLOT
    """
    toolbarplotFrame = tk.Frame(master=imageplots_frame)
    toolbarplotFrame.grid(row=1, column=1)
    toolbarplot = NavigationToolbar2Tk(canvas_plot, toolbarplotFrame)
    toolbarplot.update()

    label_preparation = tk.Label(preperation_frame,
                                 text='P R E P A R A T I O N')
    label_preparation.grid(row=0, columnspan=2)
    """
    POINTS OF INTEREST SELECTION BUTTONS
    """
    button_POIenable = tk.Button(preperation_frame,
                                 text="Select POI",
                                 fg="gold2",
                                 bg='grey18',
                                 command=enable_POIsel)
    button_POIenable.grid(row=1, column=0, padx=0, pady=10, sticky='ew')

    button_POIdisable = tk.Button(preperation_frame,
                                  text="OK!",
                                  fg="black",
                                  command=disable_POIsel)
    button_POIdisable.grid(row=1, column=1, padx=0, pady=0, sticky='ew')
    """
    REGION OF INTEREST SELECT BUTTONS
    """
    button_ROIenable = tk.Button(preperation_frame,
                                 text="Select ROI",
                                 fg="chocolate2",
                                 bg='grey18',
                                 command=enable_ROIsel)
    button_ROIenable.grid(row=2, column=0, padx=0, pady=0, sticky='ew')

    #    button_ROIdisable = tk.Button(preperation_frame,
    #                       text="OK!",
    #                       fg="black",
    #                       command=disable_ROIsel)
    #    button_ROIdisable.grid(row=2,column=1,padx=0,pady=0,sticky='ew')

    simplebuttons_frame = tk.Frame(selections_frame)
    simplebuttons_frame.grid(row=0, column=0, sticky='nswe')

    selections_frame.grid_rowconfigure(0, weight=1)
    selections_frame.grid_columnconfigure(0, weight=1)
    """
    OSCILLATE PIEZO BUTTON
    """
    button_oscillate = tk.Button(preperation_frame,
                                 text="Oscillate Piezo",
                                 fg="black",
                                 command=lambda: create_oscillationprocess(
                                     piezostep_event, stdout_queue))
    button_oscillate.grid(row=3, column=0, padx=0, pady=0, sticky='ew')
    """
    PLOT MIDLINE BUTTON
    """
    button_oscillate = tk.Button(
        preperation_frame,
        text="Display intensity across\nhor/ntal line",
        fg="black",
        command=lambda: toggle_displayMidline(plotmidline_event))
    button_oscillate.grid(row=3, column=1, padx=0, pady=0, sticky='ew')
    """
    OPTION LIST FOR NUMBER OF PIEZO STEPS - LABEL
    """
    label_piezosteps = tk.Label(piezosteps_frame, text='Piezo steps:')
    label_piezosteps.grid(row=0, column=0, padx=0, pady=0, sticky='ew')
    """
    OPTION LIST FOR NUMBER OF PIEZO STEPS - VALUES
    """
    piezosteps_options = ['100', '200', '300', '400', '500', '600']
    piezosteps_var = tk.StringVar()
    piezosteps_var.set(piezosteps_options[-1])  # default value

    optionmenu_piezosteps = tk.OptionMenu(piezosteps_frame, piezosteps_var,
                                          *piezosteps_options)
    optionmenu_piezosteps.grid(row=0, column=1, padx=0, pady=0, sticky='ew')

    label_measurement = tk.Label(measurement_frame,
                                 text='M E A S U R E M E N T')
    label_measurement.grid(row=0, columnspan=2)
    """
    EXECUTE PIEZO SCAN FOR INTERFEROGRAM STACK CAPTURING
    """
    button_oscillate = tk.Button(measurement_frame,
                                 text="Piezo scan\nCapture interferograms",
                                 fg="khaki1",
                                 bg='grey18',
                                 command=prepare_piezoscan)
    button_oscillate.grid(row=1,
                          column=0,
                          columnspan=2,
                          padx=0,
                          pady=10,
                          sticky='ew')

    CheckVar = tk.StringVar()
    CheckVar.set('m')
    C1 = tk.Radiobutton(measurement_frame,
                        text='Measurement',
                        variable=CheckVar,
                        value='m')
    C2 = tk.Radiobutton(measurement_frame,
                        text='Calibration',
                        variable=CheckVar,
                        value='c')
    C1.grid(row=2, column=0, padx=0, pady=0, sticky='we')
    C2.grid(row=2, column=1, padx=0, pady=0, sticky='we')
    """
    EXECUTE PIEZO SCAN FOR CALIBRATION PROCESS
    """
    button_oscillate = tk.Button(measurement_frame,
                                 text="Calibrate",
                                 fg="khaki1",
                                 bg='grey18',
                                 command=prepare_calibrate)
    button_oscillate.grid(row=5, column=0, padx=0, pady=0, sticky='ew')
    """
    INSERT MEASUREMENT IMAGE STACK FOLDER NAME
    """
    label_folder = tk.Label(measurement_frame,
                            text='Measurement\nfolder name:')
    label_folder.grid(row=3, column=0, padx=0, pady=0, sticky='ew')

    entry_measfolder = tk.Entry(measurement_frame)
    entry_measfolder.grid(row=3, column=1, padx=0, pady=0, sticky='we')
    entry_measfolder.delete(0, 'end')
    entry_measfolder.insert(0, 'stack')
    entry_measfolder.bind("<Return>", setMeasurementFolderName)
    """
    INSERT CALIBRATION IMAGE STACK FOLDER NAME
    """
    label_folder = tk.Label(measurement_frame,
                            text='Calibration\nfolder name:')
    label_folder.grid(row=4, column=0, padx=0, pady=0, sticky='ew')

    entry_calibfolder = tk.Entry(measurement_frame)
    entry_calibfolder.grid(row=4, column=1, padx=0, pady=0, sticky='we')
    entry_calibfolder.delete(0, 'end')
    entry_calibfolder.insert(0, 'stack')
    entry_calibfolder.bind("<Return>", setCalibrationFolderName)
    """
    EXECUTE INTERFEROGRAM STACK ANALYSIS FOR SURFACE ELEVATION MAP EXTRACTION
    """
    button_oscillate = tk.Button(measurement_frame,
                                 text="Analyze",
                                 fg="khaki1",
                                 bg='grey18',
                                 command=prepare_analysis)
    button_oscillate.grid(row=5, column=1, padx=0, pady=0, sticky='ew')

    #    """
    #    DISPLAY POI INTERFEROGRAMS
    #    """
    #    button_toggleDispInterf = tk.Button(oscillation_frame,
    #                       text="Display/Hide\nPOI Interferograms",
    #                       fg="black",
    #                       command=toggleDispInterf_threaded)
    #    button_toggleDispInterf.grid(row=2,column=1,padx=0,pady=0,sticky='ew')
    """
    LIVE FEED BUTTON
    """
    button_live = tk.Button(simplebuttons_frame,
                            text="Live!",
                            fg="red",
                            bg='grey18',
                            command=lambda: notify_beginlive(beginlive_event))
    button_live.grid(row=0, column=0, padx=10, pady=10, sticky='ew')
    """
    STOP LIVE BUTTON
    """
    button_reset = tk.Button(simplebuttons_frame,
                             text="Stop Live Feed",
                             fg="red",
                             bg='grey18',
                             command=lambda: notify_stoplive(stoplive_event))
    button_reset.grid(row=0, column=1, padx=10, pady=10, sticky='we')
    """""" """
     || || ||
     || || ||
     VV VV VV
    """ """"""
    piezo_dispaxis = np.loadtxt('Mapping_Steps_Displacement_2.txt')
    """
    OUTPUT TEXT
    """
    redirectstdout_frame = tk.Frame(main_frame)
    redirectstdout_frame.grid(row=3, column=0, sticky='nswe')

    output_text = ScrolledText(redirectstdout_frame,
                               bg='gray18',
                               fg='thistle1',
                               width=75,
                               height=10)
    output_text.see('end')
    output_text.grid(row=0, padx=10, pady=10, sticky='nswe')
    """
    CLEAR OUTPUT TEXT BOX
    """
    button_cleartbox = tk.Button(redirectstdout_frame,
                                 text="Clear",
                                 fg="lawn green",
                                 bg='grey18',
                                 command=clear_outputtext)
    button_cleartbox.grid(row=0, column=1, padx=10, pady=10, sticky='we')
    """
    RECTANGLE SELECTOR OBJECT - for ROI selection
    """
    toggle_selector_RS = RectangleSelector(
        ax,
        line_select_callback,
        drawtype='box',
        useblit=True,
        button=[1, 3],  # don't use middle button
        minspanx=5,
        minspany=5,
        spancoords='pixels',
        interactive=True)
    toggle_selector_RS.set_active(False)
    toggle_selector_RS.set_visible(False)
    """
    STDOUT REDIRECTION
    """
    sys.stdout = StdoutQueue(stdout_queue)
    sys.stderr = StdoutQueue(stdout_queue)

    # Instantiate and start the text monitor
    monitor = Thread(target=text_catcher, args=(output_text, stdout_queue))
    monitor.daemon = True
    monitor.start()

    #    sys.stdout = StdoutRedirector(output_text)
    #    sys.stderr = StderrRedirector(output_text)

    root.protocol("WM_DELETE_WINDOW", on_close)
    root.config(menu=menubar)
    root.mainloop()
Esempio n. 10
0



ser = serial.Serial()

dict_mm = {'num': 4, 'offset': 2, '1': 'MM_x (uT)', '2': 'MM_y (uT)', '3': 'MM_z (uT)', '4': 'MM_Magnitude (uT)', 'outFile': 'outputMM.xls', 'mag': 1}
dict_gyro = {'num': 4, 'offset': 2, '1': 'Gyro_x (deg/s)', '2': 'Gyro_y (deg/s)', '3': 'Gyro_z (deg/s)', '4': 'Gyro_Magnitude (deg/s)', 'outFile': 'outputGyro.xls', 'mag': 1}
dict_mt = {'num': 3, 'offset': 2, '1': 'MT_x', '2': 'MT_y', '3': 'MT_z', 'outFile': 'outputMT.xls', 'mag': 0}
dict_ahrs_quat = {'num': 4, 'offset': 2, '1': 'quat_1', '2': 'quat_2', '3': 'quat_3', '4': 'quat_4', 'outFile': 'outputAHRS_Quat.xls', 'mag': 0}
dict_ahrs_euler = {'num': 3, 'offset': 6, '1': 'ang_x (deg)', '2': 'ang_y (deg)', '3': 'ang_z (deg)', 'outFile': 'outputAHRS_Euler.xls', 'mag': 0}
dict_ahrs_omega = {'num': 3, 'offset': 9, '1': 'omega_x (deg/s)', '2': 'omega_y (deg/s)', '3': 'omega_z (deg/s)', 'outFile': 'outputAHRS_Omega.xls', 'mag': 0}
dict_rw = {'num': 3, 'offset': 2, '1': 'RW_rate_x (deg/s)', '2': 'RW_rate_y (deg/s)', '3': 'RW_rate_z (deg/s)', 'outFile': 'outputRW.xls', 'mag': 0}
dict_rwc = {'num': 3, 'offset': 2, '1': 'T_RW_1 (N-m)', '2': 'T_RW_2 (N-m)', '3': 'T_RW_3 (N-m)', 'outFile': 'outputCommandRW.xls', 'mag': 0}

nb = ttk.Notebook(root)
nb.grid(row=1, column=0, sticky='NW', padx=5, pady=5, ipadx=5, ipady=5)
f1 = tabsConfig.tabFrame(root, **dict_mm)
f2 = tabsConfig.tabFrame(root, **dict_gyro)
f3 = tabsConfig.tabFrame(root, **dict_mt)
f4 = tabsConfig.tabFrame(root, **dict_ahrs_quat)
f5 = tabsConfig.tabFrame(root, **dict_ahrs_euler)
f6 = tabsConfig.tabFrame(root, **dict_ahrs_omega)
f7 = tabsConfig.tabFrame(root, **dict_rw)
f8 = tabsConfig.tabFrame(root, **dict_rwc)
nb.add(f1, text='  Magnetometer ')
nb.add(f2, text='  Gyro ')
nb.add(f3, text='  MagnetoTorquer Commands ')
nb.add(f4, text='  AHRS Quaternion ')
nb.add(f5, text='  AHRS Euler Angles ')
nb.add(f6, text='  AHRS Omega ')
Esempio n. 11
0
    def __init__(self, master):
        Frame.__init__(self, master)
        controlFrame = Frame(self, width=300, height=500, background="gray25")
        controlFrame.pack_propagate(0)
        controlFrame.pack(side=LEFT)
        plotFrame = Frame(self, width=800, height=500, background="gray25")
        plotFrame.pack_propagate(0)
        plotFrame.pack(side=LEFT)

        configureFrame = Frame(controlFrame,
                               width=300,
                               height=300,
                               background="gray25")
        configureFrame.pack_propagate(0)
        configureFrame.pack()
        terminalFrame = Frame(controlFrame,
                              width=300,
                              height=200,
                              background="gray25")
        terminalFrame.pack_propagate(0)
        terminalFrame.pack()

        configureNotebook = ttk.Notebook(configureFrame)
        configureTab = ttk.Frame(configureNotebook)
        preferenceTab = ttk.Frame(configureNotebook)
        configureNotebook.add(configureTab, text="General")
        configureNotebook.add(preferenceTab, text="Preference")
        configureNotebook.pack()

        scrollable_frame = VerticalScrolledFrame(preferenceTab,
                                                 background="gray25")
        scrollable_frame.pack()

        scrollable_configure = VerticalScrolledFrame(configureTab,
                                                     background="gray25")
        scrollable_configure.pack()

        self.preferenceObject = configure_tab(scrollable_frame.interior,
                                              width=50,
                                              split_percentage=0.45)
        preference_depth, all_preference_option = json_level_count(
            preference_info)
        for option in all_preference_option:
            preference_value = preference_info
            for sub in option:
                preference_value = preference_value[sub]
            self.preferenceObject.add_instance(
                name=" ".join(option),
                method="entry",
                init_value=str(preference_value))
        self.preferenceObject.pack()

        preferenceUpdateButton = Button(scrollable_frame.interior,
                                        text="Update",
                                        command=updatePreference,
                                        width=15)
        preferenceUpdateButton.pack()

        self.notebook = PlotNotebook(plotFrame)
        self.notebook.pack()

        self.sessionObject = configure_tab(scrollable_configure.interior,
                                           width=50,
                                           split_percentage=0.15)
        sessionObjectLabel = Label(scrollable_configure.interior,
                                   text="Session Configuration",
                                   anchor="w",
                                   justify=LEFT,
                                   width=50,
                                   font="Helvetica 10 bold",
                                   background="gray25",
                                   foreground="gray100")
        sessionObjectLabel.pack(pady=(10, 0))
        self.sessionObject.add_instance(name='Session',
                                        method='menu',
                                        input_option=os.listdir('data'),
                                        init_value='Select')
        self.sessionObject.pack()
        sessionButtonFrame = Frame(scrollable_configure.interior,
                                   width=300,
                                   height=50,
                                   background="gray25")
        sessionButtonFrame.pack()
        update_session_button = Button(sessionButtonFrame,
                                       text='Update',
                                       command=self.update_session,
                                       width=15)
        update_session_button.pack(padx=5, side=LEFT)
        refresh_session_button = Button(sessionButtonFrame,
                                        text='Refresh',
                                        command=self.refresh_session,
                                        width=15)
        refresh_session_button.pack(padx=5, side=LEFT)

        self.serialObject = configure_tab(scrollable_configure.interior,
                                          width=50)
        serialObjectLabel = Label(scrollable_configure.interior,
                                  text="Serial Configuration",
                                  anchor="w",
                                  justify=LEFT,
                                  width=50,
                                  font="Helvetica 10 bold",
                                  background="gray25",
                                  foreground="gray100")
        serialObjectLabel.pack(pady=(10, 0))
        serial_list = [
            comport.device for comport in serial.tools.list_ports.comports()
        ]
        serial_list.append('buffer')
        self.serialObject.add_instance(name='Port',
                                       method='menu',
                                       input_option=serial_list,
                                       init_value='Select')
        self.serialObject.add_instance(name='Baudrate',
                                       method='entry',
                                       init_value='115200')
        self.serialObject.pack()
        update_serial_button = Button(scrollable_configure.interior,
                                      text='Connect',
                                      command=self.update_serial,
                                      width=15)
        update_serial_button.pack()

        actionLabel = Label(scrollable_configure.interior,
                            text="Action Panel",
                            anchor="w",
                            justify=LEFT,
                            width=50,
                            font="Helvetica 10 bold",
                            background="gray25",
                            foreground="gray100")
        actionLabel.pack(pady=(10, 0))
        actionFrame = Frame(scrollable_configure.interior, background="gray25")
        actionFrame.pack_propagate(0)
        actionFrame.pack()
        triggerButton = Button(actionFrame,
                               text='Trigger',
                               command=self.on_click_trigger,
                               width=15)
        reFFTButton = Button(actionFrame,
                             text="FFT",
                             command=self.redrawFFT,
                             width=15)
        triggerButton.grid(row=0, column=0, padx=5)
        reFFTButton.grid(row=0, column=1, padx=5)

        self.windowObject = configure_tab(scrollable_configure.interior,
                                          width=50)
        self.windowObject.add_instance(
            name="Window Length",
            method='entry',
            init_value=self.notebook.currentApp.plot.window_size)
        self.windowObject.bind("<Leave>", self.on_update_window)
        self.windowObject.pack(pady=5)

        terminalScroll = Scrollbar(terminalFrame)
        self.terminal = SyntaxHighlightingText(terminalFrame)
        self.terminal.config(wrap=WORD,
                             font='Helvetica 8',
                             spacing3=5,
                             bg='gray10',
                             fg="gray100")
        terminalScroll.config(command=self.terminal.yview)
        self.terminal.config(yscrollcommand=terminalScroll.set)
        terminalScroll.pack(side=RIGHT, fill=Y, padx=(0, 10), pady=5)
        self.terminal.pack(side=LEFT, padx=(10, 0), pady=5)
        self.terminal.config(state=DISABLED)

        self.file = None
        self.shift = False
    def __init__(self, master):

        self.master = master
        self.inputs = []
        self.calc_balance = 0
        self.segment_list = []
        self.segment_list_gui = []
        self.drift_run = 0
        
        # Font Set
        self.f_size = 8
        self.helv = tkFont.Font(family=' Courier New',size=self.f_size, weight='bold')
        self.helv_norm = tkFont.Font(family=' Courier New',size=self.f_size)
        self.helv_res = tkFont.Font(family=' Courier New',size=self.f_size, weight='bold', underline = True)
        
        # Menubar
        self.menubar = tk.Menu(self.master)
        self.menu = tk.Menu(self.menubar, tearoff=0)
        self.menu_props = tk.Menu(self.menubar, tearoff=0)
        self.menubar.add_cascade(label = "File", menu=self.menu)
        #self.menu.add_command(label="Save", command=self.save_inputs)
        #self.menu.add_command(label="Open", command=self.open_existing)
        self.menu.add_separator()
        self.menu.add_command(label="Quit", command=self.quit_app)
        try:
            self.master.config(menu=self.menubar)
        except AttributeError:
            self.master.tk.call(master, "config", "-menu", self.menubar)
        
        #Main Frame
        self.base_frame = tk.Frame(master, bd=2, relief='sunken', padx=1,pady=1)
        self.base_frame.pack(side=tk.BOTTOM, padx= 1, pady= 1, fill=tk.X)
        #Base Frame Items
        w=20
        h=2
        color='cornflower blue'
        self.b_quit = tk.Button(self.base_frame,text="Quit", command=self.quit_app, font=self.helv, width=w, height=h, bg='red3')
        self.b_quit.pack(side=tk.RIGHT)
        
        self.graphics_frame = tk.Frame(master, bd=2, relief='sunken', padx=1,pady=1)

        self.graphics_frame_l = tk.Frame(self.graphics_frame, padx=1,pady=1)
        self.graphics_frame_l.pack(side = tk.LEFT, anchor='c', padx= 1, pady= 1, fill=tk.BOTH, expand=1)
        self.graphics_frame_r = tk.Frame(self.graphics_frame, padx=1,pady=1)
        
        self.graphics_frame_r.pack(side = tk.RIGHT, anchor='ne')

        self.graphics_frame.pack(side=tk.RIGHT, padx= 1, pady= 1, fill=tk.BOTH, expand=1)

        self.data_frame = tk.Frame(master, bd=2, relief='sunken', padx=1,pady=1)
        self.data_frame.pack(anchor='c', padx= 1, pady= 1, fill=tk.BOTH, expand=1)
       
        #Main Notebooks
        self.nb_graphs = ttk.Notebook(self.graphics_frame_l)
        self.nb_graphs.pack(fill=tk.BOTH, expand=1)

        self.nb_data = ttk.Notebook(self.data_frame)
        self.nb_data.pack(fill=tk.BOTH, expand=1)
        
        #Graphics Frame tabs and canvases
        #Geometry - Plan
        self.g_plan = ttk.Frame(self.nb_graphs)
        self.nb_graphs.add(self.g_plan, text='Plan')

        self.g_plan_frame = tk.Frame(self.g_plan, bd=2, relief='sunken', padx=1,pady=1)
        self.g_plan_frame.pack(fill=tk.BOTH,expand=1, padx=5, pady=5)

        self.g_plan_canvas = tk.Canvas(self.g_plan_frame, width=50, height=50, bd=2, relief='sunken', background="black")
        self.g_plan_canvas.bind("<Configure>", self.draw_drift)
        self.g_plan_canvas.pack(side = tk.LEFT, anchor='c', padx= 1, pady= 1, fill=tk.BOTH, expand=1)

        #Geometry - Elevation/Section
        self.g_elev  = ttk.Frame(self.nb_graphs)
        self.nb_graphs.add(self.g_elev , text='Drift Section')

        self.g_elev_frame = tk.Frame(self.g_elev, bd=2, relief='sunken', padx=1,pady=1)
        self.g_elev_frame.pack(fill=tk.BOTH,expand=1, padx=5, pady=5)

        self.g_elev_canvas = tk.Canvas(self.g_elev_frame, width=50, height=50, bd=2, relief='sunken', background="black")
        #self.g_elev_canvas.bind("<Configure>", self.draw_elevation)
        self.g_elev_canvas.pack(side = tk.LEFT, anchor='c', padx= 1, pady= 1, fill=tk.BOTH, expand=1)
        
        #Data/calc Frame tabs
        #Basic Snow
        self.snow_input = ttk.Frame(self.nb_data)
        self.nb_data.add(self.snow_input, text='Basic Snow Input')

        self.snow_data_frame = tk.Frame(self.snow_input, bd=2, relief='sunken', padx=1,pady=1)
        
        # Pg - ground snow load
        tk.Label(self.snow_data_frame, text="Pg (psf):", font=self.helv).grid(row=0, column=0, sticky=tk.E)
        self.pg_psf_gui = tk.StringVar()
        self.inputs.append(self.pg_psf_gui)
        self.pg_psf_gui.set('25.0')
        self.pg_entry = tk.Entry(self.snow_data_frame, textvariable=self.pg_psf_gui, width=10)
        self.pg_entry.grid(row=0, column=1)

        # Ce - exposure factor
        tk.Label(self.snow_data_frame, text="Ce :", font=self.helv).grid(row=1, column=0, sticky=tk.E)
        self.ce_gui = tk.StringVar()
        self.inputs.append(self.ce_gui)
        self.ce_gui.set('1.0')
        self.ce_entry = tk.Entry(self.snow_data_frame, textvariable=self.ce_gui, width=10)
        self.ce_entry.grid(row=1, column=1)

        # Ct - thermal factor
        tk.Label(self.snow_data_frame, text="Ct :", font=self.helv).grid(row=2, column=0, sticky=tk.E)
        self.ct_gui = tk.StringVar()
        self.inputs.append(self.ct_gui)
        self.ct_gui.set('1.0')
        self.ct_entry = tk.Entry(self.snow_data_frame, textvariable=self.ct_gui, width=10)
        self.ct_entry.grid(row=2, column=1)

        # Cs - slope factor
        tk.Label(self.snow_data_frame, text="Cs :", font=self.helv).grid(row=3, column=0, sticky=tk.E)
        self.cs_gui = tk.StringVar()
        self.inputs.append(self.cs_gui)
        self.cs_gui.set('1.0')
        self.cs_entry = tk.Entry(self.snow_data_frame, textvariable=self.cs_gui, width=10)
        self.cs_entry.grid(row=3, column=1)

        # I - Importance Factor
        tk.Label(self.snow_data_frame, text="I :", font=self.helv).grid(row=4, column=0, sticky=tk.E)
        self.I_gui = tk.StringVar()
        self.inputs.append(self.I_gui)
        self.I_gui.set('1.0')
        self.I_entry = tk.Entry(self.snow_data_frame, textvariable=self.I_gui, width=10)
        self.I_entry.grid(row=4, column=1)
        
        self.b_snow_basic = tk.Button(self.snow_data_frame,text="Calc Balance Snow", command=self.snow_step_1, font=self.helv, width=w, height=h, bg=color)
        self.b_snow_basic.grid(row=5, column=1)
       
        tk.Label(self.snow_data_frame, text="Snow Density (pcf) :", font=self.helv).grid(row=6, column=0, sticky=tk.E)
        tk.Label(self.snow_data_frame, text="min. of:", font=self.helv).grid(row=7, column=0, sticky=tk.E)
        tk.Label(self.snow_data_frame, text="0.13*Pg + 14", font=self.helv).grid(row=7, column=1)
        tk.Label(self.snow_data_frame, text="30", font=self.helv).grid(row=8, column=1)
        self.snow_density_pcf_gui = tk.Label(self.snow_data_frame, text="--", font=self.helv_res)
        self.snow_density_pcf_gui.grid(row=8, column=2)
        
        #Pf - Flat Roof Snow Load
        tk.Label(self.snow_data_frame, text="Pf (psf) :", font=self.helv).grid(row=9, column=0, sticky=tk.E)
        tk.Label(self.snow_data_frame, text="0.7*Ce*Ct*I*Pg", font=self.helv).grid(row=9, column=1)
        self.pf_psf_gui = tk.Label(self.snow_data_frame, text="--", font=self.helv_res)
        self.pf_psf_gui.grid(row=9, column=2)

        #Ps - ??
        tk.Label(self.snow_data_frame, text="Ps (psf) :", font=self.helv).grid(row=10, column=0, sticky=tk.E)
        tk.Label(self.snow_data_frame, text="Cs*Pf", font=self.helv).grid(row=10, column=1)
        self.ps_psf_gui = tk.Label(self.snow_data_frame, text="--", font=self.helv_res)
        self.ps_psf_gui.grid(row=10, column=2)       
        
        #Hb - depth of balance snow load
        tk.Label(self.snow_data_frame, text="Hb (ft) :", font=self.helv).grid(row=11, column=0, sticky=tk.E)
        tk.Label(self.snow_data_frame, text="Ps/Snow Density", font=self.helv).grid(row=11, column=1)
        self.hb_ft_gui = tk.Label(self.snow_data_frame, text="--", font=self.helv_res)
        self.hb_ft_gui.grid(row=11, column=2)   

        self.snow_data_frame.pack(fill=tk.BOTH,expand=1, padx=5, pady=5)

        #Segment Add Frame
        self.segment_input = ttk.Frame(self.nb_data)
        self.nb_data.add(self.segment_input, text='Segment Input')

        self.segment_data_frame = tk.Frame(self.segment_input, bd=2, relief='sunken', padx=1,pady=1)
        #Start X
        tk.Label(self.segment_data_frame, text="x1 (ft) :", font=self.helv).grid(row=0, column=0, sticky=tk.E)
        self.segment_start_x_ft = tk.StringVar()
        self.segment_start_x_ft.set('0.0')
        self.start_x_entry = tk.Entry(self.segment_data_frame, textvariable=self.segment_start_x_ft, width=10)
        self.start_x_entry.grid(row=0, column=1)

        #Start Y
        tk.Label(self.segment_data_frame, text="y1 (ft) :", font=self.helv).grid(row=1, column=0, sticky=tk.E)
        self.segment_start_y_ft = tk.StringVar()
        self.segment_start_y_ft.set('0.0')
        self.start_y_entry= tk.Entry(self.segment_data_frame, textvariable=self.segment_start_y_ft, width=10)
        self.start_y_entry.grid(row=1, column=1)

        #End X
        tk.Label(self.segment_data_frame, text="x2 (ft) :", font=self.helv).grid(row=2, column=0, sticky=tk.E)
        self.segment_end_x_ft = tk.StringVar()
        self.segment_end_x_ft.set('0.0')
        self.end_x_entry= tk.Entry(self.segment_data_frame, textvariable=self.segment_end_x_ft, width=10)
        self.end_x_entry.grid(row=2, column=1)

        #End Y
        tk.Label(self.segment_data_frame, text="y2 (ft) :", font=self.helv).grid(row=3, column=0, sticky=tk.E)
        self.segment_end_y_ft = tk.StringVar()
        self.segment_end_y_ft.set('0.0')
        self.end_y_entry= tk.Entry(self.segment_data_frame, textvariable=self.segment_end_y_ft, width=10)
        self.end_y_entry.grid(row=3, column=1)

        #Location Exterior (Counter-Clock-Wise) vs Interior (Clock-Wise)
        tk.Label(self.segment_data_frame, text="Location (e or i):", font=self.helv).grid(row=4, column=0, sticky=tk.E)
        self.segment_location = tk.StringVar()
        self.segment_location.set('e')
        self.segment_add_menu = tk.OptionMenu(self.segment_data_frame, self.segment_location, 'e', 'i')
        self.segment_add_menu.config(font=self.helv)
        self.segment_add_menu.grid(row=4, column=1, padx= 2, sticky=tk.W)
        tk.Label(self.segment_data_frame, text="e = exterior -- segments must be defined counter clockwise", font=self.helv).grid(row=5, column=0, columnspan=3, sticky=tk.W)
        tk.Label(self.segment_data_frame, text="i = interior -- segments must be defined counter clockwise", font=self.helv).grid(row=6, column=0, columnspan=3, sticky=tk.W)        
        
        #Segment Height - min of 3" or 0.25 ft
        tk.Label(self.segment_data_frame, text="Hc (ft): ", font=self.helv).grid(row=7, column=0, sticky=tk.E)
        self.segment_hc_ft = tk.StringVar()
        self.segment_hc_ft.set('0.25')
        self.hc_entry= tk.Entry(self.segment_data_frame, textvariable=self.segment_hc_ft, width=10)
        self.hc_entry.grid(row=7, column=1)
        self.segment_data_frame.pack(fill=tk.BOTH,expand=1, padx=5, pady=5)

        # Important note
        tk.Label(self.segment_data_frame, text="Note: base program assumption is exterior segments form a closed polygon\nclose off free edges with an Hc = 0.001 ft.", font=self.helv).grid(row=8, column=0,columnspan=3, sticky=tk.E)

        # Button to Add Segment
        self.b_add_segment = tk.Button(self.segment_data_frame,text="Add Segment", command=self.add_segment, font=self.helv, width=15, height=h, bg=color)
        self.b_add_segment.grid(row=9, column=0)
        
        # Button to Romove Segment
        self.b_remove_segment = tk.Button(self.segment_data_frame,text="Remove Last", command=self.remove_segment, font=self.helv, width=15, height=h, bg=color)
        self.b_remove_segment.grid(row=9, column=1)
        
        # List box of segments
        # GUI segment list is different from used segment list
        # used segment list will be determined at run time and 
        # will pull the most current GUI segment list to perform
        # calculations and GUI Canvas drawing
        self.segment_list_frame = tk.Frame(self.segment_data_frame, padx=1,pady=1)
        self.segment_list_frame.grid(row=10, column=0,columnspan=3)
        
        self.segment_listbox = tk.Listbox(self.segment_list_frame,width=75, height=20, font=self.helv)
        self.segment_listbox.pack(side=tk.LEFT, fill=tk.Y)
        
        self.segment_listbox_scroll = tk.Scrollbar(self.segment_list_frame, orient="vertical")
        self.segment_listbox_scroll.config(command=self.segment_listbox.yview)
        self.segment_listbox_scroll.pack(side=tk.RIGHT, fill=tk.Y)
        
        self.segment_listbox.config(yscrollcommand = self.segment_listbox_scroll.set)
        
        # Button to Run Drift All
        self.b_run = tk.Button(self.segment_data_frame,text="Calc Drifts", command=self.run_drift_all, font=self.helv, width=15, height=h, bg=color)

        self.b_run.grid(row=11, column=0)

        # Button to export DXF
        self.b_run = tk.Button(self.segment_data_frame,text="Export DXF", command=self.exp_dxf, font=self.helv, width=15, height=h, bg=color)
        self.b_run.grid(row=11, column=1)

        self.draw_drift()
        # Call function to display license dialog on app start
        self.license_display()
Esempio n. 13
0
    def __init__(self, master, idx, c, cnsl_print, graph):
        self.master = master
        self.idx = idx
        self.c = c
        self.graph = graph
        self.cnsl_print = cnsl_print
        # master.title("Robot Control: Reactor Stack %d" % idx)
        # master.minsize(width=1600, height=800)

        self.reactors = {}

        slots = CFG['stacks']['stack %d' % idx]['slots']

        # 'Close Reactor Stack'
        self.stack_btn = ValveButton(
            c,
            self.cnsl_print,
            CFG['stacks']['stack %d' % idx]['close reactor stack festo'],
            master,
            text='Close Reactor Stack %d' % idx,
            height=3).grid(row=1, column=0, sticky=N + S + E + W)

        # Reactors
        nb = ttk.Notebook(master)
        for i, e in enumerate(slots):
            # f = Frame(master)
            page = ttk.Frame(nb)
            rd = ReactorDisplay(page, i, int(e), c, self.cnsl_print, idx,
                                graph)
            self.reactors[i] = rd
            nb.add(page, text='Reactor ' + e + '\n')
        nb.grid(row=0, column=0, columnspan=2)

        # 'Close Fitting Actuator'
        self.fitting_btn = ValveButton(
            c,
            self.cnsl_print,
            CFG['stacks']['stack %d' % idx]['close fitting actuator festo'],
            master,
            text='Close Fitting Actuator').grid(row=1,
                                                column=1,
                                                sticky=N + S + E + W)

        # Add pumps callback to print to console
        self.c.add_pump_callback(
            lambda msg: self.cnsl_print('Pump message received: %s' % msg))

        # Pressure controller display
        pframe = Frame(master)
        pframe.grid(row=2, column=0)
        Label(pframe, text='Back Pressure: ').grid(row=0, column=0, sticky=W)
        self.pressure_label = Label(pframe, text='')
        self.pressure_label.grid(row=0, column=1, sticky=W)
        Label(pframe, text='Set Pressure:').grid(row=1, column=0, sticky=W)
        self.pressure_set_entry = Entry(pframe, width=12)
        self.pressure_set_entry.grid(row=1, column=1, sticky=W)
        Button(pframe, text='Set',
               command=self.on_back_pressure_set).grid(row=1,
                                                       column=2,
                                                       sticky=W)
        # Add pressure callback
        self.c.add_pressure_callback(self.on_pressure_msg)
Esempio n. 14
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'
        font9 = "-family {Segoe UI} -size 13 -weight bold -slant roman"  \
            " -underline 0 -overstrike 0"
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        top.geometry("1387x1001+210+153")
        top.title("Balance Report")
        top.configure(background="#b45fd8")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])
        self.TNotebook1 = ttk.Notebook(top)
        self.TNotebook1.place(relx=0.0, rely=0.0, relheight=1.0, relwidth=1.0)
        self.TNotebook1.configure(width=1914)
        self.TNotebook1.configure(takefocus="")
        self.TNotebook1_t0 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t0, padding=3)
        self.TNotebook1.tab(
            0,
            text="Customer",
            compound="left",
            underline="-1",
        )
        self.TNotebook1_t0.configure(background="#d89a84")
        self.TNotebook1_t0.configure(highlightbackground="#d9d9d9")
        self.TNotebook1_t0.configure(highlightcolor="black")
        self.TNotebook1_t1 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t1, padding=3)
        self.TNotebook1.tab(
            1,
            text="Address",
            compound="none",
            underline="-1",
        )
        self.TNotebook1_t1.configure(background="#d89a84")
        self.TNotebook1_t1.configure(highlightbackground="#d9d9d9")
        self.TNotebook1_t1.configure(highlightcolor="black")
        self.TNotebook1_t2 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t2, padding=3)
        self.TNotebook1.tab(
            2,
            text="Purchase History",
            compound="none",
            underline="-1",
        )
        self.TNotebook1_t2.configure(background="#d89a84")
        self.TNotebook1_t2.configure(highlightbackground="#d9d9d9")
        self.TNotebook1_t2.configure(highlightcolor="black")
        self.TNotebook1_t3 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t3, padding=3)
        self.TNotebook1.tab(
            3,
            text="Card Detail",
            compound="none",
            underline="-1",
        )
        self.TNotebook1_t3.configure(background="#d89a84")
        self.TNotebook1_t3.configure(highlightbackground="#d9d9d9")
        self.TNotebook1_t3.configure(highlightcolor="black")

        self.Frame1 = tk.Frame(self.TNotebook1_t0)
        self.Frame1.place(relx=0.0, rely=0.0, relheight=0.232, relwidth=0.445)
        self.Frame1.configure(relief='groove')
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(relief="groove")
        self.Frame1.configure(background="#d9d9d9")
        self.Frame1.configure(highlightbackground="#d9d9d9")
        self.Frame1.configure(highlightcolor="black")
        self.Frame1.configure(width=615)

        self.Label1 = tk.Label(self.Frame1)
        self.Label1.place(relx=0.0, rely=0.0, height=40, width=615)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(activeforeground="black")
        self.Label1.configure(background="#2d8ed8")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(font=font9)
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(highlightbackground="#d9d9d9")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''Customer Data''')

        self.style.configure('Treeview.Heading', font="TkDefaultFont")
        self.Scrolledtreeview1 = ScrolledTreeView(self.Frame1)
        self.Scrolledtreeview1.place(relx=0.0,
                                     rely=0.178,
                                     relheight=0.8,
                                     relwidth=1.015)
        self.Scrolledtreeview1.configure(columns="Col1 Col2")
        # build_treeview_support starting.
        self.Scrolledtreeview1.heading("#0", text=" Customer Id")
        self.Scrolledtreeview1.heading("#0", anchor="center")
        self.Scrolledtreeview1.column("#0", width="104")
        self.Scrolledtreeview1.column("#0", minwidth="20")
        self.Scrolledtreeview1.column("#0", stretch="1")
        self.Scrolledtreeview1.column("#0", anchor="w")
        self.Scrolledtreeview1.heading("Col1", text="Customer Name")
        self.Scrolledtreeview1.heading("Col1", anchor="center")
        self.Scrolledtreeview1.column("Col1", width="250")
        self.Scrolledtreeview1.column("Col1", minwidth="20")
        self.Scrolledtreeview1.column("Col1", stretch="1")
        self.Scrolledtreeview1.column("Col1", anchor="w")
        self.Scrolledtreeview1.heading("Col2", text="Phone No")
        self.Scrolledtreeview1.heading("Col2", anchor="center")
        self.Scrolledtreeview1.column("Col2", width="250")
        self.Scrolledtreeview1.column("Col2", minwidth="20")
        self.Scrolledtreeview1.column("Col2", stretch="1")
        self.Scrolledtreeview1.column("Col2", anchor="w")
        self.TNotebook1.bind('<Button-1>', SecondPage_support.cardpulldata)
Esempio n. 15
0
    def create_frm_right(self):
        '''
        上半部分右边窗口:
        分为4个部分:
        1、Label显示和重置按钮和发送按钮
        2、Text显示(发送的数据)
        3、Label显示和十进制选择显示和清除接收信息按钮
        4、Text显示接收到的信息
        '''
        tabControl = ttk.Notebook(self.frm_right)  # Create Tab Control

        self.tab1 = ttk.Frame(tabControl)  # Create a tab,bg="#292929"
        tabControl.add(self.tab1, text='串口显示')  # Add the tab

        self.tab2 = ttk.Frame(tabControl)  # Add a second tab
        tabControl.add(self.tab2, text='数据显示')  # Make second tab visible

        self.tab3 = ttk.Frame(tabControl)  # Add a third tab
        tabControl.add(self.tab3, text='测试数据')  # Make second tab visible

        # tabControl.configure(padding=1)#bg="#292929"
        
        tabControl.pack(expand=1, fill="both")  # Pack to make visible
        
        #####################################################################################################
        ##############表格填充到tab3下面,figuresize貌似不能把框给扩展开,因此借用tab2里面的canvas来扩展显示区域
        #####################################################################################################
        self.sheet_frame = pytk.PyLabelFrame(self.tab3)
        self.sheet = TKsheet(frame=self.sheet_frame)



        #####################################################################################################
        #####################################################################################################
        #####################################################################################################
        # 在Tk的GUI上放置一个画布,并用.grid()来调整布局
        self.drawPic_f = Figure(figsize=(7.2, 5), tight_layout=True)  # figsize=(9, 8), dpi=100,
        self.drawPic_canvas = FigureCanvasTkAgg(self.drawPic_f, master=self.tab2)
        self.drawPic_canvas.show()
        self.drawPic_canvas.get_tk_widget().grid(row=0, columnspan=30, sticky="nsew")#columnspan=3,限制button大小的
    
        # 放置标签、文本框和按钮等部件,并设置文本框的默认值和按钮的事件函数
        Label(self.tab2, text='请输入查询日期(如20180124):').grid(row=1, column=0)
        self.inputEntry = Entry(self.tab2)
        self.inputEntry.grid(row=1, column=1)
        self.inputEntry.insert(0, '20180124')
        Button(self.tab2, text='显示该日测试数据', command=self.drawPic).grid(row=1, column=2, sticky="NSEW")#columnspan=3,限制button大小的

        
        
        
        self.frm_right_reset = pytk.PyLabelFrame(self.tab1)#self.frm_right
        self.frm_right_send = pytk.PyText(self.tab1,#self.frm_right
                                          font=g_font,
                                          width=60,
                                          height=0.1)
        
        self.frm_right_clear = pytk.PyLabelFrame(self.tab1)#self.frm_right
        self.frm_right_receive = pytk.PyText(self.tab1 ,#self.frm_right
                                             font=g_font,
                                             width=60,
                                             height=15)
        
        self.frm_right_clear.pack(fill="both", expand=0, padx=1)
        self.frm_right_receive.pack(fill="both", expand=1, padx=1)
        
        self.frm_right_reset.pack(fill="both", expand=0, padx=1)
        self.frm_right_send.pack(fill="both", expand=1, padx=1)

        self.frm_right_receive.tag_config("green", foreground="#228B22")

        self.create_frm_right_reset()
        self.create_frm_right_clear()
Esempio n. 16
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = 'wheat'  # X11 color: #f5deb3
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#b2c9f4' # Closest X11 color: 'SlateGray2'
        _ana1color = '#eaf4b2' # Closest X11 color: '{pale goldenrod}' 
        _ana2color = '#f4bcb2' # Closest X11 color: 'RosyBrown2' 
        font10 = "-family {DejaVu Sans Mono} -size 14 -weight normal "  \
            "-slant roman -underline 0 -overstrike 0"
        font11 = "TkDefaultFont"
        font9 = "-family {DejaVu Sans} -size 14 -weight normal -slant "  \
            "roman -underline 0 -overstrike 0"
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.',background=_bgcolor)
        self.style.configure('.',foreground=_fgcolor)
        self.style.configure('.',font=font9)
        self.style.map('.',background=
            [('selected', _compcolor), ('active',_ana2color)])

        top.geometry("600x881+650+150")
        top.title("New Toplevel 1")
        top.configure(background="wheat")
        top.configure(highlightbackground="wheat")
        top.configure(highlightcolor="black")



        self.TButton1 = ttk.Button(top)
        self.TButton1.place(relx=0.02, rely=0.02, height=32, width=92)
        self.TButton1.configure(takefocus="")
        self.TButton1.configure(text='''Tbutton''')

        self.style.map('TCheckbutton',background=
            [('selected', _bgcolor), ('active',"_ana2color")])
        self.TCheckbutton1 = ttk.Checkbutton(top)
        self.TCheckbutton1.place(relx=0.03, rely=0.08, relwidth=0.12
                , relheight=0.0, height=25)
        self.TCheckbutton1.configure(variable=themed_support.tch36)
        self.TCheckbutton1.configure(takefocus="")
        self.TCheckbutton1.configure(text='''Tcheck''')

        self.TCombobox1 = ttk.Combobox(top)
        self.TCombobox1.place(relx=0.03, rely=0.14, relheight=0.02, relwidth=0.3)

        self.TCombobox1.configure(textvariable=themed_support.combobox)
        self.TCombobox1.configure(takefocus="")

        self.TEntry1 = ttk.Entry(top)
        self.TEntry1.place(relx=0.05, rely=0.19, relheight=0.02, relwidth=0.27)
        self.TEntry1.configure(takefocus="")
        self.TEntry1.configure(cursor="xterm")

        self.TFrame1 = ttk.Frame(top)
        self.TFrame1.place(relx=0.05, rely=0.24, relheight=0.09, relwidth=0.21)
        self.TFrame1.configure(relief=GROOVE)
        self.TFrame1.configure(borderwidth="2")
        self.TFrame1.configure(relief=GROOVE)
        self.TFrame1.configure(width=125)

        self.TLabelframe1 = ttk.Labelframe(top)
        self.TLabelframe1.place(relx=0.05, rely=0.39, relheight=0.09
                , relwidth=0.25)
        self.TLabelframe1.configure(text='''Tlabelframe''')
        self.TLabelframe1.configure(width=150)

        self.TProgressbar1 = ttk.Progressbar(top)
        self.TProgressbar1.place(relx=0.45, rely=0.64, relwidth=0.17
                , relheight=0.0, height=19)

        self.style.map('TRadiobutton',background=
            [('selected', _bgcolor), ('active',"_ana2color")])
        self.TRadiobutton1 = ttk.Radiobutton(top)
        self.TRadiobutton1.place(relx=0.73, rely=0.64, relwidth=0.16
                , relheight=0.0, height=23)
        self.TRadiobutton1.configure(takefocus="")
        self.TRadiobutton1.configure(text='''TRadio''')

        self.TScale1 = ttk.Scale(top)
        self.TScale1.place(relx=0.85, rely=0.41, relwidth=0.0, relheight=0.11
                , width=17)
        self.TScale1.configure(orient="vertical")
        self.TScale1.configure(takefocus="")

        self.TScale2 = ttk.Scale(top)
        self.TScale2.place(relx=0.45, rely=0.68, relwidth=0.17, relheight=0.0
                , height=17)
        self.TScale2.configure(takefocus="")

        self.Scrolledlistbox1 = ScrolledListBox(top)
        self.Scrolledlistbox1.place(relx=0.05, rely=0.76, relheight=0.07
                , relwidth=0.19)
        self.Scrolledlistbox1.configure(background="white")
        self.Scrolledlistbox1.configure(disabledforeground="#b8a786")
        self.Scrolledlistbox1.configure(font=font11)
        self.Scrolledlistbox1.configure(highlightbackground="wheat")
        self.Scrolledlistbox1.configure(highlightcolor="wheat")
        self.Scrolledlistbox1.configure(selectbackground="#c4c4c4")
        self.Scrolledlistbox1.configure(width=10)

        self.Scrolledtext1 = ScrolledText(top)
        self.Scrolledtext1.place(relx=0.37, rely=0.76, relheight=0.09
                , relwidth=0.21)
        self.Scrolledtext1.configure(background="white")
        self.Scrolledtext1.configure(font=font10)
        self.Scrolledtext1.configure(highlightbackground="wheat")
        self.Scrolledtext1.configure(insertborderwidth="3")
        self.Scrolledtext1.configure(selectbackground="#c4c4c4")
        self.Scrolledtext1.configure(width=10)
        self.Scrolledtext1.configure(wrap=NONE)

        self.style.configure('Treeview.Heading',  font=font9)
        self.Scrolledtreeview1 = ScrolledTreeView(top)
        self.Scrolledtreeview1.place(relx=0.13, rely=0.86, relheight=0.12
                , relwidth=0.7)
        self.Scrolledtreeview1.configure(columns="Col1")
        self.Scrolledtreeview1.heading("#0",text="Tree")
        self.Scrolledtreeview1.heading("#0",anchor="center")
        self.Scrolledtreeview1.column("#0",width="209")
        self.Scrolledtreeview1.column("#0",minwidth="20")
        self.Scrolledtreeview1.column("#0",stretch="1")
        self.Scrolledtreeview1.column("#0",anchor="w")
        self.Scrolledtreeview1.heading("Col1",text="Col1")
        self.Scrolledtreeview1.heading("Col1",anchor="center")
        self.Scrolledtreeview1.column("Col1",width="209")
        self.Scrolledtreeview1.column("Col1",minwidth="20")
        self.Scrolledtreeview1.column("Col1",stretch="1")
        self.Scrolledtreeview1.column("Col1",anchor="w")

        self.TSizegrip1 = ttk.Sizegrip(top)
        self.TSizegrip1.place(anchor=SE, relx=1.0, rely=1.0)

        self.TLabel1 = ttk.Label(top)
        self.TLabel1.place(relx=0.05, rely=0.34, height=17, width=37)
        self.TLabel1.configure(background="wheat")
        self.TLabel1.configure(foreground="#000000")
        self.TLabel1.configure(relief=FLAT)
        self.TLabel1.configure(text='''Tlabel''')

        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab', background=
            [('selected', _compcolor), ('active',_ana2color)])
        self.TNotebook1 = ttk.Notebook(top)
        self.TNotebook1.place(relx=0.43, rely=0.05, relheight=0.26, relwidth=0.5)

        self.TNotebook1.configure(width=300)
        self.TNotebook1.configure(takefocus="")
        self.TNotebook1_t1 = ttk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t1, padding=3)
        self.TNotebook1.tab(0, text="Page 1",underline="-1",)
        self.TNotebook1_t2 = ttk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t2, padding=3)
        self.TNotebook1.tab(1, text="Page 2",underline="-1",)

        self.TPanedwindow2 = ttk.Panedwindow(top, orient="vertical")
        self.TPanedwindow2.place(relx=0.03, rely=0.49, relheight=0.23
                , relwidth=0.33)
        self.TPanedwindow2.configure(width=200)
        self.TPanedwindow2_p1 = ttk.Labelframe(height=75, text='Pane 1')
        self.TPanedwindow2.add(self.TPanedwindow2_p1)
        self.TPanedwindow2_p2 = ttk.Labelframe(text='Pane 2')
        self.TPanedwindow2.add(self.TPanedwindow2_p2)
        self.__funcid0 = self.TPanedwindow2.bind('<Map>', self.__adjust_sash0)

        self.TPanedwindow1 = ttk.Panedwindow(top, orient="horizontal")
        self.TPanedwindow1.place(relx=0.42, rely=0.34, relheight=0.23
                , relwidth=0.33)
        self.TPanedwindow1.configure(width=200)
        self.TPanedwindow1_p1 = ttk.Labelframe(width=75, text='Pane 1')
        self.TPanedwindow1.add(self.TPanedwindow1_p1)
        self.TPanedwindow1_p2 = ttk.Labelframe(text='Pane 2')
        self.TPanedwindow1.add(self.TPanedwindow1_p2)
        self.__funcid1 = self.TPanedwindow1.bind('<Map>', self.__adjust_sash1)
Esempio n. 17
0

#starting the main user interface
root = Tk()
#for large HD screen use below
#root.geometry('400x400+1370+1')
#for 7" screen use below
root.geometry('400x400+345+1')
#for 3.2" screen use below
#root.geometry('300x300+1+1')

root.title("OICO Fundus Camera")
root.wm_iconbitmap('@'+'logo-1.xbm')

#The three tabs of the user interface
note=ttk.Notebook(root)
tab1=ttk.Frame(note);
tab1.columnconfigure(0, weight=1)
tab1.rowconfigure(0, weight=1)
tab1.grid(column=3, row=20, sticky=(N,W,E,S))
tab2=ttk.Frame(note);
tab2.grid(column=5, row=20, sticky=(N,W,E,S))
tab3=ttk.Frame(note);
tab3.grid(column=3, row=20, sticky=(N,W,E,S))
tab4=ttk.Frame(note);
tab4.grid(column=3, row=20, sticky=(N,W,E,S))
tab5=ttk.Frame(note);
tab5.grid(column=3, row=20, sticky=(N,W,E,S))
note.add(tab1, text='Patient Details')
note.add(tab2, text='Camera')
note.add(tab3, text='Setup')
Esempio n. 18
0
            table_p = mlb_dump.get(0, mlb_dump.size() - 1)
            dc_server_p = dc_entry.get()
            if mlb_dump.size() == 1:
                table_p = self.convert_table_one_row(table_p)
            CAPM().dnat_for_dc(user_name, password, dc_server_p, table_p)
        else:
            pass


if __name__ == "__main__":
    root = Tk()
    root.resizable(width=False, height=False)
    root.title("Python SNMP N-Simulator ver 1.1")

    # new notebook
    note_book = ttk.Notebook(root)
    page1 = ttk.Frame(note_book)
    page2 = ttk.Frame(note_book)
    page3 = ttk.Frame(note_book)
    page4 = ttk.Frame(note_book)
    page5 = ttk.Frame(note_book)
    # note_book.add(page1, text='Settings')
    note_book.add(page2, text='General')
    # note_book.add(page3, text='Extensions')
    # note_book.add(page4, text='SimDepot')
    # note_book.add(page5, text='CAPM')
    note_book.pack(expand=1, fill="both")
    # note_book.select(1)

    app = MainApplication(root)
    # app.check_version()
def server(port, host_username, password, room_name):
    def test():
        return

    def server_thread():
        server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        server.bind(("", int(port)))

        clients_list = {}
        mute_list = []
        deaf_list = []
        messages = []

        print("server_thread is running")

        server.listen(5)

        def validate_client(connection):

            try:
                client_password = connection.recv(2000)
                print(client_password)
                if client_password == password:
                    # print("passwords match")
                    connection.send("1")
                else:
                    # print("passwords do not match")
                    connection.send("0")
                    return False
            except:
                # print("Unable to validate password")
                connection.send("0")
                connection.close()
                return False

            try:
                client_username = connection.recv(2000)
                # print(client_username)
                # print("username validated")
                if client_username not in clients_list:
                    connection.send("1")
                else:
                    connection.send("0")

                return True
            except:
                # print("unable to validate username")
                connection.send("0")
                connection.close()
                return False

        def client_thread(client, username):

            print("Running client_thread")

            client.send(room_name)

            for message in messages:
                print(message)
                client.send(message)

            broadcast_message("", username + " has entered the chat \n")

            while True:
                try:
                    message = client.recv(2000)
                    print("message received")
                    if message:
                        if message[0:3] == "***":
                            print("command received")
                            action_handler(message[3:])
                        elif username not in mute_list:
                            broadcast_message(username, message)
                    else:
                        client.close()
                        remove(username)

                except:
                    continue

        def action_handler(action):
            # print("running action handler")
            # print(action + " - action")
            # print("printing sdfasdfsd")
            action_split = action.split(" ", 1)

            for action in action_split:
                print(action)

            command = action_split[0]
            parameter = action_split[1]

            # print(command)
            # print(parameter)

            if command == "d":
                disconnect(parameter)

        def broadcast_message(sender, message):
            for client in clients_list:
                if client not in deaf_list:
                    if sender != "":
                        full_message = sender + ":   " + message + "\n"
                    else:
                        full_message = message
                    clients_list[client].send(full_message)
                    messages.append(full_message)
            print("Message broadcasted")
            # print(message)

        def remove(connection):
            # print(connection)
            if connection in clients_list:
                clients_list.pop(connection, None)
                # print(clients_list)
                details_clients = list(
                    details_server_connections_listbox.get(0, END))
                action_clients = list(
                    actions_server_connections_listbox.get(0, END))

                for client in details_clients:
                    if client == connection:
                        details_clients.remove(client)

                for client in action_clients:
                    if client == connection:
                        action_clients.remove(client)

                details_server_connections_listbox.delete(0, END)
                actions_server_connections_listbox.delete(0, END)

                for client in details_clients:
                    details_server_connections_listbox.insert(END, client)

                for client in action_clients:
                    actions_server_connections_listbox.insert(END, client)

                print("Connection removed")

        def change_room_name():
            new_room_name = actions_edit_room_name_entry.get()

            actions_edit_room_name_entry.delete(0, END)

            details_chatroom_name_label.config(text=new_room_name)

            broadcast_message("", "***rnc " + new_room_name)

        def shutdown():
            try:
                print("shutting down")
                for client in clients_list:
                    clients_list[client].send("***sd")

                time.sleep(1)
                clients_list.clear()
                server.close()
            except:
                print("unable to shut down")
            activeWindows.server_window_isactive = False
            server_window.destroy()

        def disconnect(user):
            try:
                clients_list[user].send("***d")
                remove(user)
                print("user has disconnected")
                broadcast_message("", user + " has disconnected \n")
            except:
                print("unable to disconnect user")

        def kick():
            try:
                print("getting selected user")
                user = actions_server_connections_listbox.get(
                    actions_server_connections_listbox.curselection())
                clients_list[user].send("***k")
                remove(user)
                print("user has been kicked")
                broadcast_message("",
                                  user + " has been kicked from the chat \n")
            except:
                print("unable to get selected user")

        def mute():
            try:
                user = actions_server_connections_listbox.get(
                    actions_server_connections_listbox.curselection())
                if user in mute_list:
                    clients_list[user].send("***um")
                    broadcast_message("", user + " has been unmuted \n")
                    mute_list.remove(user)
                else:
                    clients_list[user].send("***m")
                    broadcast_message("", user + " has been muted \n")
                    mute_list.append(user)
                print("user has been muted/unmuted")
            except:
                print("unable to get selected user")

        def deafen():
            print("printing user about to be deafened")
            try:
                user = actions_server_connections_listbox.get(
                    actions_server_connections_listbox.curselection())
                if user not in deaf_list:
                    clients_list[user].send("***df")
                    broadcast_message("", user + " has been deafened \n")
                    deaf_list.append(user)
                else:
                    clients_list[user].send("***udf")
                    broadcast_message("", user + " has been undeafened \n")
                    deaf_list.remove(user)
                print("user has been deafened/undeafened")
                print(str(deaf_list))
            except:
                print("unable to get selected user for deafening")

        actions_edit_room_name_button.config(command=change_room_name)
        actions_mute_user_button.config(command=mute)
        actions_deafen_user_button.config(command=deafen)
        actions_kick_user_button.config(command=kick)
        actions_shutdown_server_button.config(command=shutdown)

        server_window.protocol("WM_DELETE_WINDOW", shutdown)

        # print("Button has been bound")

        while True:
            clientsocket, address = server.accept()

            try:
                validated = clientsocket.recv(2000)
                print("validated: " + validated)
                clientsocket.send("1")
                if bool(int(validated)):
                    client_username = clientsocket.recv(2000)
                    clients_list[client_username] = clientsocket
                    details_server_connections_listbox.insert(
                        END, client_username)
                    actions_server_connections_listbox.insert(
                        END, client_username)
                    clientsocket.send("1")
                    ct = threading.Thread(target=client_thread,
                                          args=(clientsocket, client_username))
                    ct.daemon = True
                    ct.start()
                elif not validate_client(clientsocket):
                    clientsocket.close()
            except:
                break
        print("broke out of loop")

    def timer():
        timer_counter = [0, 0, 0]
        timer_pattern = '{0:02d}:{1:02d}:{2:02d}'

        while True:
            timer_counter[2] += 1
            if timer_counter[2] >= 60:
                timer_counter[2] = 0
                timer_counter[1] += 1

            if timer_counter[1] >= 60:
                timer_counter[1] = 0
                timer_counter[0] += 1

            time_string = timer_pattern.format(timer_counter[0],
                                               timer_counter[1],
                                               timer_counter[2])
            try:
                details_server_time_running.config(text=time_string)
            except:
                pass
            time.sleep(1)

    def display_server_details():
        details_server_ip_address.config(
            text=socket.gethostbyname(socket.gethostname()))
        details_server_port.config(text=str(port))
        details_server_password.config(text=password)

    def alert_popup(title, reason, description):
        popup = tk.Toplevel()
        popup.title(title)

        title = Label(popup, text=title + ":")
        description = Label(popup, text=reason + ": " + description)
        ok_button = Button(popup, text="OK", command=popup.destroy)

        title.pack()
        description.pack()
        ok_button.pack()

        popup.mainloop()

    if port == "" or host_username == "" or room_name == "":
        alert_popup(
            "Error", "Parameter Error",
            "One or more of your parameters are either invalid or blank.")
        exit()

    try:
        int(port)
    except:
        alert_popup("Error", "Parameter Error", "Your port number is invalid.")
        exit()

    ### Window, Notebook, Toolbar, and Frames

    server_window = tk.Toplevel()
    server_window.title(room_name)
    server_window.geometry("350x500")
    server_window.iconbitmap("images//logo.ico")
    server_window.resizable(False, False)

    toolbar = Menu(server_window)
    server_window.config(menu=toolbar)

    toolbar.add_command(label="Exit", command=server_window.destroy)
    toolbar.add_command(label="Help", command=test)
    toolbar.add_command(label="Test", command=test)

    notebook = ttk.Notebook(server_window)

    details_frame = Frame(notebook)
    action_frame = Frame(notebook)
    logs_frame = Frame(notebook)

    notebook.pack(fill="both", expand=True)

    details_frame.pack(fill="both", expand=True)
    action_frame.pack(fill="both", expand=True)
    logs_frame.pack(fill="both", expand=True)

    ##### Widgets and Images #####

    details_main_logo = ImageTk.PhotoImage(
        Image.open("images//logo.png").resize((30, 30)))
    actions_main_logo = ImageTk.PhotoImage(
        Image.open("images//logo.png").resize((75, 75)))
    chat_main_logo = ImageTk.PhotoImage(
        Image.open("images//logo.png").resize((100, 100)))

    ### Details

    # Labels
    details_chatroom_name_label = Label(details_frame,
                                        text=room_name,
                                        font=("Helvetica", 15))
    details_title_label = Label(details_frame,
                                text="Server Details:",
                                font=("Helvetica", 14))
    details_server_room_name_label = Label(details_frame,
                                           text="Room Name: ",
                                           font=("Helvetica", 10))
    details_server_time_running_label = Label(details_frame,
                                              text="Time Active: ",
                                              font=("Helvetica", 10))
    details_server_ip_address_label = Label(details_frame,
                                            text="Server IPV4 Address: ",
                                            font=("Helvetica", 10))
    details_server_port_label = Label(details_frame,
                                      text="Server Port: ",
                                      font=("Helvetica", 10))
    details_server_password_label = Label(details_frame,
                                          text="Server Password: "******"Helvetica", 10))
    details_server_connections_label = Label(details_frame,
                                             text="Connected Clients: ",
                                             font=("Helvetica", 10))

    details_server_room_name = Label(details_frame, text=room_name)
    details_server_time_running = Label(details_frame, text="00:00")
    details_server_ip_address = Label(details_frame, text="XXX.XXX.X.XXX")
    details_server_port = Label(details_frame, text="1234")
    details_server_password = Label(details_frame, text="abcdefg123")

    details_logo_label = Label(details_frame, image=details_main_logo)

    # Listboxes
    details_server_connections_listbox = Listbox(details_frame,
                                                 width=33,
                                                 height=8,
                                                 borderwidth=5,
                                                 font=("Courier", 13))

    ### Actions

    # Labels
    actions_title_label = Label(action_frame,
                                text="Server Actions",
                                font=("Helvetica", 15))
    actions_logo_label = Label(action_frame, image=actions_main_logo)

    # Buttons
    actions_edit_room_name_button = Button(action_frame,
                                           text="Change Room Name",
                                           borderwidth=3)
    actions_kick_user_button = Button(action_frame,
                                      text="Kick User",
                                      borderwidth=3)
    actions_mute_user_button = Button(action_frame,
                                      text="Mute/Unmute User",
                                      borderwidth=3)
    actions_deafen_user_button = Button(action_frame,
                                        text="Deafen/Undeafen User",
                                        borderwidth=3)
    actions_shutdown_server_button = Button(action_frame,
                                            text="Shut down Server",
                                            borderwidth=3)

    # Entries
    actions_edit_room_name_entry = Entry(action_frame, borderwidth=5)

    # Listboxes
    actions_server_connections_listbox = Listbox(action_frame,
                                                 width=33,
                                                 height=8,
                                                 borderwidth=5,
                                                 font=("Courier", 13))

    ##### Grids #####

    ### Details

    # Labels
    details_chatroom_name_label.grid(row=0, column=0, pady=3, columnspan=2)
    details_title_label.grid(row=1, column=0, pady=1, columnspan=2)
    details_server_room_name_label.grid(row=2, column=0, pady=1)
    details_server_time_running_label.grid(row=3, column=0, pady=1)
    details_server_ip_address_label.grid(row=4, column=0, pady=1)
    details_server_port_label.grid(row=5, column=0, pady=1)
    details_server_password_label.grid(row=6, column=0, pady=1)
    details_server_connections_label.grid(row=7, column=0, pady=1)

    details_server_room_name.grid(row=2, column=1, pady=1)
    details_server_time_running.grid(row=3, column=1)
    details_server_ip_address.grid(row=4, column=1)
    details_server_port.grid(row=5, column=1)
    details_server_password.grid(row=6, column=1)

    details_logo_label.grid(row=9, column=0, columnspan=2)

    # Listboxes
    details_server_connections_listbox.grid(row=8,
                                            column=0,
                                            columnspan=2,
                                            pady=7)

    ### Logs

    ### Actions

    # Labels
    actions_title_label.grid(row=0, column=0, columnspan=2, pady=5)
    actions_logo_label.grid(row=6, column=0, columnspan=2)

    # Buttons
    actions_edit_room_name_button.grid(row=1, column=0, pady=5)
    actions_mute_user_button.grid(row=2, column=1, pady=5)
    actions_deafen_user_button.grid(row=2, column=0, pady=5)
    actions_kick_user_button.grid(row=4, column=0, pady=5, columnspan=2)
    actions_shutdown_server_button.grid(row=5, column=0, pady=5, columnspan=2)

    # Entries
    actions_edit_room_name_entry.grid(row=1, column=1, pady=5)

    # Listboxes
    actions_server_connections_listbox.grid(row=3,
                                            column=0,
                                            columnspan=2,
                                            pady=5)

    ### Frames
    notebook.add(details_frame, text="Details")
    notebook.add(action_frame, text="Actions")
    notebook.add(logs_frame, text="Log")

    ### Commands to be run
    display_server_details()
    st = threading.Thread(target=server_thread)
    st.daemon = True
    st.start()

    tt = threading.Thread(target=timer)
    tt.daemon = True
    tt.start()

    ### Mainloop
    server_window.mainloop()
Esempio n. 20
0
    def __init__(self, top=None, eth_interface=None):

        self.top = top

        # Store Ethernet interface locally
        self.eth_interface = eth_interface

        # Preparing GUI variables
        self.RunningVar = BooleanVar()
        self.PortEntryVar = StringVar()

        # Setting up Window
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        top.geometry("482x212+593+264")
        top.title("Ethernet Interface")
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])
        self.RiderTab = ttk.Notebook(top)
        self.RiderTab.place(relx=0.02,
                            rely=0.05,
                            relheight=0.78,
                            relwidth=0.94)
        self.RiderTab.configure(width=454)
        self.RiderTab.configure(takefocus="")
        self.RiderTab_t1 = ttk.Frame(self.RiderTab)
        self.RiderTab.add(self.RiderTab_t1, padding=3)
        self.RiderTab.tab(
            0,
            text="Server",
            underline="-1",
        )

        self.PortLabel = Label(self.RiderTab_t1)
        self.PortLabel.place(relx=0.04, rely=0.14, height=21, width=28)
        self.PortLabel.configure(activebackground="#f9f9f9")
        self.PortLabel.configure(activeforeground="black")
        self.PortLabel.configure(background="#d9d9d9")
        self.PortLabel.configure(disabledforeground="#a3a3a3")
        self.PortLabel.configure(foreground="#000000")
        self.PortLabel.configure(highlightbackground="#d9d9d9")
        self.PortLabel.configure(highlightcolor="black")
        self.PortLabel.configure(text='''Port''')

        self.PortEntry = Entry(self.RiderTab_t1)
        self.PortEntry.place(relx=0.22,
                             rely=0.14,
                             relheight=0.14,
                             relwidth=0.72)

        self.PortEntry.configure(background="white")
        self.PortEntry.configure(disabledforeground="#a3a3a3")
        self.PortEntry.configure(font="TkFixedFont")
        self.PortEntry.configure(foreground="#000000")
        self.PortEntry.configure(highlightbackground="#d9d9d9")
        self.PortEntry.configure(highlightcolor="black")
        self.PortEntry.configure(insertbackground="black")
        self.PortEntry.configure(selectbackground="#c4c4c4")
        self.PortEntry.configure(selectforeground="black")
        self.PortEntry.configure(textvariable=self.PortEntryVar)
        self.PortEntry.configure(width=324)

        self.StartButton = Button(self.RiderTab_t1)
        self.StartButton.place(relx=0.22, rely=0.71, height=24, width=70)
        self.StartButton.configure(activebackground="#d9d9d9")
        self.StartButton.configure(activeforeground="#000000")
        self.StartButton.configure(background="#d9d9d9")
        self.StartButton.configure(command=self.start_server)
        self.StartButton.configure(disabledforeground="#a3a3a3")
        self.StartButton.configure(foreground="#000000")
        self.StartButton.configure(highlightbackground="#d9d9d9")
        self.StartButton.configure(highlightcolor="black")
        self.StartButton.configure(pady="0")
        self.StartButton.configure(text='''Start Server''')

        self.StopButton = Button(self.RiderTab_t1)
        self.StopButton.place(relx=0.42, rely=0.71, height=24, width=67)
        self.StopButton.configure(activebackground="#d9d9d9")
        self.StopButton.configure(activeforeground="#000000")
        self.StopButton.configure(background="#d9d9d9")
        self.StopButton.configure(command=self.stop_server)
        self.StopButton.configure(disabledforeground="#a3a3a3")
        self.StopButton.configure(foreground="#000000")
        self.StopButton.configure(highlightbackground="#d9d9d9")
        self.StopButton.configure(highlightcolor="black")
        self.StopButton.configure(pady="0")
        self.StopButton.configure(text='''Stop Server''')

        self.RunningLabel = Label(self.RiderTab_t1)
        self.RunningLabel.place(relx=0.04, rely=0.43, height=21, width=51)
        self.RunningLabel.configure(background="#d9d9d9")
        self.RunningLabel.configure(disabledforeground="#a3a3a3")
        self.RunningLabel.configure(foreground="#000000")
        self.RunningLabel.configure(text='''Running''')

        self.RunningCheck = Checkbutton(self.RiderTab_t1)
        self.RunningCheck.place(relx=0.22,
                                rely=0.43,
                                relheight=0.18,
                                relwidth=0.06)
        self.RunningCheck.configure(activebackground="#d9d9d9")
        self.RunningCheck.configure(activeforeground="#000000")
        self.RunningCheck.configure(background="#d9d9d9")
        self.RunningCheck.configure(disabledforeground="#a3a3a3")
        self.RunningCheck.configure(foreground="#000000")
        self.RunningCheck.configure(highlightbackground="#d9d9d9")
        self.RunningCheck.configure(highlightcolor="black")
        self.RunningCheck.configure(justify=LEFT)
        self.RunningCheck.configure(state=DISABLED)
        self.RunningCheck.configure(variable=self.RunningVar)

        self.ExitButton = Button(top)
        self.ExitButton.place(relx=0.83, rely=0.85, height=24, width=57)
        self.ExitButton.configure(activebackground="#d9d9d9")
        self.ExitButton.configure(activeforeground="#000000")
        self.ExitButton.configure(background="#d9d9d9")
        self.ExitButton.configure(command=self.exit_window)
        self.ExitButton.configure(disabledforeground="#a3a3a3")
        self.ExitButton.configure(foreground="#000000")
        self.ExitButton.configure(highlightbackground="#d9d9d9")
        self.ExitButton.configure(highlightcolor="black")
        self.ExitButton.configure(pady="0")
        self.ExitButton.configure(text='''Exit''')
        self.ExitButton.configure(width=57)

        self.get_status()
    def frames(self):
        frame1 = Tk.Frame(root, bd=5, relief='raised', borderwidth=1)
        frame2 = Tk.Frame(root, bd=5, relief='raised')

        note = ttk.Notebook(frame2)
        self.tab1 = ttk.Frame(note)
        self.tab2 = ttk.Frame(note)

        note.add(self.tab1, text = "Frquency")
        note.add(self.tab2, text = "Time")

        # Positioning
        frame1.pack(side='left', fill='both', padx=5, pady=5)
        frame2.pack(side='right', fill='both', expand='true')

        boton_open = Tk.Button(frame1, text ="Open file", command=self.open_file)
        boton_save = Tk.Button(frame1, text ="Save to file", command=self.save_file)
        boton_scan = Tk.Button(frame1, text="Scan serial ports", command=self.scan_ports)
        boton_read = Tk.Button(frame1, text="Read serial data", command=self.read_serial)

        label1 = Tk.Label(frame1, text="Select Serial Port:")
        self.sel_puerto = ttk.Combobox(frame1, textvariable='', state="readonly")
        portnames = scan_serial()
        self.sel_puerto['values'] = portnames        
        if (portnames != []):
            self.sel_puerto.current(0)

        self.text_message = ScrolledText(frame1, height=10, width=20)

        self.window_var = Tk.IntVar()
        self.window_var.set(1)        #Option rectangular window 
        radio_button1 = Tk.Radiobutton(frame1, text="Rectangular Window",
                                       variable=self.window_var, value=1, command=self.win_sel)
        radio_button2 = Tk.Radiobutton(frame1, text="Hann Window",
                                       variable=self.window_var, value=2, command=self.win_sel)
        radio_button3 = Tk.Radiobutton(frame1, text="Flattop Window",
                                       variable=self.window_var, value=3, command=self.win_sel)
        # Grid
        boton_open.grid(row=1, column=0, padx=5, pady=5)
        boton_save.grid(row=2, column=0, padx=5, pady=5)
        boton_scan.grid(row=3, column=0, padx=5, pady=5)
        label1.grid(row=4, column=0, padx=5, pady=5)
        self.sel_puerto.grid(row=5, column=0, padx=5, pady=5)
        boton_read.grid(row=6, column=0, padx=5, pady=5)
        self.text_message.grid(row=7, column=0, padx=5, pady=5)
        radio_button1.grid(row=8, column=0, sticky="W")
        radio_button2.grid(row=9, column=0, sticky="W")
        radio_button3.grid(row=10, column=0, sticky="W")

        #note.grid(row = 0, column=0)
        note.pack(side='top', fill='both', padx=5, pady=5)

        #Figure 1
        fig1 = Figure(figsize=(10,7))
        fig1.suptitle('Sampled signal - Acceleration')
        ax_11 = fig1.add_subplot(3,1,1)
        ax_11.hold(False)
        ax_11.set_title("Channel X")
        ax_11.set_ylabel('g')
        ax_11.grid()                       #Shows grid.

        ax_12 = fig1.add_subplot(3,1,2)
        ax_12.hold(False)
        ax_12.set_title("Channel Y")
        #ax_12.set_xlabel('ms')
        ax_12.set_ylabel('g')
        ax_12.grid()                       #Shows grid.

        ax_12 = fig1.add_subplot(3,1,3)
        ax_12.hold(False)
        ax_12.set_title("Channel Z")
        ax_12.set_xlabel('ms')
        ax_12.set_ylabel('g')
        ax_12.grid()                       #Shows grid.

        #Figure 2
        fig2 = Figure(figsize=(10,7))
        fig2.suptitle('FFT spectrum')

        ax_21 = fig2.add_subplot(3,1,1)
        ax_21.hold(False)
        ax_21.set_title("Channel X")
        ax_21.set_ylabel('g')
        ax_21.set_xlim(xmax=max_freq)
        ax_21.grid()            

        ax_22 = fig2.add_subplot(3,1,2)
        ax_22.hold(False)
        ax_22.set_title("Channel Y")
        #ax_22.set_xlabel('Hz')
        ax_22.set_xlim(xmax=max_freq)
        ax_22.set_ylabel('g')
        ax_22.grid()

        ax_23 = fig2.add_subplot(3,1,3)
        ax_23.hold(False)
        ax_23.set_title("Channel Z")
        ax_23.set_xlabel('Hz')
        #ax_23.set_xlim(xmax=max_freq)
        ax_23.set_xlim(xmax=max_freq_z)
        ax_23.set_ylabel('g')
        ax_23.grid()            

        # Canvas
        self.canvas2 = FigureCanvasTkAgg(fig1, master=self.tab2)
        self.canvas2.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.toolbar2 = NavigationToolbar2TkAgg(self.canvas2, self.tab2)
        self.toolbar2.update()
        self.canvas2._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.canvas1 = FigureCanvasTkAgg(fig2, master=self.tab1)
        self.canvas1.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.toolbar1 = NavigationToolbar2TkAgg(self.canvas1, self.tab1)
        self.toolbar1.update()
        self.canvas1._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
Esempio n. 22
0
    def createWidgets(self):

        self.n = ttk.Notebook(self)

        self.n.grid(column=0, row=0)

        self.daily_frame = ttk.Frame(self.n)
        self.postseason_frame = ttk.Frame(self.n)
        self.init_frame = ttk.Frame(self.n)

        # Begin "daily tasks" page in the notebook

        self.label2 = ttk.Label(self.daily_frame)
        self.label2["text"] = "load dead birds from file(s):\n"
        self.label2.grid(column=0, row=0, columnspan=7, sticky=(W))

        self.load_birds_entry = ttk.Entry(self.daily_frame)
        self.load_birds_entry.grid(column=0,
                                   row=1,
                                   columnspan=4,
                                   sticky=(E, W))

        self.bird_file_button = ttk.Button(self.daily_frame)
        self.bird_file_button["text"] = "select files"
        self.bird_file_button["command"] = self.set_bird_file

        self.bird_file_button.grid(column=6, row=1)

        self.load_birds_button = ttk.Button(self.daily_frame)
        self.load_birds_button["text"] = "load birds"
        self.load_birds_button["command"] = self.load_birds

        self.load_birds_button.grid(column=7, row=1)

        self.sep1 = ttk.Separator(self.daily_frame)
        self.sep1.grid(column=0,
                       row=2,
                       columnspan=8,
                       sticky=(N, S, E, W),
                       ipadx=40)

        self.label3 = ttk.Label(self.daily_frame)
        self.label3[
            "text"] = "generate daily risk for the following date(s): (in YYYY-MM-DD format)\n"
        self.label3.grid(column=0, row=3, columnspan=7, sticky=(W, S))

        self.label_entry1 = ttk.Label(self.daily_frame)
        self.label_entry1["text"] = "start date:"
        self.label_entry1.grid(column=0, row=4)

        self.daily_risk_entry1 = ttk.Entry(self.daily_frame)
        self.daily_risk_entry1.insert(
            0,
            datetime.date.today().strftime("%Y-%m-%d"))
        self.daily_risk_entry1.grid(column=1, row=4, sticky=(W, S))

        self.label_entry2 = ttk.Label(self.daily_frame)
        self.label_entry2["text"] = "end date:"
        self.label_entry2.grid(column=2, row=4)

        self.daily_risk_entry2 = ttk.Entry(self.daily_frame)
        self.daily_risk_entry2.insert(
            0,
            datetime.date.today().strftime("%Y-%m-%d"))
        self.daily_risk_entry2.grid(column=3, row=4, sticky=(W, S))

        self.daily_risk_button = ttk.Button(self.daily_frame)
        self.daily_risk_button["text"] = "run risk"
        self.daily_risk_button["command"] = self.run_daily_risk

        self.daily_risk_button.grid(column=7, row=4)

        self.daily_risk_params_frame = ttk.Frame(self.daily_frame)

        self.daily_risk_cs_label = ttk.Label(self.daily_risk_params_frame)
        self.daily_risk_cs_label["text"] = "closeness in space (miles):"
        self.daily_risk_cs_label.grid(column=0, row=50, sticky=(E))

        self.daily_risk_cs_entry = ttk.Entry(self.daily_risk_params_frame,
                                             width=5)
        self.daily_risk_cs_entry.insert(0, dycast.get_default_parameters()[0])
        self.daily_risk_cs_entry.grid(column=1, row=50)

        self.daily_risk_ct_label = ttk.Label(self.daily_risk_params_frame)
        self.daily_risk_ct_label["text"] = "closeness in time (days):"
        self.daily_risk_ct_label.grid(column=2, row=50, sticky=(E))

        self.daily_risk_ct_entry = ttk.Entry(self.daily_risk_params_frame,
                                             width=5)
        self.daily_risk_ct_entry.insert(0, dycast.get_default_parameters()[1])
        self.daily_risk_ct_entry.grid(column=3, row=50)

        self.daily_risk_sd_label = ttk.Label(self.daily_risk_params_frame)
        self.daily_risk_sd_label["text"] = "spatial domain (miles):"
        self.daily_risk_sd_label.grid(column=4, row=50, sticky=(E))

        self.daily_risk_sd_entry = ttk.Entry(self.daily_risk_params_frame,
                                             width=5)
        self.daily_risk_sd_entry.insert(0, dycast.get_default_parameters()[2])
        self.daily_risk_sd_entry.grid(column=5, row=50)

        self.daily_risk_td_label = ttk.Label(self.daily_risk_params_frame)
        self.daily_risk_td_label["text"] = "temporal domain (days):"
        self.daily_risk_td_label.grid(column=6, row=50, sticky=(E))

        self.daily_risk_td_entry = ttk.Entry(self.daily_risk_params_frame,
                                             width=5)
        self.daily_risk_td_entry.insert(0, dycast.get_default_parameters()[3])
        self.daily_risk_td_entry.grid(column=7, row=50)

        self.daily_risk_params_frame.grid(column=0, row=50, columnspan=8)

        self.sep2 = ttk.Separator(self.daily_frame)
        self.sep2.grid(column=0,
                       row=60,
                       columnspan=8,
                       sticky=(N, S, E, W),
                       ipadx=40)

        self.label3 = ttk.Label(self.daily_frame)
        self.label3[
            "text"] = "export daily risk for the following date(s): (in YYYY-MM-DD format)\n"
        self.label3.grid(column=0, row=70, columnspan=7, sticky=(W, S))

        self.label_export_dir_entry = ttk.Label(self.daily_frame)
        self.label_export_dir_entry["text"] = "export directory:"
        self.label_export_dir_entry.grid(column=0, row=80)

        self.export_dir_entry = ttk.Entry(self.daily_frame)
        self.export_dir_entry.grid(column=1,
                                   row=80,
                                   columnspan=6,
                                   sticky=(E, W))

        self.browse_export_dir_button = ttk.Button(self.daily_frame)
        self.browse_export_dir_button["text"] = "browse"
        self.browse_export_dir_button["command"] = self.set_export_dir

        self.browse_export_dir_button.grid(column=7, row=80)

        self.label_entry1 = ttk.Label(self.daily_frame)
        self.label_entry1["text"] = "start date:"
        self.label_entry1.grid(column=0, row=90)

        self.export_risk_entry1 = ttk.Entry(self.daily_frame)
        self.export_risk_entry1.insert(
            0,
            datetime.date.today().strftime("%Y-%m-%d"))
        self.export_risk_entry1.grid(column=1, row=90, sticky=(W, S))

        self.label_entry2 = ttk.Label(self.daily_frame)
        self.label_entry2["text"] = "end date:"
        self.label_entry2.grid(column=2, row=90)

        self.export_risk_entry2 = ttk.Entry(self.daily_frame)
        self.export_risk_entry2.insert(
            0,
            datetime.date.today().strftime("%Y-%m-%d"))
        self.export_risk_entry2.grid(column=3, row=90, sticky=(W, S))

        self.export_risk_button = ttk.Button(self.daily_frame)
        self.export_risk_button["text"] = "export"
        self.export_risk_button["command"] = self.run_export_risk

        self.export_risk_button.grid(column=7, row=90)

        # Begin "postseason" page in the notebook

        self.postseason_frame.grid(column=0,
                                   row=0,
                                   columnspan=7,
                                   sticky=(E, W))

        self.label_kappa = ttk.Label(self.postseason_frame)
        self.label_kappa["text"] = "Kappa analysis:\n"
        self.label_kappa.grid(column=0, row=0)

        self.kappa_window_start_label = ttk.Label(self.postseason_frame)
        self.kappa_window_start_label["text"] = "window start:"
        self.kappa_window_start_label.grid(column=0, row=1, sticky=(E))

        self.kappa_window_start_entry = ttk.Entry(self.postseason_frame)
        self.kappa_window_start_entry.grid(column=1, row=1)

        self.kappa_window_end_label = ttk.Label(self.postseason_frame)
        self.kappa_window_end_label["text"] = "window end:"
        self.kappa_window_end_label.grid(column=2, row=1, sticky=(E))

        self.kappa_window_end_entry = ttk.Entry(self.postseason_frame)
        self.kappa_window_end_entry.grid(column=3, row=1)

        self.kappa_window_step_label = ttk.Label(self.postseason_frame)
        self.kappa_window_step_label["text"] = "window step:"
        self.kappa_window_step_label.grid(column=4, row=1, sticky=(E))

        self.kappa_window_step_entry = ttk.Entry(self.postseason_frame)
        self.kappa_window_step_entry.grid(column=5, row=1)

        self.kappa_lag_start_label = ttk.Label(self.postseason_frame)
        self.kappa_lag_start_label["text"] = "lag start:"
        self.kappa_lag_start_label.grid(column=0, row=2, sticky=(E))

        self.kappa_lag_start_entry = ttk.Entry(self.postseason_frame)
        self.kappa_lag_start_entry.grid(column=1, row=2)

        self.kappa_lag_end_label = ttk.Label(self.postseason_frame)
        self.kappa_lag_end_label["text"] = "lag end:"
        self.kappa_lag_end_label.grid(column=2, row=2, sticky=(E))

        self.kappa_lag_end_entry = ttk.Entry(self.postseason_frame)
        self.kappa_lag_end_entry.grid(column=3, row=2)

        self.kappa_lag_step_label = ttk.Label(self.postseason_frame)
        self.kappa_lag_step_label["text"] = "lag step:"
        self.kappa_lag_step_label.grid(column=4, row=2, sticky=(E))

        self.kappa_lag_step_entry = ttk.Entry(self.postseason_frame)
        self.kappa_lag_step_entry.grid(column=5, row=2)

        self.kappa_startdate_label = ttk.Label(self.postseason_frame)
        self.kappa_startdate_label["text"] = "start date:"
        self.kappa_startdate_label.grid(column=0, row=3, sticky=(E))

        self.kappa_startdate_entry = ttk.Entry(self.postseason_frame)
        self.kappa_startdate_entry.insert(
            0,
            datetime.date.today().strftime("%Y-%m-%d"))
        self.kappa_startdate_entry.grid(column=1, row=3)

        self.kappa_enddate_label = ttk.Label(self.postseason_frame)
        self.kappa_enddate_label["text"] = "end date:"
        self.kappa_enddate_label.grid(column=2, row=3, sticky=(E))

        self.kappa_enddate_entry = ttk.Entry(self.postseason_frame)
        self.kappa_enddate_entry.insert(
            0,
            datetime.date.today().strftime("%Y-%m-%d"))
        self.kappa_enddate_entry.grid(column=3, row=3)

        self.kappa_export_dir_label = ttk.Label(self.postseason_frame)
        self.kappa_export_dir_label["text"] = "export directory:"
        self.kappa_export_dir_label.grid(column=0, row=4, sticky=(E))

        self.kappa_export_dir_entry = ttk.Entry(self.postseason_frame)
        self.kappa_export_dir_entry.grid(column=1,
                                         row=4,
                                         columnspan=5,
                                         sticky=(E, W))

        self.kappa_export_dir_button = ttk.Button(self.postseason_frame)
        self.kappa_export_dir_button["text"] = "browse"
        self.kappa_export_dir_button["command"] = self.set_kappa_export_dir
        self.kappa_export_dir_button.grid(column=6, row=4)

        self.kappa_export_file_label = ttk.Label(self.postseason_frame)
        self.kappa_export_file_label["text"] = "export filename:"
        self.kappa_export_file_label.grid(column=0, row=5, sticky=(E))

        self.kappa_export_file_entry = ttk.Entry(self.postseason_frame)
        self.kappa_export_file_entry.insert(0, "kappa.tsv")
        self.kappa_export_file_entry.grid(column=1, row=5)

        self.kappa_button = ttk.Button(self.postseason_frame)
        self.kappa_button["text"] = "run kappa"
        self.kappa_button["command"] = self.run_kappa

        self.kappa_button.grid(column=6, row=5)

        # Begin "initialization" page in the notebook

        self.init_frame.grid(column=0, row=0, columnspan=7, sticky=(E, W))

        self.init_frame.columnconfigure(1, weight=1)
        self.init_frame.columnconfigure(2, weight=2)
        self.init_frame.columnconfigure(3, weight=1)

        self.label_nmcm = ttk.Label(self.init_frame)
        self.label_nmcm["text"] = "Monte Carlo simulations:\n"
        self.label_nmcm.grid(column=0, row=0)

        self.nmcm_close_space_label = ttk.Label(self.init_frame)
        self.nmcm_close_space_label["text"] = "closeness in space (miles):"
        self.nmcm_close_space_label.grid(column=0, row=1, sticky=(E))

        self.nmcm_close_space_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_close_space_entry.insert(0,
                                           dycast.get_default_parameters()[0])
        self.nmcm_close_space_entry.grid(column=1, row=1)

        self.nmcm_close_time_label = ttk.Label(self.init_frame)
        self.nmcm_close_time_label["text"] = "closeness in time (days):"
        self.nmcm_close_time_label.grid(column=2, row=1, sticky=(E))

        self.nmcm_close_time_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_close_time_entry.insert(0,
                                          dycast.get_default_parameters()[1])
        self.nmcm_close_time_entry.grid(column=3, row=1)

        self.nmcm_spatial_domain_label = ttk.Label(self.init_frame)
        self.nmcm_spatial_domain_label["text"] = "spatial domain (miles):"
        self.nmcm_spatial_domain_label.grid(column=4, row=1, sticky=(E))

        self.nmcm_spatial_domain_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_spatial_domain_entry.insert(
            0,
            dycast.get_default_parameters()[2])
        self.nmcm_spatial_domain_entry.grid(column=5, row=1)

        self.nmcm_temporal_domain_label = ttk.Label(self.init_frame)
        self.nmcm_temporal_domain_label["text"] = "temporal domain (days):"
        self.nmcm_temporal_domain_label.grid(column=6, row=1, sticky=(E))

        self.nmcm_temporal_domain_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_temporal_domain_entry.insert(
            0,
            dycast.get_default_parameters()[3])
        self.nmcm_temporal_domain_entry.grid(column=7, row=1)

        self.nmcm_start_number_label = ttk.Label(self.init_frame)
        self.nmcm_start_number_label["text"] = "starting number of birds:"
        self.nmcm_start_number_label.grid(column=0, row=2, sticky=(E))

        self.nmcm_start_number_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_start_number_entry.insert(0, dycast.get_default_threshold())
        self.nmcm_start_number_entry.grid(column=1, row=2)

        self.nmcm_end_number_label = ttk.Label(self.init_frame)
        self.nmcm_end_number_label["text"] = "ending number of birds:"
        self.nmcm_end_number_label.grid(column=2, row=2, sticky=(E))

        self.nmcm_end_number_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_end_number_entry.insert(0, "100")
        self.nmcm_end_number_entry.grid(column=3, row=2)

        self.nmcm_button = ttk.Button(self.init_frame)
        self.nmcm_button["text"] = "run simulation"
        self.nmcm_button["command"] = self.run_nmcm

        self.nmcm_button.grid(column=8, row=2)

        self.sep20 = ttk.Separator(self.init_frame)
        self.sep20.grid(column=0,
                        row=5,
                        columnspan=9,
                        sticky=(N, S, E, W),
                        ipadx=40)

        self.nmcm_load_label = ttk.Label(self.init_frame)
        self.nmcm_load_label[
            "text"] = "Load precalculated Monte Carlo results:"
        self.nmcm_load_label.grid(column=0, row=6, columnspan=7, sticky=(W, S))

        self.nmcm_load_cs_label = ttk.Label(self.init_frame)
        self.nmcm_load_cs_label["text"] = "closeness in space (miles):"
        self.nmcm_load_cs_label.grid(column=0, row=7, sticky=(E))

        self.nmcm_load_cs_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_load_cs_entry.insert(0, dycast.get_default_parameters()[0])
        self.nmcm_load_cs_entry.grid(column=1, row=7)

        self.nmcm_load_ct_label = ttk.Label(self.init_frame)
        self.nmcm_load_ct_label["text"] = "closeness in time (days):"
        self.nmcm_load_ct_label.grid(column=2, row=7, sticky=(E))

        self.nmcm_load_ct_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_load_ct_entry.insert(0, dycast.get_default_parameters()[1])
        self.nmcm_load_ct_entry.grid(column=3, row=7)

        self.nmcm_load_sd_label = ttk.Label(self.init_frame)
        self.nmcm_load_sd_label["text"] = "spatial domain (miles):"
        self.nmcm_load_sd_label.grid(column=4, row=7, sticky=(E))

        self.nmcm_load_sd_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_load_sd_entry.insert(0, dycast.get_default_parameters()[2])
        self.nmcm_load_sd_entry.grid(column=5, row=7)

        self.nmcm_load_td_label = ttk.Label(self.init_frame)
        self.nmcm_load_td_label["text"] = "temporal domain (days):"
        self.nmcm_load_td_label.grid(column=6, row=7, sticky=(E))

        self.nmcm_load_td_entry = ttk.Entry(self.init_frame, width=5)
        self.nmcm_load_td_entry.insert(0, dycast.get_default_parameters()[3])
        self.nmcm_load_td_entry.grid(column=7, row=7)

        self.nmcm_load_file_label = ttk.Label(self.init_frame)
        self.nmcm_load_file_label["text"] = "filename:"
        self.nmcm_load_file_label.grid(column=0, row=90)

        self.nmcm_load_file_entry = ttk.Entry(self.init_frame)
        self.nmcm_load_file_entry.grid(column=1,
                                       row=90,
                                       columnspan=7,
                                       sticky=(E, W))

        self.nmcm_load_file_button = ttk.Button(self.init_frame)
        self.nmcm_load_file_button["text"] = "browse"
        self.nmcm_load_file_button["command"] = self.set_nmcm_import_file
        self.nmcm_load_file_button.grid(column=8, row=90)

        self.nmcm_load_button = ttk.Button(self.init_frame)
        self.nmcm_load_button["text"] = "load results"
        self.nmcm_load_button["command"] = self.load_nmcm
        self.nmcm_load_button.grid(column=8, row=100)

        ##

        self.n.add(self.daily_frame, text="Daily Tasks")
        self.n.add(self.postseason_frame, text="Post Season Tasks")
        self.n.add(self.init_frame, text="Initialization Tasks")

        self.status_label = ttk.Label(self, relief=SUNKEN, anchor=W)
        self.status_label["text"] = "Status: ready"
        self.status_label.grid(column=0, row=100, columnspan=7, sticky=(E, W))
Esempio n. 23
0
import Tkinter as tk
import ttk
 
import platform
 
def quit():
    global tkTop
    tkTop.destroy()
 
tkTop = tk.Tk()
tkTop.geometry('500x300')
 
tkLabelTop = tk.Label(tkTop, text=" http://hello-python.blogspot.com ")
tkLabelTop.pack()
 
notebook = ttk.Notebook(tkTop)
frame1 = ttk.Frame(notebook)
frame2 = ttk.Frame(notebook)
notebook.add(frame1, text='Frame One')
notebook.add(frame2, text='Frame Two')
notebook.pack()
 
tkButtonQuit = tk.Button(
    tkTop,
    text="Quit",
    command=quit)
tkButtonQuit.pack()
  
tkDummyButton = tk.Button(
    frame1,
    text="Dummy Button")
Esempio n. 24
0
	def notebook_type2(self):
		_bgcolor = '#d9d9d9'  # X11 color: 'gray85'
		_fgcolor = '#000000'  # X11 color: 'black'
		_compcolor = '#d9d9d9'  # X11 color: 'gray85'
		_ana1color = '#d9d9d9'  # X11 color: 'gray85'
		_ana2color = '#ececec'  # Closest X11 color: 'gray92'
		global _images
		_images = (
			
			tk.PhotoImage("img_close", data='''R0lGODlhDAAMAIQUADIyMjc3Nzk5OT09PT
						 8/P0JCQkVFRU1NTU5OTlFRUVZWVmBgYGF hYWlpaXt7e6CgoLm5ucLCwszMzNbW
						 1v//////////////////////////////////// ///////////yH5BAEKAB8ALA
						 AAAAAMAAwAAAUt4CeOZGmaA5mSyQCIwhCUSwEIxHHW+ fkxBgPiBDwshCWHQfc5
						 KkoNUtRHpYYAADs= '''),
			
			tk.PhotoImage("img_closeactive", data='''R0lGODlhDAAMAIQcALwuEtIzFL46
						 INY0Fdk2FsQ8IdhAI9pAIttCJNlKLtpLL9pMMMNTP cVTPdpZQOBbQd60rN+1rf
						 Czp+zLxPbMxPLX0vHY0/fY0/rm4vvx8Pvy8fzy8P//////// ///////yH5BAEK
						 AB8ALAAAAAAMAAwAAAVHYLQQZEkukWKuxEgg1EPCcilx24NcHGYWFhx P0zANBE
						 GOhhFYGSocTsax2imDOdNtiez9JszjpEg4EAaA5jlNUEASLFICEgIAOw== '''),
			
			tk.PhotoImage("img_closepressed", data='''R0lGODlhDAAMAIQeAJ8nD64qELE
						 rELMsEqIyG6cyG7U1HLY2HrY3HrhBKrlCK6pGM7lD LKtHM7pKNL5MNtiViNaon
						 +GqoNSyq9WzrNyyqtuzq+O0que/t+bIwubJw+vJw+vTz+zT z////////yH5BAE
						 KAB8ALAAAAAAMAAwAAAVJIMUMZEkylGKuwzgc0kPCcgl123NcHWYW Fs6Gp2mYB
						 IRgR7MIrAwVDifjWO2WwZzpxkxyfKVCpImMGAeIgQDgVLMHikmCRUpMQgA7 ''')
		)
		
		self.style = ttk.Style()
		self.style.element_create("close", "image", "img_close",
								  ("active", "pressed", "!disabled",
								   "img_closepressed"),
								  ("active", "alternate", "!disabled",
								   "img_closeactive"), border=8, sticky='')
		
		self.style.layout("ClosetabNotebook", [("ClosetabNotebook.client",
												{"sticky": "nswe"})])
		self.style.layout("ClosetabNotebook.Tab", [
			("ClosetabNotebook.tab",
			 {"sticky": "nswe",
			  "children": [
				  ("ClosetabNotebook.padding", {
					  "side": "top",
					  "sticky": "nswe",
					  "children": [
						  ("ClosetabNotebook.focus", {
							  "side": "top",
							  "sticky": "nswe",
							  "children": [
								  ("ClosetabNotebook.label", {"side":
																  "left",
															  "sticky": ''}),
								  ("ClosetabNotebook.close", {"side":
																  "left",
															  "sticky": ''}), ]})]})]})])
		
		PNOTEBOOK = "ClosetabNotebook"
		
		self.style.configure('TNotebook.Tab', background=_bgcolor)
		self.style.configure('TNotebook.Tab', foreground=_fgcolor)
		self.style.map('TNotebook.Tab', background=
		[('selected', _compcolor), ('active', _ana2color)])
		
		self.PNotebook1 = ttk.Notebook(self.master)
		# 设置竖直的tab
		# self.PNotebook1 = ttk.Notebook(self.master, style='lefttab.TNotebook')
		# self.style.configure('lefttab.TNotebook', tabposition='wn')
		
		self.PNotebook1.place(relx=0, rely=0, relheight=1
							  , relwidth=1)
		# self.PNotebook1.configure(takefocus="")
		self.PNotebook1.configure(style=PNOTEBOOK)
		self.PNotebook1_t1 = tk.Frame(self.PNotebook1)
		self.PNotebook1.add(self.PNotebook1_t1, padding=2)
		self.PNotebook1.tab(0, text="Page 1", compound="left")
		# self.PNotebook1_t1.configure(highlightbackground="#d9d9d9")
		self.PNotebook1_t2 = tk.Frame(self.PNotebook1)
		self.PNotebook1.add(self.PNotebook1_t2, padding=2)
		self.PNotebook1.tab(1, text="Page 2", compound="left")
		# self.PNotebook1_t2.configure(highlightbackground="#d9d9d9")
		self.PNotebook1.bind('<Button-1>', _button_press)
		self.PNotebook1.bind('<ButtonRelease-1>', _button_release)
		self.PNotebook1.bind('<Motion>', _mouse_over)
Esempio n. 25
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#d9d9d9'  # X11 color: 'gray85'
        font10 = "-family {DejaVu Sans Mono} -size -12"
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        top.geometry("631x732")
        top.minsize(1, 1)
        top.maxsize(1905, 1050)
        top.resizable(1, 1)
        top.title("Carnet d adresses")
        top.configure(highlightcolor="black")

        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])
        self.TNotebook1 = ttk.Notebook(top)
        self.TNotebook1.place(relx=0.0,
                              rely=0.0,
                              relheight=1.001,
                              relwidth=0.986)
        self.TNotebook1.configure(takefocus="")
        self.pg1 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.pg1, padding=3)
        self.TNotebook1.tab(
            0,
            text="Détails",
            compound="none",
            underline="-1",
        )
        self.pg0 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.pg0, padding=3)
        self.TNotebook1.tab(
            1,
            text="Liste",
            compound="none",
            underline="-1",
        )

        self.Label1 = tk.Label(self.pg1)
        self.Label1.place(relx=0.032, rely=0.085, height=21, width=35)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(text='''Nom''')

        self.Label2 = tk.Label(self.pg1)
        self.Label2.place(relx=0.032, rely=0.127, height=21, width=54)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(text='''Prénom''')

        self.Entry7 = tk.Entry(self.pg1)
        self.Entry7.place(relx=0.516, rely=0.042, height=20, relwidth=0.316)
        self.Entry7.configure(background="white")
        self.Entry7.configure(font="TkFixedFont")
        self.Entry7.configure(selectbackground="#c4c4c4")

        self.Entry2 = tk.Entry(self.pg1)
        self.Entry2.place(relx=0.177, rely=0.085, height=20, relwidth=0.655)
        self.Entry2.configure(background="white")
        self.Entry2.configure(font="TkFixedFont")
        self.Entry2.configure(selectbackground="#c4c4c4")

        self.Entry3 = tk.Entry(self.pg1)
        self.Entry3.place(relx=0.177, rely=0.127, height=20, relwidth=0.655)
        self.Entry3.configure(background="white")
        self.Entry3.configure(font="TkFixedFont")
        self.Entry3.configure(selectbackground="#c4c4c4")

        self.Entry4 = tk.Entry(self.pg1)
        self.Entry4.place(relx=0.177, rely=0.17, height=20, relwidth=0.655)
        self.Entry4.configure(background="white")
        self.Entry4.configure(font="TkFixedFont")
        self.Entry4.configure(selectbackground="#c4c4c4")

        self.Entry6 = tk.Entry(self.pg1)
        self.Entry6.place(relx=0.177, rely=0.198, height=20, relwidth=0.655)
        self.Entry6.configure(background="white")
        self.Entry6.configure(font="TkFixedFont")
        self.Entry6.configure(selectbackground="#c4c4c4")

        self.Entry5 = tk.Entry(self.pg1)
        self.Entry5.place(relx=0.177, rely=0.24, height=20, relwidth=0.655)
        self.Entry5.configure(background="white")
        self.Entry5.configure(font="TkFixedFont")
        self.Entry5.configure(selectbackground="#c4c4c4")

        self.Entry1 = tk.Entry(self.pg1)
        self.Entry1.place(relx=0.177, rely=0.283, height=20, relwidth=0.655)
        self.Entry1.configure(background="white")
        self.Entry1.configure(font="TkFixedFont")
        self.Entry1.configure(selectbackground="#c4c4c4")

        self.Entry8 = ScrolledText(self.pg1)
        self.Entry8.place(relx=0.177,
                          rely=0.325,
                          relheight=0.096,
                          relwidth=0.655)
        self.Entry8.configure(background="white")
        self.Entry8.configure(font=font10)
        self.Entry8.configure(insertborderwidth="3")
        self.Entry8.configure(selectbackground="#c4c4c4")
        self.Entry8.configure(wrap="none")

        self.Button1 = tk.Button(self.pg1)
        self.Button1.place(relx=0.613, rely=0.424, height=29, width=97)
        self.Button1.configure(activebackground="#d9d9d9")
        self.Button1.configure(text='''Enregistrer''')

        self.TButton2 = ttk.Button(self.pg1)
        self.TButton2.place(relx=0.847, rely=0.078, height=28, width=83)
        self.TButton2.configure(takefocus="")
        self.TButton2.configure(text='''Effacer''')

        self.Label3 = tk.Label(self.pg1)
        self.Label3.place(relx=0.032, rely=0.17, height=21, width=56)
        self.Label3.configure(activebackground="#f9f9f9")
        self.Label3.configure(text='''Adresse''')

        self.Label4 = tk.Label(self.pg1)
        self.Label4.place(relx=0.032, rely=0.24, height=21, width=81)
        self.Label4.configure(activebackground="#f9f9f9")
        self.Label4.configure(text='''Code postal''')

        self.Label5 = tk.Label(self.pg1)
        self.Label5.place(relx=0.032, rely=0.283, height=21, width=33)
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(text='''Ville''')

        self.TButton1 = ttk.Button(self.pg1)
        self.TButton1.place(relx=0.847, rely=0.276, height=28, width=83)
        self.TButton1.configure(takefocus="")
        self.TButton1.configure(text='''Effacer''')

        self.TButton3 = ttk.Button(self.pg1)
        self.TButton3.place(relx=0.847, rely=0.12, height=28, width=83)
        self.TButton3.configure(takefocus="")
        self.TButton3.configure(text='''Effacer''')

        self.TButton4 = ttk.Button(self.pg1)
        self.TButton4.place(relx=0.847, rely=0.184, height=25, width=83)
        self.TButton4.configure(takefocus="")
        self.TButton4.configure(text='''Effacer''')

        self.TButton5 = ttk.Button(self.pg1)
        self.TButton5.place(relx=0.847, rely=0.233, height=28, width=83)
        self.TButton5.configure(takefocus="")
        self.TButton5.configure(text='''Effacer''')

        self.style.map('TCheckbutton',
                       background=[('selected', _bgcolor),
                                   ('active', _ana2color)])
        self.TCheckbutton1 = ttk.Checkbutton(self.pg1)
        self.TCheckbutton1.place(relx=0.032,
                                 rely=0.014,
                                 relwidth=0.126,
                                 relheight=0.0,
                                 height=21)
        self.TCheckbutton1.configure(variable=carnet_support.tch58)
        self.TCheckbutton1.configure(takefocus="")
        self.TCheckbutton1.configure(text='''Monsieur''')

        self.TCheckbutton2 = ttk.Checkbutton(self.pg1)
        self.TCheckbutton2.place(relx=0.032,
                                 rely=0.042,
                                 relwidth=0.121,
                                 relheight=0.0,
                                 height=21)
        self.TCheckbutton2.configure(variable=carnet_support.tch58)
        self.TCheckbutton2.configure(takefocus="")
        self.TCheckbutton2.configure(text='''Madame''')

        self.TCheckbutton3 = ttk.Checkbutton(self.pg1)
        self.TCheckbutton3.place(relx=0.161,
                                 rely=0.014,
                                 relwidth=0.252,
                                 relheight=0.0,
                                 height=21)
        self.TCheckbutton3.configure(variable=carnet_support.tch58)
        self.TCheckbutton3.configure(takefocus="")
        self.TCheckbutton3.configure(text='''Monsieur et Madame''')

        self.TCheckbutton4 = ttk.Checkbutton(self.pg1)
        self.TCheckbutton4.place(relx=0.419,
                                 rely=0.014,
                                 relwidth=0.423,
                                 relheight=0.0,
                                 height=21)
        self.TCheckbutton4.configure(variable=carnet_support.tch58)
        self.TCheckbutton4.configure(takefocus="")
        self.TCheckbutton4.configure(
            text='''Monsieur et Madame et leurs enfants''')

        self.TButton6 = ttk.Button(self.pg1)
        self.TButton6.place(relx=0.032, rely=0.424, height=28, width=83)
        self.TButton6.configure(takefocus="")
        self.TButton6.configure(text='''Chercher''')

        self.TCheckbutton5 = ttk.Checkbutton(self.pg1)
        self.TCheckbutton5.place(relx=0.161,
                                 rely=0.042,
                                 relwidth=0.194,
                                 relheight=0.0,
                                 height=17)
        self.TCheckbutton5.configure(variable=carnet_support.tch58)
        self.TCheckbutton5.configure(takefocus="")
        self.TCheckbutton5.configure(text='''Mademoiselle''')

        self.TCheckbutton6 = ttk.Checkbutton(self.pg1)
        self.TCheckbutton6.place(relx=0.419,
                                 rely=0.042,
                                 relwidth=0.092,
                                 relheight=0.0,
                                 height=21)
        self.TCheckbutton6.configure(variable=carnet_support.tch58)
        self.TCheckbutton6.configure(takefocus="")
        self.TCheckbutton6.configure(text='''Autre''')

        self.TButton7 = ttk.Button(self.pg1)
        self.TButton7.place(relx=0.831, rely=0.424, height=28, width=90)
        self.TButton7.configure(takefocus="")
        self.TButton7.configure(text='''Tout effacer''')

        self.TButton13 = ttk.Button(self.pg1)
        self.TButton13.place(relx=0.847, rely=0.028, height=28, width=83)
        self.TButton13.configure(takefocus="")
        self.TButton13.configure(text='''Effacer''')

        self.Label7 = tk.Label(self.pg1)
        self.Label7.place(relx=0.032, rely=0.325, height=21, width=46)
        self.Label7.configure(activebackground="#f9f9f9")
        self.Label7.configure(text='''Divers''')

        self.TButton14 = ttk.Button(self.pg1)
        self.TButton14.place(relx=0.847, rely=0.354, height=28, width=83)
        self.TButton14.configure(takefocus="")
        self.TButton14.configure(text='''Effacer''')

        self.TNotebook2 = ttk.Notebook(self.pg1)
        self.TNotebook2.place(relx=0.25,
                              rely=0.467,
                              relheight=0.513,
                              relwidth=0.737)
        self.TNotebook2.configure(takefocus="")
        self.pg2 = tk.Frame(self.TNotebook2)
        self.TNotebook2.add(self.pg2, padding=3)
        self.TNotebook2.tab(
            0,
            text="Aperçu de l'adresse",
            compound="none",
            underline="-1",
        )
        self.pg3 = tk.Frame(self.TNotebook2)
        self.TNotebook2.add(self.pg3, padding=3)
        self.TNotebook2.tab(
            1,
            text="Téléphone",
            compound="none",
            underline="-1",
        )
        self.pg4 = tk.Frame(self.TNotebook2)
        self.TNotebook2.add(self.pg4, padding=3)
        self.TNotebook2.tab(
            2,
            text="Courriel",
            compound="none",
            underline="-1",
        )

        self.Button9 = tk.Button(self.pg2)
        self.Button9.place(relx=0.396, rely=0.03, height=29, width=86)
        self.Button9.configure(activebackground="#d9d9d9")
        self.Button9.configure(text='''Imprimer''')

        self.Canvas2 = tk.Canvas(self.pg2)
        self.Canvas2.place(relx=0.022,
                           rely=0.148,
                           relheight=0.825,
                           relwidth=0.923)
        self.Canvas2.configure(borderwidth="2")
        self.Canvas2.configure(selectbackground="#c4c4c4")

        self.Label17 = tk.Label(self.pg3)
        self.Label17.place(relx=0.066, rely=0.059, height=21, width=35)
        self.Label17.configure(activebackground="#f9f9f9")
        self.Label17.configure(text='''Nom''')

        self.Entry17 = tk.Entry(self.pg3)
        self.Entry17.place(relx=0.22, rely=0.059, height=20, relwidth=0.695)
        self.Entry17.configure(background="white")
        self.Entry17.configure(font="TkFixedFont")
        self.Entry17.configure(selectbackground="#c4c4c4")

        self.Label18 = tk.Label(self.pg3)
        self.Label18.place(relx=0.066, rely=0.148, height=21, width=56)
        self.Label18.configure(activebackground="#f9f9f9")
        self.Label18.configure(text='''Numéro''')

        self.Entry18 = tk.Entry(self.pg3)
        self.Entry18.place(relx=0.22, rely=0.148, height=20, relwidth=0.695)
        self.Entry18.configure(background="white")
        self.Entry18.configure(font="TkFixedFont")
        self.Entry18.configure(selectbackground="#c4c4c4")

        self.Button11 = tk.Button(self.pg3)
        self.Button11.place(relx=0.066, rely=0.237, height=29, width=73)
        self.Button11.configure(activebackground="#d9d9d9")
        self.Button11.configure(text='''Ajouter''')

        self.Button12 = tk.Button(self.pg3)
        self.Button12.place(relx=0.352, rely=0.237, height=29, width=93)
        self.Button12.configure(activebackground="#d9d9d9")
        self.Button12.configure(text='''Supprimer''')

        self.Text3 = ScrolledText(self.pg3)
        self.Text3.place(relx=0.068,
                         rely=0.338,
                         relheight=0.647,
                         relwidth=0.848)

        self.Text3.configure(background="white")
        self.Text3.configure(font=font10)
        self.Text3.configure(insertborderwidth="3")
        self.Text3.configure(selectbackground="#c4c4c4")
        self.Text3.configure(wrap="none")

        self.Label6 = tk.Label(self.pg4)
        self.Label6.place(relx=0.066, rely=0.059, height=21, width=109)
        self.Label6.configure(activebackground="#f9f9f9")
        self.Label6.configure(text='''Adresse courriel''')

        self.Entry9 = tk.Entry(self.pg4)
        self.Entry9.place(relx=0.066, rely=0.119, height=20, relwidth=0.848)
        self.Entry9.configure(background="white")
        self.Entry9.configure(font="-family {DejaVu Sans} -size -12")
        self.Entry9.configure(selectbackground="#c4c4c4")

        self.TButton16 = ttk.Button(self.pg4)
        self.TButton16.place(relx=0.066, rely=0.237, height=28, width=83)
        self.TButton16.configure(takefocus="")
        self.TButton16.configure(text='''Ajouter''')

        self.TButton17 = ttk.Button(self.pg4)
        self.TButton17.place(relx=0.286, rely=0.237, height=28, width=83)
        self.TButton17.configure(takefocus="")
        self.TButton17.configure(text='''Supprimer''')

        self.Scrolledtext1 = ScrolledText(self.pg4)
        self.Scrolledtext1.place(relx=0.066,
                                 rely=0.326,
                                 relheight=0.647,
                                 relwidth=0.853)
        self.Scrolledtext1.configure(background="white")
        self.Scrolledtext1.configure(font=font10)
        self.Scrolledtext1.configure(insertborderwidth="3")
        self.Scrolledtext1.configure(selectbackground="#c4c4c4")
        self.Scrolledtext1.configure(wrap="none")

        self.Text1 = ScrolledText(self.pg1)
        self.Text1.place(relx=0.032,
                         rely=0.467,
                         relheight=0.506,
                         relwidth=0.203)

        self.Text1.configure(background="#d9d9d9")
        self.Text1.configure(font=font10)
        self.Text1.configure(insertborderwidth="3")
        self.Text1.configure(selectbackground="#c4c4c4")
        self.Text1.configure(selectforeground="red")
        self.Text1.configure(wrap="word")

        self.Button2 = tk.Button(self.pg1)
        self.Button2.place(relx=0.468, rely=0.424, height=29, width=76)
        self.Button2.configure(activebackground="#d9d9d9")
        self.Button2.configure(text='''Annuler''')

        self.Button3 = tk.Button(self.pg1)
        self.Button3.place(relx=0.323, rely=0.424, height=26, width=73)
        self.Button3.configure(activebackground="#d9d9d9")
        self.Button3.configure(text='''Supprimer''')

        self.Labelframe1 = tk.LabelFrame(self.pg0)
        self.Labelframe1.place(relx=0.016,
                               rely=0.0,
                               relheight=0.219,
                               relwidth=0.927)
        self.Labelframe1.configure(relief='groove')
        self.Labelframe1.configure(text='''Carnet d'adresses''')

        self.TCombobox1 = ttk.Combobox(self.Labelframe1)
        self.TCombobox1.place(relx=0.017,
                              rely=0.09,
                              relheight=0.116,
                              relwidth=0.308,
                              bordermode='ignore')
        self.TCombobox1.configure(takefocus="")

        self.Scrolledlistbox1 = ScrolledListBox(self.Labelframe1)
        self.Scrolledlistbox1.place(relx=0.017,
                                    rely=0.219,
                                    relheight=0.703,
                                    relwidth=0.96,
                                    bordermode='ignore')
        self.Scrolledlistbox1.configure(background="white")
        self.Scrolledlistbox1.configure(cursor="xterm")
        self.Scrolledlistbox1.configure(font="TkFixedFont")
        self.Scrolledlistbox1.configure(highlightcolor="#d9d9d9")
        self.Scrolledlistbox1.configure(selectbackground="#c4c4c4")

        self.Labelframe2 = tk.LabelFrame(self.pg0)
        self.Labelframe2.place(relx=0.016,
                               rely=0.269,
                               relheight=0.233,
                               relwidth=0.927)
        self.Labelframe2.configure(relief='groove')
        self.Labelframe2.configure(text='''Liste sélectionnée''')

        self.Scrolledlistbox2 = ScrolledListBox(self.Labelframe2)
        self.Scrolledlistbox2.place(relx=0.017,
                                    rely=0.085,
                                    relheight=0.842,
                                    relwidth=0.96,
                                    bordermode='ignore')
        self.Scrolledlistbox2.configure(background="white")
        self.Scrolledlistbox2.configure(cursor="xterm")
        self.Scrolledlistbox2.configure(font="TkFixedFont")
        self.Scrolledlistbox2.configure(highlightcolor="#d9d9d9")
        self.Scrolledlistbox2.configure(selectbackground="#c4c4c4")

        self.TButton8 = ttk.Button(self.pg0)
        self.TButton8.place(relx=0.306, rely=0.226, height=25, width=73)
        self.TButton8.configure(takefocus="")
        self.TButton8.configure(text='''Ajouter''')

        self.TButton9 = ttk.Button(self.pg0)
        self.TButton9.place(relx=0.452, rely=0.226, height=25, width=73)
        self.TButton9.configure(takefocus="")
        self.TButton9.configure(text='''Enlever''')

        self.TButton10 = ttk.Button(self.pg0)
        self.TButton10.place(relx=0.306, rely=0.509, height=28, width=127)
        self.TButton10.configure(takefocus="")
        self.TButton10.configure(text='''Imprimer l'aperçu''')

        self.TButton11 = ttk.Button(self.pg0)
        self.TButton11.place(relx=0.565, rely=0.509, height=28, width=206)
        self.TButton11.configure(takefocus="")
        self.TButton11.configure(text='''Imprimer la liste sélectionnée''')

        self.Label10 = tk.Label(self.pg0)
        self.Label10.place(relx=0.032, rely=0.523, height=21, width=153)
        self.Label10.configure(activebackground="#f9f9f9")
        self.Label10.configure(text='''Aperçu de l'impression''')

        self.Canvas1 = tk.Canvas(self.pg0)
        self.Canvas1.place(relx=0.113,
                           rely=0.58,
                           relheight=0.393,
                           relwidth=0.677)
        self.Canvas1.configure(selectbackground="#d9d9d9")

        self.TButton12 = ttk.Button(self.pg0)
        self.TButton12.place(relx=0.145, rely=0.226, height=28, width=90)
        self.TButton12.configure(takefocus="")
        self.TButton12.configure(text='''Tout ajouter''')

        self.TButton15 = ttk.Button(self.pg0)
        self.TButton15.place(relx=0.597, rely=0.226, height=28, width=93)
        self.TButton15.configure(takefocus="")
        self.TButton15.configure(text='''Tout enlever''')
Esempio n. 26
0
    def __init__(self,*args,**kwargs):
        tk.Tk.__init__(self)
        self.versions={'gui_new':'','gui_all':'','gui_url':'https://github.com/dojafoja/FunKii-UI/releases','fnku_new':'','fnku_all':'',
                       'fnku_url':'https://github.com/llakssz/FunKiiU/releases'}

        self.download_list=[]
        self.selection_list=[]
        self.title_data=[]
        self.nb = ttk.Notebook(self)
        tab1 = ttk.Frame(self.nb)
        self.tab2 = ttk.Frame(self.nb)
        tab3 = ttk.Frame(self.nb)
        tab4 = ttk.Frame(self.nb)
        self.nb.add(tab1,text="Welcome")
        self.nb.add(self.tab2,text="Download")
        self.nb.add(tab3,text="Options")
        self.nb.add(tab4,text="Updates")
        self.nb.pack(fill="both", expand=True)
        self.output_dir=tk.StringVar()
        self.retry_count=tk.IntVar(value=3)
        self.patch_demo=tk.BooleanVar(value=True)
        self.patch_dlc=tk.BooleanVar(value=True)
        self.tickets_only=tk.BooleanVar(value=False)
        self.simulate_mode=tk.BooleanVar(value=False)
        self.region_usa=tk.BooleanVar(value=False)
        self.region_eur=tk.BooleanVar(value=False)
        self.region_jpn=tk.BooleanVar(value=False)
        self.filter_usa=tk.BooleanVar(value=True)
        self.filter_eur=tk.BooleanVar(value=True)
        self.filter_jpn=tk.BooleanVar(value=True)
        self.filter_game=tk.BooleanVar(value=True)
        self.filter_dlc=tk.BooleanVar(value=True)
        self.filter_update=tk.BooleanVar(value=True)
        self.filter_hasticket=tk.BooleanVar(value=False)
        self.total_dl_size=tk.StringVar()
        self.total_dl_size_warning=tk.StringVar()
        self.dl_warning_msg = "     ! You have one or more items in the list with an unknown size. This probably means\n        the tmd can not be downloaded and the title will be skipped by FunKiiU."
        self.idvar=tk.StringVar()
        self.idvar.trace('w',self.id_changed)
        self.usa_selections={'game':[],'dlc':[],'update':[]}
        self.eur_selections={'game':[],'dlc':[],'update':[]}
        self.jpn_selections={'game':[],'dlc':[],'update':[]}
        self.title_sizes_raw={}
        self.title_sizes={}
        self.reverse_title_names={}
        self.title_dict={}
        self.has_ticket=[]
        self.errors=0
        

        # Tab 1
        t1_frm1=ttk.Frame(tab1)   
        t1_frm2=ttk.Frame(tab1)
        t1_frm3=ttk.Frame(tab1)
        t1_frm4=ttk.Frame(tab1)
        t1_frm5=ttk.Frame(tab1)
        t1_frm6=ttk.Frame(tab1)
        
        self.img = PhotoImage(file='logo.gif')
        logo=ttk.Label(t1_frm1,image=self.img).pack()
        lbl=ttk.Label(t1_frm2,justify='center',text='This is a simple GUI by dojafoja that was written for FunKiiU.\nCredits to cearp for writing FunKiiU and cerea1killer for rewriting\n it in way that made writing a GUI much easier.').pack()
        lbl=ttk.Label(t1_frm3,justify='center',text='If you plan on using an online methond to obtain keys or tickets\n then FunKiiU will need to know the name of *that key site*. If you\nhaven\'t already provided the address to the key site, you MUST do so\nbelow before proceeding. You only need to provide this information once!').pack(pady=15)
        self.enterkeysite_lbl=ttk.Label(t1_frm4,text='Enter the name of *that key site*. Something like wiiu.thatkeysite.com')
        self.enterkeysite_lbl.pack(pady=15,side='left')
        self.http_lbl=ttk.Label(t1_frm5,text='http://')
        self.http_lbl.pack(pady=15,side='left')
        self.keysite_box=ttk.Entry(t1_frm5,width=40)
        self.keysite_box.pack(pady=15,side='left')
        self.submitkeysite_btn=ttk.Button(t1_frm6,text='submit',command=self.submit_key_site)
        self.submitkeysite_btn.pack()
        self.updatelabel=ttk.Label(t1_frm6,text='')
        self.updatelabel.pack(pady=15)
        
        t1_frm1.pack()
        t1_frm2.pack()
        t1_frm3.pack()
        t1_frm4.pack()
        t1_frm5.pack()
        t1_frm6.pack()

        self.load_program_revisions()
        self.check_config_keysite()
        
        # Tab2
        t2_frm0=ttk.Frame(self.tab2)
        t2_frm1=ttk.Frame(self.tab2)
        t2_frm2=ttk.Frame(self.tab2)   
        t2_frm3=ttk.Frame(self.tab2)
        t2_frm4=ttk.Frame(self.tab2)
        t2_frm5=ttk.Frame(self.tab2)
        t2_frm6=ttk.Frame(self.tab2)
        t2_frm7=ttk.Frame(self.tab2)
        t2_frm8=ttk.Frame(self.tab2)
        t2_frm9=ttk.Frame(self.tab2)
        t2_frm10=ttk.Frame(self.tab2)
        t2_frm11=ttk.Frame(self.tab2)
        
        lbl=ttk.Label(t2_frm0,text='Enter as many Title ID\'s as you would like to the list. If you are going to use the key method to download then be sure a key is provided for every title\nyou add to the list or it will fail. Use the selection box to make life easier, it has auto-complete. You can always enter a title Id and key manually.').pack(padx=5,pady=7)
        lbl=ttk.Label(t2_frm1,text='Choose regions to display:').pack(padx=5,pady=5,side='left')
        filter_box_usa=ttk.Checkbutton(t2_frm1,text='USA',variable=self.filter_usa,command=lambda:self.populate_selection_box(download_data=False)).pack(padx=5,pady=5,side='left')
        filter_box_eur=ttk.Checkbutton(t2_frm1,text='EUR',variable=self.filter_eur,command=lambda:self.populate_selection_box(download_data=False)).pack(padx=5,pady=5,side='left')
        filter_box_jpn=ttk.Checkbutton(t2_frm1,text='JPN',variable=self.filter_jpn,command=lambda:self.populate_selection_box(download_data=False)).pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t2_frm2,text='Choose content to display:').pack(padx=5,pady=5,side='left')
        filter_box_usa=ttk.Checkbutton(t2_frm2,text='Game',variable=self.filter_game,command=lambda:self.populate_selection_box(download_data=False)).pack(padx=5,pady=5,side='left')
        filter_box_eur=ttk.Checkbutton(t2_frm2,text='Update',variable=self.filter_update,command=lambda:self.populate_selection_box(download_data=False)).pack(padx=5,pady=5,side='left')
        filter_box_jpn=ttk.Checkbutton(t2_frm2,text='DLC',variable=self.filter_dlc,command=lambda:self.populate_selection_box(download_data=False)).pack(padx=5,pady=5,side='left')
        filter_box_ticket=ttk.Checkbutton(t2_frm2,text='Only show items with an online ticket',variable=self.filter_hasticket,command=lambda:self.populate_selection_box(download_data=False)).pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t2_frm3,text='Selection:').pack(padx=5,pady=7,side='left')
        self.selection_box=AutocompleteCombobox(t2_frm3,values=(self.selection_list),width=73)
        self.selection_box.bind('<<ComboboxSelected>>', self.selection_box_changed)
        self.selection_box.bind('<Return>', self.selection_box_changed)

        ## Change the selection box behavior slightly to clear title id and key boxes on any
        ## non-hits while auto completing. Not sure which is more preferred. 
        #self.selection_box.bind('<<NoHits>>', self.clear_id_key_boxes)
        
        self.selection_box.pack(padx=5,pady=7,side='left')
        btn=ttk.Button(t2_frm3,text='refresh',width=8,command=self.populate_selection_box).pack(side='left')
        lbl=ttk.Label(t2_frm4,text='Title ID:').pack(padx=5,pady=7,side='left')
        self.id_box=ttk.Entry(t2_frm4,width=40,textvariable=self.idvar)
        self.id_box.pack(padx=5,pady=5,side='left')
        btn=ttk.Button(t2_frm4,text='Add to list',command=self.add_to_list).pack(padx=5,pady=5,side='left')
        self.dl_size_lbl=ttk.Label(t2_frm4,text='Size:,',font='Helvetica 10 bold')
        self.dl_size_lbl.pack(side='left')
        lbl=ttk.Label(t2_frm4,text='Online ticket:',font='Helvetica 10 bold').pack(side='left',padx=5)
        self.has_ticket_lbl=ttk.Label(t2_frm4,text='',font='Helvetica 10 bold')
        self.has_ticket_lbl.pack(side='left')
        lbl=ttk.Label(t2_frm5,text='Key:').pack(padx=5,pady=7,side='left')
        self.key_box=ttk.Entry(t2_frm5,width=40)
        self.key_box.pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t2_frm6,text='Download list:').pack()
        #lbl=ttk.Label(t2_frm6,text='Items marked with * have a key provided. Items marked with ! have an unknown size.').pack()
        dl_scroller=ttk.Scrollbar(t2_frm6,orient='vertical')
        dl_scroller.pack(side='right',fill='y')
        self.dl_listbox=tk.Listbox(t2_frm6,width=78,height=12)
        self.dl_listbox.pack(fill='y',pady=3)
        self.dl_listbox.config(yscrollcommand=dl_scroller.set)
        dl_scroller.config(command=self.dl_listbox.yview)
        btn=ttk.Button(t2_frm7,text='Remove selected',command=self.remove_from_list).pack(padx=3,pady=2,side='left',anchor='w')
        btn=ttk.Button(t2_frm7,text='Clear list',command=self.clear_list).pack(padx=3,pady=2,side='left')
        lbl=ttk.Label(t2_frm8,text='',textvariable=self.total_dl_size,font='Helvetica 10 bold').pack(side='left')
        lbl=ttk.Label(t2_frm10,text='',textvariable=self.total_dl_size_warning,foreground='red').pack(side='left')
        lbl=ttk.Label(t2_frm9,justify='center',text='Add an entry to the download list one at a time.\nWhen you are done, click on a download button\nbelow based on your preferred method. Items marked\nwith * have a key provided and items marked with ! have\nan unknown size. Don\'t forget to visit the options tab\nbefore you download.').pack(padx=20,pady=10)
        btn=ttk.Button(t2_frm11,text='Download using online tickets',width=30,command=lambda:self.download_clicked(1)).pack(padx=5,pady=10,side='left')
        btn=ttk.Button(t2_frm11,text='Download using keys method',width=30,command=lambda:self.download_clicked(2)).pack(padx=5,pady=10,side='left')

        self.load_title_sizes()
        self.populate_selection_box()
        self.total_dl_size.set('Total Size:')
        
        
        t2_frm0.grid(row=0,column=1,columnspan=3,sticky='w')
        t2_frm1.grid(row=1,column=1,sticky='w')
        t2_frm2.grid(row=2,column=1,columnspan=2,sticky='w')
        t2_frm3.grid(row=3,column=1,columnspan=2,sticky='w')
        t2_frm4.grid(row=4,column=1,columnspan=3,sticky='w')
        t2_frm5.grid(row=5,column=1,sticky='w')
        t2_frm6.grid(row=6,column=2,rowspan=3,columnspan=3,sticky='e')
        t2_frm7.grid(row=9,column=3,sticky='e')
        t2_frm8.grid(row=9,column=2,padx=20,sticky='w')
        t2_frm9.grid(row=6,column=1,sticky='w')
        t2_frm10.grid(row=10,column=2,padx=5,columnspan=2,sticky='nw')
        t2_frm11.grid(row=11,column=2,columnspan=3)
        
        
        # Tab3
        t3_frm1=ttk.Frame(tab3)
        t3_frm2=ttk.Frame(tab3)
        t3_frm3=ttk.Frame(tab3)
        t3_frm4=ttk.Frame(tab3)
        t3_frm5=ttk.Frame(tab3)
        t3_frm6=ttk.Frame(tab3)
        t3_frm7=ttk.Frame(tab3)
        t3_frm8=ttk.Frame(tab3)
        
        lbl=ttk.Label(t3_frm1,text='To use the default output directory, leave the entry blank').pack(padx=5,pady=10,side='left')
        lbl=ttk.Label(t3_frm2,text='Output directory').pack(padx=5,pady=5,side='left')
        self.out_dir_box=ttk.Entry(t3_frm2,width=35,textvariable=self.output_dir)
        self.out_dir_box.pack(padx=5,pady=5,side='left')
        btn=ttk.Button(t3_frm2,text='Browse',command=self.get_output_directory).pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t3_frm3,text='Retry count:').pack(padx=5,pady=5,side='left')
        self.retry_count_box=ttk.Combobox(t3_frm3,state='readonly',width=5,values=range(10),textvariable=self.retry_count)
        self.retry_count_box.set(3)
        self.retry_count_box.pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t3_frm4,text='Patch demo play limit:').pack(padx=5,pady=5,side='left')
        self.patch_demo_true=ttk.Radiobutton(t3_frm4,text='Yes',variable=self.patch_demo,value=True)
        self.patch_demo_false=ttk.Radiobutton(t3_frm4,text='No',variable=self.patch_demo,value=False)
        self.patch_demo_true.pack(padx=5,pady=5,side='left')
        self.patch_demo_false.pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t3_frm5,text='Patch DLC:').pack(padx=5,pady=5,side='left')
        self.patch_dlc_true=ttk.Radiobutton(t3_frm5,text='Yes',variable=self.patch_dlc,value=True)
        self.patch_dlc_false=ttk.Radiobutton(t3_frm5,text='No',variable=self.patch_dlc,value=False)
        self.patch_dlc_true.pack(padx=5,pady=5,side='left')
        self.patch_dlc_false.pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t3_frm6,text='Tickets only mode:').pack(padx=5,pady=5,side='left')
        self.tickets_only_true=ttk.Radiobutton(t3_frm6,text='On',variable=self.tickets_only,value=True)
        self.tickets_only_false=ttk.Radiobutton(t3_frm6,text='Off',variable=self.tickets_only,value=False)
        self.tickets_only_true.pack(padx=5,pady=5,side='left')
        self.tickets_only_false.pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t3_frm7,text='Simulation mode:').pack(padx=5,pady=5,side='left')
        self.simulate_mode_true=ttk.Radiobutton(t3_frm7,text='On',variable=self.simulate_mode,value=True)
        self.simulate_mode_false=ttk.Radiobutton(t3_frm7,text='Off',variable=self.simulate_mode,value=False)
        self.simulate_mode_true.pack(padx=5,pady=5,side='left')
        self.simulate_mode_false.pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t3_frm8,text='Download ALL titles on NUS except system\ntitles. Choose the regions you would like:').pack(padx=5,pady=5,side='left')
        self.region_box_usa=ttk.Checkbutton(t3_frm8,text='USA',variable=self.region_usa).pack(padx=5,pady=5,side='left')
        self.region_box_eur=ttk.Checkbutton(t3_frm8,text='EUR',variable=self.region_eur).pack(padx=5,pady=5,side='left')
        self.region_box_jpn=ttk.Checkbutton(t3_frm8,text='JPN',variable=self.region_jpn).pack(padx=5,pady=5,side='left')
        btn=ttk.Button(t3_frm8,text='Go',width=4,command=lambda:self.download_clicked(3)).pack(pady=20,side='left')
                
        t3_frm1.grid(row=1,column=1,sticky='w')
        t3_frm2.grid(row=2,column=1,sticky='w')
        t3_frm3.grid(row=3,column=1,sticky='w')
        t3_frm4.grid(row=4,column=1,sticky='w')
        t3_frm5.grid(row=5,column=1,sticky='w')
        t3_frm6.grid(row=6,column=1,sticky='w')
        t3_frm7.grid(row=7,column=1,sticky='w')
        t3_frm8.grid(row=8,column=1,padx=10,pady=70,sticky='w')

        # Tab 4
        t4_frm0=ttk.Frame(tab4)
        t4_frm1=ttk.Frame(tab4)
        t4_frm2=ttk.Frame(tab4)
        t4_frm3=ttk.Frame(tab4)
        t4_frm4=ttk.Frame(tab4)
        t4_frm5=ttk.Frame(tab4)
        t4_frm6=ttk.Frame(tab4)
        t4_frm7=ttk.Frame(tab4)
        t4_frm8=ttk.Frame(tab4)
        t4_frm9=ttk.Frame(tab4)
        t4_frm10=ttk.Frame(tab4)
        t4_frm11=ttk.Frame(tab4)

        lbl=ttk.Label(t4_frm0,text='Version Information:\n\nSince the FunKii-UI GUI and FunKiiU are two seperate applications developed by different authors,\nswitching versions can break compatibility and shouldn\'t be done if you don\'t know what you are\ndoing. I will try to implement a compatibility list in a future release').pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm1,text='GUI application:',font="Helvetica 13 bold").pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t4_frm2,text='Running version:\nTargeted for:').pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm2,text=__VERSION__+'\n'+targetversion).pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm3,text='Latest release:').pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t4_frm3,text=self.versions['gui_new']).pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm4,text='Update to latest release:').pack(padx=5,pady=1,side='left')
        btn=ttk.Button(t4_frm4,text='Update',command=lambda:self.update_application('gui',self.versions['gui_new'])).pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm5,text='Switch to different version:').pack(padx=5,pady=1,side='left')
        self.gui_switchv_box=ttk.Combobox(t4_frm5,width=7,values=[x for x in self.versions['gui_all']],state='readonly')
        self.gui_switchv_box.pack(padx=5,pady=1,side='left')
        btn=ttk.Button(t4_frm5,text='Switch',command=lambda:self.update_application('gui',self.gui_switchv_box.get())).pack(padx=5,pady=1,side='left')        
        lbl=ttk.Label(t4_frm6,text='').pack(pady=15,side='left')
        lbl=ttk.Label(t4_frm7,text='FunKiiU core application:',font="Helvetica 13 bold").pack(padx=5,pady=5,side='left')
        lbl=ttk.Label(t4_frm8,text='running version:').pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm8,text=fnku.__VERSION__).pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm9,text='latest release:').pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm9,text=self.versions['fnku_new']).pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm10,text='Update to latest release:').pack(padx=5,pady=1,side='left')
        btn=ttk.Button(t4_frm10,text='Update',command=lambda:self.update_application('fnku',self.versions['fnku_new'])).pack(padx=5,pady=1,side='left')
        lbl=ttk.Label(t4_frm11,text='Switch to different version:').pack(padx=5,pady=1,side='left')
        self.fnku_switchv_box=ttk.Combobox(t4_frm11,width=7,values=[x for x in self.versions['fnku_all']],state='readonly')
        self.fnku_switchv_box.pack(padx=5,pady=1,side='left')
        btn=ttk.Button(t4_frm11,text='Switch',command=lambda:self.update_application('fnku',self.fnku_switchv_box.get())).pack(padx=5,pady=1,side='left')
        
        t4_frm0.grid(row=0,column=1,padx=5,pady=5,sticky='w')
        t4_frm1.grid(row=1,column=1,padx=5,sticky='w')
        t4_frm2.grid(row=2,column=1,padx=25,sticky='w')
        t4_frm3.grid(row=3,column=1,padx=25,sticky='w')
        t4_frm4.grid(row=4,column=1,padx=25,sticky='w')
        t4_frm5.grid(row=5,column=1,padx=25,sticky='w')
        t4_frm6.grid(row=6,column=1,padx=5,sticky='w')
        t4_frm7.grid(row=7,column=1,padx=5,sticky='w')
        t4_frm8.grid(row=8,column=1,padx=25,sticky='w')
        t4_frm9.grid(row=9,column=1,padx=25,sticky='w')
        t4_frm10.grid(row=10,column=1,padx=25,sticky='w')
        t4_frm11.grid(row=11,column=1,padx=25,sticky='w')
        

        ## Build an sqlite database of all the data in the titlekeys json as well as size information
        ## for the title. Raw size in bytes as well as human readable size is recorded.
        ## The database that ships with the releases are minimal, containing ONLY size information.
        ## A full db build is mostly for redundancy and can be built by deleting the old data.db file,
        ## setting sizeonly=False, uncomment self.build_database() below and run the program.
        ## Be sure to re-comment out self.build_database() before running the program again.
        ## This will take a short while to fetch all the download size information.
        
        #self.build_database()

        if len(self.title_sizes) != len(self.title_data):
            print('\n\nSize informataion database is out of sync with titlekeys.json.')
            self.build_database()
Esempio n. 27
0
                smtpObj.login(myEmail, MY_SECRET_PASSWORD) # Login, code 235 for success
                smtpObj.sendmail(myEmail, toEmail, text) # Send email
                smtpObj.quit() # Disconnect from server
            except:
                tkMessageBox.showerror("Connection Error", "No se pudo conectar con el servidor.\nIntenta mas tarde.")
    except:
        tkMessageBox.showerror("Data Error", "No hay base de datos.")

# --- GUI ---

master = Tk()
master.title("Correspondencia")
master.geometry('740x340')
master.resizable(False, False)

ntBook = ttk.Notebook(width=740, height=340)
ntBook.pack()

tabPer = ttk.Frame(ntBook)
ntBook.add(tabPer, text="Persona")
tabFile = ttk.Frame(ntBook)
ntBook.add(tabFile, text="Archivo")
tabInfo = ttk.Frame(ntBook)
ntBook.add(tabInfo, text="Info")

lbName = Label(tabPer, text="Nombre(s)").grid(column=0, row=0)
nameGUI = StringVar()
txtBoxName = Entry(tabPer, textvariable=nameGUI)
txtBoxName.grid(column=1, row=0)
lbFirstName = Label(tabPer, text="Apellido Paterno").grid(column=0, row=1)
firstNameGUI = StringVar()
Esempio n. 28
0
    def __init__(self):
        self.root = Tk()
        self.root.geometry('350x460')
        rows = 0
        while rows < 50:
            self.root.rowconfigure(rows, weight=1)
            self.root.columnconfigure(rows, weight=1)
            rows += 1
        style = ttk.Style()
        style.theme_create("test",
                           parent="alt",
                           settings={
                               "TNotebook": {
                                   "configure": {
                                       "tabmargins": [2, 5, 2, 0]
                                   }
                               },
                               "TNotebook.Tab": {
                                   "configure": {
                                       "padding": [5, 2]
                                   },
                                   "map": {
                                       "expand": [("selected", [1, 1, 1, 0])]
                                   }
                               }
                           })
        self.issue_retrieval_method_var = IntVar()
        style.theme_use("test")
        nb = ttk.Notebook(self.root)
        nb.grid(row=1, column=0, columnspan=50, rowspan=49, sticky='NESW')
        settings_frame = ttk.Frame(nb)
        nb.add(settings_frame, text='Settings')
        main_frame = ttk.Frame(nb)
        nb.add(main_frame, text='Sprint Report')
        commits_frame = ttk.Frame(nb)
        nb.add(commits_frame, text='Commits Report')
        right_margin = Frame(main_frame, width=20)
        right_margin.pack(side=RIGHT)
        left_margin = Frame(main_frame, width=20)
        left_margin.pack(side=LEFT)
        bot_margin = Frame(main_frame, height=10)
        bot_margin.pack(side=BOTTOM)
        top_margin = Frame(main_frame, height=20)
        top_margin.pack(side=TOP)
        right_margin = Frame(settings_frame, width=20)
        right_margin.pack(side=RIGHT)
        left_margin = Frame(settings_frame, width=20)
        left_margin.pack(side=LEFT)
        bot_margin = Frame(settings_frame, height=10)
        bot_margin.pack(side=BOTTOM)
        top_margin = Frame(settings_frame, height=20)
        top_margin.pack(side=TOP)
        username_container = Frame(settings_frame, width=30)
        username_container.pack()
        password_container = Frame(settings_frame, width=30)
        password_container.pack()
        repo_container = Frame(settings_frame, width=30)
        repo_container.pack()
        username_label = Label(username_container,
                               width=15,
                               height=1,
                               text="Github username",
                               anchor='w')
        username_label.pack(side=LEFT)
        self.username_input = Entry(username_container,
                                    width=25,
                                    borderwidth=1,
                                    font='Calibri, 12')
        self.username_input.pack(side=RIGHT)
        self.username_input.focus()
        sep2 = Frame(main_frame, height=10)
        sep2.pack(side=BOTTOM)
        password_label = Label(password_container,
                               width=15,
                               height=1,
                               text="Github password",
                               anchor='w')
        password_label.pack(side=LEFT)
        self.password_input = Entry(password_container,
                                    show='*',
                                    width=25,
                                    borderwidth=1,
                                    font='Calibri, 12')
        self.password_input.pack(side=RIGHT)
        repo_label = Label(repo_container,
                           width=15,
                           height=1,
                           text="Repository name",
                           anchor='w')
        repo_label.pack(side=LEFT)
        self.repo_input = Entry(repo_container,
                                width=25,
                                borderwidth=1,
                                font='Calibri, 12')
        self.repo_input.pack(side=RIGHT)
        email_container = Frame(main_frame, width=30)
        email_container.pack()
        email_pwd_container = Frame(main_frame, width=30)
        email_pwd_container.pack()
        recipent_container = Frame(main_frame, width=30)
        recipent_container.pack()
        sep1 = Frame(main_frame, height=10)
        sep1.pack()
        radio_butt_frame = Frame(main_frame, width=30)
        radio_butt_frame.pack()
        start_date_container = Frame(main_frame, width=30)
        end_date_container = Frame(main_frame, width=30)
        sprint_weeks_container = Frame(main_frame, width=35)
        sprint_override_container = Frame(main_frame, width=35)
        self.start_date_input = Entry(start_date_container,
                                      width=15,
                                      borderwidth=1,
                                      font='Calibri, 12')
        self.end_date_input = Entry(end_date_container,
                                    width=15,
                                    borderwidth=1,
                                    font='Calibri, 12')
        self.sprint_weeks_input = Entry(sprint_weeks_container,
                                        width=20,
                                        borderwidth=1,
                                        font='Calibri, 12')
        self.sprint_override_input = Entry(sprint_override_container,
                                           width=20,
                                           borderwidth=1,
                                           font='Calibri, 12')
        rad1 = Radiobutton(radio_butt_frame,
                           text="Report by sprint",
                           variable=self.issue_retrieval_method_var,
                           value=1,
                           padx=5,
                           command=self.sprint_toggle_callback)
        rad1.pack(side=LEFT)
        rad1.select()
        rad2 = Radiobutton(radio_butt_frame,
                           text="Report by dates",
                           variable=self.issue_retrieval_method_var,
                           value=2,
                           padx=5,
                           command=self.date_toggle_callback)
        rad2.pack(side=LEFT)
        sep1 = Frame(main_frame, height=10)
        sep1.pack()
        sprint_override_container.pack()
        sprint_override_label = Label(sprint_override_container,
                                      width=20,
                                      height=1,
                                      text="Sprint title",
                                      anchor='w')
        sprint_override_label.pack(side=LEFT)
        sprint_weeks_container.pack()
        sprint_weeks_label = Label(sprint_weeks_container,
                                   width=20,
                                   height=1,
                                   text="Sprint weeks",
                                   anchor='w')
        sprint_weeks_label.pack(side=LEFT)
        start_date_container.pack()
        start_date_label = Label(start_date_container,
                                 width=25,
                                 height=1,
                                 text="Start date [YYYY-MM-DD]",
                                 anchor='w')
        start_date_label.pack(side=LEFT)
        self.start_date_input.pack(side=RIGHT)
        end_date_container.pack()
        end_date_label = Label(end_date_container,
                               width=25,
                               height=1,
                               text="End date [YYYY-MM-DD]",
                               anchor='w')
        end_date_label.pack(side=LEFT)
        self.sprint_override_input.pack(side=RIGHT)
        isscount_override_container = Frame(main_frame, width=35)
        isscount_override_container.pack()
        isscount_override_label = Label(isscount_override_container,
                                        width=20,
                                        height=1,
                                        text="Issue count override",
                                        anchor='w')
        isscount_override_label.pack(side=LEFT)
        self.isscount_override_input = Entry(isscount_override_container,
                                             width=20,
                                             borderwidth=1,
                                             font='Calibri, 12')
        self.isscount_override_input.pack(side=RIGHT)
        self.sprint_weeks_input.insert(0, '2')
        self.sprint_weeks_input.pack(side=RIGHT)
        self.end_date_input.pack(side=RIGHT)
        team_container = Frame(main_frame, width=35)
        team_container.pack()
        team_label = Label(team_container,
                           width=20,
                           height=1,
                           text="Filter by team label",
                           anchor='w')
        team_label.pack(side=LEFT)
        self.team_input = Entry(team_container,
                                width=20,
                                borderwidth=1,
                                font='Calibri, 12')
        self.team_input.pack(side=RIGHT)
        issue_term_container = Frame(main_frame, width=35)
        issue_term_container.pack()
        issue_term_label = Label(issue_term_container,
                                 width=20,
                                 height=1,
                                 text="Terminate at issue #",
                                 anchor='w')
        issue_term_label.pack(side=LEFT)
        self.issue_term_input = Entry(issue_term_container,
                                      width=20,
                                      borderwidth=1,
                                      font='Calibri,12')
        self.issue_term_input.pack(side=RIGHT)

        self.status_label = Label(main_frame, width=35, height=1, text="")
        self.status_label.pack(side=BOTTOM)
        email_label = Label(email_container,
                            width=15,
                            height=1,
                            text="Sender Email",
                            anchor='w')
        email_label.pack(side=LEFT)
        self.email_input = Entry(email_container,
                                 width=25,
                                 borderwidth=1,
                                 font='Calibri, 12')
        self.email_input.pack(side=RIGHT)
        email_pwd_label = Label(email_pwd_container,
                                width=15,
                                height=1,
                                text="Sender Password",
                                anchor='w')
        email_pwd_label.pack(side=LEFT)
        email_pwd_input = Entry(email_pwd_container,
                                width=25,
                                borderwidth=1,
                                font='Calibri, 12')
        email_pwd_input.pack(side=RIGHT)
        recipent_label = Label(recipent_container,
                               width=15,
                               height=1,
                               text="Recipent Email",
                               anchor='w')
        recipent_label.pack(side=LEFT)
        self.recipent_input = Entry(recipent_container,
                                    width=25,
                                    borderwidth=1,
                                    font='Calibri, 12')
        self.recipent_input.pack(side=RIGHT)
        sep2 = Frame(main_frame, height=10)
        sep2.pack(side=BOTTOM)
        self.commits_button = Button(commits_frame,
                                     width=35,
                                     bd=2,
                                     text="Commit Messages Report")
        self.sprint_report_button = Button(main_frame,
                                           width=35,
                                           bd=2,
                                           text="Generate Report")
        self.sprint_report_button.configure(
            command=lambda: ghsprintreporter.sprint_report_main(self))
        self.sprint_report_button.pack(side=BOTTOM)
        right_margin = Frame(commits_frame, width=20)
        right_margin.pack(side=RIGHT)
        left_margin = Frame(commits_frame, width=20)
        left_margin.pack(side=LEFT)
        bot_margin = Frame(commits_frame, height=30)
        bot_margin.pack(side=BOTTOM)
        top_margin = Frame(commits_frame, height=20)
        top_margin.pack(side=TOP)
        sep2 = Frame(commits_frame, height=10)
        sep2.pack(side=BOTTOM)
        issue_criteria_container = Frame(commits_frame, width=30)
        issue_criteria_container.pack()
        issue_criteria_label = Label(issue_criteria_container,
                                     width=15,
                                     height=1,
                                     text="Issue ref. criteria",
                                     anchor='w')
        issue_criteria_label.pack(side=LEFT)
        self.issue_criteria_input = Entry(issue_criteria_container,
                                          width=25,
                                          borderwidth=1,
                                          font='Calibri, 12')
        self.issue_criteria_input.pack(side=RIGHT)
        commits_date_container = Frame(commits_frame, width=30)
        commits_date_container.pack()
        commits_date_label = Label(commits_date_container,
                                   width=25,
                                   height=1,
                                   text="Start date [YYYY-MM-DD]",
                                   anchor='w')
        commits_date_label.pack(side=LEFT)
        self.commits_date_input = Entry(commits_date_container,
                                        width=15,
                                        borderwidth=1,
                                        font='Calibri, 12')
        self.commits_date_input.pack(side=RIGHT)
        self.commits_status_label = Label(commits_frame,
                                          width=35,
                                          height=1,
                                          text="",
                                          anchor='w')
        self.commits_status_label.pack(side=BOTTOM)
        sep2 = Frame(commits_frame, height=20)
        sep2.pack(side=BOTTOM)
        commits_sender_email_container = Frame(commits_frame, width=30)
        commits_sender_email_container.pack()
        commits_sender_email_label = Label(commits_sender_email_container,
                                           width=15,
                                           height=1,
                                           text="Sender Email",
                                           anchor='w')
        commits_sender_email_label.pack(side=LEFT)
        self.commits_sender_email_input = Entry(commits_sender_email_container,
                                                width=25,
                                                borderwidth=1,
                                                font='Calibri, 12')
        self.commits_sender_email_input.pack(side=RIGHT)
        commits_sender_pwd_container = Frame(commits_frame, width=30)
        commits_sender_pwd_container.pack()
        commits_sender_pwd_label = Label(commits_sender_pwd_container,
                                         width=15,
                                         height=1,
                                         text="Sender Password",
                                         anchor='w')
        commits_sender_pwd_label.pack(side=LEFT)
        self.commits_sender_pwd_input = Entry(commits_sender_pwd_container,
                                              width=25,
                                              borderwidth=1,
                                              font='Calibri, 12')
        self.commits_sender_pwd_input.pack(side=RIGHT)
        commits_admin_email_container = Frame(commits_frame, width=30)
        commits_admin_email_container.pack()
        commits_admin_email_label = Label(commits_admin_email_container,
                                          width=15,
                                          height=1,
                                          text="BCC Admin Email",
                                          anchor='w')
        commits_admin_email_label.pack(side=LEFT)
        self.commits_admin_email_input = Entry(commits_admin_email_container,
                                               width=25,
                                               borderwidth=1,
                                               font='Calibri, 12')
        self.commits_admin_email_input.pack(side=RIGHT)
        self.commits_button.configure(
            command=lambda: ghsprintreporter.commits_report(self))
        self.commits_button.pack(side=BOTTOM)

        self.start_date_input.config(state='disabled')
        self.end_date_input.config(state='disabled')

        self.root.title("Github Project Reporting")
        self.root.resizable(width=FALSE, height=FALSE)
        self.root.lift()
        self.root.focus()
        self.root.attributes('-topmost', True)
        self.root.after_idle(self.root.attributes, '-topmost', False)
Esempio n. 29
0
    def __init__(self, master):
        self.master = master
        self.master.rowconfigure(0, weight=10)
        self.master.rowconfigure(1, weight=1)
        self.master.columnconfigure(0, weight=1)

        self.settings = {setting: tk.StringVar() for setting in SETTINGS}

        # Items
        self.asset_list_header = [
            header[0] for header in sorted([(column, COLUMN_INDEX[column])
                                            for column in COLUMN_INDEX],
                                           key=itemgetter(1))
            if header[0] not in ['Description', 'Comments']
        ]
        self.asset_list_items = []

        # Tabs for asset list / shopping cart
        self.notebook = ttk.Notebook(self.master)
        self.notebook.grid(row=0, column=0, sticky='nesw')
        self.notebook.rowconfigure(0, weight=1)
        self.notebook.columnconfigure(0, weight=1)

        # Asset list frame
        self.asset_frame = ttk.Frame(self.notebook, name='asset_frame')
        self.asset_frame.grid(row=0, column=0, sticky='nesw')
        self.asset_frame.rowconfigure(1, weight=1)
        self.asset_frame.columnconfigure(0, weight=1)
        self.notebook.add(self.asset_frame, text='Asset List')
        self.asset_frame.bind(
            '<Visibility>',
            lambda event: self.tab_update_description("Asset Frame"))

        # Search bar
        self.search_query = tk.StringVar()
        self.search_query.set(SEARCH_HINT)
        self.search_bar = tk.Entry(self.asset_frame,
                                   exportselection=0,
                                   textvariable=self.search_query)
        self.search_bar.grid(row=0, column=0, sticky='nesw')
        self.search_bar.bind('<FocusIn>', self.search_clear)
        self.search_query.trace('w', self.search)

        # Asset List
        self.asset_list = AssetList(self.asset_frame, self,
                                    self.asset_list_header,
                                    self.asset_list_items)
        self.asset_list.grid(row=1, column=0, sticky='nesw')
        self.asset_list.rowconfigure(0, weight=1)
        self.asset_list.columnconfigure(0, weight=1)

        # Item Description Frame
        self.item_frame = ttk.LabelFrame(self.master, text='Description')
        self.item_frame.rowconfigure(0, weight=1)
        self.item_frame.columnconfigure(0, weight=1)
        self.item_frame.grid(row=1, column=0, sticky='nesw', padx=10, pady=10)

        self.item_msg = tk.Text(self.item_frame,
                                wrap=tk.WORD,
                                state=tk.DISABLED,
                                height=3)
        self.item_msg.grid(row=0, column=0, sticky='nesw')
        msg_vsb = ttk.Scrollbar(self.item_frame,
                                orient=tk.VERTICAL,
                                command=self.item_msg.yview)
        msg_vsb.grid(row=0, column=1, sticky='nes')

        # History message
        self.history_msg = tk.StringVar()
        self.history_msg.set('No action performed yet')
        self.history_label = tk.Label(self.master,
                                      textvariable=self.history_msg,
                                      justify=tk.LEFT,
                                      anchor=tk.W)
        self.history_label.grid(row=2, column=0, sticky='nesw')

        # Shopping cart frame
        self.cart_frame = tk.Frame(self.notebook, name='cart_frame')
        self.cart_frame.grid(row=0, column=0, sticky='nesw')
        self.cart_frame.rowconfigure(0, weight=1)
        self.cart_frame.columnconfigure(0, weight=2)
        self.cart_frame.columnconfigure(1, weight=1)
        self.notebook.add(self.cart_frame, text='Shopping Cart (0)')
        self.cart_frame.bind(
            '<Visibility>',
            lambda event: self.tab_update_description("Cart Frame"))

        # Shopping cart list
        self.shopping_cart_header = ['Asset Number', 'Item']
        self.shopping_cart = ShoppingCart(self.cart_frame, self,
                                          self.shopping_cart_header,
                                          self.asset_list_items)
        self.shopping_cart.grid(row=0, column=0, sticky='nesw')
        self.shopping_cart.rowconfigure(0, weight=1)
        self.shopping_cart.columnconfigure(0, weight=1)

        # User Profile Frame
        self.label_font = tkFont.Font(size=8, weight='bold')

        self.profile_frame = ttk.LabelFrame(self.cart_frame,
                                            text='Your Info',
                                            labelanchor='n')
        self.profile_frame.grid(row=0,
                                column=1,
                                sticky='nesw',
                                padx=20,
                                pady=20)
        self.profile_frame.columnconfigure(0, weight=1)

        # Name Label
        self.profile_fname_lbl = tk.Label(self.profile_frame,
                                          text='First Name',
                                          font=self.label_font)
        self.profile_fname_lbl.grid(row=0,
                                    column=0,
                                    sticky='w',
                                    padx=15,
                                    pady=(15, 0))
        self.first_name_entry = tk.Entry(
            self.profile_frame, textvariable=self.settings['first_name'])
        self.first_name_entry.grid(row=1, column=0, sticky='ew', padx=15)
        self.profile_lname_lbl = tk.Label(self.profile_frame,
                                          text='Last Name',
                                          font=self.label_font)
        self.profile_lname_lbl.grid(row=2,
                                    column=0,
                                    sticky='w',
                                    padx=15,
                                    pady=(15, 0))
        self.last_name_entry = tk.Entry(
            self.profile_frame, textvariable=self.settings['last_name'])
        self.last_name_entry.grid(row=3, column=0, sticky='ew', padx=15)

        self.profile_email_lbl = tk.Label(self.profile_frame,
                                          text='Email',
                                          font=self.label_font)
        self.profile_email_lbl.grid(row=4,
                                    column=0,
                                    sticky='w',
                                    padx=15,
                                    pady=(15, 0))
        self.email_entry = tk.Entry(self.profile_frame,
                                    textvariable=self.settings['email'])
        self.email_entry.grid(row=5,
                              column=0,
                              sticky='ew',
                              padx=15,
                              pady=(0, 10))

        self.reason_lbl = tk.Label(self.profile_frame,
                                   text='Reason for Use',
                                   font=self.label_font)
        self.reason_lbl.grid(row=6,
                             column=0,
                             sticky='w',
                             padx=15,
                             pady=(15, 0))
        self.checkout_reason = tk.Text(self.profile_frame, height=5)
        self.checkout_reason.grid(row=7, column=0, sticky='ew', padx=15)

        # Checkout Button
        self.checkout_button = tk.Button(self.profile_frame,
                                         text='Checkout Items',
                                         command=self.checkout_cart)
        self.checkout_button.grid(row=8,
                                  column=0,
                                  sticky='s',
                                  padx=15,
                                  pady=15)

        # Settings
        self.settings_frame = tk.Frame(self.notebook, name='settings_frame')
        self.settings_frame.rowconfigure(0, weight=1)
        self.settings_frame.columnconfigure(1, weight=1)
        self.notebook.add(self.settings_frame, text="Settings")

        self.about_frame = tk.Frame(self.settings_frame)
        self.about_frame.grid(row=0, column=1, sticky='new')
        self.about_frame.columnconfigure(0, weight=1)

        # Database Path Finder
        self.db_path_frame = tk.LabelFrame(self.about_frame,
                                           text='Database Path',
                                           labelanchor='n')
        self.db_path_frame.grid(row=0,
                                column=0,
                                sticky='new',
                                padx=15,
                                pady=(25, 0))
        self.db_path_frame.columnconfigure(0, weight=0)
        self.db_path_frame.columnconfigure(1, weight=1)

        self.file_choose_btn = tk.Button(self.db_path_frame,
                                         text='Choose',
                                         command=self.choose_db_file)
        self.file_choose_btn.grid(row=0,
                                  column=0,
                                  sticky='new',
                                  padx=(15, 0),
                                  pady=15)
        self.db_path_msg = tk.Entry(
            self.db_path_frame,
            textvariable=self.settings['database_path'],
            disabledforeground='black',
            disabledbackground='white',
            state=tk.DISABLED)
        self.db_path_msg.grid(row=0,
                              column=1,
                              sticky='new',
                              padx=(0, 15),
                              pady=15)
        self.db_warning_lbl = tk.Label(
            self.db_path_frame,
            text='WARNING: all unsaved changes will be lost',
            font=self.label_font)
        self.db_warning_lbl.grid(row=1,
                                 column=0,
                                 columnspan=2,
                                 padx=15,
                                 pady=5)

        if os.path.exists(SETTINGS_PATH):
            with open(SETTINGS_PATH, 'r') as config_file:
                in_settings = json.load(config_file)
                for setting in in_settings:
                    self.settings[setting].set(in_settings[setting])

                self.update_asset_items(
                    self.retrieve_assets(self.settings['database_path'].get()))
                self.asset_list.filtered_items_ix = list(
                    range(len(self.asset_list_items)))
                self.shopping_cart.filtered_items_ix = list(range(0))

                self.asset_list.repopulate_list()
                self.shopping_cart.repopulate_list()
        else:
            self.notebook.select(
                self.notebook.tabs()[NOTEBOOK_INDEX['Settings']])
            messagebox.showwarning(
                title='Missing database path',
                message='Please select the database file to read in.')
Esempio n. 30
0
    def __init__(self):

        # Available models
        self.available_models = opendrift.get_model_names()

        tk.Tk.__init__(self)

        ##################
        # Layout frames
        ##################
        self.n = ttk.Notebook(self.master)
        self.n.grid()
        self.seed = ttk.Frame(self.n)
        self.config = ttk.Frame(self.n)
        self.n.add(self.seed, text='Seeding')
        self.n.add(self.config, text='Config')

        # Top
        self.top = tk.Frame(self.seed, relief=tk.FLAT, pady=25, padx=25)
        self.top.grid(row=0, column=1, rowspan=1)
        # Config
        self.con = tk.Label(self.config, text="\n\nConfiguration\n\n")
        self.con.grid(row=0, column=1, rowspan=1)
        # Time start and end
        self.start_t = tk.Frame(self.seed, relief=tk.FLAT)
        self.start_t.grid(row=2, column=0, rowspan=1)
        self.end_t = tk.Frame(self.seed, relief=tk.FLAT)
        self.end_t.grid(row=3, column=0, rowspan=1)
        self.start = tk.Frame(self.seed,
                              bg='lightgray',
                              bd=2,
                              relief=tk.SUNKEN,
                              pady=5,
                              padx=5)
        self.start.grid(row=2, column=1, rowspan=1)
        self.end = tk.Frame(self.seed,
                            bg='gray',
                            bd=2,
                            relief=tk.SUNKEN,
                            padx=5,
                            pady=5)
        self.end.grid(row=3, column=1)
        self.coastline = tk.Frame(self.seed,
                                  bd=2,
                                  relief=tk.FLAT,
                                  padx=5,
                                  pady=0)
        self.coastline.grid(row=4, column=1)
        self.duration = tk.Frame(self.seed,
                                 bd=2,
                                 relief=tk.FLAT,
                                 padx=5,
                                 pady=5)
        self.duration.grid(row=5, column=1)
        self.output = tk.Frame(self.seed, bd=2, relief=tk.FLAT, padx=5, pady=0)
        self.output.grid(row=7, column=0, columnspan=7, sticky='nsew')

        self.results = tk.Frame(self.seed,
                                bd=2,
                                relief=tk.FLAT,
                                padx=5,
                                pady=0)
        self.results.grid(row=6, column=7, columnspan=1, sticky='ew')

        ##########################
        self.title('OpenDrift')
        self.o = OpenOil3D(weathering_model='noaa', location='NORWAY')
        try:
            img = ImageTk.PhotoImage(
                Image.open(self.o.test_data_folder() +
                           '../../docs/opendrift_logo.png'))
            panel = tk.Label(self.seed, image=img)
            panel.image = img
            panel.grid(row=0, column=0)
        except:
            pass  # Could not display logo
        #######################################################
        tk.Label(self.top, text='Simulation type').grid(row=0, column=0)
        self.model = tk.StringVar()
        models = opendrift.get_model_names()
        self.model.set(models[0])
        self.modeldrop = tk.OptionMenu(self.top,
                                       self.model,
                                       *(models),
                                       command=self.set_model)
        self.modeldrop.grid(row=0, column=1)

        help_button = tk.Button(self.top, text='Help', command=self.show_help)
        help_button.grid(row=0, column=2, padx=50)

        ##########
        # Release
        ##########
        startlabel = tk.Label(self.start_t, text="\n\nStart release\n\n")
        startlabel.grid(row=0, column=0)

        tk.Label(self.start, text='Longitude').grid(row=0, column=1)
        tk.Label(self.start, text='Latitude').grid(row=0, column=0)
        tk.Label(self.start, text='Radius [m]').grid(row=0, column=2)
        self.latvar = tk.StringVar()
        self.lonvar = tk.StringVar()
        self.radiusvar = tk.StringVar()
        self.lat = tk.Entry(self.start,
                            textvariable=self.latvar,
                            width=6,
                            justify=tk.RIGHT)
        self.lon = tk.Entry(self.start,
                            textvariable=self.lonvar,
                            width=6,
                            justify=tk.RIGHT)
        self.radius = tk.Entry(self.start,
                               width=6,
                               textvariable=self.radiusvar,
                               justify=tk.RIGHT)
        self.lon.grid(row=1, column=1)
        self.lon.insert(0, '4.5')
        self.lat.grid(row=1, column=0)
        self.lat.insert(0, '60.0')
        self.radius.grid(row=1, column=2)
        self.radius.insert(0, '1000')
        self.lonvar.trace('w', self.copy_position)
        self.latvar.trace('w', self.copy_position)
        self.radiusvar.trace('w', self.copy_position)
        ##########
        # Time
        ##########
        now = datetime.utcnow()
        tk.Label(self.start, text='Day').grid(row=2, column=0)
        tk.Label(self.start, text='Month').grid(row=2, column=1)
        tk.Label(self.start, text='Year').grid(row=2, column=2)
        tk.Label(self.start, text='Hour').grid(row=2, column=3)
        tk.Label(self.start, text='Minutes [UTC]').grid(row=2, column=4)
        self.datevar = tk.StringVar()
        self.dates = range(1, 32)
        self.datevar.set(now.day)
        self.date = tk.OptionMenu(self.start, self.datevar, *self.dates)
        self.date.grid(row=3, column=0)

        self.monthvar = tk.StringVar()
        self.months = [
            'January', 'February', 'March', 'April', 'May', 'June', 'July',
            'August', 'September', 'October', 'November', 'December'
        ]
        self.monthvar.set(self.months[now.month - 1])
        self.month = tk.OptionMenu(self.start, self.monthvar, *self.months)
        self.month.grid(row=3, column=1)

        self.yearvar = tk.StringVar()
        self.years = range(2015, now.year + 1)
        self.yearvar.set(now.year)
        self.year = tk.OptionMenu(self.start, self.yearvar, *self.years)
        self.year.grid(row=3, column=2)

        self.hourvar = tk.StringVar()
        self.hours = range(0, 24)
        self.hourvar.set(now.hour)
        self.hour = tk.OptionMenu(self.start, self.hourvar, *self.hours)
        self.hour.grid(row=3, column=3)

        self.minutevar = tk.StringVar()
        self.minutes = range(0, 60, 5)
        self.minutevar.set(now.minute)
        self.minute = tk.OptionMenu(self.start, self.minutevar, *self.minutes)
        self.minute.grid(row=3, column=4)

        self.datevar.trace('w', self.copy_position)
        self.monthvar.trace('w', self.copy_position)
        self.yearvar.trace('w', self.copy_position)
        self.hourvar.trace('w', self.copy_position)
        self.minutevar.trace('w', self.copy_position)

        ###############
        # Release End
        ###############
        endlabel = tk.Label(self.end_t, text="\n\nEnd release\n\n")
        endlabel.grid(row=0, column=0)
        tk.Label(self.end, text='Longitude', bg='gray').grid(row=0, column=1)
        tk.Label(self.end, text='Latitude', bg='gray').grid(row=0, column=0)
        tk.Label(self.end, text='Radius [m]', bg='gray').grid(row=0, column=2)
        self.elat = tk.Entry(self.end, width=6, justify=tk.RIGHT)
        self.elon = tk.Entry(self.end, width=6, justify=tk.RIGHT)
        self.eradius = tk.Entry(self.end, width=6, justify=tk.RIGHT)
        self.elon.grid(row=1, column=1)
        self.elon.insert(0, '4.5')
        self.elat.grid(row=1, column=0)
        self.elat.insert(0, '60.0')
        self.eradius.grid(row=1, column=2)
        self.eradius.insert(0, '1000')
        ##########
        # Time
        ##########
        now = datetime.utcnow()
        tk.Label(self.end, text='Day', bg='gray').grid(row=2, column=0)
        tk.Label(self.end, text='Month', bg='gray').grid(row=2, column=1)
        tk.Label(self.end, text='Year', bg='gray').grid(row=2, column=2)
        tk.Label(self.end, text='Hour', bg='gray').grid(row=2, column=3)
        tk.Label(self.end, text='Minutes [UTC]', bg='gray').grid(row=2,
                                                                 column=4)
        self.edatevar = tk.StringVar()
        self.edates = range(1, 32)
        self.edatevar.set(now.day)
        self.edate = tk.OptionMenu(self.end, self.edatevar, *self.edates)
        self.edate.grid(row=3, column=0)

        self.emonthvar = tk.StringVar()
        self.emonthvar.set(self.months[now.month - 1])
        self.emonth = tk.OptionMenu(self.end, self.emonthvar, *self.months)
        self.emonth.grid(row=3, column=1)

        self.eyearvar = tk.StringVar()
        self.eyears = range(2015, now.year + 1)
        self.eyearvar.set(now.year)
        self.eyear = tk.OptionMenu(self.end, self.eyearvar, *self.eyears)
        self.eyear.grid(row=3, column=2)

        self.ehourvar = tk.StringVar()
        self.ehours = range(0, 24)
        self.ehourvar.set(now.hour)
        self.ehour = tk.OptionMenu(self.end, self.ehourvar, *self.ehours)
        self.ehour.grid(row=3, column=3)

        self.eminutevar = tk.StringVar()
        self.eminutes = range(0, 60, 5)
        self.eminutevar.set(now.minute)
        self.eminute = tk.OptionMenu(self.end, self.eminutevar, *self.eminutes)
        self.eminute.grid(row=3, column=4)
        self.eyear.config(bg='gray')
        self.emonth.config(bg='gray')
        self.edate.config(bg='gray')
        self.ehour.config(bg='gray')
        self.eminute.config(bg='gray')

        # Check seeding
        check_seed = tk.Button(self.end_t,
                               text='Check seeding',
                               command=self.check_seeding)
        check_seed.grid(row=1, column=0, padx=0)

        #######################
        # Simulation duration
        #######################
        tk.Label(self.coastline, text='Coastline resolution ').grid(row=4,
                                                                    column=1)
        self.mapresvar = tk.StringVar()
        self.mapres = tk.OptionMenu(self.coastline, self.mapresvar,
                                    *['full', 'high'])
        self.mapres.grid(row=4, column=2)
        self.mapresvar.set('high')

        tk.Label(self.duration, text='Run simulation ').grid(row=5, column=0)
        self.durationhours = tk.Entry(self.duration, width=3, justify=tk.RIGHT)
        self.durationhours.grid(row=5, column=1)
        self.durationhours.insert(0, 12)
        tk.Label(self.duration, text=' hours ').grid(row=5, column=2)

        self.directionvar = tk.StringVar()
        self.directionvar.set('forwards')
        self.direction = tk.OptionMenu(self.duration, self.directionvar,
                                       'forwards', 'backwards')
        self.direction.grid(row=5, column=3)
        tk.Label(self.duration, text=' in time ').grid(row=5, column=4)

        ##############
        # Output box
        ##############
        self.text = tk.Text(self.output, wrap="word", height=18)
        self.text.grid(row=6, columnspan=6, sticky='nsw')
        self.text.tag_configure("stderr", foreground="#b22222")
        sys.stdout = TextRedirector(self.text, "stdout")
        sys.stderr = TextRedirector(self.text, "stderr")
        s = tk.Scrollbar(self)
        s.grid(row=6, column=6, sticky='ns')
        s.config(command=self.text.yview)
        self.text.config(yscrollcommand=s.set)

        # Diana
        self.dianadir = '/vol/vvfelles/opendrift/output/'
        if os.path.exists(self.dianadir):
            self.has_diana = True
            print('Diana is available!')
            self.outputdir = '/vol/vvfelles/opendrift/output_native/'
            startbutton = 'PEIS PAO'
        else:
            self.has_diana = False
            startbutton = 'START'

        ##############
        # Initialise
        ##############
        #o = OpenOil3D()
        self.set_model(self.available_models[0])

        ##########
        # RUN
        ##########
        tk.Button(self.seed,
                  text=startbutton,
                  bg='green',
                  command=self.run_opendrift).grid(row=8,
                                                   column=1,
                                                   sticky=tk.W,
                                                   pady=4)