Ejemplo n.º 1
0
    def initUI(self):
        self.parent.title("Dat title")
        #self.style = Style()
        #self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        button = Button(self, text="Quit", command=self.quit)
        button.grid(row=4, column=1)

        button = Button(self, text="New Conversation")
        button.grid(row=0, column=0)
        button.bind('<Button-1>', self.onClickNewConv)

        self.listConv = Listbox(self)
        self.listConv.grid(row=1,column=0,rowspan=3,sticky=W+S+N+E)
        self.listConv.bind('<<ListboxSelect>>',self.onClickConv)

        self.text = Text(self)
        self.text.config(takefocus=False,wrap=WORD)
        self.text.tag_configure("red", background="#6666FF", foreground="#FFFFFF")
        self.text.tag_configure("blue", background="#0000FF", foreground="#FFFFFF")
        self.text.insert(END,"Retest\n")
        self.text.grid(row=0,column=1,rowspan=2,sticky=W+E+N+S)
        self.text.config(state=DISABLED)

        self.entry = Entry(self)
        self.entry.grid(row=3,column=1,sticky=W+E)
        self.entry.bind('<Return>', self.onReturnPressed)

        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=3)
        self.rowconfigure(1, weight=1)
Ejemplo n.º 2
0
    def setup_widgets(self):
        """Five control widgets created along bottom"""

        # clear button
        clear_button = Button(self, text="Clear")
        clear_button.grid(row=3, column=1, padx=5, pady=5, sticky=W)
        clear_button.bind("<ButtonRelease-1>", self.clear_text)

        # Silent/Verbose select
        verbose_check = Checkbutton(self, text="Silent", \
            variable=self.verbose_flag, onvalue="-s", offvalue="")
        verbose_check.grid(row=3, column=2, padx=5, pady=5)

        # Analysis model menu
        choices2 = ['Select Model', 'model1', 'model2']
        om2 = OptionMenu(self, self.model, *choices2)  # pylint: disable=W0142
        om2.grid(row=3, column=3, padx=10, pady=20)

        # EMR Server Region menu
        choices = ['Select Region', 'Oregon', 'California', 'Virginia']
        om1 = OptionMenu(self, self.region, *choices)  # pylint: disable=W0142
        om1.grid(row=3, column=4, padx=10, pady=20)

        # Run EMR button
        emrbutton = Button(self, text="Run EMR")
        emrbutton.grid(row=3, column=5, padx=5, pady=5)
        emrbutton.bind("<ButtonRelease-1>", self.run_emr)
Ejemplo n.º 3
0
    def initUI(self):
        self.parent.title("Title")
        self.canvas = Canvas(self, bd=0)
        #canvas.pack()
        self.columnconfigure(0,weight=1)
        self.rowconfigure(0,weight=1)

        #self.canvas.create_image(0,0,image=self.photo,anchor=NW,tags="MAP")
        self.canvas.grid(row=0, sticky=W+N+E+S)
        self.bind("<Configure>", self.resize)

        button = Button(self)
        button.bind("<Button-1>", self.changeMapAc)
        button.grid(row=1)

        self.pack(fill=BOTH, expand=1)
Ejemplo n.º 4
0
    def initUI(self):
        self.parent.title("Minesweeper")
        s = Style()
        s.theme_use('classic')
        s.configure('TButton',
                    width=2,
                    padding=(0, 0, 0, 0),
                    background='#b9b9b9',
                    relief=tk.FLAT)
        s.map('TButton',
              background=[('disabled', '#555555'), ('pressed', '#777777'),
                          ('active', '#a8a8a8')])
        s.configure('Cleared.TButton', background='white')
        s.map('Cleared.TButton', background=[('active', 'white')])
        s.configure('Flagged.TButton', background='0066ff')
        s.map('Flagged.TButton', background=[('active', '#0044dd')])
        s.configure('Revealed.TButton', background='black')
        s.map('Revealed.TButton', background=[('active', 'black')])
        s.configure('Triggered.TButton', background='red')
        s.map('Triggered.TButton', background=[('active', 'red')])
        minefield = Minefield()
        self.__minefield = minefield

        # self.button_frame = Frame(self.parent)
        for i in range(minefield.get_row_count()):
            self.rowconfigure(i, pad=0)
        for i in range(minefield.get_column_count()):
            self.columnconfigure(i, pad=0)

        for row in range(minefield.get_row_count()):
            self.buttons.append(list())
            for column in range(minefield.get_column_count()):
                cell = minefield.get_cell([row, column])
                coordinates = cell.get_coordinates()
                button = Button(self, style='TButton')

                def run(event, self=self, internal_coordinates=coordinates):
                    return self.click_action(event, internal_coordinates)

                button.bind('<Button-1>', run)
                button.bind('<Button-2>', run)
                button.bind('<Button-3>', run)
                button.grid(row=row, column=column)
                self.buttons[row].append(button)

        self.pack()
