user interface - Python Tkinter scrollbar issue -


i recieving strange bahavior , exception of tkinter scrollbar. gui uses tkinter text widget related/referenced scrollbar.

    self.textframe = tkinter.labelframe (self.mainframe,padx=0,pady=0,width=200,height=100)     self.textframe.grid(row=5, column =1, sticky = "nw", padx = 5, pady = 10)     self.conslable = tkinter.label (self.textframe,text = "log-console:",font ="verdana 8 bold")     self.conslable.grid (row =6,column =1, sticky = "nw", padx = 5, pady = 1)     self.constext= tkinter.text(self.textframe, wrap = "word")     self.constext.grid(row =7,column =1, rowspan =4)     self.constext.tag_configure("stderr", foreground="#b22222")     self.scrolltext= tkinter.scrollbar(self.textframe,command = self.constext.yview)     self.scrolltext.grid(row =7,column =2,rowspan =4,sticky='nsew')     self.constext.config(yscrollcommand = self.scrolltext.set)      # referencing output location of console "print or sys.stderr" methods     sys.stdout = gemeindesteckbrief__supporttools__.textredirector(self.constext, "stdout")     sys.stderr=  gemeindesteckbrief__supporttools__.textredirector(self.constext, "stderr") 

in text widget python console entries inserted using sys.stdoutand sys.stderr. insert text support class used overwrites .sys.stderr.writeor printmethod , writes text tkinter text widget.

class textredirector(object): def __init__(self,widget, tag):     self.targetwidget = widget     self.targettag = tag  #@override sys.stdout & sys.stderr methods write text widget instead of python console def write(self, str):     self.targetwidget.configure(state="normal")     self.targetwidget.insert("end", str, (self.targettag,))     self.targetwidget.configure(state="disabled") 

inserting text text widget works expected, clicking widget , scrolling using mouse wheel works fine, using , down buttons of scrollbar works. trouble starts using bar , trying slide , down. effect tclerror: expected floating-point number got "0,0028"

exception in tkinter callback traceback (most recent call last): file "c:\python26\arcgis10.0\lib\lib-tk\tkinter.py", line 1410, in __call__ return self.func(*args) file "c:\python26\arcgis10.0\lib\lib-tk\tkinter.py", line 3156, in yview self.tk.call((self._w, 'yview') + what) tclerror: expected floating-point number got "0,0028" 

so, found kind of workaround solution problem tkinter seems have problems concerning multple threads. changed tkinter.scrollbar ttk.scrollbar. ttk module extended version of tkinter , solves weird behaviors of tkinter module.

look @ http://docs.python.org/3.1/library/tkinter.ttk.html

after changing module of widget works expected!

this solution workaround of actual issue works!!


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -