Tkinter: scrollbar - unable to scroll the scrollbar if I click on arrow buttons of scroll bars
dudeja.rajat at gmail.com
dudeja.rajat at gmail.com
Mon Sep 29 13:36:56 EDT 2008
On Mon, Sep 29, 2008 at 5:10 PM, <dudeja.rajat at gmail.com> wrote:
>
>
> On Sun, Sep 28, 2008 at 4:51 PM, <dudeja.rajat at gmail.com> wrote:
>
>>
>> Hi,
>>
>>
>> Im using a tkinter scrollbars for horinzontal and vertical scrolling. Well
>> the problem is I'm unable to scroll if I click on the arrows buttons of
>> scrollbars ( with both types of scrollbars)
>>
>>
>> Please suggest if I m missing some configuration.
>>
>>
>> My code is as below:
>>
>> self.hsb = Scrollbar(appGuiFrame, orient = HORIZONTAL)
>> self.hsb.grid(row = 2,column = 0, sticky = E+W)
>> #vertical scroll bar
>> self.vsb = Scrollbar(appGuiFrame)
>> self.vsb.grid(row = 1,column = 2, sticky = N+S)
>>
>>
>>
>> self.txtLogger = Text(appGuiFrame, \
>> height = 20,\
>> width = 100, \
>> state = DISABLED, \
>> xscrollcommand = self.hsb.set, \
>> yscrollcommand = self.vsb.set, \
>> wrap = NONE, \
>> font = ("courier",12))
>> self.hsb.config(command = self.txtLogger.xview())
>> self.vsb.config(command = self.txtLogger.yview())
>>
>>
>> Please help.
>>
>>
>> Thanks and regards,
>> Rajat
>>
>
>
> Hi folks,
>
> Any help on the above problem.
>
> Regards,
> Rajat
>
Hi,
The problem got solved. After finding for such a long time I got a snippet
at google and used the same in my code. It solved the problem.
Here is the complete code now:
class cLogToGUI:
def __init__(self, logObj, appGUI):
self.__logger = logObj
self.__logger.debug("Inside cLogToGUI::__init__")
appGuiFrame = appGUI.frame4
#hor. scroll bar
self.hsb = Scrollbar(appGuiFrame, orient = HORIZONTAL)
self.hsb.grid(row = 2,column = 0, sticky = E+W)
#vertical scroll bar
self.vsb = Scrollbar(appGuiFrame)
self.vsb.grid(row = 1,column = 2, sticky = N+S)
self.txtLogger = Text(appGuiFrame, \
height = 20,\
width = 100, \
state = DISABLED, \
xscrollcommand = self.hsb.set, \
yscrollcommand = self.vsb.set, \
wrap = NONE, \
font = ("courier",12))
#self.hsb.config(command = self.txtLogger.xview())
#self.vsb.config(command = self.txtLogger.yview())
self.hsb.config(command = self.__hsbScrollHandler)
self.vsb.config(command = self.__vsbScrollHandler)
self.txtLogger.bind("<<updateDisplay>>", self.outputText)
self.txtLogger.grid(row = 1)
self.txtLogger.tag_configure("error", foreground = "red")
self.txtLogger.tag_configure("warning", foreground = "orange")
self.txtLogger.tag_configure("success", foreground = "blue")
self.__logger.debug("return from cLogToGUI::__init__")
def outputText(self, event):
self.__logger.debug("Inside cLogToGUI::outputText()")
self.txtLogger.configure(state = NORMAL)
string = TASymbols.strScrolledTextLine
tag = TASymbols.strScrolledTextLineTag
if not string:
self.txtLogger.delete('1.0', END)
else:
self.txtLogger.insert(END, string, tag)
#self.txtLogger.focus()
self.txtLogger.see(END)
self.txtLogger.configure(state = DISABLED)
self.__logger.debug("return from cLogToGUI::outputText()")
def __hsbScrollHandler(self, *L):
op, howMany = L[0], L[1]
if op == "scroll":
units = L[2]
self.txtLogger.xview_scroll ( howMany, units )
elif op == "moveto":
self.txtLogger.xview_moveto ( howMany )
def __vsbScrollHandler(self, *L):
op, howMany = L[0], L[1]
if op == "scroll":
units = L[2]
self.txtLogger.yview_scroll ( howMany, units )
elif op == "moveto":
self.txtLogger.yview_moveto ( howMany )
Thanks and regards,
Rajat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080929/f52e6d63/attachment-0001.html>
More information about the Python-list
mailing list