Ejemplo n.º 5
0
    def __init__(self):
        self.root = Tk()
        self.root.title("Fast Sudoku Solver")
        self.root.geometry("380x435+500+500")
        self.style = Style()
        self.style.theme_use("default")

        self.topFrame = Frame(self.root)
        self.topFrame.pack(fill=BOTH, side=TOP)
        self.txt = Text(self.root, width=300, height=25)
        self.txt.pack(fill=BOTH, side=TOP)

        self.bottomFrame = Frame(self.root)
        self.bottomFrame.pack(fill=BOTH, side=BOTTOM)

        #store a sudoku problem and solution
        self.prob = StringVar(self.root)
        self.sol = StringVar(self.root)

        #Buttons
        openFileButton = Button(self.bottomFrame, text="New Problem!", command=self.openfile)
        openFileButton.pack(fill=BOTH, side=LEFT)

        processFileButton = Button(self.bottomFrame, text="Get Solution!!", command=self.processSudoku)
        processFileButton.pack(fill=BOTH, side=LEFT)

        refreshTxtButton = Button(self.bottomFrame, text="Clean Window")
        refreshTxtButton.bind("<Button-1>", self.refresh)
        refreshTxtButton.pack(fill=BOTH, side=LEFT)

        saveButton = Button(self.bottomFrame, text="Save Solution")
        saveButton.bind("<Button-1>", self.save)
        saveButton.pack(fill=BOTH, side=LEFT)

        quitButton = Button(self.bottomFrame, text='Quit', command=self.root.quit)
        quitButton.pack(fill=BOTH, side=LEFT)

        self.root.mainloop()
Ejemplo n.º 6
0
    def initUI(self):
        self.style = Style()
        self.style.theme_use("default")

        close_button = Button(self, text="Close")
        close_button.pack(side=RIGHT, padx=5, pady=5)
        close_button.bind("<ButtonRelease-1>", self.h_close)

        ok_button = Button(self, text="OK")
        ok_button.pack(side=RIGHT)
        ok_button.bind("<ButtonRelease-1>", self.h_ok)

        rs_button = Button(self, text="Reset")
        rs_button.pack(side=RIGHT)
        rs_button.bind("<ButtonRelease-1>", self.h_rst)

        self.pack(fill=BOTH, expand=False)
Ejemplo n.º 7
0
class AdderApp(Frame):
    def __init__(self):
        Frame.__init__(self)
        self.master.title("Adder App")
        #self.master.geometry("200x150")

        self.instructions = Label(self, text="Enter the value to add to:")
        self.instructions.pack(pady=5)

        self.number = Entry(self)
        self.number.focus_set()
        self.number.pack(pady=5)

        self.total = Tkinter.StringVar()
        self.time = Tkinter.StringVar()

        self.total_frame = Frame(self)
        self.total_frame.pack(pady=0)
        Label(self.total_frame, text="Total:").pack(side=Tkinter.LEFT, padx=5)
        Label(self.total_frame, textvariable=self.total).pack(side=Tkinter.LEFT)
        self.time_frame = Frame(self)
        self.time_frame.pack(pady=0)
        Label(self.time_frame, text="Time:").pack(side=Tkinter.LEFT)
        Label(self.time_frame, textvariable=self.time).pack(side=Tkinter.LEFT)
        self.complete_msg = Tkinter.StringVar()
        Label(self, textvariable=self.complete_msg).pack(pady=2)

        self.buttons = Frame(self)
        self.buttons.pack(side=Tkinter.BOTTOM, pady=2)
        self.quit_btn = Button(self.buttons, text="Quit", command=self.quit)
        self.quit_btn.pack(side=Tkinter.LEFT)
        self.quit_btn.bind("<Return>", (lambda e, b=self.quit_btn: b.invoke()))
        self.run_btn = Button(self.buttons, text="Run", command=self.run, default=Tkinter.ACTIVE)
        self.run_btn.pack(side=Tkinter.LEFT)

        self.pack(fill=Tkinter.X)
        self.master.bind("<Return>", (lambda e, b=self.run_btn: b.invoke()))

    def run_btn_invoke(self, e):
        print("starting run with button enter")
        self.run_btn.invoke()

    def run(self):
        self.complete_msg.set("")

        self.add_run = adder.Adder()
        self.t = threading.Thread(target=self.add_run.run_to, args=(int(self.number.get()),))
        self.t.start()

        self.update_status()

    def update_status(self):
        self.total.set(self.add_run.total)
        try:
            self.time.set(self.add_run.elapsed_seconds())
        except Exception:
            pass

        if self.add_run.complete:
            self.add_run.complete = False
            self.complete_msg.set("Run Complete")
            self.quit_btn.focus_set()

        self.after(50, self.update_status)
