Andrey Antonov (Gmail | 1 Feb 2011 10:12
Picon

GUI with SWITCHING BETWEEN SEVERAL REGIONAL LANGUAGES

Hi folks,

I have a GUI and I want to redraw/refresh all the GUI elements/widgets
when the user wants to  switch to its own regional language.

Any tools with Tkinter, or any idea outside Tkinter.

Thx

Andrewerol
python | 1 Feb 2011 14:15
Favicon

Tkinter library/technique that supports panels that can be docked, undocked, and resized?

Wondering if there's a 3rd party Tkinter or Tk library or a general
programming technique that would allow one to create Tkinter based
applications with panels that can be docked, undocked, and resized
(while docked and undocked)?

Here's an example of what I'm talking about. This is a short 1 minute
screencast of a wxPython based framework called Dabo demonstrating the
capabilities that my users have asked for.
http://screencast.com/t/3qRgqHsJVbK

I'm using Python 2.7 under Windows and have noticed that Tkinter appears
to have some built-in concept of docking when TopLevel windows are moved
around the desktop. Is there a way to trap these Tkinter docking events
and use Tkinter's built-in docking behaviors to implement this type of
functionality?

Regards,
Malcolm
Kevin Walzer | 1 Feb 2011 15:29
Favicon

Re: Tkinter library/technique that supports panels that can be docked, undocked, and resized?

On 2/1/11 8:15 AM, python <at> bdurham.com wrote:
> Wondering if there's a 3rd party Tkinter or Tk library or a general
> programming technique that would allow one to create Tkinter based
> applications with panels that can be docked, undocked, and resized
> (while docked and undocked)?

I don't think Tk has support for this, either as a library or a core 
function. You can fake it using various techniques, but it would be a 
lot of work.

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Martin B. | 1 Feb 2011 16:16

scrolling more widgets with one scrollbar

Hi all,
I need scroll 3 Text widgets with one scrollbar.
All is packed into grid [text, text, text, scrollbar]

all Text widgets have font on same size
how i scroll all 3 widgets 'synced' using scrollbar ?

i have a method which is scrollbar.command

def update_widgets(self, *args):
	# scrolling all 3 widgets
	for win in self.textwindows:
		win.yview_moveto(args[1])

this scrolling widgets but after few 'slides' rows are not synced :(

and second question is 'how i set next 2 widgets and scrollbar if i
scroll some widget using keyboard? '

i think it must be something like scrollbar.set(*args) in
widget.yscrollcommand but i'm trying without luck.

thanks
Michael Lange | 3 Feb 2011 11:56
Picon

Re: scrolling more widgets with one scrollbar

Hi,

Thus spoketh "Martin B." <spooky.ln <at> tbs-software.com> 
unto us on Tue, 1 Feb 2011 16:16:56 +0100:

> Hi all,
> I need scroll 3 Text widgets with one scrollbar.
> All is packed into grid [text, text, text, scrollbar]
> 
> all Text widgets have font on same size
> how i scroll all 3 widgets 'synced' using scrollbar ?
> 
> i have a method which is scrollbar.command
> 
> def update_widgets(self, *args):
> 	# scrolling all 3 widgets
> 	for win in self.textwindows:
> 		win.yview_moveto(args[1])
> 
> this scrolling widgets but after few 'slides' rows are not synced :(

I'd replace this with something like:

def update_widgets(self, *args):
    for win in self.textwindows:
        win.yview(*args)

If this still doesn't work properly, i would try and add an
update_idletasks() to the function. At least here this does not seem to
be necessary though.
(Continue reading)

Martin B. | 3 Feb 2011 18:34

Re: scrolling more widgets with one scrollbar

Thanks this helps a lot.
Your code for  keypress looks like you call internal Tcl/Tk commands ?

Seems like my for mousewheel.

But <MouseWheel> dont generate any signal i must use Button-4 and
Button-5 on linux.

def mousewheel_cb(event):
	direction = 1 if event.num == 5 else -1
	for win in self.textwindows:
		win.yview('scroll', direction, 'units')

this working nice.
Martin B. | 3 Feb 2011 18:50

Text spacing.

Hi again,
I write simple hexedit for my home use and i searching solution for
setting some spaces between chars in Text widget. Something like
'spacingN' for Y. Exists ? I dont want to insert extra space between
chars like now.

i have 16bytes on line in {0:02X}format.

0011223344556677           > this is ugly
00 11 22 33 44 55 66 77    > this with spaces in bettween is better

can i make this without spaces ?
thanks 
Michael Lange | 3 Feb 2011 18:55
Picon

Re: scrolling more widgets with one scrollbar

Hi again,

Thus spoketh Michael Lange <klappnase <at> web.de> 
unto us on Thu, 3 Feb 2011 11:56:35 +0100:

> I set up a minimal example that shows how to use this technique to set
> up modified key bindings that allow to scroll two text widgets
> synchronously with the Up and Down keys:
> 

At a second glance my example isn't so nice either, because it does not
only sync the yview but also the cursor position, which is most likely
not wanted. However this can be easily fixed by restoring the "slave"
widget's cursor position with something like:

    def down(event):
        oldinsert = slave[event.widget].index('insert')
        root.tk.call('tk::TextSetCursor', slave[event.widget],
                root.tk.call('tk::TextUpDownLine', event.widget, 1))
        slave[event.widget].mark_set('insert', oldinsert)

Doing this for lots of event sequences is quite a pita though, maybe
wrapping it like this is a bit better:

slave = {t1: t2, t2: t1}
def callback(textwidget, *args):
    oldinsert = slave[textwidget].index('insert')
    root.tk.call(*args)
    slave[textwidget].mark_set('insert', oldinsert)

(Continue reading)

Martin B. | 3 Feb 2011 18:57

Re: scrolling more widgets with one scrollbar

sorry im late.
this is picture with 'not synced rows'. 

http://oops.rajce.idnes.cz/nastenka/#xcg.jpg
Michael Lange | 3 Feb 2011 19:12
Picon

Re: scrolling more widgets with one scrollbar

Hi,

Thus spoketh "Martin B." <spooky.ln <at> tbs-software.com> 
unto us on Thu, 3 Feb 2011 18:34:24 +0100:

> Thanks this helps a lot.
> Your code for  keypress looks like you call internal Tcl/Tk commands ?

Yes, as I said these commands are defined in text.tcl (on linux this can
usually be found at /usr/lib/tk8.x or so), and the widget.tk.call()
mechanism is the magic that allows us to access Tcl/Tk's internal
commands from Python. Once you understood how to handle Tcl/Tk commands
from Python it is quite straightforward and a great and powerful way to
enhance Tkinter's capabilities, so I absolutely recommend to have a
closer look at it ;)
A great way to learn using tk.call() is to compare for example the button
widget's tcl man page (just try "man button") with the code from
"class Button" in Tkinter.py, you will easily see how this works.

> 
> Seems like my for mousewheel.
> 
> But <MouseWheel> dont generate any signal i must use Button-4 and
> Button-5 on linux.

I think <MouseWheel> is windows and OSX only.

> 
> def mousewheel_cb(event):
> 	direction = 1 if event.num == 5 else -1
(Continue reading)


Gmane