def create_gui():
    """thread worker function"""
    global scale_com, scale_RF, scale_LF, button_contact_RF, button_contact_LF, com_vel_entry
    master = Tk(className='TSID GUI')
    scale_com = Scale3d(master, 'CoM', [-10, -15, -40], [10, 15, 40],
                        [5, 5, 10], [200, 250, 300], 3 * [HORIZONTAL],
                        update_com_ref_scale)
    scale_RF = Scale3d(master, 'Right foot', 3 * [-30], 3 * [30], 3 * [10],
                       3 * [300], 3 * [HORIZONTAL], update_RF_ref_scale)
    scale_LF = Scale3d(master, 'Left foot', 3 * [-30], 3 * [30], 3 * [10],
                       3 * [300], 3 * [HORIZONTAL], update_LF_ref_scale)
    button_contact_RF = Button(master,
                               text='Break contact right foot',
                               command=switch_contact_RF)
    button_contact_RF.pack(side=tk.LEFT)
    button_contact_LF = Button(master,
                               text='Break contact left foot',
                               command=switch_contact_LF)
    button_contact_LF.pack(side=tk.LEFT)
    Button(master, text='Toggle wireframe',
           command=toggle_wireframe_mode).pack(side=tk.LEFT)

    #    Frame(height=2, bd=1, relief=tk.SUNKEN).pack(fill=tk.X, padx=5, pady=5)
    Button(master, text='Push robot CoM', command=push_robot).pack()
    com_vel_entry = Entry3d(master, 'CoM vel')
    mainloop()
    return
Example #2
0
def write_data(file_name):
    f=""
    data = ""
    if isfile(file_name):
        f = open(file_name, 'a+')
        f_b = open(file_name+"_backup", 'a+')
    else:
        f=open(file_name+"_backup","a+")
        f_b = open(file_name+"_buffer", 'a+')


    def keyup_write_twofiles(e):
        c = e.char
        f.write(c)
        f_b.write(c)
        f.flush()
        print "Written {0} in to {1}".format(c,f.name)
        f_b.flush()
        print "Written {0} in to {1}".format(c,f_b.name)
    def keyup_write_onefile(e):
        c=e.char
        f_b.write(c)
        f_b.flush()
        print "Written {0} in to {1}".format(c,f_b.name)

    data = f.read()
    root = Tk()
    T = Text(root, height=100, width=100)
    T.pack()
    T.insert(END, data)
    if isfile(file_name):
        T.bind("<KeyRelease>", keyup_write_twofiles)
    else:
        T.bind("<KeyRelease>", keyup_write_onefile)
    mainloop()
Example #3
0
    def run(self):
        print "Creating animation server..."
        if os.path.exists(SOCKET_NAME):
            os.remove(SOCKET_NAME)

        self.server = Animator(AnimationRequestHandler, self.simulate)
        if not self.simulate:
            print "Starting animation server..."
            print "Animation server is running on socket {0}".format(
                SOCKET_NAME)
            #print "Quit the server with CONTROL-C."
            self.server.serve_forever()
        else:
            print "Starting simulation..."
            button_window = Toplevel()
            button_window.title('Button Input')
            img = PhotoImage(file="easy_button.gif")
            single_easy_button = Button(button_window, image=img)
            single_easy_button.pack()
            single_easy_button.bind(
                "<Button-1>",
                lambda e: server.processCommand(ButtonEvent.SINGLEPRESS))
            double_easy_button = Button(button_window, text="double tap")
            double_easy_button.pack()
            double_easy_button.bind(
                "<Button-1>",
                lambda e: server.processCommand(ButtonEvent.DOUBLEPRESS))
            mainloop()
    def gui(self):
        self.root = Tk()
        self.root.title('video converter')
        self.entry_link = Entry(self.root, width=self.ENTRY_WITDH, state='disabled')
        self.entry_link.grid(row=0, column=0, columnspan=2)
        self.link_contend = StringVar()
        self.entry_link.config(textvariable=self.link_contend)
        self.link_contend.set('plz choose:')
        self.choose_button = Button(self.root, text='choose', width=self.button_width, command=self.chooseFile)
        self.choose_button.grid(row=1, column=0, columnspan=1)
        self.clear_button = Button(self.root, text='empty', width=self.button_width, command=self.emptyIt)
        self.clear_button.grid(row=1, column=1, columnspan=1)
        self.outType = StringVar()
        self.typeChosen = Combobox(self.root, width=self.ENTRY_WITDH, textvariable=self.outType)
        self.typeChosen['values'] = ('wav', 'mp4', 'flv', 'mp3', 'gif')
        self.typeChosen.current(3)
        self.typeChosen.grid(row=2, column=0, columnspan=2)

        self.startButton = Button(self.root, text='Start Convert', width=self.button_width * 2,
                                  command=self.startFFmpeg)
        self.startButton.grid(row=3, column=0, columnspan=2)

        self.result_link = Entry(self.root, width=self.ENTRY_WITDH, state='disabled')
        self.result_link.grid(row=4, column=0, columnspan=2)
        self.result_link_contend = StringVar()
        self.result_link.config(textvariable=self.result_link_contend)
        self.result_link_contend.set('plz hold on:')

        mainloop()
Example #5
0
    def plot_results(self):
        grid_x = (self.canvas_width -
                  2 * self.canvas_margin) / (self.grid_size)
        grid_y = (self.canvas_height -
                  2 * self.canvas_margin) / (self.grid_size)
        pin_dx = grid_x / 6
        pin_dy = grid_y / 6

        master = Tk()

        w = Canvas(master, width=self.canvas_width, height=self.canvas_height)
        w.pack()

        for node in self.graph:
            i, j = self.id_to_coord(node)
            if node[-1] == 's':
                i += 0.5
                j += 0.5
            nx, ny = self.get_xy(i, j)
            if node[-1] == 's':
                fill_col = 'green'
                w.create_rectangle(nx - pin_dx,
                                   ny - pin_dy,
                                   nx + pin_dx,
                                   ny + pin_dy,
                                   fill=fill_col)
            else:
                fill_col = 'black'
                w.create_oval(nx - 2, ny - 2, nx + 2, ny + 2, fill=fill_col)

        self.draw_routes(w)

        w.update()
        w.postscript(file='sol35.ps', colormode='color')
        mainloop()
