Exemplo n.º 1
0
 def cancel(self):
     tab_text = self.tab.get_text()
     if tab_text != None:
         db = Database.instance()
         tab_text.text.configure(font=db.global_font)
     self.canvas1.grab_release()
     self.canvas1.destroy()
Exemplo n.º 2
0
 def change_dropdown(self, *args):
     db = Database.instance()
     tab_text = self.tab.get_text()
     if tab_text == None: return
     self.new_font = self.tkvar.get()
     font = self.new_font + " " + self.font_size.get()
     tab_text.text.configure(font=font)
Exemplo n.º 3
0
 def change_dropdown(self, *args):
     db = Database.instance()
     db.instance().actual_proj = self.tkvar.get()
     self.event_generate("<<ProjChange>>", when="tail")
     if self.top_level == False:
         tab_text = self.tab.get_text()
         if tab_text == None: return
         tab_text.highlight(None)
Exemplo n.º 4
0
    def btn_apply(self):
        db = Database.instance()
        db.delete_proj(db.instance().actual_proj)

        for patern, color in self.text_frame.data.items():
            db.add_item(db.instance().actual_proj, patern, color)

        self.btn_end()
Exemplo n.º 5
0
    def reset_dropdown(self):
        db = Database.instance()
        menu = self["menu"]
        menu.delete(0, "end")
        for string in list(tkFont.families()):
            menu.add_command(label=string,
                             command=lambda value=string:
                                  self.tkvar.set(value))

        self.tkvar.set(db.global_font.split(" ")[0])
Exemplo n.º 6
0
    def init_text(self, event):
        self.text.configure(state='normal')
        db = Database.instance()
        self.text.delete('1.0', 'end')
        self.data.clear()

        for pattern in db.get_keys():
            self.data[pattern] = db.get_value(pattern)
            self.text.insert('end', pattern + "\n")
        self.update_text()
Exemplo n.º 7
0
 def __init__(self, tab, frame, tkvar, top_level=False):
     ttk.OptionMenu.__init__(self, frame, tkvar, ())
     self.tab = tab
     self.frame = frame
     self.tkvar = tkvar
     self.top_level = top_level
     db = Database.instance()
     self.tkvar.trace('w', self.change_dropdown)
     self.reset_dropdown()
     self.tkvar.set(db.instance().actual_proj)
Exemplo n.º 8
0
    def apply_font(self):
        tab_text = self.tab.get_text()
        if tab_text != None:
            new_font = self.popupMenu.get_font() + " " + self.font_size.get()
            tab_text.text.configure(font=new_font)

            db = Database.instance()
            db.global_font = new_font

        self.canvas1.grab_release()
        self.canvas1.destroy()
Exemplo n.º 9
0
 def reset_dropdown(self):
     db = Database.instance()
     menu = self["menu"]
     menu.delete(0, "end")
     for string in db.get_projects():
         menu.add_command(
             label=string,
             command=lambda value=string: self.tkvar.set(value))
     self.tkvar.set(db.instance().actual_proj)
     if self.top_level == False:
         self.after(3000, self.reset_dropdown)
Exemplo n.º 10
0
 def del_proj(self):
     proj = self.entry_project.get()
     db = Database.instance()
     if proj != "" and proj != None:
         db.delete_proj(proj)
         StatusBar().set("project deleted with success")
     else:
         if db.instance().actual_proj != "None" and db.instance(
         ).actual_proj != None:
             db.delete_proj(db.instance().actual_proj)
             StatusBar().set("project deleted with success")
         else:
             StatusBar().set(
                 "aborted - select a project or a new project name")
Exemplo n.º 11
0
    def highlight(self, event):
        self.clean_highlight()

        lastline = self.text.index("end").split(".")[0]
        for i in range(1, int(lastline)):
            contents = self.text.get("%s.0" % i, "%s.end" % i)
            db = Database.instance()
            for pattern in db.get_keys():
                x = re.search(pattern, contents)
                if (x != None):
                    self.text.tag_configure("ptrn-" + pattern,
                                            background=db.get_value(pattern))
                    self.text.tag_add("ptrn-" + pattern, "%s.0" % i,
                                      "%s.end" % i)
Exemplo n.º 12
0
    def find_prev(self, edit):
        db = Database.instance()
        tab_text = self.tab.get_text().text
        if tab_text == None: return
        edit_txt = edit.get()

        if edit_txt =="":
            return

        if db.actual_pos == '0.0':
            db.actual_pos = tk.END

        idx = tab_text.search(edit_txt, db.actual_pos, backwards=True, nocase=1, stopindex='1.0')
        if idx:
            db.actual_pos = '%s-%dc' % (idx, len(edit_txt))
            tab_text.see(db.actual_pos)
Exemplo n.º 13
0
    def add_proj(self):
        proj = self.entry_project.get()
        db = Database.instance()
        if proj != "" and proj != None:
            db.add_item(proj, "None", "#ccc")
            StatusBar().set("project added with success")
        else:
            if db.instance().actual_proj != "None" and db.instance(
            ).actual_proj != None:
                db.add_item(db.instance().actual_proj, "None", "#ccc")
                StatusBar().set("project added with success")
            else:
                StatusBar().set(
                    "aborted - select a project or a new project name")

        self.canvas1.grab_release()
        self.canvas1.destroy()
Exemplo n.º 14
0
    def edit_font(self):
        db = Database.instance()
        tab_text = self.tab.get_text()
        if tab_text == None:
            StatusBar().set("aborted - aba not found")
            return
        db.global_font = tab_text.text["font"] + tab_text.text["font"]

        tkvar = tk.StringVar(self.root)
        self.font_size = tk.StringVar(value =db.global_font.split(" ")[1])

        self.canvas1 = tk.Toplevel(self.root)
        self.canvas1.geometry('250x150')
        self.canvas1.minsize(200, 100)
        self.canvas1.maxsize(300, 200)
        self.canvas1.protocol('WM_DELETE_WINDOW', self.confirmExit)

        label1 = tk.Label(self.canvas1, text='Edit Font')
        label1.config(font=('helvetica', 15))
        label1.grid(row=0, column=0, padx= 10, pady=2, columnspan=2)

        label1 = tk.Label(self.canvas1, text='Font:')
        label1.config(font=('helvetica', 10))
        label1.grid(row=1, column=0, padx= 2, pady=2)

        self.popupMenu = FontMenu(self.tab, self.canvas1, tkvar,self.font_size)
        self.popupMenu.grid(row=1, column=1, padx= 2, pady=2)
        self.popupMenu.configure(width=20)

        label1 = tk.Label(self.canvas1, text='Size:')
        label1.config(font=('helvetica', 10))
        label1.grid(row=2, column=0, padx= 2, pady=2)

        sp = tk.Spinbox(self.canvas1, from_= 1, to = 50, command=self.update_font, textvariable = self.font_size)
        sp.grid(row=2, column=1, padx= 2, pady=2)
        self.update_font()

        button_cancel = tk.Button(self.canvas1, text='Cancel', command=self.cancel, font=('helvetica', 9, 'bold'))
        button_cancel.grid(row=3, column=0, padx= 10, pady=2)

        button_add = tk.Button(self.canvas1, text='Apply', command=self.apply_font, font=('helvetica', 9, 'bold'))
        button_add.grid(row=3, column=1, padx= 10, pady=2)

        self.canvas1.grab_set()
Exemplo n.º 15
0
    def find(self, sv, edit, text=""):
        db = Database.instance()
        tab_text = self.tab.get_text().text
        if tab_text == None: return

        tab_text.tag_remove('found', '1.0', tk.END)
        s = edit.get() if edit != None else text
        db.actual_find = s
        if s:
            idx = '1.0'
            while 1:
                idx = tab_text.search(s, idx, nocase=1, stopindex=tk.END)
                if not idx: break
                lastidx = '%s+%dc' % (idx, len(s))
                tab_text.tag_add('found', idx, lastidx)
                idx = lastidx

        if tab_text.index(tk.INSERT) != tab_text.index("end-1c"):
            db.actual_pos = tab_text.index(tk.INSERT)
        else:
            db.actual_pos = '0.0'
        tab_text.tag_config('found', foreground='red')
Exemplo n.º 16
0
    def __init__(self, root, tab):
        super().__init__(root, bg='#e6e6e6')
        self.root = root
        self.tab = tab
        self.changed = False
        self.refresh_enable = False
        self.refresh_interv = 5

        # create a Text widget
        self.text = CustomText(self)
        self.linenumbers = TextLineNumbers(self, width=30)
        self.linenumbers.attach(self.text)

        # create a Scrollbar and associate it with txt
        scrollb = ttk.Scrollbar(self, command=self.text.yview)
        self.text['yscrollcommand'] = scrollb.set

        self.linenumbers.pack(side="left", fill="y")
        scrollb.pack(side="right", fill="y")
        self.text.pack(side="right", fill="both", expand=True)

        db = Database.instance()
        if db.global_font != None:
            self.text.config(font=db.global_font, undo=True, wrap='word')
        else:
            self.text.config(font=("consolas", 10), undo=True, wrap='word')

        self.text.config(borderwidth=3, relief="sunken")
        style = ttk.Style()
        style.theme_use('clam')

        self.bind_text_event()

        self.saved_path = ""

        self.popup_menu = PopUpMenu(self.root, self.tab)
        self.text_sync = TextSync(self.tab, self, self.text)
Exemplo n.º 17
0
 def _on_change(self, event):
     tab_text = self.tab.get_text().text
     if tab_text == None: return
     if tab_text.index(tk.INSERT) != "1.0":
         db = Database.instance()
         self.find(None, None, text=db.actual_find)