def yview(self, *args): ## callback for vertscrollbar_command # args can be ('scroll', number, type) where type is page or unit # or ('moveto', '0.2854982') #print args if args[0] == "scroll": # ('scroll', '1', 'pages') when click on back of bar # ('scroll', '1', 'units') when click on bar arrow self.yview_scroll(args[1], args[2]) else: # ('moveto', '0.350939') when dragging bar percent = float(args[1]) line = int(self.nbLines * float(percent)) #print 'GAGA', line, self.firstVisibleNodeLineNum if self.firstVisibleNodeLineNum != line: v = self.scrollView(line - self.firstVisibleNodeLineNum) if v: # compute percentage of motion total = self.nbLines + (self.headerHeight / float(self.nodeHeight)) percent = self.firstVisibleNodeLineNum / total ScrolledCanvas.yview_moveto(self, percent) self.redraw() self.redrawHeader(args)
def yview_scroll(self, *args): # mouse wheel or arrow keys up and down args = (1, 'units'), (-1, 'units') # page up and down keys (1, 'pages')(13, 'units') # (-1, 'pages')(-13, 'units') # end key args = "jumping to End" # home key args = "jumping to Home" height = self.winfo_height() - self.headerHeight #print 'yview_scroll', args #height = int(self.canvas['height']) - self.headerHeight if self.nbLines * self.nodeHeight <= height: return if args[1] == "pages": # FIXME we scroll the whole thing one page linesPerPage = int(args[0]) * (height / self.nodeHeight) self.yview_scroll(linesPerPage, "units") else: # it is a unit scroll of args[0] units v = self.scrollView(int(args[0])) if v: ScrolledCanvas.yview_scroll(self, *args) self.redraw() self.redrawHeader(args)
def yview(self, *args): ## callback for vertscrollbar_command # args can be ('scroll', number, type) where type is page or unit # or ('moveto', '0.2854982') #print args if args[0] == "scroll": # ('scroll', '1', 'pages') when click on back of bar # ('scroll', '1', 'units') when click on bar arrow self.yview_scroll(args[1], args[2]) else: # ('moveto', '0.350939') when dragging bar percent = float(args[1]) line = int(self.nbLines * float(percent)) #print 'GAGA', line, self.firstVisibleNodeLineNum if self.firstVisibleNodeLineNum != line: v = self.scrollView(line - self.firstVisibleNodeLineNum) if v: # compute percentage of motion total = self.nbLines+(self.headerHeight/float(self.nodeHeight)) percent = self.firstVisibleNodeLineNum/total ScrolledCanvas.yview_moveto(self, percent) self.redraw() self.redrawHeader(args)
def destroy(self): if self.root: self.root.destroy() ScrolledCanvas.destroy(self)