Ejemplo n.º 8
0
        l = AnimatedGIF(root, "BCI Design 5.gif")
        l.bind("<ButtonRelease-1>", change5)
    elif (time_taken >= 8 and time_taken < 10):
        l = AnimatedGIF(root, "BCI Design 6.gif")
        l.bind("<ButtonRelease-1>", change6)
    l.pack()


def done(self):
    global label
    global button
    label['text'] = 'Your word is :' + label['text']


if __name__ == "__main__":
    from tkinter import Tk, Label

    root = Tk()
    root.minsize(150, 100)
    # Add the path to a GIF to make the example working
    l = AnimatedGIF(root, "BCI Design 1.gif")
    start = time.time()
    l.bind("<ButtonRelease-1>", change)
    l.pack()
    label = Label(root, text='')
    button = Button(root, text='Word Complete?')
    button.bind("<ButtonRelease-1>", done)
    button.pack()
    label.pack()
    root.mainloop()
Ejemplo n.º 9
0
class PromptFrame(Frame):
    def __init__(self,
                 parent,
                 question,
                 yestxt="Yes",
                 notxt='No',
                 title='Default'):
        Frame.__init__(self, parent)
        self.answer = StringVar()
        #        yestxt = "Start Test"
        #        notxt  = "Exit Test"
        self.title = Label(self, text=title, style='Title.TLabel')
        self.title.grid(column=0, row=0, padx=10, pady=10)
        self.question = Label(self, text=question, style='Title.TLabel')
        self.question.grid(column=0, row=1, padx=10, pady=10, sticky='w')
        #        self.entry = Entry( self, width=25, textvariable=self.answer ); self.entry.grid(column=0, row=1, padx=10)
        #        self.entry.select_range(0,END)
        #        self.entry.icursor(END)
        #        self.entry.bind('<Return>', func=lambda e: self.quit())
        #        self.entry.focus_force()

        self.bar = Separator(self, orient=HORIZONTAL)
        self.bar.grid(column=0,
                      row=2,
                      columnspan=2,
                      padx=5,
                      pady=5,
                      sticky='nsew')

        self.ok = Button(self,
                         text=yestxt,
                         style='TButton',
                         command=self.ButtonYes)
        self.ok.grid(column=0, row=2, padx=5, pady=5, sticky='w')
        self.no = Button(self,
                         text=notxt,
                         style='TButton',
                         command=self.ButtonNo)
        self.no.grid(column=0, row=2, padx=5, pady=5, sticky='e')
        self.ok.bind('<Return>', func=lambda e: self.ButtonYes())
        self.ok.focus_force()

        self.grid()

        # Center the Window
        parent.update_idletasks()
        xp = (parent.winfo_screenwidth() / 2) - (self.winfo_width() / 2) - 8
        yp = (parent.winfo_screenheight() / 2) - (self.winfo_height() / 2) - 20
        parent.geometry('{0}x{1}+{2}+{3}'.format(self.winfo_width(),
                                                 self.winfo_height(), xp, yp))

        self.update()
        parent.mainloop()

    def OkBut(self):
        self.answer.set("OK")
        self.quit()

    def ButtonYes(self):
        self.answer.set(True)
        self.quit()

    def ButtonNo(self):
        self.answer.set(False)
        self.quit()
Ejemplo n.º 10
0
Archivo: gui.py Proyecto: ojobabs/ML
class FrameBuilder(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)  # Initializes the frame
        self.parent = parent  # Assigns the root variable to parent
        self.initUI()  # Initializes the GUI configuration

    def initUI(self):

        # Configures the GUI
        self.parent.title("Neural Networks for Handwritten Digit Recognition")
        self.style = Style()
        self.pack(fill=BOTH, expand=1)

        # Creates a grid 5x4 in to which we will place elements.
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, weight=0)
        self.columnconfigure(3, weight=0)
        self.columnconfigure(4, weight=0)
        self.columnconfigure(5, weight=0)
        self.columnconfigure(6, weight=0)
        self.columnconfigure(7, weight=0)
        self.columnconfigure(8, weight=0)
        self.rowconfigure(1, weight=1)
        self.rowconfigure(2, weight=0)
        self.rowconfigure(3, weight=0)
        self.rowconfigure(4, weight=0)

        # Create explanation text for app
        explanation = """
        "This program is capable of utilizing different learning algorithms as a mean to achieve a +90% accuracy in recognizing MNIST
    	digits based on Neural Networks as a way of detecting the different numbers and classifying them correctly" \n
        Select the checkboxes that you wish to utilize ([ ] Learn from starting random values, [X] Learn from preexisting data / [ ] Do not
        save the results [X] Save the final values of the Weights and Biases), Press the Run button to start the Neural Network\n"""

        self.exp = Label(self, text=explanation)
        self.exp.grid(
            row=2,
            column=1,
            columnspan=4,
            padx=2,
            pady=2,
        )

        # Creates the Y scrollbar that is spawned through the whole grid
        yscrollbar = Scrollbar(self, orient=VERTICAL)
        yscrollbar.grid(row=1, column=8, sticky=N + S)

        # Creates the text area and spawns it through the whole window
        self.textarea = Text(self,
                             wrap=NONE,
                             bd=0,
                             yscrollcommand=yscrollbar.set)

        self.textarea.grid(row=1,
                           column=1,
                           columnspan=4,
                           rowspan=1,
                           padx=0,
                           sticky=E + W + S + N)

        yscrollbar.config(command=self.textarea.yview)

        # Creates the run button in the lower row
        self.runButton = Button(self, text="Run Neural Network")
        self.runButton.grid(row=4, column=1, padx=5, pady=5, sticky=W)
        self.runButton.bind("<ButtonRelease-1>", self.runNN)

        # Creates the variable initialization checkbox in the lower row
        self.initvalVar = StringVar()
        initvalCheck = Checkbutton(self,
                                   text="Learn from Initial Values",
                                   variable=self.initvalVar,
                                   onvalue="-l",
                                   offvalue="")
        initvalCheck.grid(row=4, column=2, padx=5, pady=5)

        # Creates the save variables checkbox in the lower row
        self.saveValVar = StringVar()
        saveVal = Checkbutton(self,
                              text="Save final Weights & Biases",
                              variable=self.saveValVar,
                              onvalue="-s",
                              offvalue="")
        saveVal.grid(row=4, column=3, padx=5, pady=5)

        # Creates the clear button for the textbox
        self.clearButton = Button(self, text="Clear")
        self.clearButton.grid(row=4, column=4, padx=5, pady=5)
        self.clearButton.bind("<ButtonRelease-1>", self.clearText)

        # Defines the tags that are used to colorise the text added to the text widget.
        self.textarea.tag_config("errorstring",
                                 foreground="#CC0000")  # Red Color
        self.textarea.tag_config("infostring",
                                 foreground="#008800")  # Green Color

    def tagsForLine(self, line):
        # Returns a tuple of tags to be applied to the line of text when being added
        l = line.lower()
        if "error" in l or "traceback" in l:
            return ("errorstring", )
        return ()

    def addText(self, str, tags=None):
        # Add a line of text to the textWidget.
        self.textarea.insert(INSERT, str, tags or self.tagsForLine(str))
        self.textarea.yview(END)

    def clearText(self, event):
        # Clears all the text from the textbox
        self.textarea.delete("1.0", END)

    def moveCursorToEnd(self):
        # Moves the cursor to the end of the text widget's text
        self.textarea.mark_set("insert", END)

    def runNN(self, event):
        self.moveCursorToEnd()
        self.addText(
            "The Neural Network has Started %s\n" % (str(datetime.now())),
            ("infostring", ))
        self.addText("*" * 80 + "\n", ("infostring", ))

        cmdlist = filter(lambda x: x if x else None, [
            pythonpath, mainpath,
            self.initvalVar.get(),
            self.saveValVar.get()
        ])

        self.addText(" ".join(cmdlist) + "\n", ("infostring", ))

        proc = sp.Popen(cmdlist,
                        stdout=sp.PIPE,
                        stderr=sp.STDOUT,
                        universal_newlines=True)

        while True:
            line = proc.stdout.readline()
            if not line:
                break
            self.addText(line)
            self.textarea.update_idletasks()

        self.addText("Neural Network Finished %s \n" % (str(datetime.now())),
                     ("infostring", ))
        self.addText("*" * 80 + "\n", ("infostring", ))