[Tkinter-discuss] FocusOut not working as expected - tix broken?

2012-09-25 Thread mkieverpy

Dear list,

I built a GUI using tkinter and tix (python 3.1/linux)
and have a frame which wants to receive key events
in a certain "mode". I do this when initializing the frame:

class WBuildMenu(Frame, View):
...
self._keyID = self.bind('', self._onKey, add=True)


and later when entering the "mode":

...
self.focus_set()
self._FocusID = self.bind('' , self._focusLost, add=True)

I then receive key events correctly.
I expected to get  event when my frame loses
focus and no longer receives key events.
Am I correct in expecting this behaviour?
(I wanted to repeat "self.focus_set()" in this case)

What I really get is this: I only get FocusOut when the mouse
leaves the application window. I do not get FocusOut event
when I click some other part of the application window
which nonetheless results in the frame losing focus and no longer
receiving key events.
Currently, my guess is that this is broken in tix
(which unluckily seems not to be under development any more).

Any other opinions?
Any other method to track focus which I missed?

Thanks for any hints,
Matthias Kievernagel
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] FocusOut not working as expected - tix broken?

2012-09-26 Thread mkieverpy


Hello Michael,

Me:

What I really get is this: I only get FocusOut when the mouse
leaves the application window. I do not get FocusOut event
when I click some other part of the application window
which nonetheless results in the frame losing focus and no longer
receiving key events.
Currently, my guess is that this is broken in tix
(which unluckily seems not to be under development any more).


Michael:
(...)
and here it worked as expected (python 3.1,, debian squeeze with 
IceWM).
It might very well be a WM specific issue though, did you try 
different

WMs?


Sorry, lost focus completely, so to speak. Hardware failure.
Hopefully back next week.

Before breakdown I tried IceWM and got same result for my and your 
program.
I'm on debian wheezy, ctwm, self compiled python 3.1.1 (tcl/tk 8.4 not 
sure)
I am not getting any 'focus out' messages from your program. No idea 
why.

I'll try to post a minimal example some time next week.

Regards,
Matthias.
(sent from my mac cookie box)


___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] FocusOut not working as expected - tix broken?

2012-10-07 Thread mkieverpy

Hello Michael,

I'm back and tested a bit more.
I updated to standard packages (debian wheezy) python 3.2
tcl/tk 8.5 tix 8.4.3 to avoid any problems with who is using
who. I then expanded your test program to emulate my configuration
and what I want to implement. There I noticed that it's not
a tix problem at all, but standard tcl/tk focus behaves the same.
Here's the program:

---
import tkinter

root = tkinter.Tk()
f = tkinter.Frame(root)
f.pack(fill='both', expand=1)
tkinter.Button(f, text='foo').pack()

f2 = tkinter.Frame(root)
f2.pack(fill='both')
tkinter.Button(f2, text='bar').pack()

def on_key(event):
print('key')
def on_focus_out(event):
print('focus out')
f.focus_set()
f.focus_set()
f.bind('', on_key)
f.bind('', on_focus_out)

root.mainloop()
---

The problem is when I use the 'Tab' key to move
the focus. The first 'Tab' moves the focus
to the 'foo' button. 'f' no longer gets key events
but does not get the focus out event either.
The next 'Tab' moves the focus to the 'bar' button,
'f' gets the focus out event and key events arrive again
after I do 'focus_set'.
So it looks like tk standard behaviour. Can I get what I want?
In my program it's a mouse click that can move
the focus away. So tweaking or disabling 'Tab' is not a solution.

Regards,
Matthias Kievernagel
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] FocusOut not working as expected - tix broken?

2012-10-08 Thread mkieverpy

Hello Michael,

I found a workaround:


import tkinter

root = tkinter.Tk()
f = tkinter.Frame(root)
f.pack(fill='both', expand=1)
tkinter.Button(f, text='foo').pack()

f2 = tkinter.Frame(root)
f2.pack(fill='both')
tkinter.Button(f2, text='bar').pack()

f3 = tkinter.Frame(root)
f3.pack(fill='both')

def on_key(event):
print('key')
def on_focus_out(event):
print('focus out')
f3.focus_set()
f3.focus_set()
f3.bind('', on_key)
f3.bind('', on_focus_out)

root.mainloop()


The other program does not look wrong though.
I think I'll ask at tcl/tk if they think it's a bug.

Regards,
Matthias Kievernagel


___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] FocusOut not working as expected - tix broken?

2012-10-11 Thread mkieverpy


Hi,

On Wed, 10 Oct 2012 11:37:35 +0200, Michael Lange wrote:

