src/m5_tkinter_practice.py
def main():
    """ Constructs a GUI with stuff on it. """
    # -------------------------------------------------------------------------
    # Done: 2. After reading and understanding the m1e module,
    #   ** make a window that shows up. **
    # -------------------------------------------------------------------------
    root = tkinter.Tk()
    root.title("Work Please")




    # -------------------------------------------------------------------------
    # Done: 3. After reading and understanding the m2e module,
    #   ** put a Frame on the window. **
    # -------------------------------------------------------------------------
    main_frame = ttk.Frame(root, padding=100, relief='groove')
    main_frame.grid()
    # -------------------------------------------------------------------------
    # Done: 4. After reading and understanding the m2e module,
    #   ** put a Button on the Frame. **
    # -------------------------------------------------------------------------
    go_forward_button = ttk.Button(main_frame, text='Hello')
    go_forward_button.grid(row = 1, column = 2)
    # -------------------------------------------------------------------------
    # Done: 5. After reading and understanding the m3e module,
    #   ** make your Button respond to a button-press **
    #   ** by printing   "Hello"  on the Console.     **
    # -------------------------------------------------------------------------
    go_forward_button['command'] = (lambda: print_hello())
    # -------------------------------------------------------------------------
    # Done: 6. After reading and understanding the m4e module,
    #   -- Put an Entry box on the Frame.
    #   -- Put a second Button on the Frame.
    #   -- Make this new Button, when pressed, print "Hello"
    #        on the Console if the current string in the Entry box
    #        is the string 'ok', but print "Goodbye" otherwise.
    # -------------------------------------------------------------------------
    entry_box = ttk.Entry(main_frame)
    entry_box.grid(row = 0, column = 0)
    print_entry_button = ttk.Button(main_frame, text='Print Word')
    print_entry_button.grid()
    print_entry_button['command'] = (lambda:
                                     check_entry_box(entry_box))
    # -------------------------------------------------------------------------
    # Done: 7.
    #    -- Put a second Entry on the Frame.
    #    -- Put a third Button on the frame.
    #    -- Make this new Button respond to a button-press as follows:
    #
    #    Pressing this new Button causes the STRING that the user typed
    #    in the FIRST Entry box to be printed N times on the Console,
    #      where N is the INTEGER that the user typed
    #      in the SECOND Entry box.
    #
    #    If the user fails to enter an integer,
    #    that is a "user error" -- do NOT deal with that.
    #
    # -------------------------------------------------------------------------
    ####################################################################
    # HINT:
    #   You will need to obtain the INTEGER from the STRING
    #   that the GET method returns.
    #   Use the   int   function to do so, as in this example:
    #      s = entry_box.get()
    #      n = int(s)
    ####################################################################
    second_entry = ttk.Entry(main_frame)
    second_entry.grid()
    print_entry = ttk.Button(main_frame, text='Print Entry')
    print_entry.grid()
    print_entry['command'] = (lambda: print_N_times(second_entry,entry_box))
    # -------------------------------------------------------------------------
    # TODO: 8. As time permits, do other interesting GUI things!
    # -------------------------------------------------------------------------
    root.mainloop()
 Constructs a GUI with stuff on it. 
Constructs a GUI with stuff on it.
Constructs a GUI with stuff on it .
def main():
    root = tkinter.Tk()
    root.title("Work Please")
    main_frame = ttk.Frame(root, padding=100, relief='groove')
    main_frame.grid()
    go_forward_button = ttk.Button(main_frame, text='Hello')
    go_forward_button.grid(row = 1, column = 2)
    go_forward_button['command'] = (lambda: print_hello())
    entry_box = ttk.Entry(main_frame)
    entry_box.grid(row = 0, column = 0)
    print_entry_button = ttk.Button(main_frame, text='Print Word')
    print_entry_button.grid()
    print_entry_button['command'] = (lambda:
                                     check_entry_box(entry_box))
        Pressing this new Button causes the STRING that the user typed
        in the FIRST Entry box to be printed N times on the Console,
          where N is the INTEGER that the user typed
          in the SECOND Entry box.
        If the user fails to enter an integer,
        that is a "user error" -- do NOT deal with that.
     HINT:
       You will need to obtain the INTEGER from the STRING
       that the GET method returns.
       Use the   int   function to do so, as in this example:
          s = entry_box.get()
          n = int(s)
    second_entry = ttk.Entry(main_frame)
    second_entry.grid()
    print_entry = ttk.Button(main_frame, text='Print Entry')
    print_entry.grid()
    print_entry['command'] = (lambda: print_N_times(second_entry,entry_box))
     TODO: 8. As time permits, do other interesting GUI things!
    root.mainloop()
def main ( ) : root = tkinter . Tk ( ) root . title ( "Work Please" ) main_frame = ttk . Frame ( root , padding = 100 , relief = 'groove' ) main_frame . grid ( ) go_forward_button = ttk . Button ( main_frame , text = 'Hello' ) go_forward_button . grid ( row = 1 , column = 2 ) go_forward_button [ 'command' ] = ( lambda : print_hello ( ) ) entry_box = ttk . Entry ( main_frame ) entry_box . grid ( row = 0 , column = 0 ) print_entry_button = ttk . Button ( main_frame , text = 'Print Word' ) print_entry_button . grid ( ) print_entry_button [ 'command' ] = ( lambda : check_entry_box ( entry_box ) ) second_entry = ttk . Entry ( main_frame ) second_entry . grid ( ) print_entry = ttk . Button ( main_frame , text = 'Print Entry' ) print_entry . grid ( ) print_entry [ 'command' ] = ( lambda : print_N_times ( second_entry , entry_box ) ) root . mainloop ( )
Constructs a GUI with stuff on it.
Constructs a GUI with stuff on it .
""" Constructs a GUI with stuff on it. """ # ------------------------------------------------------------------------- # Done: 2. After reading and understanding the m1e module, #   ** make a window that shows up. ** # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # Done: 3. After reading and understanding the m2e module, #   ** put a Frame on the window. ** # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # Done: 4. After reading and understanding the m2e module, #   ** put a Button on the Frame. ** # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # Done: 5. After reading and understanding the m3e module, #   ** make your Button respond to a button-press ** #   ** by printing   "Hello"  on the Console.     ** # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # Done: 6. After reading and understanding the m4e module, #   -- Put an Entry box on the Frame. #   -- Put a second Button on the Frame. #   -- Make this new Button, when pressed, print "Hello" #        on the Console if the current string in the Entry box #        is the string 'ok', but print "Goodbye" otherwise. # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # Done: 7. #    -- Put a second Entry on the Frame. #    -- Put a third Button on the frame. #    -- Make this new Button respond to a button-press as follows: # #    Pressing this new Button causes the STRING that the user typed #    in the FIRST Entry box to be printed N times on the Console, #      where N is the INTEGER that the user typed #      in the SECOND Entry box. # #    If the user fails to enter an integer, #    that is a "user error" -- do NOT deal with that. # # ------------------------------------------------------------------------- #################################################################### # HINT: #   You will need to obtain the INTEGER from the STRING #   that the GET method returns. #   Use the   int   function to do so, as in this example: #      s = entry_box.get() #      n = int(s) #################################################################### # ------------------------------------------------------------------------- # TODO: 8. As time permits, do other interesting GUI things! # -------------------------------------------------------------------------