def syn_disable(self): tab_text = self.tab.get_text() if tab_text != None: tab_text.text_sync.syn_disable() self.external = False StatusBar().set("sync disabled") else: StatusBar().set("aborted - sync not disabled") self.close_window()
def __init__(self, root): self.root = root self.op_fac = OperationFactory() self.tab = TabCtrl(self.root) self.toolbar = ToolBar(self.root, self.tab) self.menu = Menu(self.root, self.tab) self.status = StatusBar(self.root) self.status.set("ready") self.tab.add_tab()
def add_patter(self): color = askcolor(title="Pattern Color") if color != None: pattern = self.entry_pattern.get() StatusBar().set("new patern:%s color:%s" % (pattern, color[1])) self.text_frame.data[pattern] = color[1] self.text_frame.update_text() self.entry_pattern.delete(0, "end") else: StatusBar().set("aborted - operation aborted")
class App: '''The application class initialize all basic components''' def __init__(self, root): self.root = root self.op_fac = OperationFactory() self.tab = TabCtrl(self.root) self.toolbar = ToolBar(self.root, self.tab) self.menu = Menu(self.root, self.tab) self.status = StatusBar(self.root) self.status.set("ready") self.tab.add_tab()
def color_chooser(self): color = askcolor(title="Pattern Color") if color != None: line_idx = self.text_frame.text.index("insert").split(".")[0] pattern = self.text_frame.text.get("%s.0" % line_idx, "%s.end" % line_idx) if pattern in self.text_frame.data: StatusBar().set("new color %s" % (color[1])) self.text_frame.data[pattern] = color[1] self.button_color.configure(bg=self.text_frame.data[pattern]) else: StatusBar().set("aborted - operation aborted")
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")
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()
def syn_enable(self): tab_text = self.tab.get_text() if tab_text != None: interv = self.entry_interv.get() interv = int(interv) if interv != "" else 5 if self.external != True: tab_text.text_sync.syn_local_enable(interv) StatusBar().set("local sync enabled") else: server = self.entry_ip.get() user = self.entry_user.get() passwor = self.entry_pass.get() path = self.entry_path.get() ret = tab_text.text_sync.syn_ext_enable( server, 22, user, passwor, path, interv) if ret == True: StatusBar().set("external sync enabled") self.close_window()
def execute(self): tab_text = self.tab.get_text() if tab_text == None: return tab_text.text.clipboard_clear() text = tab_text.text.get("sel.first", "sel.last") if text != '': tab_text.text.clipboard_append(text) StatusBar().set("copied")
def execute(self): tab_text = self.tab.get_text() if tab_text == None: return filename = tab_text.saved_path if self.cmd_name == "save_as" or filename == "": filename = filedialog.asksaveasfilename( initialdir="/", title="Select An Image", filetypes=(("text files", "*.txt"), ("log files", "*.log*"))) if filename == '': return if self.save_file(tab_text, filename) == True: tab_text.saved_path = filename head, tail = os.path.split(filename) self.tab.set_tab_name(tail) StatusBar().set("saved: %s" % (filename)) else: StatusBar().set("aborted - saving process: %s" % (filename))
def connect(self, tab_id, server, port, user, password): try: self.buffer_file = "buffer"+tab_id+".txt" self.ssh = self.createSSHClient(server, port, user, password) self.scp_conn = SCPClient(self.ssh.get_transport()) f= open(self.buffer_file,"w+") f.close() return True except: StatusBar().set("aborted - external connection error") return False
def execute(self): tab_text = self.tab.get_text() if tab_text == None: return lineno = simpledialog.askinteger("Go to Line", "Type a line number and press Enter:", parent=tab_text.winfo_toplevel()) if lineno is not None: column = tab_text.text.index('insert').split('.')[1] tab_text.text.mark_set('insert', '%d.%s' % (lineno, column)) tab_text.text.see('insert') StatusBar().set("got to: %d" % (lineno)) tab_text.text.focus()
def ext_refresh(self): valeu = self.scp.get_text(self.path) if valeu == None: StatusBar().set("synced canceled: %s" % (datetime.now().strftime("%H:%M:%S"))) return if self.text == None: StatusBar().set("synced canceled: %s" % (datetime.now().strftime("%H:%M:%S"))) return if self.pause == False: self.text.delete('1.0', 'end') self.text.insert('1.0', valeu) self.text.see('end') if self.refresh_enable: self.text.after(self.refresh_interv * 1000, self.ext_refresh) if self.pause == False: StatusBar().set("synced: %s" % (datetime.now().strftime("%H:%M:%S")))
def get_text(self, path): """ Gets a file from the remote server Arguments: - path: Source file in the remote server. """ try: self.scp_conn.get(path, self.buffer_file) f = open(self.buffer_file, 'r') f2 = f.read() f.close() return f2 except: StatusBar().set("aborted - invalid path: %s" %(path)) return "invalid path: %s" %(path)
def local_refresh(self): if self.text == None: StatusBar().set("synced canceled: %s" % (datetime.now().strftime("%H:%M:%S"))) return filename = self.combo.saved_path if filename == "": StatusBar().set("synced canceled: %s" % (datetime.now().strftime("%H:%M:%S"))) return if self.pause == False: f = open(filename, 'r') valeu = f.read() self.text.delete('1.0', 'end') self.text.insert('1.0', valeu) f.close() self.text.see('end') if self.refresh_enable: self.text.after(self.refresh_interv * 1000, self.local_refresh) if self.pause == False: StatusBar().set("synced: %s" % (datetime.now().strftime("%H:%M:%S")))
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()
def get_text(self, path): StatusBar().set("external sync - ssh and scp libs not intalled")
def connect(self, server, port, user, passwor): StatusBar().set("external sync- ssh and scp libs not intalled")
def confirmExit(self): StatusBar().set("aborted - operation aborted") self.canvas1.destroy()