(...)

The problem is when I use the 'Tab' key to move
the focus. The first 'Tab' moves the focus
to the 'foo' button. 'f' no longer gets key events
but does not get the focus out event either.
The next 'Tab' moves the focus to the 'bar' button,
'f' gets the focus out event and key events arrive again
after I do 'focus_set'.
So it looks like tk standard behaviour. Can I get what I want?


With your example from the previous post the focus will never reach 
the

"bar" button, maybe it was a typo in on_focus_out() and should be
f2.focus.set() ?
Anyway, I am not sure what exactly you want to achieve (maybe I 
missed
something from your previous posts?), is there a particular reason 
why not

to do nothing about focus handling and just leave it to the WM?


Sorry, to have been unclear here.
My main interest is capturing all keyboard input
with these lines:
--
def on_key(event):
print('key')

f.bind('', on_key)
--
I want to use this to implement keyboard control for some features.
In the case where 'f' has children which can get focus
I may loose keyboard input because 'f' won't get notified
about FocusOut (lines 2-4 in my above description).
In the workaround I use a frame without children.
In this case I always get the FocusOut event and
can reclaim focus with 'f.focus_set()'.

Regards,
Matthias Kievernagel

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] FocusOut not working as expected - tix broken?

2012-10-16 Thread mkieverpy

Hello,

thanks for the new hints/information Michael and Bryan.
I don't know if your hints would work in my setup, though.
Except bind_all, which should work, I guess.

My program structure:
I have a Frame, which is nearly the complete toplevel window
(only a title label and quit button outside;
this is the Frame I originally tried to let capture all the keys).
The left half is taken by a tix Tree and the right half
contains one of a few editor classes (subclassed from Frame)
which get exchanged based on the selected Tree node.
One type of nodes opens a Canvas in the right half
where I want the key shortcuts to work.

The problem I see with both your hints (bind keys to all widgets,
tag widgets and bind keys to tag) is I doubt they will work with tix Tree.
I don't think tix Tree hands down any bind or tag to
its subwidgets (or does it?).

Thanks again,
Matthias Kievernagel
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] tkinter extensions

2013-06-13 Thread mkieverpy

>   Tix  (
>   http://www.python.org/doc/current/lib/module-Tix.html)

I am a tix user and I found the Demo in the python
distribution very helpful (in the path 'Demo/tix/').
As far as I can remember it contains examples
for nearly every tix widget.

Regards,
Matthias Kievernagel
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Button Press Freezes

2013-06-13 Thread mkieverpy


Quaki Gaffar:
>Here's my situation. I have two tkinter buttons:
>
>Play Button: plays a sound
>Stop Button: to stop the sound during play
>
>Code is as follows:
>
>def Play(self):
>//plays a file with pygame module
>
>def Stop(self):
>//Stop using pygame stop

Greg Ewing:
>No, music.play() is not supposed to block. However, I haven't tried to use
>it outside the context of a pygame app, so I don't know how it behaves if
>there isn't a pygame event loop running.

If my memory serves me well, you cannot mix tkinter and pygame.
Both want their event loop running. I once looked into this
and to my knowledge no one succeeded in embedding one into the other.
And I won't try using just music.play without setting up pygame.
I don't think this would work, but that's just a guess.

Regards,
Matthias Kievernagel
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Event debugger

2015-01-04 Thread mkieverpy

Hello Vasilis,

>So my questions is, does it exist any event debugger so I can monitor
>the events on a specific widget to find out what happens in between
> the two clicks?

if your on X11 xev (+ possibly a pipeline through grep) might
be sufficient for your debugging needs.
I'm not a heavy user of xev, though.

Hope this helps,
Matthias

And Happy New Year to all the list :-)
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Event debugger

2015-01-05 Thread mkieverpy

Hi Vasilis and Michael,

I thought you could use xev just by starting it
in another shell with "xev -id ".
Or do you lose some info by running it this way?
(I mean even more than by the other heavy restrictions
 - they seem to make xev useless for event debugging.
 I'll have to look at the other tools you mentioned
 one of these days...)

Best Regards,
Matthias.

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] creating widgets generically, with a loop?