Example #6
0
def draw(sequence):
    screen = Tk()
    w = Canvas(screen, width=480, height = 480)
    w.pack()

    w.create_oval(80,80,160,160,fill="green") 
    w.create_oval(80 +120,80,160 +120,160, fill="green")
    w.create_oval(80 +240,80,160 +240,160, fill="green")
    w.create_oval(80,80 +120,160,160+120,fill="green") 
    w.create_oval(80 +120,80 +120,160 +120,160+120, fill="green")
    w.create_oval(80 +240,80+120,160 +240,160+120, fill="green")
    w.create_oval(80,80 +240,160,160+240,fill="green") 
    w.create_oval(80 +120,80 +240,160 +120,160+240, fill="green")
    w.create_oval(80 +240,80+240,160 +240,160+240, fill="green")
   
    
    pos_dict = {"1":(120,120), "2":(240,120), "3":(360,120), "4":(120,240), "5":(240,240), "6":(360,240), "7":(120,360), "8":(240,360), "9":(360,360)}

    for i in range(len(sequence)-1):
        x1 = pos_dict[sequence[i]][0]
        y1 = pos_dict[sequence[i]][1]
        x2 = pos_dict[sequence[i+1]][0]
        y2 = pos_dict[sequence[i+1]][1]
        w.create_line(x1,y1,x2,y2,arrow="last",fill="red",width="5")

    mainloop()
Example #7
0
def main():
    master = Tk()
    w = Canvas(master, width=WIDTH, height=HEIGHT)
    w.pack()

    img = PhotoImage(width=WIDTH, height=HEIGHT, master=master)
    w.create_image((WIDTH/2, HEIGHT/2), image=img, state="normal")

    cam = Camera()
    cam.look_at(np.array([0, 10, -8]),
                np.array([0, 0, 3.0]),
                np.array([0, 1.0, 0]))

    init_world(world_objects)
    init_light(light_objects)
    # Generate rays for each pixel and determine color
    progress_interval = HEIGHT*WIDTH / 10
    progress_tick = 0
    print 'Progress (10 ticks): [ -',
    sys.stdout.flush()
    for y in xrange(HEIGHT):
        for x in xrange(WIDTH):
            progress_tick += 1
            if progress_tick > progress_interval:
                progress_tick = 0
                print ' -',
                sys.stdout.flush()
            ray = compute_camera_ray(WIDTH, HEIGHT, cam, 3, x, y)
            color = trace_ray(world_objects, light_objects, ray)
            # TKinter requires a hex string as color input for photo image
            img.put('#%02X%02X%02X' % tuple(color), (x, y))
    print ' ]'
    mainloop()
Example #8
0
 def Msg(name):
     master = tk()
     master.title('Error message')
     msg = Message(master, text='unable to load ' + name + ' from file')
     # msg.config()
     msg.pack()
     # close_button = Button(master, text='OK', command=master.destroy)
     mainloop()
 def finished(self):
     if self.pairs:
         self.index = 0
         self.update_labels()
         mainloop()
     else:
         print ("No duplicated images found. Maybe f_image.py was not run" +
                " yet? Or there are no images in the path given.")
Example #10
0
def main():
    root.title('XOX Game with Tkinter')

    menubar = Menu(root)
    menubar.add_command(label="NEW GAME", command=start)
    menubar.add_command(label="EXIT", command=root.quit)

    root.config(menu=menubar)
    start()
    mainloop()
Example #11
0
def main():
    root.title('XOX Game with Tkinter')

    menubar = Menu(root)
    menubar.add_command(label="NEW GAME", command=start)
    menubar.add_command(label="EXIT", command=root.quit)

    root.config(menu=menubar)
    start()
    mainloop()
Example #12
0
    def interactive(self):
        """Start interactive mode (doesn't return)"""
        print "Click anywhere on the canvas to place the robot"

        def callback(event):
            print "@", event.x, ",", event.y
            self.place_robot(event.x, event.y)

        self.canvas.bind("<Button-1>", callback)
        mainloop()
Example #13
0
    def interactive(self):
        """Start interactive mode (doesn't return)"""
        print "Click anywhere on the canvas to place the robot"

        def callback(event):
            print "@", event.x, ",", event.y
            self.place_robot(event.x, event.y)

        self.canvas.bind("<Button-1>", callback)
        mainloop()
Example #14
0
    def __init__(self):
        """Display a form to enter the size of the grid of the go game
        and start it

        Arguments:
            -

        Attributes updated by this function:
            self.grid_size
        """

        # Create screen to ask for game settings
        starting_screen = Tk()

        # Create an input field for the grid size of the go game
        # (also add a callback method to detect changes)
        Label(starting_screen, text='Grid Size').grid(row=0)
        sv_grid_size = StringVar()
        sv_grid_size.trace("w",
                           lambda name, index, mode, sv=sv_grid_size: self.
                           callback_grid_size())
        self.grid_size = Entry(starting_screen, textvariable=sv_grid_size)
        self.grid_size.grid(row=0, column=1)

        # Create an input field for the name of the first (black) player
        # (also add a callback method to detect changes)
        Label(starting_screen, text='Name Player 1 (Black)').grid(row=1)
        sv_player_1 = StringVar()
        sv_player_1.trace(
            "w",
            lambda name, index, mode, sv=sv_player_1: self.callback_player_1())
        self.player_1_name = Entry(starting_screen, textvariable=sv_player_1)
        self.player_1_name.grid(row=1, column=1)

        # Create an input field for the name of the second (white) player
        # (also add a callback method to detect changes)
        Label(starting_screen, text='Name Player 2 (White)').grid(row=3)
        sv_player_2 = StringVar()
        sv_player_2.trace(
            "w",
            lambda name, index, mode, sv=sv_player_2: self.callback_player_1())
        self.player_2_name = Entry(starting_screen, textvariable=sv_player_2)
        self.player_2_name.grid(row=3, column=1)

        # Add a button to start a new go game
        Button(starting_screen, text='Start',
               command=self.start_game).grid(row=4, column=1, sticky=W, pady=4)

        # Create a label for messages
        self.info_label = Label(starting_screen, text='')
        self.info_label.grid(row=5, columnspan=2)

        # Display the starting screen
        mainloop()
Example #15
0
 def run(self, ticks=1000):
     # run for 1000 ticks
     self.done = False
     if DEBUG:
         self.screen.ontimer(self._print_fps, 1000)
     self.ticks = ticks
     self.screen.ontimer(self.tick, 33)
     if mainloop:
         mainloop()
     else:
         self.screen.mainloop()
Example #16
0
 def run(self, ticks=1000):
     # run for 1000 ticks
     self.done = False
     if DEBUG:
         self.screen.ontimer(self._print_fps, 1000)
     self.ticks = ticks
     self.screen.ontimer(self.tick, self.tick_interval)
     if mainloop:
         mainloop()
     else:
         self.screen.mainloop()
Example #17
0
def draw_binary_tree(depth, nodes):
    tree_w = 128*depth	# tree width
    level_h = 75	# level height

    master = Tk()
    w = Canvas(master, width=tree_w, height=tree_w + level_h/2)
    w.pack()

    for node in nodes.values():
        draw_node(w, node, tree_w, level_h)

    mainloop()
Example #18
0
def draw_data(points, data):
    master = Tk()
    w = Canvas(master, width=SIZE[0]*2, height=SIZE[1])
    w.pack()
    maxx, minx, maxy, miny = [f(l) for l in [[p[0] for p in points], [p[1] for p in points]] for f in [max, min]]
    dx, dy = maxx - minx, maxy - miny
    for x, y, radious in data:
        drawcircle(w, (x-minx) / dx *SIZE[0]+SIZE[0],
                (y - miny) / dy * SIZE[1], math.sqrt(radious))
    for x, y in points:
        drawcircle(w, (x-minx) / dx*SIZE[0], (y-miny) / dy *SIZE[1], 2)
    mainloop()
Example #19
0
def main():
    global im
    root=Tk()
    root.withdraw()
    tkinternet.install(root)
    im=im2.InstanceMessenger()
    im.logging=1
    tkutil.GenericLogin(our_callback,[["Username","my_screen_name"],
                                      ["Password","my_password",{"show":"*"}],
                                      ["Server","toc.oscar.aol.com"],
                                      ["Port","9898"]])
    mainloop()
    tkinternet.stop()
Example #20
0
def gui():
    def encode():
        global dc
        x = e1.get()
        q = mtalk.encode(x)
        if q != dc:
            dc = q
            e3.delete(0, END)
            e3.insert(0, q)
        e3.after(500, encode)

    def decode():
        global cd
        global y
        if e2.get() == '':
            y = "a"
        else:
            y = e2.get()
        r = ''
        if y[-1] == ' ':
            r = mtalk.decode(y)
            if r != cd:
                cd = r
                e4.delete(0, END)
                e4.insert(0, r)
        e4.after(500, decode)

    font1 = 'Courier', 25, 'bold'
    font2 = 'Courier', 15, 'bold'
    master = Tk()
    master.title("morse_talk")

    Label(master, text="Encode", font=font1).grid(row=3)
    Label(master, text="Decode", font=font1).grid(row=11)
    Label(master, text="Encoded text", font=font1).grid(row=6)
    Label(master, text="Decoded code", font=font1).grid(row=14)

    e1 = Entry(master, font=font2)
    e2 = Entry(master, font=font2)
    e3 = Entry(master, font=font2)
    e4 = Entry(master, font=font2)

    e1.grid(row=3, column=1, ipadx=35)
    e2.grid(row=11, column=1, ipadx=35)
    e3.grid(row=6, column=1, ipadx=35)
    e4.grid(row=14, column=1, ipadx=35)

    encode()
    decode()
    mainloop()
Example #21
0
def main():
    global im
    root = Tk()
    root.withdraw()
    tkinternet.install(root)
    im = im2.InstanceMessenger()
    im.logging = 1
    tkutil.GenericLogin(
        our_callback, [["Username", "my_screen_name"],
                       ["Password", "my_password", {
                           "show": "*"
                       }], ["Server", "toc.oscar.aol.com"], ["Port", "9898"]])
    mainloop()
    tkinternet.stop()
Example #22
0
def display():
    window = Tk()
    canvas = Canvas(window, width=WIDTH, height=HEIGHT, bg="#000000")
    canvas.pack()
    img = PhotoImage(width=WIDTH, height=HEIGHT)
    canvas.create_image((WIDTH/2, HEIGHT/2), image=img, state="normal")

    data = ""
    for i in range(HEIGHT):
        data += '{' + ' '.join(map(
            convert_color,
            memory_dump(i*WIDTH, i*WIDTH + WIDTH)
        )) + '} '
    img.put(data[:-1])

    mainloop()
Example #23
0
def _selftest():
    from Tkinter import Button, mainloop

    # mixin usage
    class content:
        "same code used as a Tk, Toplevel, and Frame"

        def __init__(self):
            Button(self, text='Larch', command=self.quit).pack()
            Button(self, text='Sing ', command=self.destroy).pack()

    class contentmix(MainWindow, content):
        def __init__(self):
            MainWindow.__init__(self, 'mixin', 'Main')
            content.__init__(self)

    contentmix()

    class contentmix(PopupWindow, content):
        def __init__(self):
            PopupWindow.__init__(self, 'mixin', 'Popup')
            content.__init__(self)

    prev = contentmix()

    class contentmix(ComponentWindow, content):
        def __init__(self):  # nested frame
            ComponentWindow.__init__(self, prev)  # on prior window
            content.__init__(self)  # Sing erases frame

    contentmix()

    # subclass usage
    class contentsub(PopupWindow):
        def __init__(self):
            PopupWindow.__init__(self, 'popup', 'subclass')
            Button(self, text='Pine', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()

    contentsub()

    # non-class usage
    win = PopupWindow('popup', 'attachment')
    Button(win, text='Redwood', command=win.quit).pack()
    Button(win, text='Sing   ', command=win.destroy).pack()
    mainloop()
Example #24
0
def main():
	global ROOT 
	ROOT = Tk()
	ROOT.protocol('WM_DELETE_WINDOW', terminateAll)
	w = ROOT.winfo_screenwidth()
	h = ROOT.winfo_screenheight()
	ROOT.geometry("%dx%d" % (w/1.6, h/3))
	app = Window(ROOT)
	ROOT = mainloop()
Example #25
0
def render_2d(header, blocks):
    from Tkinter import Tk, Label, mainloop, PhotoImage
    # Create a random color map from the set of blocks values
    colors = {}
    for unique_item in set(chain.from_iterable(blocks)):
        if unique_item == 0:
            colors[0] = (0, 0, 0)
        else:
            colors[unique_item] = (randrange(128), randrange(128), randrange(128))
    master = Tk()
    # Build image
    photo = PhotoImage(width=header["z"], height=header["y"])
    #{#ff0000 #ff0000 #ff0000} {#ff0000 #ff0000 #ff0000} {#ff0000 #ff0000 #ff0000} {#ff0000 #ff0000 #ff0000}
    horizontal_line = " ".join(["{" + " ".join(["#%02x%02x%02x" % tuple(colors[blockId]) for blockId in row]) + "}" for row in blocks])
    photo.put(horizontal_line)
    photo = photo.zoom(4, 4)
    label = Label(master, image=photo)
    label.pack()
    mainloop()
Example #26
0
def gui():
    master = Tk()

    rawfile = askopenfilename(title="Select raw file or first tiff in series",
                              filetypes=[("Raw files", "*.raw"),
                                         ("Tiff files", "*.tif")])

    if len(rawfile) == 0:
        quit(0)

    rawtrunk, rawext = os.path.splitext(rawfile)

    if rawext == ".raw":
        Label(master, text="Raw conversion").grid(row=0, sticky=W)
        var = IntVar()
        Checkbutton(master, text="LMZA lossless compression",
                    variable=var).grid(row=1, sticky=W)
        Button(master, text='Cancel', command=quit).grid(row=2,
                                                         sticky=W,
                                                         pady=4)
        Button(master, text='Convert', command=master.quit).grid(row=3,
                                                                 sticky=W,
                                                                 pady=4)
        mainloop()
        compress = var.get() != 0
        mp = False
    elif rawext == ".tif":
        Label(master, text="Multipage TIFF").grid(row=0, sticky=W)
        var = IntVar()
        Checkbutton(master, text="Generate multipage TIFF",
                    variable=var).grid(row=1, sticky=W)
        Button(master, text='Cancel', command=quit).grid(row=2,
                                                         sticky=W,
                                                         pady=4)
        Button(master, text='Convert', command=master.quit).grid(row=3,
                                                                 sticky=W,
                                                                 pady=4)
        mainloop()
        compress = False
        mp = var.get() != 0

    return rawfile, mp, compress
Example #27
0
def display(image_file):

    root = Tk()
    root.title("Dataflow Graph")
    screen_width = root.winfo_screenwidth() * 1.0
    screen_height = root.winfo_screenheight() * 0.875

    image1 = Image.open(image_file)
    width, height = image1.size
    if width > screen_width or height > screen_height:
        factor = max(width / screen_width, height / screen_height)
        image1 = image1.resize((int(width / factor), int(height / factor)),
                               Image.ANTIALIAS)

    frame = Frame(root, width=image1.size[0], height=image1.size[1])
    frame.grid(row=0, column=0)
    canvas = Canvas(frame,
                    bg='#FFFFFF',
                    width=image1.size[0],
                    height=image1.size[1],
                    scrollregion=(0, 0, image1.size[0], image1.size[1]))
    img = ImageTk.PhotoImage(image1)
    canvas.create_image(0, 0, image=img, anchor="nw")

    hbar = Scrollbar(frame, orient=HORIZONTAL)
    hbar.pack(side=BOTTOM, fill=Tkinter.X)
    hbar.config(command=canvas.xview)
    vbar = Scrollbar(frame, orient=VERTICAL)
    vbar.pack(side=RIGHT, fill=Tkinter.Y)
    vbar.config(command=canvas.yview)
    canvas.config(width=image1.size[0], height=image1.size[1])
    canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
    canvas.pack(side=LEFT, expand=True, fill=BOTH)

    frame.pack()
    # added so that the windows pops up (and is not minimized)
    # --> see http://stackoverflow.com/questions/9083687/python-tkinter-gui-always-loads-minimized
    root.attributes('-topmost', 1)
    root.update()
    root.attributes('-topmost', 0)
    mainloop()
def _selftest():

    # mixin usage
    class content:
        "same code used as a Tk, Toplevel, and Frame"
        def __init__(self):
            Button(self, text='Larch', command=self.quit).pack()
            Button(self, text='Sing ', command=self.destroy).pack()

    class contentmix(MainWindow, content):
        def __init__(self):
            MainWindow.__init__(self, 'mixin', 'Main')
            content.__init__(self)
    contentmix()

    class contentmix(PopupWindow, content):
        def __init__(self):
            PopupWindow.__init__(self, 'mixin', 'Popup')
            content.__init__(self)
    prev = contentmix()

    class contentmix(ComponentWindow, content):
        def __init__(self):                               # nested frame
            ComponentWindow.__init__(self, prev)          # on prior window
            content.__init__(self)                        # Sing erases frame
    contentmix()

    # subclass usage
    class contentsub(PopupWindow):
        def __init__(self):
            PopupWindow.__init__(self, 'popup', 'subclass')
            Button(self, text='Pine', command=self.quit).pack()
            Button(self, text='Sing', command=self.destroy).pack()
    contentsub()

    # non-class usage
    win = PopupWindow('popup', 'attachment')
    Button(win, text='Redwood', command=win.quit).pack()
    Button(win, text='Sing   ', command=win.destroy).pack()
    mainloop()
Example #29
0
    def doGUI(self, hostname=None):
        self.master = Tk()
        self.master.title('Blessclient - MFA')
        textmsg = 'Enter your AWS MFA code: '
        if hostname:
            textmsg = 'Enter your AWS MFA code to connect to {}: '.format(
                hostname)
        Label(self.master, text=textmsg).grid(row=0)
        self.e1 = Entry(self.master)
        self.e1.grid(row=0, column=1, padx=4)
        Button(self.master,
               text='OK',
               command=self.show_entry_fields,
               default=ACTIVE).grid(row=3, column=0, sticky=W, pady=4)
        Button(self.master, text='Cancel', command=self.quit).grid(row=3,
                                                                   column=1,
                                                                   sticky=W,
                                                                   pady=4)

        self.center()
        self.master.bind('<Return>', self.show_entry_fields)
        self.master.lift()
        self.master.attributes('-topmost', True)
        self.master.focus_force()
        self.e1.focus_set()
        if platform.system() == 'Darwin':
            try:
                from Cocoa import (NSRunningApplication,
                                   NSApplicationActivateIgnoringOtherApps)

                app = NSRunningApplication.runningApplicationWithProcessIdentifier_(
                    os.getpid())
                app.activateWithOptions_(
                    NSApplicationActivateIgnoringOtherApps)
            except ImportError:
                pass

        mainloop()
Example #30
0
 def run(self):
     print "Creating animation server..."
     if os.path.exists(SOCKET_NAME):
         os.remove(SOCKET_NAME)
     
     self.server = Animator(AnimationRequestHandler, self.simulate)
     if not self.simulate:
         print "Starting animation server..."
         print "Animation server is running on socket {0}".format(SOCKET_NAME)
         #print "Quit the server with CONTROL-C."        
         self.server.serve_forever()
     else:
         print "Starting simulation..."
         button_window = Toplevel()
         button_window.title('Button Input')
         img = PhotoImage(file="easy_button.gif")
         single_easy_button = Button(button_window, image=img)
         single_easy_button.pack()
         single_easy_button.bind("<Button-1>", lambda e: server.processCommand(ButtonEvent.SINGLEPRESS))
         double_easy_button = Button(button_window, text="double tap")
         double_easy_button.pack()
         double_easy_button.bind("<Button-1>", lambda e: server.processCommand(ButtonEvent.DOUBLEPRESS))        
         mainloop()
Example #31
0
def display(image_file):
    
    root = Tk()
    root.title("Dataflow Graph")
    screen_width=root.winfo_screenwidth()*1.0
    screen_height=root.winfo_screenheight()*0.875
    
    image1 = Image.open(image_file)
    width,height=image1.size
    if width>screen_width or height>screen_height:
        factor=max(width/screen_width,height/screen_height)
        image1=image1.resize((int(width/factor),int(height/factor)), Image.ANTIALIAS)

    
    frame = Frame(root, width=image1.size[0],height=image1.size[1])
    frame.grid(row=0,column=0)
    canvas=Canvas(frame,bg='#FFFFFF',width=image1.size[0],height=image1.size[1],scrollregion=(0,0,image1.size[0],image1.size[1]))
    img = ImageTk.PhotoImage(image1)
    canvas.create_image(0,0,image=img, anchor="nw")

    hbar=Scrollbar(frame,orient=HORIZONTAL)
    hbar.pack(side=BOTTOM,fill=Tkinter.X)
    hbar.config(command=canvas.xview)
    vbar=Scrollbar(frame,orient=VERTICAL)
    vbar.pack(side=RIGHT,fill=Tkinter.Y)
    vbar.config(command=canvas.yview)
    canvas.config(width=image1.size[0],height=image1.size[1])
    canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
    canvas.pack(side=LEFT,expand=True,fill=BOTH)

    frame.pack()
    # added so that the windows pops up (and is not minimized) 
    # --> see http://stackoverflow.com/questions/9083687/python-tkinter-gui-always-loads-minimized
    root.attributes('-topmost', 1)
    root.update()
    root.attributes('-topmost', 0)    
    mainloop()
Example #32
0
    def doGUI(self, hostname=None):
        self.master = Tk()
        self.master.title('Blessclient - MFA')
        textmsg = 'Enter your AWS MFA code: '
        if hostname:
            textmsg = 'Enter your AWS MFA code to connect to {}: '.format(hostname)
        Label(self.master, text=textmsg).grid(row=0)
        self.e1 = Entry(self.master)
        self.e1.grid(row=0, column=1, padx=4)
        Button(self.master, text='OK', command=self.show_entry_fields, default=ACTIVE).grid(row=3, column=0, sticky=W, pady=4)
        Button(self.master, text='Cancel', command=self.quit).grid(row=3, column=1, sticky=W, pady=4)

        self.center()
        self.master.bind('<Return>', self.show_entry_fields)
        self.master.lift()
        self.master.attributes('-topmost', True)
        self.master.focus_force()
        self.e1.focus_set()

        if platform.system() == 'Darwin':
            # Hack to get the GUI dialog focused in OSX
            os.system('/usr/bin/osascript -e \'tell app "Finder" to set frontmost of process "python" to true\'')

        mainloop()
Example #33
0
 def start(self):
     self.construct_credentials_fields()
     self.construct_women_done_frame()
     self.construct_only_with_photo_checkbox()
     mainloop()
Example #34
0
        # draw the blank squares for the outputs
        if self.use_rwo:
            src.canvas.itemconfig(self.text, text=str(self.rwo.n_vecs))
        self.matrix_display.update(self.state)


def key_tk(*args, **kwargs):
    import keyboard

    current_state = keyboard.stash_state()
    q = Queue()
    keys = Process(target=capture_keys, args=(q, ))
    keys.start()
    k = KeyDisplay(q, *args, **kwargs)
    keyboard.restore_state(current_state)
    time.sleep(0.5)
    keyboard.restore_state(current_state)
    return current_state


if __name__ == "__main__":
    import keyboard, atexit

    current_state = keyboard.stash_state()
    atexit.register(keyboard.restore_state, current_state)
    q = Queue()
    keys = Process(target=capture_keys, args=(q, ))
    keys.start()
    k = KeyDisplay(q)
    mainloop()
Example #35
0
def main_of_me():
    show_the_project()

    mainloop()
    return 0
 def start():
     mainloop()
Example #37
0
def main():
    DirList(os.curdir)
    mainloop()
Example #38
0
# -*- coding: utf-8 -*-
''' accpy gui starter
author:     felix.kramer(at)physik.hu-berlin.de

grep checking:
    n: show line number
    h: hide file name
    r: recursively check all subfolders
    w: whole word match
    x: whole line match
    grep --include=\*.py -hrw '.' -e 'import'
'''
try:
    from Tkinter import Tk, mainloop, PhotoImage
except:
    from tkinter import Tk, mainloop, PhotoImage
from accpy.gui.mainwin import mainwindow
from gc import enable


if __name__ == '__main__':
    root = Tk()  # create window
    icon = PhotoImage(file='accpy/icons/icon.gif')
    icon_start = PhotoImage(file='accpy/icons/start.gif').subsample(10, 10)
    icon_stop = PhotoImage(file='accpy/icons/stop.gif').subsample(10, 10)
    root.tk.call('wm', 'iconphoto', root._w, icon)
    version = 0.6
    mainwindow(root, version, icon_start, icon_stop)
    enable()
    mainloop()   # start Tk mainloop
Example #39
0
 def takeControl(self):
     """
     Give full control to the window. Blocks current thread. Program will exit when window is closed.
     """
     mainloop()
Example #40
0
	def mainloop(self):
		mainloop()
Example #41
0
 def takeControl(self):
     """
     Give full control to the window. Blocks current thread. Program will exit when window is closed.
     """
     mainloop()
Example #42
0
def gui():
    '''make the GUI version of this command that is run if no options are
    provided on the command line'''

    def button_go_callback():
        ''' what to do when the "Go" button is pressed '''
        input_file = entry.get()
        if input_file.rsplit('.')[-1] != 'csv':
            statusText.set('Filename must end in ".csv"')
            message.configure(fg='red')
            return
        else:
            table_contents = read_csv(input_file)
            if table_contents is None:
                statusText.set('Error reading file "{}"'.format(input_file))
                message.configure(fg='red')
                return
            output_file = get_output_filename(input_file)
            if write_table(output_file, table_contents):
                statusText.set('Output is in {}'.format(output_file))
                message.configure(fg='black')
            else:
                statusText.set('Writing file '
                               '"{}" did not succeed'.format(output_file))
                message.configure(fg='red')

    def button_browse_callback():
        ''' What to do when the Browse button is pressed '''
        filename = tkFileDialog.askopenfilename()
        entry.delete(0, END)
        entry.insert(0, filename)

    root = Tk()
    frame = Frame(root)
    frame.pack()

    statusText = StringVar(root)
    statusText.set('Press Browse button or enter CSV filename, '
                   'then press the Go button')

    label = Label(root, text='CSV file: ')
    label.pack()
    entry = Entry(root, width=50)
    entry.pack()
    separator = Frame(root, height=2, bd=1, relief=SUNKEN)
    separator.pack(fill=X, padx=5, pady=5)

    button_go = Button(root,
                       text='Go',
                       command=button_go_callback)
    button_browse = Button(root,
                           text='Browse',
                           command=button_browse_callback)
    button_exit = Button(root,
                         text='Exit',
                         command=sys.exit)
    button_go.pack()
    button_browse.pack()
    button_exit.pack()

    separator = Frame(root, height=2, bd=1, relief=SUNKEN)
    separator.pack(fill=X, padx=5, pady=5)

    message = Label(root, textvariable=statusText)
    message.pack()

    mainloop()
Example #43
0
def paintTest():
    global canvas
    master = Tk()

    canvas_width = win_max_x
    canvas_height = win_max_y
    canvas = Canvas(master, width=win_max_x, height=win_max_y)
    canvas.pack()

    y = int(win_max_y / 2)
    #w.create_line(0, y, win_max_x, y, fill="#476042")
    img = PhotoImage(master=master, width=win_max_x, height=win_max_y)
    #img = w.create_image(0,0, state="normal")
    canvas.bind("<Button-1>", click)

    mainloop()
    return
    for x in range(0, win_max_x):
        for y in range(0, win_max_y):
            color = 128 + int(64 * sin(x * y / 16.0))
            drawColor = color_rgb(255, color, color)
            img.put(drawColor, (x, y))

    w.create_image((win_max_x / 2, win_max_y / 2), image=img, state="normal")
    #w.create_image((win_max_x/2, win_max_y/2), image=img, state="normal")

    mainloop()
    return

    WIDTH, HEIGHT = 640, 480

    window = Tk()
    canvas = Canvas(window, width=WIDTH, height=HEIGHT, bg="#000000")
    canvas.pack()
    img = PhotoImage(width=WIDTH, height=HEIGHT)
    canvas.add
    #canvas.create_image((WIDTH/2, HEIGHT/2), image=img, state="normal")

    for x in range(4 * WIDTH):
        y = int(HEIGHT / 2 + HEIGHT / 4 * sin(x / 80.0))
        img.put("#ffffff", (x // 4, y))

#win.getMouse()
    return

    img = Image.New('RGB', (255, 255), "black")  # create a new black image
    pixels = img.load()  # create the pixel map

    for i in range(img.size[0]):  # for every pixel:
        for j in range(img.size[1]):
            pixels[i, j] = (i, j, 100)  # set the colour accordingly

    img.show()

    return

    master = Tk()

    canvas = Canvas(master, width=win_max_x, height=win_max_y)
    canvas.pack()

    #img = PhotoImage(file="myimage.jpg")
    #canvas.create_image(20,20, anchor=NW, image=img)

    return

    #pixels = " ".join('#%02x%02x%02x')
    img = Image.new('RGB', (255, 255), "black")  # create a new black image
    pixels = img.load()  # create the pixel map

    for i in range(img.size[0]):  # for every pixel:
        for j in range(img.size[1]):
            pixels[i, j] = (i, j, 100)  # set the colour accordingly

    #img.Show(win)

    myImage = graphics.Image(pixels)
    myImage.draw(window)
Example #44
0
    99: 'black'
}

def mandel(c):
    z = 0
    i = 0
    for h in range(0,20):
        z = z*z + c
        if abs(z) > 2:
            break
        else:
            i+=1
    if abs(z) >= 2:
        return i
    else:
        return 99

print('Drawing...')

for x in range(0,600):
    real = x / 200.0 - 2.2
    for y in range(0, 600):
        imag = y / 200.0 - 1.5
        c = complex(real, imag)
        p = mandel(c)
        w.create_line(x, 600-y, x+1, 601-y, fill=colors[p])
        w.pack()

print('Complete!')
mainloop()
Example #45
0
def Last():
    global Variables, labels, Rango, Flag_5, Tabla, Indice, g, h, Tabla_Datos
    global Lista_Cluster, Lista_Position, Lista_Indice, n_clusters_
    global List_Countries, cluster_centers, Var_G5, Var_G6

    Book = xlwt.Workbook()  #Parametro para grabar nueva hoja de Excel
    Sheet_1 = Book.add_sheet(
        'sheet1')  #Hoja dentro del nuevo archivo donde se guardaran los datos
    Indice = []
    Tabla = []
    Tabla = Tabla_Datos
    Indice = Lista_Indice

    if Var_G6.get() == 0:
        kmeans = KMeans(
            n_clusters=vart.get())  #Inicializacion de Kmeans con 3 Clusters
        kmeans.fit(Tabla)  #Ejecutar Kmeans sobre la Tabla
        labels = kmeans.labels_  #Etiqueta representando a que cluster pertenece cada elemento de la tabla
        n_clusters_ = len(numpy.unique(labels))  #Cantidad de Clusters
        cluster_centers = kmeans.cluster_centers_  #Posicion de los Centros de cada Cluster
    elif Var_G6.get() == 1:
        ms = MeanShift()
        ms.fit(Tabla)
        labels = ms.labels_
        n_clusters_ = len(numpy.unique(labels))
        cluster_centers = ms.cluster_centers_
    else:
        db = DBSCAN(eps=0.3, min_samples=10).fit(Tabla)
        core_samples_mask = numpy.zeros_like(db.labels_, dtype=bool)
        core_samples_mask[db.core_sample_indices_] = True
        labels = db.labels_
        n_clusters_ = len(numpy.unique(labels))

    Variables = var_4(Indice, New_Ind_2[0])
    Criteria = []
    Criteria.append(List_Var[State_2])

    Rango = []
    if Criteria[0] == "Age":
        Lista_Position, Lista_Cluster, Rango = Intervalos_0(
            Variables, labels,
            Indice)  #Separar en Sub-listas con los rangos de a 5 en 5
    else:
        List_Countries = []
        Ind, aux = numpy.unique(
            Variables, return_counts=True
        )  #Ver cuantos elementos                                                  #unicos estan en la                                                   #lista
        for i in range(len(aux)):
            if aux[i] >= 35:
                List_Countries.append(Ind[i])

        Lista_Cluster = []
        Lista_Position = []
        Index_Aux_0 = []
        Index_Aux_1 = []

        for i in range(len(List_Countries)):
            for j in range(len(Variables)):
                if Variables[j] == List_Countries[i]:
                    Index_Aux_0.append(labels[j])
                    Index_Aux_1.append(Indice[j])
            Lista_Cluster.append(Index_Aux_0)
            Lista_Position.append(Index_Aux_1)
            Index_Aux_0 = []
            Index_Aux_1 = []

    Tabla_Porcentual = [
    ]  #Tabla de Clusters expresada en porcentajes cada lista con respecto a si misma
    for i in range(len(
            Lista_Cluster)):  #Iteracion por el largo de la lista de Clusters
        Ind_0, Val_0 = numpy.unique(
            Lista_Cluster[i],
            return_counts=True)  #Indice de elementos unicos y sus cantidades
        Aux_0 = copy.copy(Val_0)  #Copiar la tabla de cantidades a una auxiliar
        Aux_0 = Aux_0 * 1.0  #Nueva tabla expresada con puntos decimales
        Aux_0 = Porcentaje(
            Aux_0
        )  #Tabla de cantidades expresada en porcentaje con respecto a si misma
        if sum(Val_0) >= 35:
            if Criteria[0] != "Age":
                Rango.append(List_Countries[i])  #Se guarda el rango de edades
            Tabla_Porcentual.append(Aux_0)

    k = 0
    for i in range(len(Tabla_Porcentual)):
        if len(Tabla_Porcentual[i]) > k:
            k = len(Tabla_Porcentual[i])

    for i in range(len(Tabla_Porcentual)):
        for j in range(len(Tabla_Porcentual[i]), k, 1):
            Tabla_Porcentual[i] = numpy.append(Tabla_Porcentual[i], 0)

    for i in range(0, len(Tabla_Porcentual), 1):  #Visualizar la lista
        if Criteria[0] == "Age":
            print 'Rango    ', int(Rango[i]), '-', int(
                Rango[i] + 5)  #Mostrar los rangos de edades
        else:
            print 'Rango    ', Rango[i]
        print 'Elementos', Tabla_Porcentual[
            i]  #Mostrar la ponderacion porcentual

    SW2 = Tkinter.Toplevel()
    if Var_G6.get() == 0:
        SW2.wm_title("Metodo de Clusterizacion: Kmeans  " +
                     "Numero de Clusters: " + str(vart.get()))
    elif Var_G6.get() == 1:
        SW2.wm_title("Metodo de Clusterizacion: MeanShift")
    else:
        SW2.wm_title("Metodo de Clusterizacion: DBSCAN")

    if Criteria[0] == "Age":
        Aux_0 = ()  #Auxliar para el texto de cada fila y columna
        for i in range(0, len(Rango), 1):  #Iteracion por la cantidad de rangos
            Aux_0 = (int(Rango[i]), '-', (int(Rango[i] + 5))
                     )  #Texto para el titulo de las filas y columnas
            Label(SW2, text=Aux_0, relief=GROOVE,
                  width=15).grid(row=i + 1,
                                 column=0)  #Rangos como titulos en las filas
            Label(SW2, text=Aux_0, relief=GROOVE, width=15).grid(
                row=0, column=i + 1)  #Rangos como titulos en las columnas
            Sheet_1.write(i + 1, 0, str(
                (Rango[i] * 5, '-', (Rango[i] + 1) *
                 5)))  #Guardar las filas en un archivo de excel
            Sheet_1.write(0, i + 1, str(
                (Rango[i] * 5, '-', (Rango[i] + 1) *
                 5)))  #Guardar las columnas en un archivo de excel
    else:
        Aux_0 = ()  #Auxliar para el texto de cada fila y columna
        for i in range(0, len(Rango), 1):  #Iteracion por la cantidad de rangos
            Aux_0 = (Rango[i])  #Texto para el titulo de las filas y columnas
            Label(SW2, text=Aux_0, relief=GROOVE,
                  width=15).grid(row=i + 1,
                                 column=0)  #Rangos como titulos en las filas
            Label(SW2, text=Aux_0, relief=GROOVE, width=15).grid(
                row=0, column=i + 1)  #Rangos como titulos en las columnas
            Sheet_1.write(i + 1, 0, str(
                (Aux_0)))  #Guardar las filas en un archivo de excel
            Sheet_1.write(0, i + 1, str(
                (Aux_0)))  #Guardar las columnas en un archivo de excel

    Aux_1 = 0  #Variable Auxiliar
    Distancias_Vectoriales = []  #Lista para las distancias vectoriales
    for i in range(len(Tabla_Porcentual)):  #Iteracion por el numero de filas
        for j in range(
                len(Tabla_Porcentual)):  #Iteracion por el numero de columnas
            Aux_1 = vector(
                Tabla_Porcentual[i],
                Tabla_Porcentual[j])  #Calcular distancias entre dos puntos
            Distancias_Vectoriales.append(
                Aux_1)  #Guardar las distancias en una lista

    Distancias_Vectoriales = Escalar(
        Distancias_Vectoriales, 255,
        4)  #Convertir las distancias a una escala de 255

    Aux_2 = 0  #Variable Auxiliar
    Aux_3 = 0  #Contador
    for i in range(0, len(Rango), 1):  #Iteracion por el numero de filas
        for j in range(0, len(Rango), 1):  #Iteracion por el numero de Columnas
            Aux_2 = Distancias_Vectoriales[
                Aux_3]  #Auxiliar es igual a la distancia entre el rango de las filas y el rango de las columnas
            Color_1 = '#%02x%02x%02x' % (
                Aux_2, Aux_2, Aux_2
            )  #Color de la celda proporcional al valor de la distancia, en escala de grises
            Color_2 = '#%02x%02x%02x' % (
                255 - Aux_2, 255 - Aux_2, 255 - Aux_2
            )  #Color para el texto inverso al color de la celda
            Label(SW2,
                  text=("%.1f" % Aux_2),
                  bg=Color_1,
                  fg=Color_2,
                  relief=RIDGE,
                  width=15).grid(row=i + 1, column=j +
                                 1)  #Crea una celda en la ventada de Display
            Sheet_1.write(i + 1, j + 1,
                          Aux_2)  #Guarda el valor en la celda correspondiente
            Aux_3 = Aux_3 + 1  #Contador incrementa en 1

    Var_G5 = IntVar()
    my_objects_3 = []
    for i in range(2):
        my_objects_3.append(MyClass(i))
    k = 0
    d = 0
    for i in ["TSNE", "MDS"]:
        my_objects_3[k] = Radiobutton(top, text=i, variable=Var_G5, value=k)
        my_objects_3[k].place(x=220, y=105 + d * 20)
        k = k + 1
        d = d + 1

    Flag_5 == 0
    name = "random.xls"  #Nombre del Archivo de Excel
    Book.save(name)  #Grabar archivo Excel con el nombre definido
    Book.save(TemporaryFile())  #Grabar archivo Excel en la carpeta Definida
    mainloop()