Exemple #1
0
def _create_edit_menu(master: Widget) -> Menu:
    menu = Menu(master, tearoff=0)
    menu.add_command(label="Undo",
                     command=lambda: master.focus_get().edit_undo(),
                     underline=0,
                     accelerator=_KEYS["undo"][0])
    menu.add_command(label="Redo",
                     command=lambda: master.focus_get().edit_redo(),
                     underline=0,
                     accelerator=_KEYS["redo"][0])
    menu.add_separator()
    menu.add_command(
        label="Cut",
        command=lambda: master.focus_get().event_generate("<<Cut>>"),
        underline=2,
        accelerator=_KEYS["cut"][0])
    menu.add_command(
        label="Copy",
        command=lambda: master.focus_get().event_generate("<<Copy>>"),
        underline=0,
        accelerator=_KEYS["copy"][0])
    menu.add_command(
        label="Paste",
        command=lambda: master.focus_get().event_generate("<<Paste>>"),
        underline=0,
        accelerator=_KEYS["paste"][0])
    menu.add_separator()
    menu.add_command(
        label="Delete",
        command=lambda: master.focus_get().delete(SEL_FIRST, SEL_LAST),
        underline=0,
        accelerator=_KEYS["delete"][0])

    def before():
        text = master.focus_get()
        if not isinstance(text, Text):
            for i in 0, 1, 3, 4, 5, 7:
                menu.entryconfigure(i, state=DISABLED)
        else:
            menu.entryconfigure(0, state=_to_state(text.edit("canundo")))
            menu.entryconfigure(1, state=_to_state(text.edit("canredo")))
            has_selection = text.tag_ranges(SEL) != ()
            for i in 3, 4, 7:
                menu.entryconfigure(i, state=_to_state(has_selection))
            try:
                master.clipboard_get()
                menu.entryconfigure(5, state=NORMAL)
            except TclError:
                menu.entryconfigure(5, state=DISABLED)

    menu.configure(postcommand=before)
    return menu
Exemple #2
0
    astr()
    clear_func()


menuarrays = [
    ('File', [('New File', create_new_doc, 'Ctrl+N'), ('separator', '', ''),
              ('Open', open_files, 'Ctrl+O'), ('Save', save_file, 'Ctrl+S'),
              ('Save as', save_as, 'Ctrl+Shift+S'), ('separator', '', ''),
              ('Run', run, 'Ctrl+R'), ('separator', '', ''),
              ('Settings', file, ''), ('Close', exit, 'Ctrl+Q')]),
    ('Run', [('Run', astr, ''), ('Save and Run', savaandrun, 'Ctrl+Shift+A'),
             ('Clear and Run', clearRun, '')]),
]
global menu_bar
menu_bar = Menu(compiler)
menu_bar.configure(font=Font_tuple)
for top, name in menuarrays:
    barname = 'bar_{}'.format(str(name).lower())
    barname = Menu(menu_bar, tearoff=0)
    # barname.add_command(label=name, command=functions)
    for actname, func, acc in name:
        if actname == 'separator':
            barname.add_separator()
        else:
            barname.add_command(label=actname,
                                command=func,
                                accelerator=str(acc))
    menu_bar.add_cascade(label=top, menu=barname)
    # menu_bar.bind_all('<Control-o>', open_files)
menu_bar.add_command(label='Clear Console',
                     command=clear_func,
Exemple #3
0
class BaseWidget(Toplevel):
    def __init__(self, name, master=None, **kw):
        """
        Create a  desktop widget that sticks on the desktop.
        """
        Toplevel.__init__(self, master)
        self.name = name
        if CONFIG.getboolean('General', 'splash_supported', fallback=True):
            self.attributes('-type', 'splash')
        else:
            self.attributes('-type', 'toolbar')

        self.style = Style(self)

        self._position = StringVar(self, CONFIG.get(self.name, 'position'))
        self._position.trace_add(
            'write',
            lambda *x: CONFIG.set(self.name, 'position', self._position.get()))

        self.ewmh = EWMH()
        self.title('scheduler.{}'.format(self.name.lower()))

        self.withdraw()

        # control main menu checkbutton
        self.variable = BooleanVar(self, False)

        # --- menu
        self.menu = Menu(self, relief='sunken', activeborderwidth=0)
        self._populate_menu()

        self.create_content(**kw)

        self.x = None
        self.y = None

        # --- geometry
        geometry = CONFIG.get(self.name, 'geometry')
        self.update_idletasks()
        if geometry:
            self.geometry(geometry)
        self.update_idletasks()

        if CONFIG.getboolean(self.name, 'visible', fallback=True):
            self.show()

        # --- bindings
        self.bind('<Configure>', self._on_configure)

    def create_content(self):
        # to be overriden by subclass
        pass

    def _populate_menu(self):
        self.menu_pos = Menu(self.menu, relief='sunken', activeborderwidth=0)
        self.menu_pos.add_radiobutton(label=_('Normal'),
                                      value='normal',
                                      variable=self._position,
                                      command=self.show)
        self.menu_pos.add_radiobutton(label=_('Above'),
                                      value='above',
                                      variable=self._position,
                                      command=self.show)
        self.menu_pos.add_radiobutton(label=_('Below'),
                                      value='below',
                                      variable=self._position,
                                      command=self.show)
        self.menu.add_cascade(label=_('Position'), menu=self.menu_pos)
        self.menu.add_command(label=_('Hide'), command=self.hide)

    def update_style(self):
        bg = CONFIG.get(self.name, 'background', fallback='grey10')
        fg = CONFIG.get(self.name, 'foreground', fallback='white')
        active_bg = active_color(*self.winfo_rgb(bg))
        self.attributes('-alpha', CONFIG.get(self.name, 'alpha',
                                             fallback=0.85))
        self.configure(bg=bg)
        self.menu.configure(bg=bg,
                            fg=fg,
                            selectcolor=fg,
                            activeforeground=fg,
                            activebackground=active_bg)
        self.menu_pos.configure(bg=bg,
                                fg=fg,
                                selectcolor=fg,
                                activeforeground=fg,
                                activebackground=active_bg)

    def update_position(self):
        if self._position.get() == 'normal':
            if CONFIG.getboolean('General', 'splash_supported', fallback=True):
                self.attributes('-type', 'splash')
            else:
                self.attributes('-type', 'toolbar')
        if self.variable.get():
            self.withdraw()
            self.deiconify()

    def _on_configure(self, event):
        CONFIG.set(self.name, 'geometry', self.geometry())
        save_config()

    def hide(self):
        CONFIG.set(self.name, 'visible', 'False')
        self.variable.set(False)
        save_config()
        self.withdraw()

    def show(self):
        ''' make widget sticky '''
        self.deiconify()
        self.update_idletasks()
        splash_supp = CONFIG.getboolean('General',
                                        'splash_supported',
                                        fallback=True)
        try:
            pos = self._position.get()
            for w in self.ewmh.getClientList():
                if w.get_wm_name() == self.title():
                    if pos == 'above':
                        self.attributes('-type', 'dock')
                        self.ewmh.setWmState(w, 1, '_NET_WM_STATE_ABOVE')
                        self.ewmh.setWmState(w, 0, '_NET_WM_STATE_BELOW')
                        self.ewmh.setWmState(w, 1, '_NET_WM_STATE_STICKY')
                        self.ewmh.setWmState(w, 1,
                                             '_NET_WM_STATE_SKIP_TASKBAR')
                        self.ewmh.setWmState(w, 1, '_NET_WM_STATE_SKIP_PAGER')
                    elif pos == 'below':
                        self.attributes('-type', 'desktop')
                        self.ewmh.setWmState(w, 0, '_NET_WM_STATE_ABOVE')
                        self.ewmh.setWmState(w, 1, '_NET_WM_STATE_BELOW')
                        self.ewmh.setWmState(w, 1, '_NET_WM_STATE_STICKY')
                        self.ewmh.setWmState(w, 1,
                                             '_NET_WM_STATE_SKIP_TASKBAR')
                        self.ewmh.setWmState(w, 1, '_NET_WM_STATE_SKIP_PAGER')
                    else:
                        if splash_supp:
                            self.attributes('-type', 'splash')
                        else:
                            self.attributes('-type', 'toolbar')
                        self.ewmh.setWmState(w, 0, '_NET_WM_STATE_BELOW')
                        self.ewmh.setWmState(w, 0, '_NET_WM_STATE_ABOVE')
                        self.ewmh.setWmState(w, 1, '_NET_WM_STATE_STICKY')
                        self.ewmh.setWmState(w, 1,
                                             '_NET_WM_STATE_SKIP_TASKBAR')
                        self.ewmh.setWmState(w, 1, '_NET_WM_STATE_SKIP_PAGER')
            self.ewmh.display.flush()
            if not splash_supp:
                self.withdraw()
                self.deiconify()
            CONFIG.set(self.name, 'visible', 'True')
            self.variable.set(True)
            save_config()
        except TypeError:
            pass

    def _start_move(self, event):
        self.x = event.x
        self.y = event.y

    def _stop_move(self, event):
        self.x = None
        self.y = None
        self.configure(cursor='arrow')

    def _move(self, event):
        if self.x is not None and self.y is not None:
            self.configure(cursor='fleur')
            deltax = event.x - self.x
            deltay = event.y - self.y
            x = self.winfo_x() + deltax
            y = self.winfo_y() + deltay
            self.geometry("+%s+%s" % (x, y))
Exemple #4
0
    def show(self):


        try:
            cursor.execute("USE tabulationSystemKU")
            cursor.execute("SELECT schoolName,disciplineName from disciplineInfo")
            discipline = cursor.fetchone()
        except pymysql.Error as err:

            print(err)
        if discipline==None:
            discipline = ("", "")
        win = tk.Tk()


        win.state('zoomed')
        win.title('TABULATION SYSTEM KHULNA UNIVERSITY')

        lblfrm=ttk.LabelFrame(win)
        lbl=ttk.Label(lblfrm,text='TABULATION SYSTEM KU',font=('',50))
        lbl.pack()

        schoolLabel =ttk.Label(lblfrm,text = "SCHOOL : "+discipline[0],font =("",50))
        schoolLabel.pack()
        disciplineLabel = ttk.Label(lblfrm,text="DISCIPLINE : "+discipline[1],font = ("",50))
        disciplineLabel.pack()


        lblfrm.pack()

        addcrse=AddCourse()
        addstdnt = NewStudentForm()
        mrksEntry=MarksEntry()



        def addcrsecommand():

            win.destroy()
            addcrse.show()


        def addStdntCmmnd():
            win.destroy()
            addstdnt.show()


        def mrksEntrycmmnd():
            win.destroy()
            mrksEntry.show()


        def loginPagecmmnd():
             win.destroy()
             lgnpage=loginPage.Login()
             lgnpage.show()

        def disciplineFormcommand():
            win.destroy()
            dscipline = disciplineForm.DisciplineFormClass()
            dscipline.show()
        def regisgtrationFormCommand():
            win.destroy()
            registrationObject = registration.Registration()
            registrationObject.show()

        def registrationConfigurationCommad():
            win.destroy()
            registrationConfigurationObject=registrationConfiguration.RegistrationConfiguratinClass()
            registrationConfigurationObject.show()

        def student_wise_show():
            win.destroy()
            student_wise_result =StudentWiseResult()
            student_wise_result.get_info()

        def course_wise_show():
            win.destroy()
            course_wise_result =CourseWiseResult()
            course_wise_result.get_term_data()

        def change_password():
            win.destroy()
            settings =Settings()
            settings.change_password()

        def credit_function():
            win.destroy()
            creditObject =credit.Credit()
            creditObject.show()

        def add_prerequisite():
            win.destroy()
            prerequisiteObject =prerequisite.Prerequisite()
            prerequisiteObject.show()

        def withdraw_courses_function():
            win.destroy()
            obj = withdrawCourse.WithdrawCoures()
            obj.show()


        def closeApplication():
            win.destroy()

        menubar=Menu(win)
        win.config(menu=menubar)

        menubar.add_separator()

        fileMenu=Menu(menubar,tearoff=0)
        fileMenu.add_command(label='Configure Discipline',command=disciplineFormcommand)
        fileMenu.add_separator()
        fileMenu.add_command(label='Add Student',command=addStdntCmmnd)
        fileMenu.add_separator()
        fileMenu.add_command(label='Add Courses',command=addcrsecommand)
        fileMenu.add_separator()
        fileMenu.add_command(label ="Add prerequisites",command  =add_prerequisite)
        fileMenu.add_separator()
        fileMenu.add_command(label='Exit',command=closeApplication)

        menubar.add_cascade(label='File',menu=fileMenu)

        menubar.add_separator()

        editMenu = Menu(menubar,tearoff=0)
        editMenu.add_command(label="Withdraw courses",command = withdraw_courses_function)
        editMenu.add_separator()
        editMenu.add_command(label="Remove prerequisite")
        menubar.add_cascade(label="Edit",menu= editMenu)
        menubar.add_separator()

        reg=Menu(menubar)
        reg.configure(tearoff=0)
        reg.add_command(label='Configure Registration',command=  registrationConfigurationCommad)
        reg.add_separator()
        reg.add_command(label='Registration',command = regisgtrationFormCommand)
        #reg.add_separator()
        #reg.add_command(label='Add commant')

        menubar.add_cascade(label='Registration',menu=reg)

        menubar.add_separator()
        resultMenu=Menu(menubar,tearoff=0)
        resultMenu.add_command(label = 'Marks Entry',command=mrksEntrycmmnd)
        resultMenu.add_separator()
        #resultMenu.add_command(label='Show Result')
        #resultMenu.add_separator()
        #resultMenu.add_command(label='Print Result')

        show_result_submenu = Menu(resultMenu, tearoff=0)
        show_result_submenu.add_command(label="Course wise",command=course_wise_show)
        show_result_submenu.add_separator()
        show_result_submenu.add_command(label="Student wise",command =student_wise_show)
        resultMenu.add_cascade(label ="Show result",menu=show_result_submenu,underline=0)

        submenu1 =Menu(resultMenu,tearoff=0)
        submenu1.add_command(label="Course wise")
        submenu1.add_separator()
        submenu1.add_command(label = "Student wise")
        resultMenu.add_cascade(label='Print result', menu=submenu1, underline=0)

        menubar.add_cascade(label='Result',menu=resultMenu)

        menubar.add_separator()

        helpMenu=Menu(menubar,tearoff=0)

        helpMenu.add_command(label='Help')
        helpMenu.add_separator()
        helpMenu.add_command(label='About Us',command =credit_function)

        menubar.add_cascade(label='Help',menu=helpMenu)

        settings_menu = Menu(menubar,tearoff=0)
        settings_menu.add_command(label="Change password",command=change_password)
        menubar.add_cascade(label ="Settings",menu=settings_menu)

        win.mainloop()
Exemple #5
0
class Pomodoro(BaseWidget):
    """ Chronometre de temps de travail pour plus d'efficacité """
    def __init__(self, master):
        BaseWidget.__init__(self, 'Pomodoro', master)

    def create_content(self, **kw):
        self.minsize(190, 190)

        self.on = False  # is the timer on?

        if not CONFIG.options("Tasks"):
            CONFIG.set("Tasks", _("Work"), CMAP[0])

        self._stats = None

        # --- colors
        self.background = {
            _("Work"): CONFIG.get("Pomodoro", "work_bg"),
            _("Break"): CONFIG.get("Pomodoro", "break_bg"),
            _("Rest"): CONFIG.get("Pomodoro", "rest_bg")
        }
        self.foreground = {
            _("Work"): CONFIG.get("Pomodoro", "work_fg"),
            _("Break"): CONFIG.get("Pomodoro", "break_fg"),
            _("Rest"): CONFIG.get("Pomodoro", "rest_fg")
        }

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

        # nombre de séquence de travail effectuées d'affilée (pour
        # faire des pauses plus longues tous les 4 cycles)
        self.nb_cycles = 0
        self.pomodori = IntVar(self, 0)

        # --- images
        self.im_go = PhotoImage(master=self, file=IM_START)
        self.im_stop = PhotoImage(master=self, file=IM_STOP)
        self.im_tomate = PhotoImage(master=self, file=IM_POMODORO)
        self.im_graph = PhotoImage(master=self, file=IM_GRAPH)

        # --- tasks list
        tasks_frame = Frame(self, style='pomodoro.TFrame')
        tasks_frame.grid(row=3, column=0, columnspan=3, sticky="wnse")
        tasks = [t.capitalize() for t in CONFIG.options("PomodoroTasks")]
        tasks.sort()
        self.task = StringVar(self, tasks[0])
        self.menu_tasks = Menu(tasks_frame,
                               relief='sunken',
                               activeborderwidth=0)
        self.choose_task = Menubutton(tasks_frame,
                                      textvariable=self.task,
                                      menu=self.menu_tasks,
                                      style='pomodoro.TMenubutton')
        Label(tasks_frame,
              text=_("Task: "),
              style='pomodoro.TLabel',
              font="TkDefaultFont 12",
              width=6,
              anchor="e").pack(side="left", padx=4)
        self.choose_task.pack(side="right", fill="x", pady=4)

        # --- display
        self.tps = [CONFIG.getint("Pomodoro", "work_time"),
                    0]  # time: min, sec
        self.activite = StringVar(self, _("Work"))
        self.titre = Label(self,
                           textvariable=self.activite,
                           font='TkDefaultFont 14',
                           style='timer.pomodoro.TLabel',
                           anchor="center")
        self.titre.grid(row=0,
                        column=0,
                        columnspan=2,
                        sticky="we",
                        pady=(4, 0),
                        padx=4)
        self.temps = Label(self,
                           text="{0:02}:{1:02}".format(self.tps[0],
                                                       self.tps[1]),
                           style='timer.pomodoro.TLabel',
                           anchor="center")
        self.temps.grid(row=1, column=0, columnspan=2, sticky="nswe", padx=4)
        self.aff_pomodori = Label(self,
                                  textvariable=self.pomodori,
                                  anchor='e',
                                  padding=(20, 4, 20, 4),
                                  image=self.im_tomate,
                                  compound="left",
                                  style='timer.pomodoro.TLabel',
                                  font='TkDefaultFont 14')
        self.aff_pomodori.grid(row=2, columnspan=2, sticky="ew", padx=4)

        # --- buttons
        self.b_go = Button(self,
                           image=self.im_go,
                           command=self.go,
                           style='pomodoro.TButton')
        self.b_go.grid(row=4, column=0, sticky="ew")
        self.b_stats = Button(self,
                              image=self.im_graph,
                              command=self.display_stats,
                              style='pomodoro.TButton')
        self.b_stats.grid(row=4, column=1, sticky="ew")

        self._corner = Sizegrip(self, style="pomodoro.TSizegrip")
        self._corner.place(relx=1, rely=1, anchor='se')

        # --- bindings
        self.bind('<3>', lambda e: self.menu.tk_popup(e.x_root, e.y_root))
        tasks_frame.bind('<ButtonPress-1>', self._start_move)
        tasks_frame.bind('<ButtonRelease-1>', self._stop_move)
        tasks_frame.bind('<B1-Motion>', self._move)
        self.titre.bind('<ButtonPress-1>', self._start_move)
        self.titre.bind('<ButtonRelease-1>', self._stop_move)
        self.titre.bind('<B1-Motion>', self._move)
        self.temps.bind('<ButtonPress-1>', self._start_move)
        self.temps.bind('<ButtonRelease-1>', self._stop_move)
        self.temps.bind('<B1-Motion>', self._move)
        self.b_stats.bind('<Enter>', self._on_enter)
        self.b_stats.bind('<Leave>', self._on_leave)

    def update_style(self):
        self.menu_tasks.delete(0, 'end')
        tasks = [t.capitalize() for t in CONFIG.options('PomodoroTasks')]
        tasks.sort()
        for task in tasks:
            self.menu_tasks.add_radiobutton(label=task,
                                            value=task,
                                            variable=self.task)
        if self.task.get() not in tasks:
            self.stop(False)
            self.task.set(tasks[0])

        self.attributes('-alpha', CONFIG.get(self.name, 'alpha',
                                             fallback=0.85))
        bg = CONFIG.get('Pomodoro', 'background')
        fg = CONFIG.get('Pomodoro', 'foreground')
        active_bg = active_color(*self.winfo_rgb(bg))
        self.style.configure('pomodoro.TMenubutton',
                             background=bg,
                             relief='flat',
                             foreground=fg,
                             borderwidth=0,
                             arrowcolor=fg)
        self.style.configure('pomodoro.TButton',
                             background=bg,
                             relief='flat',
                             foreground=fg,
                             borderwidth=0)
        self.style.configure('pomodoro.TLabel', background=bg, foreground=fg)
        self.style.configure('pomodoro.TFrame', background=bg)
        self.style.configure('pomodoro.TSizegrip', background=bg)
        self.style.map('pomodoro.TSizegrip',
                       background=[('active', active_bg)])
        self.style.map('pomodoro.TButton',
                       background=[('disabled', bg),
                                   ('!disabled', 'active', active_bg)])
        self.style.map('pomodoro.TMenubutton',
                       background=[('disabled', bg),
                                   ('!disabled', 'active', active_bg)])
        self.configure(bg=bg)
        self.menu.configure(bg=bg,
                            fg=fg,
                            selectcolor=fg,
                            activeforeground=fg,
                            activebackground=active_bg)
        self.menu_pos.configure(bg=bg,
                                fg=fg,
                                selectcolor=fg,
                                activeforeground=fg,
                                activebackground=active_bg)
        self.menu_tasks.configure(bg=bg,
                                  activebackground=active_bg,
                                  fg=fg,
                                  selectcolor=fg,
                                  activeforeground=fg)
        self.background = {
            _("Work"): CONFIG.get("Pomodoro", "work_bg"),
            _("Break"): CONFIG.get("Pomodoro", "break_bg"),
            _("Rest"): CONFIG.get("Pomodoro", "rest_bg")
        }
        self.foreground = {
            _("Work"): CONFIG.get("Pomodoro", "work_fg"),
            _("Break"): CONFIG.get("Pomodoro", "break_fg"),
            _("Rest"): CONFIG.get("Pomodoro", "rest_fg")
        }
        act = self.activite.get()
        self.style.configure('timer.pomodoro.TLabel',
                             font=CONFIG.get("Pomodoro", "font"),
                             foreground=self.foreground[act],
                             background=self.background[act])

    def _on_enter(self, event=None):
        self._corner.state(('active', ))

    def _on_leave(self, event=None):
        self._corner.state(('!active', ))

    def _start_move(self, event):
        self.x = event.x
        self.y = event.y

    def _stop_move(self, event):
        self.x = None
        self.y = None
        self.configure(cursor='arrow')

    def _move(self, event):
        if self.x is not None and self.y is not None:
            self.configure(cursor='fleur')
            deltax = event.x - self.x
            deltay = event.y - self.y
            x = self.winfo_x() + deltax
            y = self.winfo_y() + deltay
            self.geometry("+%s+%s" % (x, y))

    def hide(self):
        if self._stats is not None:
            self._stats.destroy()
        BaseWidget.hide(self)

    def stats(self, time=None):
        """Save stats."""
        if time is None:
            time = CONFIG.getint("Pomodoro", "work_time")
        today = dt.date.today().toordinal()
        task = self.task.get().lower().replace(' ', '_')
        db = sqlite3.connect(PATH_STATS)
        cursor = db.cursor()
        try:
            cursor.execute('SELECT * FROM {} ORDER BY id DESC LIMIT 1'.format(
                scrub(task)))
            key, date, work = cursor.fetchone()
        except sqlite3.OperationalError:
            cursor.execute('''CREATE TABLE {} (id INTEGER PRIMARY KEY,
                                               date INTEGER,
                                               work INTEGER)'''.format(
                scrub(task)))
            cursor.execute(
                'INSERT INTO {}(date, work) VALUES (?, ?)'.format(scrub(task)),
                (today, time))
        else:
            if today != date:
                cursor.execute(
                    'INSERT INTO {}(date, work) VALUES (?, ?)'.format(
                        scrub(task)), (today, time))
            else:  # update day's value
                cursor.execute(
                    'UPDATE {} SET work=? WHERE id=?'.format(scrub(task)),
                    (work + time, key))
        finally:
            db.commit()
            db.close()

    def display_stats(self):
        """ affiche les statistiques """
        if self._stats is None:
            self._stats = Stats(self)
            self._stats.bind('<Destroy>', self._on_close_stats)
        else:
            self._stats.lift()

    def _on_close_stats(self, event):
        self._stats = None

    def go(self):
        if self.on:
            self.stop()
        else:
            self.on = True
            self.choose_task.state(["disabled"])
            self.b_go.configure(image=self.im_stop)
            self.after(1000, self.affiche)
            logging.info('Start work cycle for task ' + self.task.get())

    def stop(self, confirmation=True):
        """ Arrête le décompte du temps et le réinitialise,
            demande une confirmation avant de le faire si confirmation=True """
        tps = int(
            CONFIG.getint("Pomodoro", "work_time") - self.tps[0] -
            self.tps[1] / 60)
        self.on = False
        rep = True
        if confirmation:
            rep = askyesno(
                title=_("Confirmation"),
                message=_(
                    "Are you sure you want to give up the current session?"))
        if rep:
            self.choose_task.state(["!disabled"])
            self.b_go.configure(image=self.im_go)
            if self.activite.get() == _("Work"):
                self.stats(tps)
            self.pomodori.set(0)
            self.nb_cycles = 0
            self.tps = [CONFIG.getint("Pomodoro", "work_time"), 0]
            self.temps.configure(
                text="{0:02}:{1:02}".format(self.tps[0], self.tps[1]))
            act = _("Work")
            self.activite.set(act)
            self.style.configure('timer.pomodoro.TLabel',
                                 background=self.background[act],
                                 foreground=self.foreground[act])
            logging.info('Pomodoro session interrupted.')
        else:
            self.on = True
            self.affiche()
        return rep

    @staticmethod
    def ting():
        """ joue le son marquant le changement de période """
        if not CONFIG.getboolean("Pomodoro", "mute", fallback=False):
            Popen([
                CONFIG.get("General", "soundplayer"),
                CONFIG.get("Pomodoro", "beep")
            ])

    def affiche(self):
        if self.on:
            self.tps[1] -= 1
            if self.tps[1] == 0:
                if self.tps[0] == 0:
                    self.ting()
                    if self.activite.get() == _("Work"):
                        self.pomodori.set(self.pomodori.get() + 1)
                        self.nb_cycles += 1
                        self.choose_task.state(["!disabled"])
                        logging.info(
                            'Pomodoro: completed work session for task ' +
                            self.task.get())
                        if self.nb_cycles % 4 == 0:
                            # pause longue
                            self.stats()
                            self.activite.set(_("Rest"))
                            self.tps = [
                                CONFIG.getint("Pomodoro", "rest_time"), 0
                            ]
                        else:
                            # pause courte
                            self.stats()
                            self.activite.set(_("Break"))
                            self.tps = [
                                CONFIG.getint("Pomodoro", "break_time"), 0
                            ]
                    else:
                        self.choose_task.state(["disabled"])
                        self.activite.set(_("Work"))
                        self.tps = [CONFIG.getint("Pomodoro", "work_time"), 0]
                    act = self.activite.get()
                    self.style.configure('timer.pomodoro.TLabel',
                                         background=self.background[act],
                                         foreground=self.foreground[act])
            elif self.tps[1] == -1:
                self.tps[0] -= 1
                self.tps[1] = 59
            self.temps.configure(text="{0:02}:{1:02}".format(*self.tps))
            self.after(1000, self.affiche)
Exemple #6
0
    def create_widgets(self):
        '''
        Long method to create all widgets on the root window
        '''

        # Creating a Menu Bar

        menu_bar = Menu(root)
        root.config(menu=menu_bar)
        menu_bar.config(background = background, foreground = text_color)
        # Code for the cascading File menu
        file_menu = Menu(menu_bar, tearoff=0)
        file_menu.add_command(label='New   Ctrl+n', command=self._new)
        file_menu.add_separator()
        file_menu.add_command(label='Save  Ctrl+s', command=self._save)
        file_menu.add_separator()
        file_menu.add_command(label='Quit  Ctrl+q', command=self._quit)
        file_menu.configure(background = background, foreground = text_color)
        menu_bar.add_cascade(label='File', menu=file_menu)

        # Code for cascading config menu

        config_menu = Menu(menu_bar, tearoff=0)
        config_menu.add_command(label='Set Default Save Path', command=DefaultPath)
        config_menu.add_separator()
        config_menu.add_command(label='Use Bullet Points (' + use_bp + ')', command=SetBulletPoints)
        config_menu.add_separator()
        config_menu.add_command(label='Format Filename (' + fn_format + ')', command=FilenameFormat)
        config_menu.configure(background = background, foreground = text_color)
        config_menu.add_separator()
        config_menu.add_command(label='Use Dark Mode (' + dark_mode + ')', command=UseDarkMode)
        config_menu.configure(background = background, foreground = text_color)
        menu_bar.add_cascade(label='Config', menu=config_menu)

        # Code for the cascading Help menu
        help_menu = Menu(menu_bar, tearoff=0)
        help_menu.add_command(label='Program Help  Ctrl+h', command=HelpWindow)
        help_menu.add_separator()
        help_menu.add_command(label='About', command=AboutWindow)
        help_menu.configure(background = background, foreground = text_color)
        menu_bar.add_cascade(label='Help', menu=help_menu)

        # Top frame for the recipe name entry
        nameLabel = ttk.Label(foreground=label_text, background=label_bg, text=' Enter Recipe Title')
        self.title_frame = ttk.LabelFrame(self.frame, labelwidget=nameLabel)
        self.title_frame.grid(column=0, row=0, columnspan=2, padx=8, pady=4, sticky='W')

        # Left frame for the ingredients list
        ingLabel = ttk.Label(foreground=label_text, background=label_bg, text=' Ingreidents')
        self.ing_frame = ttk.LabelFrame(self.frame, labelwidget=ingLabel)
        self.ing_frame.grid(column=0, row=1, padx=8, pady=4, sticky = 'news')
        self.ing_frame.rowconfigure(0, weight = 1)
        self.ing_frame.columnconfigure(0, weight = 1)

        # Right frame for the directions
        dirLabel = ttk.Label(foreground=label_text, background=label_bg, text=' Directions')
        self.dir_frame = ttk.LabelFrame(self.frame, labelwidget=dirLabel)
        self.dir_frame.grid(column=1, row=1, padx=8, pady=4, sticky='nwes')
        self.dir_frame.rowconfigure(0, weight = 1)
        self.dir_frame.columnconfigure(0, weight = 1)

        # Adding a text box entry widget for the recipe title
        self.title = tk.StringVar()
        self.title_entered = tk.Entry(self.title_frame, width=75, textvariable=self.title,
                                      bd=5, relief=tk.RIDGE)
        self.title_entered.configure(background = entry_bg, foreground = entry_text, insertbackground='white')
        self.title_entered.grid(column=0, row=2, padx=8, pady=(3, 8), sticky='W')
        self.title_entered.bind("<Tab>", self.focus_next_widget)
        tt.create_ToolTip(self.title_entered, 'Enter the title of the recipe here')

        # Add a scroll box for ingredients
        self.ingredients = scrolledtext.ScrolledText(self.ing_frame, width = 30, bd=5,\
                wrap=tk.WORD, relief=tk.RIDGE)
        self.ingredients.configure(background = entry_bg, foreground = entry_text, insertbackground='white')
        self.ingredients.vbar.configure(troughcolor = scroll_color, background = scroll_bg, activebackground = scrollbar_color)
        self.ingredients.grid(column=0, row=0, padx=8, pady=(0, 20), sticky=tk.N+tk.S+tk.E+tk.W)
        self.ingredients.bind("<Tab>", self.focus_next_widget)
        tt.create_ToolTip(self.ingredients, 'Enter ingredients here, one per line\nBegin line with a period to omit bullet point')

        # Add a scroll text box for directions
        self.directions = scrolledtext.ScrolledText(self.dir_frame, bd=5,\
                wrap=tk.WORD, relief=tk.RIDGE)
        self.directions.configure(background = entry_bg, foreground = entry_text, insertbackground='white')
        self.directions.vbar.configure(troughcolor = scroll_color, background = scroll_bg, activebackground = scrollbar_color)
        self.directions.grid(column=0, row=0, padx=8, pady=(0, 20), sticky=tk.N+tk.S+tk.E+tk.W)
        self.directions.bind("<Tab>", self.focus_next_widget)
        tt.create_ToolTip(self.directions, 'Enter the recipe instructions here')

        self.title_entered.focus()  # Place cursor into the title entry box
Exemple #7
0
class EditorNotebook(Notebook):
    def __init__(self, master, **kw):
        Notebook.__init__(self, master, **kw)
        self._closecommand = self.close
        self.files = {}  # tab: file_path
        self.wrapper = TooltipNotebookWrapper(self)
        self.last_closed = []
        self.menu = Menu(self, tearoff=False)
        self.menu.add_command(label='Set Console working directory',
                              command=self.set_console_wdir)
        self.menu.add_separator()
        self.menu.add_command(label='Close all other tabs',
                              command=self.close_other_tabs)
        self.menu.add_command(label='Close tabs to the right',
                              command=self.close_tabs_right)
        self.menu.add_command(label='Close tabs to the left',
                              command=self.close_tabs_left)
        self._files_mtime = {}  # file_path: mtime
        self._files_check_deletion = {}  # file_path: bool

    def _popup_menu(self, event, tab):
        self._show(tab)
        if self.menu is not None:
            self.menu.tk_popup(event.x_root, event.y_root)

    def _check_modif(self, tab):
        """Check if file has been modified outside PyTkEditor."""
        file = self.files[tab]
        try:
            mtime = os.stat(file).st_mtime
            if mtime > self._files_mtime[tab]:
                # the file has been modified
                logging.info(f'{file} has been modified')
                self.edit_modified(True, tab=tab, generate=True)
                self.update_idletasks()
                ans = askoptions(
                    'Warning',
                    f'{file} has been modified outside PyTkEditor. What do you want to do?',
                    self, 'warning', 'Reload', 'Overwrite', 'Cancel')
                if ans == 'Reload':
                    self.select(tab)
                    self.event_generate('<<Reload>>')
                elif ans == 'Overwrite':
                    self.save(tab=tab)
                    self.edit_modified(False, tab=tab, generate=True)
                self._files_mtime[tab] = os.stat(file).st_mtime
        except (FileNotFoundError, NotADirectoryError):
            # the file has been deleted
            try:
                if self._files_check_deletion[tab]:
                    logging.info(f'{file} has been deleted')
                    self.edit_modified(True, tab=tab, generate=True)
                    self.update_idletasks()
                    ans = askoptions(
                        'Warning',
                        f'{file} has been deleted. What do you want to do?',
                        self, 'warning', 'Save', 'Close', 'Cancel')
                    if ans == 'Save':
                        self.save(tab=tab)
                        self.edit_modified(False, tab=tab, generate=True)
                        self._files_check_deletion[tab] = True
                    elif ans == 'Close':
                        self._close(tab)
                    else:
                        self._files_check_deletion[tab] = False
            except KeyError:
                # the file does not exist yet
                return

    def _menu_insert(self, tab, text):
        label = '{} - {}'.format(text, self.files.get(tab, ''))
        menu = []
        for t in self._tabs.keys():
            menu.append((self.tab(t, 'text'), t))
        menu.sort()
        ind = menu.index((text, tab))
        self._tab_menu.insert_radiobutton(ind,
                                          label=label,
                                          variable=self._tab_var,
                                          value=tab,
                                          command=lambda t=tab: self._show(t))
        for i, (text, tab) in enumerate(menu):
            self._tab_menu_entries[tab] = i

    def get_open_files(self):
        return [self.files[tab] for tab in self._visible_tabs]

    @property
    def filename(self):
        return self.tab(self.current_tab, 'text')

    def update_style(self):
        for editor in self._tabs.values():
            editor.update_style()

        fg = self.menu.option_get('foreground', '*Menu')
        bg = self.menu.option_get('background', '*Menu')
        activebackground = self.menu.option_get('activeBackground', '*Menu')
        disabledforeground = self.menu.option_get('disabledForeground',
                                                  '*Menu')
        self.menu.configure(bg=bg,
                            activebackground=activebackground,
                            fg=fg,
                            selectcolor=fg,
                            activeforeground=fg,
                            disabledforeground=disabledforeground)
        self._tab_menu.configure(bg=bg,
                                 activebackground=activebackground,
                                 fg=fg,
                                 selectcolor=fg,
                                 activeforeground=fg,
                                 disabledforeground=disabledforeground)
        self._canvas.configure(
            bg=self._canvas.option_get('background', '*Canvas'))

    # --- undo / redo
    def undo(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].undo()

    def redo(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].redo()

    # --- cut / copy / paste
    def cut(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].event_generate("<Control-x>")

    def copy(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].event_generate("<Control-c>")

    def paste(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].event_generate("<Control-v>")

    # --- edit
    def insert(self, index, text, tab=None):
        if tab is None:
            tab = self.current_tab
        if tab >= 0:
            self._tabs[tab].insert(index, text)

    def delete(self, index1, index2=None, tab=None):
        if tab is None:
            tab = self.current_tab
        if tab >= 0:
            self._tabs[tab].delete(index1, index2)

    def edit_reset(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].text.edit_reset()

    def edit_modified(self, *args, widget=None, generate=False, tab=None):
        if widget is None:
            if tab is None:
                tab = self.current_tab
            widget = self._tabs[tab]
        else:
            tab = self.index(widget)
        widget.text.edit_modified(*args)
        b = widget.text.edit_modified()
        title = self._tab_labels[tab].tab_cget('text').strip('*')
        # self._tab_labels[tab].tab_configure(text=title + '*' * b)
        self.tab(tab, text=title + '*' * b)
        if generate:
            self.event_generate('<<Modified>>')
        return b

    def delete_lines(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].delete_lines()

    def duplicate_lines(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].duplicate_lines()

    # --- filetype
    def get_filetype(self):
        if self.current_tab >= 0:
            return self._tabs[self.current_tab].filetype

    def set_filetype(self, filetype):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].filetype = filetype
            self.event_generate('<<FiletypeChanged>>')

    def set_console_wdir(self):
        self.event_generate('<<SetConsoleWDir>>')

    # --- formatting
    def toggle_comment(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].toggle_comment()

    def upper_case(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].upper_case()

    def lower_case(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].lower_case()

    def set_cells(self, cells):
        self._tabs[self.current_tab].set_cells(cells)

    # --- indent
    def indent(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].on_tab(force_indent=True)

    def unindent(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].unindent()

    # --- select
    def select(self, tab_id=None):
        res = Notebook.select(self, tab_id)
        tab = self.current_tab
        if tab >= 0:
            self._tabs[tab].focus_set()
        return res

    def select_all(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].select_all()

    def focus_tab(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].text.focus_set()

    # --- find / replace
    def find(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].find()

    def find_all(self, pattern, case_sensitive, regexp, full_word):
        options = {
            'regexp': regexp,
            'nocase': not case_sensitive,
            'stopindex': 'end'
        }

        if full_word:
            pattern = r'\y%s\y' % pattern
            options['regexp'] = True
        results = {}
        for tab in self._visible_tabs:
            path = self.files[tab]
            name = self.tab(tab, 'text')
            results[tab] = f"{name} - {path}", self._tabs[tab].find_all(
                pattern, options)

        return results

    def replace(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].replace()

    def replace_all(self, pattern, new_text, replacements):
        try:
            for tab, matches in replacements.items():
                for start, end in reversed(matches):
                    self._tabs[tab].replace_text(start, end, pattern, new_text)
                self._tabs[tab].update_nb_line()
                self._tabs[tab].parse_all()
        except re.error as e:
            showerror("Error", f"Replacement error: {e.msg}", parent=self)

    # --- syntax check
    def show_syntax_issues(self, results):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].show_syntax_issues(results)

    def get_syntax_issues(self):
        if self.current_tab >= 0:
            return self._tabs[self.current_tab].syntax_issues_menuentries
        else:
            return []

    # --- get
    def get(self, tab=None, strip=True):
        if tab is None:
            tab = self.current_tab
        return self._tabs[tab].get(strip)

    def get_selection(self):
        if self._current_tab < 0:
            return ''
        sel = self._tabs[self._current_tab].text.tag_ranges('sel')
        if sel:
            return self._tabs[self._current_tab].text.get(
                'sel.first', 'sel.last')
        else:
            return ''

    def get_cell(self, goto_next=False):
        if self._current_tab >= 0:
            return self._tabs[self._current_tab].get_cell(goto_next)
        else:
            return ''

    def get_last_closed(self):
        if self.last_closed:
            return self.last_closed.pop()

    def get_docstring(self, obj):
        if self.current_tab >= 0:
            return self._tabs[self.current_tab].get_docstring(obj)
        else:
            return ("", "")

    # --- close
    def _close(self, tab):
        """Close a tab."""
        self.wrapper.remove_tooltip(self._tab_labels[tab])
        ed = self._tabs[tab]
        if self.files[tab]:
            self.last_closed.append(self.files[tab])
        try:
            del self._files_check_deletion[tab]
            del self._files_mtime[tab]
        except KeyError:
            pass
        del self.files[tab]
        self.forget(tab)
        if not self._visible_tabs:
            self.event_generate('<<NotebookEmpty>>')
        ed.destroy()

    def close(self, tab):
        """Close tab and ask before dropping modifications."""
        rep = False
        if self.edit_modified(widget=self._tabs[tab]):
            rep = askyesnocancel(
                'Confirmation',
                'The file %r has been modified. Do you want to save it?' %
                self.files[tab])
        if rep:
            self.save(tab)
        elif rep is None:
            return False
        self._close(tab)
        return True

    def closeall(self, event=None):
        """Close all tabs."""
        b = True
        tabs = self.tabs()
        i = 0
        while b and i < len(tabs):
            b = self.close(tabs[i])
            i += 1
        return b

    def close_other_tabs(self):
        """Close all tabs except current one."""
        for tab in self.tabs():
            if tab != self.current_tab:
                self.close(tab)

    def close_tabs_right(self):
        """Close all tabs on the right of current one."""
        ind = self._visible_tabs.index(self.current_tab)
        for tab in self._visible_tabs[ind + 1:]:
            self.close(tab)

    def close_tabs_left(self):
        """Close all tabs on the left of current one."""
        ind = self._visible_tabs.index(self.current_tab)
        for tab in self._visible_tabs[:ind]:
            self.close(tab)

    # --- save
    def save(self, tab=None, force=False):
        if tab is None:
            tab = self.current_tab
        if tab < 0:
            return False
        if not self.files[tab]:
            res = self.saveas(tab)
        else:
            if force or self.edit_modified(tab=tab):
                file = self.files[tab]
                try:
                    with open(file, 'w') as f:
                        f.write(self.get(tab))
                except PermissionError as e:
                    showerror("Error",
                              f"PermissionError: {e.strerror}: {file}",
                              parent=self)
                self._files_mtime[tab] = os.stat(file).st_mtime
                self._files_check_deletion[tab] = True
                res = True
            else:
                res = True
        return res

    def saveas(self, tab=None, name=None):
        if tab is None:
            tab = self.current_tab
        if name is None:
            file = self.files.get(tab, '')
            if file:
                initialdir, initialfile = os.path.split(file)
            else:
                initialdir, initialfile = '', 'new.py'
            name = asksaveasfilename(self,
                                     initialfile=initialfile,
                                     initialdir=initialdir,
                                     defaultext='.py',
                                     filetypes=[('Python', '*.py'),
                                                ('All files', '*')])
        if name:
            if self.files[tab]:
                self._files_check_deletion[tab] = False
            self.files[tab] = name
            self._tabs[tab].file = name
            self.tab(tab, text=os.path.split(name)[1])
            self.wrapper.set_tooltip_text(tab, os.path.abspath(name))
            self.save(tab, force=True)
            self._files_check_deletion[tab] = True
            return True
        else:
            return False

    # --- goto
    def goto_line(self):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].goto_line()

    def goto_start(self):
        if self._current_tab >= 0:
            self._tabs[self._current_tab].text.mark_set('insert', '1.0')
            self._tabs[self._current_tab].see('1.0')

    def goto_item(self, *args):
        if self.current_tab >= 0:
            self._tabs[self.current_tab].goto_item(*args)

    # --- misc
    def run(self, interactive=True):
        """Run file in external console"""
        if self.current_tab >= 0:
            file = self.files[self.current_tab]
            if file:
                filename = os.path.join(
                    os.path.dirname(os.path.dirname(__file__)), 'utils',
                    'console.py')
                external_console = CONFIG.get('Run',
                                              'external_console',
                                              fallback='').split()
                try:

                    Popen(external_console +
                          [f"python {filename} {file} {interactive}"])
                except Exception:
                    showerror(
                        "Error",
                        "PyTkEditor failed to run the file, please check \
the external terminal configuration in the settings.",
                        parent=self)

    def new(self, file=None):
        if file is None:
            new_files = [-1]
            pattern = re.compile(r"^new(\d+).py - $")
            for i in self._tab_menu_entries.values():
                name = self._tab_menu.entrycget(i, 'label')
                match = pattern.search(name)
                if match:
                    new_files.append(int(match.groups()[0]))
            title = f'new{max(new_files) + 1}.py'
            file = ''
        else:
            title = os.path.split(file)[-1]

        editor = Editor(self, 'Python' if title.endswith('.py') else 'Text')
        if len(self._visible_tabs) == 0:
            self.event_generate('<<NotebookFirstTab>>')
        tab = self.add(editor, text=title)
        editor.bind('<FocusIn>', lambda e: self._check_modif(tab))
        if file in self.last_closed:
            self.last_closed.remove(file)
        self.files[tab] = file
        if file:
            self._files_mtime[tab] = os.stat(file).st_mtime
            self._files_check_deletion[tab] = True

        self._tab_menu.entryconfigure(self._tab_menu_entries[tab],
                                      label="{} - {}".format(
                                          title, os.path.dirname(file)))
        self._tabs[tab].file = file
        self.wrapper.add_tooltip(tab, file if file else title)
        editor.text.bind(
            '<<Modified>>',
            lambda e: self.edit_modified(widget=editor, generate=True))
        editor.text.bind('<Control-Tab>', self._select_next)
        editor.text.bind('<Shift-Control-ISO_Left_Tab>', self._select_prev)
        editor.busy(False)

    def _select_next(self, event):
        self.select_next(True)
        return "break"

    def _select_prev(self, event):
        self.select_prev(True)
        return "break"

    def file_switch(self, event=None):
        def ok(event):
            file = c.get()
            if file not in files:
                top.destroy()
            else:
                self.select(list(self.files.keys())[files.index(file)])
                top.destroy()

        def sel(event):
            self.select(list(self.files.keys())[files.index(c.get())])
            self.after(2, c.entry.focus_set)

        top = Toplevel(self)
        top.geometry('+%i+%i' % self.winfo_pointerxy())
        top.transient(self)
        top.title('File switcher')
        top.grab_set()

        files = [
            "{1} - {0}".format(*os.path.split(file))
            for file in self.files.values()
        ]
        c = AutoCompleteEntryListbox(top,
                                     completevalues=sorted(files),
                                     width=60)
        c.pack(fill='both', expand=True)
        c.entry.bind('<Escape>', lambda e: top.destroy())
        c.listbox.bind('<Escape>', lambda e: top.destroy())
        c.entry.bind('<Return>', ok)
        c.listbox.bind('<Return>', ok)
        c.bind('<<ItemSelect>>', sel)
        c.focus_set()
        return "break"

    def choose_color(self):
        tab = self.current_tab
        if tab >= 0:
            self._tabs[self.current_tab].choose_color()
Exemple #8
0
def deep_dream_tk_gui():
    # toolbar functions ********************
    # column one, 'File' ******************
    def load_image():
        file_to_open = filedialog.askopenfile()
        image = PIL.Image.open(file_to_open.name)
        print(file_to_open.name)

    def tb_new():
        messagebox.showinfo(title="Deep-Dream GUI",
                            message='Still working on it.')

    def save_image():

        print(messagebox.askyesno(title='Hungry?',
                                  message='Do you want SPAM?'))
        messagebox.showinfo(title="Deep-Dream GUI",
                            message='Still working on it.')

    def tb_open():
        file_to_open = filedialog.askopenfile()
        print(file_to_open.name)

    def close_application():
        exit()

    # column two, 'Edit' ******************
    def tb_undo():
        messagebox.showinfo(title="Deep-Dream GUI",
                            message='Still working on it.')

    def tb_redo():
        messagebox.showinfo(title="Deep-Dream GUI",
                            message='Still working on it.')

    root = Tk()
    root.geometry('450x450+100+200')
    root.title('Deep-Dream GUI')
    toolbar = Menu(root)
    root.config(menu=toolbar)
    # Toolbar Column One ******************************************************
    subMenu1 = Menu(toolbar)
    toolbar.add_cascade(label='File', menu=subMenu1)
    subMenu1.configure(background='whitesmoke')
    # Column One Options
    subMenu1.add_command(label='Load Image', command=load_image)
    subMenu1.add_command(label='Save Image', command=save_image)
    subMenu1.add_separator()
    subMenu1.add_command(label='Exit', command=close_application)

    # Deep Dream Options Interface ****************************************************
    load_img_button = Button(root,
                             text='Load Image',
                             fg='black',
                             bg='silver',
                             command=load_image).pack()
    dd_label_1 = Label(root, text='Choose a layer').pack()
    layer = StringVar()
    combobox = ttk.Combobox(root, textvariable=layer)
    combobox.pack()
    combobox.config(values=('conv2d1', 'conv2d2', 'mixed3a', 'mixed3b',
                            'mixed4a', 'mixed4b', 'mixed4c', 'mixed4d',
                            'mixed4e', 'mixed5a', 'mixed5b'))

    dd_label_2 = Label(root, text='Choose Iteration Level').pack()
    iterations = StringVar()
    Spinbox(root, from_=1, to=33, textvariable=iterations).pack()

    dd_label_2 = Label(root, text='Choose Repeat Level').pack()
    repeats = StringVar()
    Spinbox(root, from_=1, to=12, textvariable=repeats).pack()

    dd_button = Button(root, text='Deep Dream', fg='black', bg='silver').pack()

    root.mainloop()