2006-06-21 Thread mkieverpy
> 
> Some background info: I have a Python/Tkinter script that displays a
> dialog with buttons, where each button launches a file for editing.
> Sort of like an HTML file in a browser, except with my script I can
> launch it using a particular program.
> 
> I've been trying to figure out a way of storing widget information
> (name of each widget, x and y positions, and a command to execute
> when activated) in an array so I can generically create each widget
> instead of hard-coding all the information. For example, here's a
> snippet of what I currently use:
> 
> ...
> Button(top, text="OO design info",
> command=self.launch_file23).grid(sticky="w",row=10,column=5)
> ...
> 
> ...
> def launch_file23 ( self ): os.spawnl ( os.P_NOWAIT ,
> "c:\\Program Files\\TextPad 4\\TextPad.exe" , "TextPad.exe" , "d:\\My
> 
> 
> Documents\\prog_oo_design.txt" )
> ...
> 
> If there was a way I could pass arguments to launch_file23 from the
> "command=" parameter, that would solve the problem nicely - I could
> store the info in an array, and then just loop to create the buttons.
> 
> Any ideas?
> 
> 
> Michael Steiner
> [EMAIL PROTECTED]
> (480) 720-8902 (cell)
> 
> __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> ___
> Tkinter-discuss mailing list
> Tkinter-discuss@python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss

An idea using subclassing of 'Button':
--
from Tkinter import *

class ButtonParam ( Button ):
def __init__ ( self, param, parent, **kw ):
Button.__init__ ( self, parent, kw )
self.Param = param
def launch ( self ):
print 'My Param:', self.Param

if __name__ == '__main__':
tk = Tk ()
for bspec in [('text1','par1'),('text2','par2'),('text3','par3')]:
b = ButtonParam ( bspec [1], tk, text=bspec [0] )
b.configure ( command=b.launch )
b.pack ()
tk.mainloop ()
--

Perhaps the parameters to __init__ need additional tweaking
and you might want more than one parameter.

Hope this helps,

Matthias Kievernagel
Software-Development
mkiever/at/web/dot/de

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] creating widgets generically, with a loop?

2006-06-21 Thread mkieverpy
> 
> Some background info: I have a Python/Tkinter script that displays a
> dialog with buttons, where each button launches a file for editing.
> Sort of like an HTML file in a browser, except with my script I can
> launch it using a particular program.
> 
> I've been trying to figure out a way of storing widget information
> (name of each widget, x and y positions, and a command to execute
> when activated) in an array so I can generically create each widget
> instead of hard-coding all the information. For example, here's a
> snippet of what I currently use:
> 
> ...
> Button(top, text="OO design info",
> command=self.launch_file23).grid(sticky="w",row=10,column=5)
> ...
> 
> ...
> def launch_file23 ( self ): os.spawnl ( os.P_NOWAIT ,
> "c:\\Program Files\\TextPad 4\\TextPad.exe" , "TextPad.exe" , "d:\\My
> 
> 
> Documents\\prog_oo_design.txt" )
> ...
> 
> If there was a way I could pass arguments to launch_file23 from the
> "command=" parameter, that would solve the problem nicely - I could
> store the info in an array, and then just loop to create the buttons.
> 
> Any ideas?
> 
> 
> Michael Steiner
> [EMAIL PROTECTED]
> (480) 720-8902 (cell)
> 
> __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> ___
> Tkinter-discuss mailing list
> Tkinter-discuss@python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss

An idea using subclassing of 'Button':
--
from Tkinter import *

class ButtonParam ( Button ):
def __init__ ( self, param, parent, **kw ):
Button.__init__ ( self, parent, kw )
self.Param = param
def launch ( self ):
print 'My Param:', self.Param

if __name__ == '__main__':
tk = Tk ()
for bspec in [('text1','par1'),('text2','par2'),('text3','par3')]:
b = ButtonParam ( bspec [1], tk, text=bspec [0] )
b.configure ( command=b.launch )
b.pack ()
tk.mainloop ()
--

Perhaps the parameters to __init__ need additional tweaking
and you might want more than one parameter.

Hope this helps,

Matthias Kievernagel
Software-Development
mkiever/at/web/dot/de

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] simple script -Tkinter question.

2006-07-04 Thread mkieverpy
Hi jkuo!

>Hi everyone,
>Here is my simple Tkinter script:

>## start of entry.py
>from Tkinter import *
>root=Tk()
>e1=Entry(root, width=16)
>e1.pack()
>e2=Entry(root, width=16)
>e2.pack()
>mainloop()
>## end

You should call 'root.mainloop()'!
Just mainloop() is the mainloop of Tcl, not Tk.
I don't know what the effects of this might be.
On Linux everything seems to work, nonetheless.

Hope this helps,

Matthias Kievernagel
mkiever/at/web/dot/de
software development

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] simple script -Tkinter question.

2006-07-04 Thread mkieverpy
Michael Lange wrote:
>Really? From Tkinter.py it looks to me like it should be equivalent:
>
>def mainloop(n=0):
>"""Run the main loop of Tcl."""
>_default_root.tk.mainloop(n)
>
>(...snip...)

I trusted the documentation :-(. So I thought this to be the cause of this 
strange behaviour.
Otherwise I have no idea (I'm not doing a lot of windows).

Matthias Kievernagel
mkiever/at/web/dot/de
software development

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Unicode in Tkinter in MacOS

2006-10-04 Thread mkieverpy
Mike Gasser wrote:
> This may be just a Mac problem, but I find that in MacOS (10.4) I can
> only get Tkinter to display the characters in the Latin-1 set and
> Japanese.  Possibly others, I don't know, but many Unicode characters
> display as garbage characters.  The simplest way to illustrate this
> is with the little Romanian "hello world" program that Jason
> Orendorff uses to illustrate Unicode display in Tkinter on his oft-
> cited "Unicode for Programmers" site: http://www.jorendorff.com/
> articles/unicode/python.html
> ...

Earlier on this year or late last year I had similar problems
(with extendedA and B characters). I finally dropped the idea.
As far as I can remember from googling the web for a solution
is that this problem was/is due to brokenness of Tk (Tk Aqua) on the newer 
MacOSs.
A reference I just refound: 
http://aspn.activestate.com/ASPN/Mail/Message/tcl-mac/2865240
My problems were with Python 2.3.5 with Tcl/Tk 8.4.
I do not follow the development on MacOS regularly, so I cannot tell you the 
current state
of affairs.

Hope this helps,

Matthias Kievernagel
mkiever-at-web-dot-de

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Unicode in Tkinter in MacOS

2006-10-04 Thread mkieverpy
Mike Gasser wrote:
> This may be just a Mac problem, but I find that in MacOS (10.4) I can
> only get Tkinter to display the characters in the Latin-1 set and
> Japanese.  Possibly others, I don't know, but many Unicode characters
> display as garbage characters.  The simplest way to illustrate this
> is with the little Romanian "hello world" program that Jason
> Orendorff uses to illustrate Unicode display in Tkinter on his oft-
> cited "Unicode for Programmers" site: http://www.jorendorff.com/
> articles/unicode/python.html
> ...

Earlier on this year or late last year I had similar problems
(with extendedA and B characters). I finally dropped the idea.
As far as I can remember from googling the web for a solution
is that this problem was/is due to brokenness of Tk (Tk Aqua) on the newer 
MacOSs.
A reference I just refound: 
http://aspn.activestate.com/ASPN/Mail/Message/tcl-mac/2865240
My problems were with Python 2.3.5 with Tcl/Tk 8.4.
I do not follow the development on MacOS regularly, so I cannot tell you the 
current state
of affairs.

Hope this helps,

Matthias Kievernagel
mkiever-at-web-dot-de

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Unicode in Tkinter in MacOS

2006-10-04 Thread mkieverpy
Mike Gasser wrote:
> This may be just a Mac problem, but I find that in MacOS (10.4) I can
> only get Tkinter to display the characters in the Latin-1 set and
> Japanese.  Possibly others, I don't know, but many Unicode characters
> display as garbage characters.  The simplest way to illustrate this
> is with the little Romanian "hello world" program that Jason
> Orendorff uses to illustrate Unicode display in Tkinter on his oft-
> cited "Unicode for Programmers" site: http://www.jorendorff.com/
> articles/unicode/python.html
> ...

Earlier on this year or late last year I had similar problems
(with extendedA and B characters). I finally dropped the idea.
As far as I can remember from googling the web for a solution
is that this problem was/is due to brokenness of Tk (Tk Aqua) on the newer 
MacOSs.
A reference I just refound: 
http://aspn.activestate.com/ASPN/Mail/Message/tcl-mac/2865240
My problems were with Python 2.3.5 with Tcl/Tk 8.4.
I do not follow the development on MacOS regularly, so I cannot tell you the 
current state
of affairs.

Hope this helps,

Matthias Kievernagel
mkiever-at-web-dot-de

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Textbox in undecorated window (was - no subject -)

2006-10-07 Thread mkieverpy
Sorin Schwimmer wrote:
>I am trying to use a textbox in an undecorated window. It works under Windows, 
>it fails under Linux.
>Here is a test code:
> ...

The code works fine for me. What does not work?
SuSE Linux 9.x, Python 2.4.1, Tk/Tcl 8.4.6, X11 with twm.

What's your Linux configuration?

Matthias Kievernagel
mkiever at web dot de

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] OptionMenu, change the list of choices

2006-10-24 Thread mkieverpy
Vasilis Vlachoudis wrote:
> 
> values=["One","Two","Three"]   # Initial list
> o = OptionMenu(frame, *values)
> #...
> #then later in the code read new values from a file
> newvalues = f.readline().split()
> o.config(???=newvalues)
> 
With
  m = o.children ['menu']
you can access the menu which implements the OptionMenu.
OptionMenu uses 'command' entries.
So you can add new entries with
  
m.add_command(label='a_new_entry',command=if_you_need_to_set_a_var_or_something)
I never used this personally.
Hope it works for you.

Matthias Kievernagel
mkiever at web dot de

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Method to call when gui is first displayed

2006-11-27 Thread mkieverpy
Tony Cappellini askted:
>I want to call the function which talks to CVS after the gui is displayed,
>but without formal having to do anything.

>After I call mainloop(), the gui is displayed, but then nothing happens
>until the user selects a menu option. (as it should be).

>Is there a tk method that I can register a callback with that indicates the
>gui is displayed, and mainloop is running?

There are some events you can use (see the documentation of bind).
This example using the '' event of an Entry works for me (on Linux/X11):
---
from Tkinter import *

def ready(evt):
print 'ready', evt.__dict__
l.delete(0,END)
l.insert(0, 'gui ready')

tk = Tk()
l = Entry(tk, width=20)
l.insert(0, 'building gui')
l.pack()
l.bind('', ready)
tk.mainloop()
---

The problem is: you should use the event callback just to start
the network activity, not monitoring it.
You'll need some kind of threading/subprocesses or other
to do this.
The event types are not well documented in my tk/tcl installation,
so I cannot tell you if '' is the best choice here.

Hope this helps,

Matthias Kievernagel
(mkiever - at - web - dot - de)

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Method to call when gui is first displayed

2006-11-27 Thread mkieverpy
Tony Cappellini askted:
>I want to call the function which talks to CVS after the gui is displayed,
>but without formal having to do anything.

>After I call mainloop(), the gui is displayed, but then nothing happens
>until the user selects a menu option. (as it should be).

>Is there a tk method that I can register a callback with that indicates the
>gui is displayed, and mainloop is running?

There are some events you can use (see the documentation of bind).
This example using the '' event of an Entry works for me (on Linux/X11):
---
from Tkinter import *

def ready(evt):
print 'ready', evt.__dict__
l.delete(0,END)
l.insert(0, 'gui ready')

tk = Tk()
l = Entry(tk, width=20)
l.insert(0, 'building gui')
l.pack()
l.bind('', ready)
tk.mainloop()
---

The problem is: you should use the event callback just to start
the network activity, not monitoring it.
You'll need some kind of threading/subprocesses or other
to do this.
The event types are not well documented in my tk/tcl installation,
so I cannot tell you if '' is the best choice here.

Hope this helps,

Matthias Kievernagel
(mkiever - at - web - dot - de)

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Method to call when gui is first displayed

2006-11-27 Thread mkieverpy
Oops, sorry - too fast.

The Map-Event occurs every time the widget is mapped to the screen,
i.e. every transition from iconified->windowed calls ready().
So the ready-callback should be changed so it runs only once.

Some questions from me:
Any pointer to a better documentation (better than 'man n bind') for the event 
types?
'man n bind' mentions a 'Create' event type, python does not. Who is wrong, who 
is right? Why?

Matthias Kievernagel
(mkiever - at - web - dot - de)

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Method to call when gui is first displayed

2006-11-27 Thread mkieverpy
> On Mon, Nov 27, 2006 at 09:54:52AM +0100, [EMAIL PROTECTED] wrote:
> > >I want to call the function which talks to CVS after the gui is displayed,
> > >but without formal having to do anything.
>   .
> > The problem is: you should use the event callback just to start
> > the network activity, not monitoring it.
> > You'll need some kind of threading/subprocesses or other
> > to do this.
> > The event types are not well documented in my tk/tcl installation,
> > so I cannot tell you if '' is the best choice here.
>   .
> ?  I suspect we're confusing each other.  It certainly is possible
> to monitor network activity in an event-oriented way; were you say-
> ing that you do not recommend such an approach?

No. What I wanted to say is that the gui is inactive while an event callback
is processed. So the Map-event callback should only be used to initiate the
network activity but return immediately afterwards.
(not polling/waiting for the end of network transfer).
Different events/callbacks or similar should be used for monitoring.

But, of course, Fredrik Lundh's proposed method is better
(I did not know this one), if the application allows for network
activity to finish with the gui being inactive.

Matthias Kievernagel
(mkiever - at - web - dot - de)

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Method to call when gui is first displayed

2006-11-27 Thread mkieverpy
> On Mon, Nov 27, 2006 at 09:54:52AM +0100, [EMAIL PROTECTED] wrote:
> > >I want to call the function which talks to CVS after the gui is displayed,
> > >but without formal having to do anything.
>   .
> > The problem is: you should use the event callback just to start
> > the network activity, not monitoring it.
> > You'll need some kind of threading/subprocesses or other
> > to do this.
> > The event types are not well documented in my tk/tcl installation,
> > so I cannot tell you if '' is the best choice here.
>   .
> ?  I suspect we're confusing each other.  It certainly is possible
> to monitor network activity in an event-oriented way; were you say-
> ing that you do not recommend such an approach?

No. What I wanted to say is that the gui is inactive while an event callback
is processed. So the Map-event callback should only be used to initiate the
network activity but return immediately afterwards.
(not polling/waiting for the end of network transfer).
Different events/callbacks or similar should be used for monitoring.

But, of course, Fredrik Lundh's proposed method is better
(I did not know this one), if the application allows for network
activity to finish with the gui being inactive.

Matthias Kievernagel
(mkiever - at - web - dot - de)

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] How to dettach a Toplevel

2006-11-30 Thread mkieverpy
Sorin Schwimmer wrote:
>Hi Michael, While the two toplevel solution will work nicely, I'm not sure how 
>would I close the main >application (at one point I want to be able to do so). 
>As for the other suggestion, that was my first >approach, but it doesn't work. 
>I don't know why, and sometime I'll have to find out, as I'll need later in 
>>my project. What happens is that when the users logs in (no authentication 
>required) I have a small >script in KDE Autostart to issue an xhost local:root 
>allowing the daemon to show his stuff. The daemon >waits until KDE is up and 
>running and xhost was executed, then it does a root=Tk(screenName=':0.0') 
>>Nothing comes on. If I fire up a Python interpreter and do the things 
>manualy, it works flawless: I have a >graphic window controlled by root, can 
>populate it, withdraw it, iconify it, destroy it... It proves that from >an X 
>server standpoint things are set correctly, but my daemon does something wrong 
>(it may be that >the window is created and destroyed immediately,
  I don't know). Thanks for your ideas, and give me >more if possible Sorin

Do you use a normal process or really a daemon?
When using a daemon it might have something to do
with the restricted process environment which prevents
python/tcl from starting or something like that.
Try to get easy things to work first, like create an empty
file from python in a place where everybody is allowed to.

Hope this helps,
Matthias Kievernagel
(mkiever.at.web.dot.de)

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Problems with lambda functions in callbacks

2007-02-16 Thread mkieverpy

Hello Dídac,

just to add an explanation, why your code doesn't work:

>from Tkinter import *
>
>root = Tk();
>
>def cb(x):
>print x;
   
>for i in range(5):
>b = Button(root,text=i,command=lambda:cb(i));

The part "lambda:cb(i)" is a function which gets evaluated
(called) when a button is clicked. It is evaluated
in the scope where it is defined. In this scope (the global scope)
the for-loop has finished running long ago.
Thus 'i' is always evaluated to '4' regardless which
button is pressed because this is the value of 'i'
after the end of the loop.

Stewart's code:
   b = Button(root,text=i,command=lambda i=i:cb(i));
This code works because it turns the loop variable 'i'
into a default value for the parameter 'i' of the lambda function.
And default values are evaluated when the function is defined,
i.e. while the loop is running.

>b.pack();
>
>root.mainloop();

Hope this helps to demystify this behaviour,

Matthias Kievernagel
(mkiever/at/web/dot/de)
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Multipage Postscript printing from canvas

2007-02-20 Thread mkieverpy

Hello Vasilis,

the options to the postscript function are quite extensively
explained in the tk canvas man-page (man n canvas).
(Beware! I never used this :-)
What I have seen from a cursory glance:
 Use pagewidth or pageheight options for scaling to A4/Letter size
 Use x, y, height and width options to select a part of the canvas

Remember also: there is no size information in canvas coordinates.
  Scaling of the output is completely up to you.

(A4 is 20.99 x 29.70 (says gimp); so for the upper left part 
 of the canvas you might use:
 c.postscript(... pageheight="29.70c",x="0",y="0",height="297",width="209.9")

As I have said, I never used this, this is just what the man-page
says (just tried the line above).
It says also, that it generates encapsulated postscript,
so (with postscript hacking know-how) you could embed all generated
parts into a single postscript template file which just references the parts.
You might even do this in python, if you don't use the
file option.

Greetings,
Matthias Kievernagel
(mkiever/at/web/dot/de)
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Unicode characters in canvas postscript

2007-03-20 Thread mkieverpy

Hello Vasilis,

>I want to add "print to postscript" functionality on my program. I have
>used the "postscript" method of Canvas, and it works nicely apart from
>all no-latin (Unicode) characters. On the screen appear Ok but on the
>postscript are replaced by question marks ?.

Do you mean question marks in the Postscript file or the printout?
If the Postscript file looks ok, it's your printing system.
At least on Mac OS X there were several issues regarding unicode and Tk.
So your Tk should be quite recent.
I could give it a try on a Linux system, if you're interested.

Regards,

Matthias Kievernagel
(mkiever/at/web/dot/de)


___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Possibly n00bish question about ImageTk

2007-06-28 Thread mkieverpy

Hi Alan,

in your function 'moo' 'pi' is a local variable which
gets garbage collected when the function returns.
Thus your image goes to gc nirvana.
Making 'pi' global like this

def moo(master):
global pi
img = Image.open('plotfig.png')
f = Tkinter.Frame(master, width=800, height=600)
pi = ImageTk.PhotoImage(img)
t = Tkinter.Label(f, image=pi)
f.pack()
t.place(x=0, y=0, width=800, height=600)
t.pack()

should do the trick.
This is a guess as I am not using Image and ImageTk.
But I had the same problem with Tix.PhotoImage. So I guess this is it.

BTW you use 'place' and 'pack' for the label. As I understood
your supposed to use exactly ONE geometry handler for a gui element in tk.

Hope this helps,

Matthias Kievernagel
(mkiever/at/web/dot/de)
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Unicode in MacOSX: any progress?

2007-10-10 Thread mkieverpy
Hello Michael,

in my answer back in october 2006 to Mike Gasser on this list,
I referred to a thread I found here:
  http://aspn.activestate.com/ASPN/Mail/Message/tcl-mac/2865240
This thread discusses a patch for tk 8.4.9 to enable support
for something called "Apple Type Services for Unicode Imaging" (ATSUI).
Being also somewhat interested I looked into the ChangeLogs
of the current releases of tk. From the info found there
I guess that this patch has never been incorporated in the 8.4 branch
(No mention of it in the current 8.4.16 release).
But it is mentioned in the current 8.5 Beta release.

This looks like you have to move to 8.5 for unicode on MacOSX
(and see what other things in Tkinter break :-)
or find the patch and do it yourself for 8.4.

BTW Mike Gasser never reported success/failure to the list.
I would be very interested to hear if and how it works for you.


Matthias Kievernagel
mkiever-at-web-dot-de
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] .mainloop(), what's the parameter for?

2007-11-20 Thread mkieverpy

Hi Ron,

I didn't know that parameter either, so I thought I'd take a look.
I found the following loop in 'Tkapp_MainLoop' in '_tkinter.c':

while (Tk_GetNumMainWindows() > threshold &&
  !quitMainLoop &&
  !errorInCmd)
{
...

The parameter 'n' is the 'threshold' in the above 'if'.
If I understand the man-page of 'Tk_GetNumMainWindows' right
the code above drops out of the 'mainloop' when the
number of toplevel windows drops to 'threshold' or below.

Has anyone used this for values other than '0'?
I have never seen code using this.
What is the idea? Close the application when one of the
main windows gets closed?

Regards,
Matthias Kievernagel
(mkiever/at/web/dot/de)

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Problems to show menubar

2007-11-26 Thread mkieverpy
Hi Mathias,

you need to attach your menubar to a Toplevel window.
A simple Frame cannot have a menubar.
It works, if you change your code like this:


from Tkinter import *

class DistManager(Frame):
...
def createMenuBar(self):
menubar=Menu(self)
kundenmenu=Menu(menubar, tearoff=0)
kundenmenu.add_command(label="Kunden anzeigen")
kundenmenu.add_command(label="Kunden anlegen")
kundenmenu.add_command(label="Kunden bearbeiten")
menubar.add_cascade(label="Kunden", menu=kundenmenu)

self.master.config(menu=menubar)


tk = Tk()
app=DistManager(tk)
app.master.title("CCB- DistributionsManager")
app.master.geometry("800x600")
tk.mainloop()


The menu is attached to the master.
The master must be a widget that can have a menu, like
Tk itself or a Toplevel window.
Another method would be to derive DistManager
from Toplevel (haven't tried though).

Schöne Grüße,
Matthias Kievernagel (mkiever/at/web/dot/de)
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] General Doubt about tkinter windows...

2007-12-03 Thread mkieverpy

Hi José,

>I am trying to develop a simple application in python (I am very newby), but
>I have some general doubts… my main window is Tk(), I am using grid manager,
>and when in the application user changes the view, what I do is take a frame
>out of the grid and put another one (and sometimes there are position
>changes of other remaining frames :-S). My doubt is how can I change the
>window?? Because if I use Toplevel window, main window remains under it, and
>user can also continue changing it, what I don’t want, I just want one
>active window in every moment. Could you give me some hints of how doing it?

please state your problem more clearly.
Also: Try to ask one question at a time.

At the moment I can only guess:
Is your problem about modal / non-modal dialogs
like in a 'file-open'- or 'colour-chooser'-dialog?


Regards,
Matthias Kievernagel
(mkiever/at/web/dot/de)
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Threads and GUI

2008-01-23 Thread mkieverpy

Hello Bob,

You wrote:
>Is there anything that is OK for a thread to do to the GUI?  Like  
>would just calling .update() on a Button() be OK?  It seems to work,  
>but is it OK?

>I'm calling it on a "Stop" button, specifically, in the thread every  
>quarter second, instead of peppering the code with updates() to give  
>the button a chance to set it's IntVar value and then stop everything  
>when the code gets around to checking that.

>From what I remember everybody says: Don't do that!
Some refs I found googling for 'tkinter and threads':

A clear warning
  http://mail.python.org/pipermail/tkinter-discuss/2005-February/000313.html
  (the cited reference is dead, though)
  In the following answer is a small example using threading.

Another example using thread and Queue (from effbot):
  http://effbot.org/zone/tkinter-threads.htm

I have used a solution from Mark Lutz (Programming Python/O'Reilly)
but just for popup dialogs that block the GUI while a thread
is running (communicating via a simple variable).
This might be applicable to your scenario, too.

In a socket testing application I have used 'after' in the GUI thread
to look at a common buffer if new data have arrived.


BTW have you found some info regarding your signals problem?

Hope this helps,
Matthias Kievernagel
(mkiever/at/web/dot/de)
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] fgstipple on Text widget

2008-03-25 Thread mkieverpy

Hi Ron,

>from Tkinter import *

>root = Tk()
>t = Text(root)
>t.insert( END, '01234567890123456789' )
>t.tag_add( 'x', '1.4', '1.12')
>t.tag_config( 'x', fgstipple='gray12' )
>t.pack( )
>root.mainloop()

your code works fine for me. With 'grey12' the
text is just hard to see. Retry with 'grey75'.
For completeness: I'm on Linux, Python 2.4.1, tcl/tk 8.4.6


Cheers,

Matthias Kievernagel
(mkiever/at/web/dot/de)
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] lower() in class Misc

2008-04-02 Thread mkieverpy

Hi Ron,

>Don't know if this is the place to report this.  Not really a bug, however,
>method lower() is defined twice in class Misc in the module Tkinter.py. 
>Both definitions are identical.

right place would have been here:
  http://bugs.python.org/

I created a corresponding entry with a patch
which removes the first Misc.lower:
  http://bugs.python.org/issue2535#

Cheers,
--
Matthias Kievernagel  Software development
mkiever/at/web/dot/de http://mkiever.home.tlink.de
--
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] thread module

2008-04-05 Thread mkieverpy

Hi Amit,

>1.   I created a global variable named "QuitThread" on my main module.
>2.   I initially set it to "False".
>3.   When clicking on the "Run" button of my GUI (defined in the main
>module), a new thread starts using start_new_thread, where QuitThread is
>one of the variables in its tuple.

This sounds wrong. You don't need QuitThread as a parameter to
start_new_thread.

>4.   This new thread runs a function from a second module. In this
>module I also added "import thread".
>5.   This function runs a loop in which it checks every iteration
>whether QuitThread is True or False.
>6.   If it is True, it executes "thread.exit()".
>7.   Nothing happens. The thread continues on running.

has your problem been solved in the mean time?
If not two things to check/try:
- thread.exit works by throwing an exception. Make sure you don't
  catch it by accident.
- Print/log value of QuitThread on every access in both threads.


Cheers,
--
Matthias Kievernagel  Software development
mkiever/at/web/dot/de http://mkiever.home.tlink.de
--
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss