[Tkinter-discuss] Python 2.7: Themed "common dialog" tkinter interfaces via Ttk

2010-10-22 Thread python
I'm cross posting the following question from this thread on
stackoverflow.com:
http://stackoverflow.com/questions/3991130/python-2-7-themed-comm
on-dialog-tkinter-interfaces-via-ttk

Python 2.7 (32-bit) Windows: We're experimenting with Python
2.7's support for themed Tkinter (ttk) for simple GUI's and have
come away very impressed!! The one area where the new theme
support seems to have come up short is how OS specific common
dialogs are wrapped.
In other words, the MESSAGEBOX and COLORCHOOSER common dialogs
have "ugly" looking Win 95 style blocky looking buttons vs. the
themed (rounded/gradient) buttons that normally show up on these
common dialogs under XP, Vista, and Windows 7. (I'm testing on
all 3 platforms with identical, un-themed results).
Note: The filedialog common dialogs (askopenfilename,
askopenfilenames, asksaveasfilename, askdirectory) are all
properly themed.
import tkMessageBox as messagebox
messagebox.showinfo()
import tkColorChooser as colorchooser
color = colorchooser.askcolor( parent=root, title='Customize
colors' )
Any ideas on what's required to get Tkinter's MESSAGEBOX and
COLORCHOOSER common dialogs to be OS theme compatible (at least
under Windows XP or higher)?

Note that Rafe Kettler just filed the following Bug Report on
this:
http://bugs.python.org/issue10171

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


[Tkinter-discuss] Control position of Tkinter common dialogs?

2010-10-25 Thread python
Python 2.7 under Windows: How can we control the position of
Tkinter's common dialogs?

Here's what we've discovered:

  * Certain common dialogs always open up relative to their
parent window

  * Certain common dialogs always open up centered on the user's
desktop

  * All common dialogs appear to ignore the optional parent=
parameter

Questions:

  * How can we force a dialog to open up relative to its parent
window?

  * How can we force a dialog to open up centered on the user's
desktop?

Background:

import tkColorChooser as colorchooser
import tkFileDialog as filedialog
import tkMessageBox as messagebox

# always open up relative to parent windows
fileOpen   = filedialog.askopenfilename()
fileOpens  = filedialog.askopenfilenames()
fileSaveAs = filedialog.asksaveasfilename()
color  = colorchooser.askcolor()

# always open up centered on desktop
folderOpen = filedialog.askdirectory()
messagebox.askquestion()

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


Re: [Tkinter-discuss] Control position of Tkinter common dialogs?

2010-10-26 Thread python
Firat,

> You can create a new toplevel window in the middle of the
screen, then make it invisible and position the dialog windows
relative to this new toplevel... Like this:
[1]http://paste-it.net/public/q2a5594/

Thank you very much for your solution - that's an excellent
workaround for me.

Best regards,
Malcolm

References

1. http://paste-it.net/public/q2a5594/
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Control position of Tkinter common dialogs?

2010-10-27 Thread python
Hi Matt,

> I have a similar issue, however not for common dialogs but for a custom 
toplevel transient dialogs. As you create your dialog it's dimensions
are not known until all idletasks have completed for child widgets being
added to the dialog.

Disclaimer: I'm new to Tkinter development so take this untested idea
with a grain of salt ...

Have you tried positioning your toplevel window off screen (negative
coordinates) so that it can be fully rendered (and you can capture its
dimensions after all layout calculations have completed), then center
your window afterwards?

If you come up with a working solution, I would love to hear about it.
I'll do the same from my end.

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


[Tkinter-discuss] Cancel a window resize/move event trapped via

2010-10-28 Thread python
Is it possible to cancel a window event, eg. if one wanted to
constrain a window to a certain location on a user's desktop?
Returning 'break' from a window's  event does not
cancel window move or resize events.

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


[Tkinter-discuss] Advanced Text example showing "rich text" like or syntax color coding markup?

2010-10-28 Thread python
I'm new to Tkinter development. We have a very simple markup
language that we would like to "syntax color code" using
Tkinter's Text widget.

I'm looking for a simple code snippet, demo app, or high-level
narrative description that explains how one might do this from
one or more of the following perspectives:

- initial markup during load
- realtime markup while a user edits content (including clipboard
pastes)
- at file save time when one must walk the editted content

To start the discusson, how might one do this with an example
markup language with the following syntax?

- any word beginning with '*' gets coded blue
- any word beginning with '@' gets coded green
- all other text has no formatting

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


[Tkinter-discuss] Using Win32 API to get around Tkinter limitations?

2010-10-29 Thread python
Wondering if there are ways to use the Win32 API to get around
the following Tkinter limitations?

1. Inability to set custom mouse cursors via *.cur/*.ani files.

2. Determine the height or width of window properties such as
titlebar, left/right and bottom window frame edges?

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


Re: [Tkinter-discuss] Using Win32 API to get around Tkinter limitations?

2010-10-29 Thread python
Hi Igor,

> Why not use conventional tcl/tk functionality? It seems tcl/tk
allows to use cur/ani files for custom cursor:
> [1]http://wiki.tcl.tk/8674

Thanks for your response. You are correct, under Windows the
cursor='@path/to/file.ext' technique works as expected. I had
tried that, but from within IDLE (Python 2.7) this syntax raises
an exception. Using this technique in scripts running from the
command line (outside of IDLE) works well.

Malcolm

References

1. http://wiki.tcl.tk/8674
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


[Tkinter-discuss] Cross platform way to discover the height/width of window borders/titlebar, etc.

2010-10-29 Thread python
Is there a cross-platform way to discover the height/width of
operating system rendered window borders/titlebars, etc?

If not, any suggestions on how one might discover these
properties when running under Windows using either ctypes or the
pywin32 library?

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


[Tkinter-discuss] How does Python's new ttk (Title) support work under Linux Qt and GTk?

2010-10-29 Thread python
Any comments on the concerns about ttk portability to Qt and GTk 
windowing systems?

The following is from a recent thread on the python-list mailing list.

> Tkinter is built-in and available on Windows, Mac, and Linux. If
you're using Python 2.7 or 3.1 you can take advantage of Tkinter's ttk
(Tile) support for platform native user interfaces.

Reponse: 

You get a native UI using the correct theme even on Linux under Qt or 
GTk?

>From what I've read of ttk, it still isn't using native UI elements.
It just has a bunch of its own "themes" that look mostly/sort-of like
native UI elements. Right?

Under Linux does ttk automagically pick the theme that looks most like
the current Qt or Gtk theme?

On systems where both are installed, how does ttk decide whether to
look like Qt or Gtk?

In addition to looking like native UI elements, does ttk also change
UI behaviors to match native UI elements?  For example will it
automatically use emacs key-bindings for text-entry editing if that's
enabled in my Gtk configuration?
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


[Tkinter-discuss] Tkinter/ttk compatibility with Citrix/WTS (Windows Terminal Services)?

2010-11-03 Thread python
Anyone have any experience using Python Tkinter/ttk applications
with Citrix or WTS (Windows Terminal Services)?

Any concerns, gotchas, or workarounds we should be aware of?

I googled this topic [1], [2] and came up with nothing. No news
is good news ... but just checking to make sure.

Thanks,
Malcolm

[1] tkinter (citrix | ts|terminal services)
[2] tcl (citrix | ts|terminal services)
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


[Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background)

2010-11-03 Thread python
New to Tkinter: Is it possible to stack frames on top of one
another and if so, can frames have transparency?

My goal is to create widgets with gradient backgrounds. I was
hoping I could do this by placing an image in a frame and then
placing an identical sized frame over this image frame. This
on-top frame would contain all my child widgets.

Details: Is it possible to place a frame on top of an image
background? From my reading, the only way to do this appears to
be to use a Canvas as my container (vs. a Frame). The downside to
using a canvas appears to be that Labels do not have transparent
backgrounds so any text I place in such a (canvas based)
container must be placed with Canvas.create_text() vs. laid out
via one of the pack/grid/place layout managers. Am I
understanding this right?

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


Re: [Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background)

2010-11-04 Thread python
Michael,

> To see what can be done, look at my tkinter-based interface,
> at: http://www.wagsoft.com/CorpusTool/img/main.jpg

Nice! So each of your top buttons (Project, Search, Autocode, etc) is
actually a custom widget based on a canvas containing 3 images (manually
placed via .create_image) and then manually labeled with text via
.create_text)? And your canvas backgroundcolors are set to the
backgroundcolor of their parent frame? If I understand your technique,
you place everything manually vs. using a layout manager like pack/grid?

I noticed your buttons are not all the same width - do you have custom
width centre images or is there a way to horizontally stretch an image?
(I've looked for this capability without success). 

Thanks for sharing your technique and screenshot. The screenshot really
helped me understand what you're saying.

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


Re: [Tkinter-discuss] Possible to stack frames with frame transparency? (create widget w/gradient background)

2010-11-05 Thread python
Hi Michael,

> Full code for these buttons available from:
> http://www.wagsoft.com/CTButtonCode.zip

Thank you very much - I learned a lot from studying your code.

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


[Tkinter-discuss] Undo/redo in Entry widget or use a Text widget instead?

2010-11-05 Thread python
Is there a way to implement undo/redo in an Entry widget or
should we use 1 line Text widgets in place of an Entry widget
when we want a textbox like control with undo/redo?

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


[Tkinter-discuss] Possible to stretch an image via Label() or create_image() without PIL?

2010-11-07 Thread python
Is it possible to stretch a Tkinter image horizontally or
vertically when the image is used in a Label() or painted via
create_image() without having to dynamically create stretched
images via PIL?

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


Re: [Tkinter-discuss] Possible to stretch an image via Label() or create_image() without PIL?

2010-11-08 Thread python
Lion,

> PhotoImage has .zoom & .subsample;
> You'd still be dynamically creating stretched images, but you
wouldn't need PIL.
>
[1]http://www.pythonware.com/library/tkinter/introduction/x6606-m
ethods.htm
> Would that work for you?

Thank you - that's exactly the solution I was looking for.

Regards,
Malcolm

References

1. http://www.pythonware.com/library/tkinter/introduction/x6606-methods.htm
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


[Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox?

2010-11-10 Thread python
How can I create non-selectable horizontal separator items in a
Listbox, eg. separators equivalent to the Tkinter Menu widget's
.add_separator()? Using chars like dashes and underscores looks
awful.

If this functionality is not possible, does anyone have a
recommendation on a Unicode char similar to an underscore, but
vertically centered, that I might use as a char based separator?

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


[Tkinter-discuss] Possible to disable individual items in a Tkinter Listbox?

2010-11-10 Thread python
Is here a way to disable individual items in a Tkinter Listbox?

I'm looking for something like .itemconfig( index,
state='disabled' ) (doesn't work) or a special character string
that one might add to an item's text to cause it to be disabled.

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


Re: [Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox?

2010-11-12 Thread python
Lion,

> You may want the "box drawing characters."
> [1]http://en.wikipedia.org/wiki/Box-drawing_characters
>  Like this 
> ── and this ──

Great reference and examples - just what I was looking for.

Thank you!
Malcolm

References

1. http://en.wikipedia.org/wiki/Box-drawing_characters
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Possible to disable individual items in a Tkinter Listbox?

2010-11-12 Thread python
Cameron,

>> Is here a way to disable individual items in a Tkinter Listbox?
.
> Unless recent versions have a configuration for this I haven't 
yet learned, the functionality you're after requires a custom 
binding.

A custom binding meets my need. 

Thank you,
Malcolm

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


Re: [Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox?

2010-11-12 Thread python
Hi Michael,

> tktreectrl can be found here: http://tktreectrl.sourceforge.net/
> and the python wrapper: http://klappnase.bubble.org/TkinterTreectrl/

> tablelist: http://www.nemethi.de/
> and the python module: http://tkinter.unpy.net/wiki/TableListWrapper

Thank you for the links to tkTreeCtrl and TableList. 

I have not used custom Tk modules before. Where do you recommend I place
the custom Tk code in order for Tkinter to find it?

I'm using the 32-bit version of Python 2.7 for Windows.

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


Re: [Tkinter-discuss] Possible to create separator lines in a Tkinter Listbox?

2010-11-12 Thread python
Hi Wayne,
> unichr(8213)  looks pretty good. I'm not sure if your original
desire is possible, but you could make it non-selectable by
binding <>.
>
> 1. Is current selection one of the separators?
> 2. If not, OK
> 3. If so, change selection to the previous item

Thanks! I'm following your strategy and it works well for me.

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


[Tkinter-discuss] Definitive list of all Tkinter events?

2010-11-13 Thread python
Is there a single, master list of all possible Tkinter events?
I've been searching for such a list without success.

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


Re: [Tkinter-discuss] Definitive list of all Tkinter events?

2010-11-13 Thread python
Lion,

>  I've created
>  [1]http://tkinter.unpythonic.net/wiki/Events
> on the wiki, to note the location of such a list if it is
found, ...
Thank you very much!

Regards,
Malcolm

References

1. http://tkinter.unpythonic.net/wiki/Events
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Definitive list of all Tkinter events?

2010-11-13 Thread python
Cameron,

> The page has been updated:
> http://tkinter.unpythonic.net/wiki/Events

Thank you! These are excellent references to generic events. How does
one discover (virtual) events like <>, <>, <>,
<>, etc.

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


[Tkinter-discuss] Swap position of 2 widgets positioned in parent container via pack() or grid()?

2010-11-15 Thread python
Any tips on how I can swap the position of 2 widgets who have
been positioned in a parent container via pack() or grid()?

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


[Tkinter-discuss] Bind to event related to currently selected menu item

2010-11-18 Thread python
Wondering if there's a menu event I can bind to that's related to
the currently selected menu item? By menu item I mean the items
that show up in a popup menu like New, Open, Save, etc.
Use case: I would like to update a statusbar area of our
application with a description of the currently selected menu
item.

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


[Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item

2010-11-19 Thread python
I'm looking for an example of how to use <> to
determine currently selected menu item.

Use case: Display a context sensitive help message in an
application's statusbar as a user navigates through various menu
items.

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


Re: [Tkinter-discuss] Bind to event related to currently selected menu item

2010-11-20 Thread python
Kevin,

> Try <>.

Thanks for the recommendation. Any suggestions on how I can determine
the currently selected menu item in the event raised by <>?

# here's how I create my popup menu
popup = tk.Menu( menubar )
popup.bind( '<>', statusbarUpdate )

# here's the command I bind to
def statusbarUpdate( event=None ):
for key in dir( event ):
print key, getattr( event, key )

This outputs the following information as I move between menu items (eg.
the event is being raised properly).

Note: There seems to be no way to determine the current menu widget
(event.widget is a string vs. widget reference).

char ??
delta 0
height ??
keycode ??
keysym ??
keysym_num ??
num ??
send_event False
serial 238
state 0
time 1585806557
type 35
widget .#52754872.#52754872#52755392 <-- string vs. widget reference
width ??
x 36160384
x_root 487
y 53363120
y_root 307

Any suggestions appreciated!

Thank you,
Malcolm


> Wondering if there's a menu event I can bind to that's related to the
> currently selected menu item? By menu item I mean the items that show up
> in a popup menu like New, Open, Save, etc.
>
> Use case: I would like to update a statusbar area of our application
> with a description of the currently selected menu item.

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


Re: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item

2010-11-20 Thread python
Hi Michael,

Thank you for your idea to use the  event. That works when I use
the mouse, but it doesn't work when a user uses the cursor keys to move
between menu items.

I can trap the <> event - I just need a way to determine the
current menu widget and its active index.

The event object passed to the function I bind to has event.widget
reference to a string vs. a widget. Do you have any ideas on how I can
determine the active menu widget and its active index independent of a
current event object?

Thank you,
Malcolm


- Original message -
From: "Michael Lange" 
To: tkinter-discuss@python.org
Date: Sat, 20 Nov 2010 00:11:42 +0100
Subject: Re: [Tkinter-discuss] Looking for example of how to use
<> to determine currently selected menu item

Hi,

Thus spoketh pyt...@bdurham.com 
unto us on Fri, 19 Nov 2010 17:25:38 -0500:

> I'm looking for an example of how to use <> to
> determine currently selected menu item.
> 
> Use case: Display a context sensitive help message in an
> application's statusbar as a user navigates through various menu
> items.
> 

Maybe you are better off with a simple Motion event, you can access the
menu item under the mouse pointer through the menu's index() method
(from the menu manpage:

Many of the widget commands for a menu take as one argument an indicator
of which entry of the menu to operate on. These indicators are called
indexes and may be specified in any of the following forms:
(...)
@number
In this form, number is treated as a y-coordinate in the menu's
window; the entry closest to that y-coordinate is used. For example,
`...@0'' indicates the top-most entry in the window.

)
So, in this simple example, you will surely see the point:



from Tkinter import *

root = Tk()
m = Menu(root)
m.add_command(label='foo')
m.add_command(label='bar')
m.add_command(label='blah')

root.bind('<3>', lambda event: m.tk_popup(event.x_root, event.y_root))

def callback(event):
try:
print m.entrycget(m.index('@%d' % event.y), 'label')
except TclError:
print 'this must have been the tearoff or something'

m.bind('', callback)

root.mainloop()





I hope this helps

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. .
.-.

Extreme feminine beauty is always disturbing.
-- Spock, "The Cloud Minders", stardate 5818.4
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

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


Re: [Tkinter-discuss] Bind to event related to currently selected menu item

2010-11-21 Thread python
Michael,

Thank you! That's EXACTLY the solution I was looking for :)

Regards,
Malcolm


Change your statusbarUpdate for the following, which will print out
the index of the currently selected menu item:

def statusbarUpdate( event=None ):
   print tk.call(event.widget, "index", "active")

Note that this uses tcl/tk code, where Tkinter code should be used,
but it seems the corresponding tkinter code is broken, e.g., with

def statusbarUpdate( event=None ):
   print popup.index('active')

...always returns None on changing the menu selection.

My test code below

from Tkinter import *
import tkFont
tk = Tk()

def statusbarUpdate( event=None ):
   print tk.call(event.widget, "index", "active")

menubar=Menu(tk)
tk.config(menu=menubar)
popup = Menu( menubar )
menubar.add_cascade(label="MyMenu", menu=popup)
popup.bind( '<>', statusbarUpdate )
popup.add_command(label="Option 1")
popup.add_command(label="Option 2")
popup.add_command(label="Option 3")
tk.mainloop()


On Sat, Nov 20, 2010 at 11:19 PM,   wrote:
> Kevin,
>
>> Try <>.
>
> Thanks for the recommendation. Any suggestions on how I can determine
> the currently selected menu item in the event raised by <>?
>
> # here's how I create my popup menu
> popup = tk.Menu( menubar )
> popup.bind( '<>', statusbarUpdate )
>
> # here's the command I bind to
> def statusbarUpdate( event=None ):
>    for key in dir( event ):
>        print key, getattr( event, key )
>
> This outputs the following information as I move between menu items (eg.
> the event is being raised properly).
>
> Note: There seems to be no way to determine the current menu widget
> (event.widget is a string vs. widget reference).
>
> char ??
> delta 0
> height ??
> keycode ??
> keysym ??
> keysym_num ??
> num ??
> send_event False
> serial 238
> state 0
> time 1585806557
> type 35
> widget .#52754872.#52754872#52755392 <-- string vs. widget reference
> width ??
> x 36160384
> x_root 487
> y 53363120
> y_root 307
>
>> Wondering if there's a menu event I can bind to that's related to the
>> currently selected menu item? By menu item I mean the items that show up
>> in a popup menu like New, Open, Save, etc.
>>
>> Use case: I would like to update a statusbar area of our application
>> with a description of the currently selected menu item.


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


Re: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item

2010-11-21 Thread python
Hi Michael(s):

> At least in Python 2.5.4 linked to Tk 8.4 (Windows version),
> the following fails  because event.widget holds a string (the tcl/tk
> widget name), not a Tkinter class.
>
> def callback(event):
>    print event.widget.index('active')
>
> Maybe fixed in later editions

This fails in 32-bit Python 2.7 for Windows (linked to Tk 8.5 with
ttk/Tile).

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


Re: [Tkinter-discuss] Looking for example of how to use <> to determine currently selected menu item

2010-11-21 Thread python
Michael(s):

> def callback(event):
>    print event.widget.index('active')
>
> I see, this happens only with cascade menus, in my example I only had a
> popup menu, for which it worked as expected. Right now I am trying to
> figure out what's wrong with Tkinter (it's definitely a bug within
> Tkinter.py, and I doubt that it has been fixed since 2.6.5), I'll send
> another post when I know more. Of course for now you are right, your code
> "just works" :)

I can confirm that this bug still exists in 32-bit Python 2.7 for
Windows for both standalone and cascading menus.

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


Re: [Tkinter-discuss] Bind to event related to currently selected menu item

2010-11-21 Thread python
Hi Michael,

> The problem is apparently that the widget name of the menu's "button" is 
> assigned by Tk and there does not seem to be a way to access this subwidget 
> from within Tkinter. Besides this I don't understand why this does not happen 
> with the context
menu from my previous example but only with a cascaded menu.

Your example fails for both context and cascading menus under 32-bit
Python 2.7 for Windows.

I appreciate your and Michael's help. Thank you both!

Malcolm


Thus spoketh "Michael O'Donnell"  
unto us on Sun, 21 Nov 2010 10:26:24 +0100:

> Hi Malcom,
> 
> Change your statusbarUpdate for the following, which will print out
> the index of the currently selected menu item:
> 
> def statusbarUpdate( event=None ):
>print tk.call(event.widget, "index", "active")
> 
> Note that this uses tcl/tk code, where Tkinter code should be used,
> but it seems the corresponding tkinter code is broken, e.g., with
> 
> def statusbarUpdate( event=None ):
>print popup.index('active')
> 
> ...always returns None on changing the menu selection.

I believe this is because the button in the menu is treated as a
different
widget by Tk, so the correct call would be:

def statusbarUpdate(event):
print event.widget.index('active')

However, using this I get an error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1410, in
__call__ return self.func(*args)
  File "test2.py", line 18, in statusbarUpdate
print event.widget.index('active')
ValueError: substring not found

This is apparently because event.widget is not (as expected) a widget
instance but a string which looks like .#153369036.#153369036#153369644

Trying to feed this string to nametowidget() I get the following error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1410, in
__call__ return self.func(*args)
  File "test2.py", line 18, in statusbarUpdate
print tk.nametowidget(event.widget)#.index('active')
  File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1079, in
nametowidget w = w.children[n]
KeyError: '#153369036'

The problem is apparently that the widget name of the menu's "button" is
assigned by Tk and there does not seem to be a way to access this
subwidget from within Tkinter.
Besides this I don't understand why this does not happen with the
context
menu from my previous example but only with a cascaded menu.

This looks to me like a bug in Tkinter, but I don't have an idea how
this
could ever be fixed (at least without dealing with _tkinter's
internals),
so we probably will have to stick with Michael's workaround.

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


[Tkinter-discuss] Working with tear-off menus (change the "-----" label, customize location/appearance of tear-off window)

2010-11-21 Thread python
I've been experimenting with Tkinter tear-off menus and have the
following questions (relative to Windows):

1. Is there a way to change the default appearance of the
"--" menu label that is used to indicate a tear-off menu -OR-
is there a way to programmatically convert a menu widget to a
torn-off state? Note: The tear-off menu item does not have a
'label' property.

2. Is there a way to customize the location and appearance of the
window that contains a tear-off menu? On Windows, the tear-off
menus appear at random(?) places on the desktop. And these
windows have min/max buttons and are resizable - all behaviors
that IMO don't make sense for a floating tear-off menu. What I
would like to do is capture a reference to the window of a
tear-off and customize it like I would any other Toplevel()
window. Is this possible?

Note: I can detect the tearoff event by using the tearoffcommand=
option when I create a menu. I think this event is where I want
to take control of the tear-off menu's window properties? But how
to get a reference to the tear-off menu's window (and does it
exist yet?).

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


Re: [Tkinter-discuss] Working with tear-off menus (change the "-----" label, customize location/appearance of tear-off window)

2010-11-22 Thread python
Hi Jeff,

Thank you! Confirming that your code works under Windows 7 with 32-bit
Python 2.7.

Regards,
Malcolm



From: "Jeff Epler" 

You can manually create a tearoff from a menu:
% .m clone .mt tearoff
and post it at a desired location:
% .mt post 100 100
As suggested in the other message, you can use "wm resizeable" to make
it not change size:
% wm resiz .mt 0 0
(Of course, I only tested this on linux, so on Windows YMMV)

Unfortunately, the menu 'clone' subcommand does not seem to be wrapped
in Python.   You can add it, but it'll be gross and touches stuff that
should be considered implementation details of Tkinter (works with
all python2.x I'm aware of, though):

# --
import Tkinter, types
def makewidget(master, klass, path):
path = str(path)
self = types.InstanceType(klass)
self._name = path[len(master._w)+1:]
self._w = path
self.children = {}
master.children[self._name] = self
self.master = master
self.tk = master.tk
return self

def tearoff(menu):
child = str(menu) + ".tearoff"
menu.tk.call((menu, "clone", child, "tearoff"))
return makewidget(menu, Tkinter.Menu, child)
# --

And then you'll find that 'wm_resizable' is not available because Menu
is not a subclass of Wm.  Just call it directly through Tk:
>>> mt = tearoff(m)
>>> mt.tk.call("wm", "resizable", mt, 0, 0)
>>> mt.post(100, 100)


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


Re: [Tkinter-discuss] Working with tear-off menus (change the "-----" label, customize location/appearance of tear-off window)

2010-11-22 Thread python
Hi Michael,

Thank you for your help. Your solution works well (tested under Windows
7 with 32-bit Python 2.7).

Regards,
Malcolm



> 2. Is there a way to customize the location and appearance of the
> window that contains a tear-off menu? On Windows, the tear-off
> menus appear at random(?) places on the desktop. And these
> windows have min/max buttons and are resizable - all behaviors
> that IMO don't make sense for a floating tear-off menu. What I
> would like to do is capture a reference to the window of a
> tear-off and customize it like I would any other Toplevel()
> window. Is this possible?

Here on linux (I guess it should be the same on windows) the
tearoffcommand takes two arguments, first the menu itself and second the
newly created toplevel window, both as strings however, and Tkinter
doesn't know about the toplevel, so you will have to use the tcl-syntax
again :(

See this example:

from Tkinter import *
root = Tk()

def foo(menu, top):
root.nametowidget(menu).add_command(label='baz')
root.tk.call('wm', 'resizable', top,  '0', '0')

m = Menu(root, tearoffcommand=foo)
m.add_command(label='foo')
m.add_command(label='bar')
m.add_command(label='blah')

root.bind('<3>', lambda event: m.tk_popup(event.x_root, event.y_root))

root.mainloop()


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


[Tkinter-discuss] Change the font style (bold, italic, stikethru, normal) of widgets without explictly knowing font?

2010-11-22 Thread python
Is there a simple way to change the font style of widgets without
explictly knowing the widget's font?

For example: if I want to toggle the bold state of a widget's
text, do I need to determine its font, then build an equivalent
font object/expression with the font style I need, and pass that
full font description to widget.config() or can I use a shortcut
technique that allows me to pass 'bold' or 'normal' to control a
widget's font.

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


Re: [Tkinter-discuss] Change the font style (bold, italic, stikethru, normal) of widgets without explictly knowing font?

2010-11-22 Thread python
Wayne,

> mylabel.config(font=mylabel.config()['font'][4][:2] +
('normal',))
> mylabel.config(font=mylabel.config()['font'][4][:2] + ('bold',
'italics'))

That works!

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


Re: [Tkinter-discuss] Change the font style (bold, italic, stikethru, normal) of widgets without explictly knowing font?

2010-11-22 Thread python
Hi Michael,

> If you don't explicitely define the label's font, the font is a string (at 
> least here, on linux):
> >>> from Tkinter import *
> >>> l=Label(text='foo')
> >>> l.pack()
> >>> l.cget('font')
> 'Helvetica -12 bold'

I get strings as well (32-bit Python 2.7 under Windows 7).

> If you want to do fancy things with fonts, I'd try tkFont, with a 
> tkFont.Font() you can easily configure all kinds of font attributes.

I agree with you - tkFont is definitely the way to go.

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


[Tkinter-discuss] Tkinter support different styles of underlining?

2010-11-29 Thread python
Does Tkinter (directly of via tk/tcl) support different styles of
underlining, eg. dotted underlines or squiggly underlines
(typically used to indicate a word is misspelled in MS Word or
FireFox)?

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


[Tkinter-discuss] Possible to create equivalent of named font objects for colors?

2010-11-29 Thread python
Tkinter has a cool way to create named font objects that can be
used across widgets. When a named font object is updated, all the
widgets that use the named font automatically update their fonts
as well.

Is there a similar way to implement "named colors", eg. where we
can update a "color object" in one place and have all widgets
that reference this color object update their colors as well?

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


[Tkinter-discuss] Anyone building MS Office-like ribbonbar interfaces using Tkinter?

2010-12-01 Thread python
Curious if any of you are building MS Office-like ribbonbar user
interfaces using Tkinter? If so, I would love to see a screenshot
to see what is possible.
We're starting to get more requests for this type of modern user
interface. Personally, I hate the new MS Office ribbonbars (after
more than 2 years of trying to like this interface), but I have
to admit they do look visually more appealing (or at least more
modern) than traditional menu/toolbars interfaces.
What are your thoughts regarding the ribbonbar widget - useful,
annoying, important, impossible to implement in Tkinter, etc?

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


[Tkinter-discuss] Right justify Label against Entry using pack?

2010-12-01 Thread python
I'm experimenting with geometry layouts and would like to know if
its possible to line up a Label and an Entry widget (in the same
horizontal line) and have the Label widget right align to the
Entry widget. I know I can do this via grid, but I'm wondering if
this is possible via pack.

Here's the 1 line layout I'm trying to achieve:

 [Label] [Entry]
^^^
Where the ^^^ indicates leading space due to right alignment of
the label against its Entry.

Listed below is my test code. I've tried using Tkinter's Label
and ttk's Label. I've tried using anchor, justify, and fill in
various combinations without success. One interesting
observation: the ttk Label widget always seems to align left in
the scenario below while I can get the Tkinter Label widget to
center or left align, but never right align.

Perhaps I'm confused about when to use justification vs.
alignment to achieve my goal?

Your thoughts appreciated!

import Tkinter as tk
import ttk
root = tk.Tk()
frame = tk.Frame( root )

parent = frame
label = tk.Label( parent )

# note that I'm explictly setting width to create an environment
for alignment or justification
label.config( text='Password', width=20, justify='right' )
label.pack( side='left', anchor='e', padx=4, pady=4 )
entry = ttk.Entry( parent )
entry.pack( side='left', anchor='w', fill='x', expand=True,
padx=4, pady=4 )
frame.pack( side='top', anchor='n', fill='x', expand=True,
padx=4, pady=4 )

root.mainloop()

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


Re: [Tkinter-discuss] Right justify Label against Entry using pack?

2010-12-01 Thread python
John,

> The following simplification of your code works for me on linux, also 
> illustrating the use of justify:

Thank you for your explanation and sample code. My problem was I didn't
know that anchor was an option for widgets - I thought this option only
applied to the pack() method.

Configuring my widgets with an anchor='w' gives me the solution I'm
looking for.

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


Re: [Tkinter-discuss] Anyone building MS Office-like ribbonbar interfaces using Tkinter?

2010-12-01 Thread python
Kevin,

> Tkribbon might be of interest:
> 
> http://bit.ly/hLrwIO
> 
> That link includes the announcement and a download link.
> 
> And a few  screenshots:
>
> http://www.ellogon.org/~petasis/tcl/TkRibbon/images/TkRibbon-Default.png
> http://www.ellogon.org/~petasis/tcl/TkRibbon/images/TkRibbon-Minimised.png
> http://www.ellogon.org/~petasis/tcl/TkRibbon/images/TkRibbon-Floating.png

WOW! :)

Thank you!!

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


[Tkinter-discuss] Removing/disabling a resizable window's maximize button under Windows

2010-12-01 Thread python
Looking for advice on how to remove or disable a *resizable*
window's maximize button under Windows. I'm using Python 2.7 for
Windows.

Background: I have a resizable window with min and max sizes set
via the window's minsize() and maxsize() methods. When a user
clicks the maximize button, the window moves to the upper left of
the display. This is very confusing to my users so I would like
to prevent that behavior.

My research shows several ways to disable a maximize button - but
none of these techniques seem to apply to resizable windows?

1. Prevent a window from resizing via the resizable( False, False
) method.

2. Remove all the window's controls (and border) via the
overrideredirect( True ) method.

3. Use the mysterious transient(1) method (this raises an
exception under Windows).

Is there a way I can trap the maximize event (what event to bind
to?) and return "break" to prevent the maximize from happening
(or better yet, substitute my own behavior instead)?

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


[Tkinter-discuss] Customize horizontal padding between image and text in Label widget?

2010-12-01 Thread python
Is there a way to customize the horizontal padding between an
image and text in a Label widget when compound=left or right?

The 2 ways I can think of are:

1. Use PIL to dynamically add columns of pixels to an image

2. Insert or append spaces to the text= option of the label to
force the separation of image and text

What I'm looking for is a way to specify the horizontal padding
(between image and text) in pixels.

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


Re: [Tkinter-discuss] Removing/disabling a resizable window's maximize button under Windows

2010-12-02 Thread python
Hi Michael,


The only thing I can think of is to catch the  event and try
to determine the current state of the window, like:

def on_configure(event):
if event.widget.wm_state() == 'zoomed':
...update the window geometry as desired...

root.bind('`, on_configure)


Thanks for your help. Here's what I discovered (Python 2.7 under Windows
7):

Binding a toplevel window's  event traps  events
for all of the window's widgets, not just the window itself. So here's
how I coded my event handler:

def onFrmResize( event=None ):
if not hasattr( event.widget, 'state' ):
return

if event.widget.state() == 'zoomed':
# proves I'm trapping maximize event
print 'maximize detected'

# return 'break' <--- does not work
# event.widget.geometry( '+100+100' ) <--- does not work

I can confirm that my event handler is being called properly via the
print message, but both return 'break' and explicitly setting position
via the geometry method appear to be ignored when executed within the
event handler.

Any other ideas?

Thanks,
Malcolm




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


Re: [Tkinter-discuss] Removing/disabling a resizable window's maximize button under Windows

2010-12-02 Thread python
Michael,

Here's an updated version of my event handler that restores a window to
its previous size/position when a maximize event is detected. Apparently
all one can do within the  event is change the state of a
window - changes to a window's geometry (size/position) are ignored.

The following is not a perfect technique - users can still see their
window move to the upper left corner of the display and then return to
its original state.

def onFrmResize( event=None ):
if not hasattr( event.widget, 'state' ):
return

if event.widget.state() == 'zoomed':
event.widget.state( 'normal' )

I wonder if there's an event that comes *before*  when a
window is maximized?

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


[Tkinter-discuss] Control vertical position of checkbutton [x] when wrap= creates multiline checkbutton captions

2010-12-02 Thread python
Is it possible to control the vertical position of the
checkbutton widget's [x] when the checkbutton has multi-line
text?

It appears that Tkinter vertically centers the [x] relative to
the word-wrapped checkbutton text that spans multiple lines
(activated via the wrap= option). I would like to anchor the [x]
component of the checkbutton widget to the top of the widget, eg.
aligned with the first line of the checkbutton's caption.

Is this possible?

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


[Tkinter-discuss] Possible to fade a small Tkinter image into a specific background color?

2010-12-06 Thread python
Wondering if there's a PIL/Tkinter technique I can use to fade a
small image into a specific background color?

Use case: I have a small message area that displays both an icon
and text message. I can fade my foreground text into its
background container by iteratively moving my message text's rgb
components towards its background rgb value until my text has the
same foreground and background colors.

I'm wondering if there's a similar technique I can use with PIL
and its Image, ImageTk classes to do the same with an image
displayed in Tkinter? I suspect I can do this by inspecting and
updating every pixel individually, but this seems very
inefficent.

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


[Tkinter-discuss] Force a Frame and/or Text widget to a specific width?

2010-12-07 Thread python
Is there a technique where I can force a Frame and/or Text widget
to a specific width? I understand that width= many times only
serves as a hint to Tkinter's layout managers. I'm looking for a
width setting technique that's much more forceful than a
suggestion :)

I'm using a Text widget with wrap='word' as a multi-line label. I
pack this Text widget into a Frame.

This Text widget wants to grow to a certain width inspite of
setting a specific (char) width for Text and a specific (pixel)
width for its parent Frame.

The only way I can control my Text widget's width is by placing
it in a window with a max width set via .maxsize( width, ... )
and resizing disabled via resizable( False, False ).

If I skip the resizable( False, False ) statement, then I get the
proper sized Text/Frame *until* I go to resize my window ... as
soon as I go to resize my window, it snaps to the width it wants
to go to when I don't force maxsize().

BTW: I'm using 32-bit Python 2.7 for Windows.

Am I missing something obvious?

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


Re: [Tkinter-discuss] Force a Frame and/or Text widget to a specific width?

2010-12-07 Thread python
Apologies for the poorly worded description below.

I *can* set my Text widget to a specific width. What I would like
to do is set my Text widget to a specific width, have it do its
layout with word wrap, then remove the width property so that the
Text widget can resize as its parent container resizes.

Is this possible?

Thank you,
Malcolm

- Original message -
From: pyt...@bdurham.com
To: "Python-Tkinter" 
Date: Tue, 07 Dec 2010 11:07:43 -0500
Subject: [Tkinter-discuss] Force a Frame and/or Text widget to a
specific width?

Is there a technique where I can force a Frame and/or Text widget
to a specific width? I understand that width= many times only
serves as a hint to Tkinter's layout managers. I'm looking for a
width setting technique that's much more forceful than a
suggestion :)

I'm using a Text widget with wrap='word' as a multi-line label. I
pack this Text widget into a Frame.

This Text widget wants to grow to a certain width inspite of
setting a specific (char) width for Text and a specific (pixel)
width for its parent Frame.

The only way I can control my Text widget's width is by placing
it in a window with a max width set via .maxsize( width, ... )
and resizing disabled via resizable( False, False ).

If I skip the resizable( False, False ) statement, then I get the
proper sized Text/Frame *until* I go to resize my window ... as
soon as I go to resize my window, it snaps to the width it wants
to go to when I don't force maxsize().

BTW: I'm using 32-bit Python 2.7 for Windows.

Am I missing something obvious?

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


[Tkinter-discuss] Recommendations for free and commercial icon/image sets licensed for commercial use?

2010-12-07 Thread python
Any recommendations for free and commercial icon/image sets
licensed for commercial use?

I've seen some really high quality icons/images in open source
software lately, but I suspect most of these image sets are GPL
in nature, thus (in my interpretation) not available for use in
commercial products.

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


[Tkinter-discuss] Possible to create single pixel wide horizontal/vertical ttk.Separator's?

2010-12-07 Thread python
Is there a way to create single pixel wide horizontal and
vertical ttk.Separator()'s?

Python 2.7/Windows: When I magnify the ttk Separators they are
built as 2 parallel lines - one line gray and one line a
light/white color. The latter color added to create a subtle 3d
effect?

I would like to create single pixel wide separators that have the
system default gray color. A bonus would be the ability to
programmatically discover the system color used for a separator's
gray band.

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


[Tkinter-discuss] Possible to set the min/max height or width of a Tkinter or ttk Frame?

2010-12-09 Thread python
The size of Tkinter windows can be controlled via the following
methods:

.minsize()
.maxsize()
.resizable()

Are there equivalent ways to control the size of Tkinter or ttk
Frames?

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


[Tkinter-discuss] pack equivalent of grid_remove(), eg. pack_remove() ?

2010-12-09 Thread python
Is there a pack equivalent of the grid_remove() method where a
widget's original pack() settings are restored on a re-pack()?
Use case: When I show a packed widget that has been hidden via
pack_forget(), I would like to have the widget re-packed with its
original pack settings when I issue the widget.pack() show
request.
Thanks,
Malcolm
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


[Tkinter-discuss] How to determine if a widget is pack()-ed or unpacked via pack_forget()?

2010-12-09 Thread python
Is there a widget method that returns whether a widget is
pack()-ed or unpacked?
The same question applies to widget's placed with the grid() or
place() layout managers.

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


Re: [Tkinter-discuss] pack equivalent of grid_remove(), eg. pack_remove() ?

2010-12-09 Thread python
Kevin,

> No, there isn't. You have to be careful with the packing order for 
pack_forget() to work--this works best if you limit its use to the last 
widget group packed. Otherwise, it may be packed in a different 
location, with surprising results.

Thanks for that tip! (You're right - I would have been surprised!)

Is there a best practice way to show/hide specific widgets (or
containers) in Tkinter?

Is grid a better layout manager than pack for this type of use case?

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


Re: [Tkinter-discuss] pack equivalent of grid_remove(), eg. pack_remove() ?

2010-12-09 Thread python
> Is there a best practice way to show/hide specific widgets (or containers) in 
> Tkinter?

Another way to control visibility might be to size a control/widget a
height/width of 0,0.

But Tkinter ignores this type of size request. (It does accept a size
request of 1,1, but in the case of Frame, immediately resizes itself to
its 'natural' size).

Anyone have any thoughts on this approach?

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


Re: [Tkinter-discuss] pack equivalent of grid_remove(), eg. pack_remove() ?

2010-12-09 Thread python
Michael,

Thanks for the pack_forget() implementation and for the confirmation
that one should use grid vs. pack for scenarios that require
showing/hiding widgets.

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


[Tkinter-discuss] Recommendations on when to use pack vs. grid layouts?

2010-12-09 Thread python
Are there any best practice tips regarding when one should use
pack vs. grid for their layouts?

>From what I've been reading via google, the concencus seems to be
that grid can handle any pack scenario but not vice-versa.

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


Re: [Tkinter-discuss] pack equivalent of grid_remove(), eg. pack_remove() ?

2010-12-10 Thread python
Michael,

Your pack_forget() code works like a charm!

Thank you,
Malcolm




From: "Michael Lange" 
To: tkinter-discuss@python.org
Date: Thu, 9 Dec 2010 15:51:23 +0100

There's nothing like that built in, but it is quite easy to set it up:

from Tkinter import *
root = Tk()
root.geometry('200x200')

class pFrame(Frame):
def __init(self, *args, **kw):
Frame.__init__(self, *args, **kw)
self._packinfo = {}

def pack(self, *args, **kw):
Frame.pack(self, *args, **kw)
self._packinfo = self.pack_info()
pack_configure = pack

def pack_recall(self):
self.pack(**self._packinfo)


f = pFrame(root, bg='yellow')
f.pack(fill='both', expand=1)
f.pack_forget()
f.pack_recall()

root.mainloop()


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


Re: [Tkinter-discuss] How to determine if a widget is pack()-ed or unpacked via pack_forget()?

2010-12-10 Thread python
Mick,

Perfect - that's just what I was looking for.

Malcolm


From: "Michael O'Donnell" 

Look at:

w.winfo_ismapped()

...Note that if a widget IS packed, but the parent (or some ancestor)
is not, this will return False.

w.winfo_manager()

-- will return "" if the widget is not packed/gridded etc.,
disregarding whether the parent is not packed.
Otherwise returns info on how it is placed.

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


Re: [Tkinter-discuss] Recommendations on when to use pack vs. grid layouts?

2010-12-10 Thread python
Mick,

> If you are placing a row of widgets into a frame, with pack you don't have to 
> keep track of which column you are up to, just pack them one after the other.

I think grid() will automatically increment the row if you don't specify
it.

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


[Tkinter-discuss] How do Tkinter's Entry/Text support for Ctrl+X/Ctrl+C/Ctrl+V (cut, copy, paste) work in non-English locales?

2010-12-10 Thread python
It seems that Tkinter Entry and Text widgets have built in
support for basic clipboard functionality via the keystrokes
Ctrl+X/Ctrl+C/Ctrl+V (cut, copy, paste).

Of course these make sense for English speaking locales. How does
this functionality work when Tkinter is used in non-English
locales? Are these keystroke shortcuts hard coded or do they
switch to locale/language specific shortcuts?

Is there a way to turnoff this functionality or map these
built-in clipboard keystrokes to different keys?

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


[Tkinter-discuss] Tips for using Tkinter in non-US locales and/or locale module integration with Tkinter Entry widgets

2010-12-10 Thread python
I noticed there are a lot of non-US developers on this list. I'm
looking for tips on using Tkinter in non-US locales.

In particular:

1. Are there any Unicode or font specific issues to be concerned
about?

2. Are you using the locale module to control how you display or
parse data moving into and out of Entry widgets? (has anyone
wrapped the Entry widget with locale aware code?)

3. Are you using gettext with Tkinter and if so, are there any
tips or traps to watch for? (I think gettext integration should
be seamless, but didn't think it would hurt to confirm this)

Thank you (gracias, danke, merci, grazie, muito obrigado, tusen
takk, spasibo balshoye, duizend maal dank, ... etc)

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


[Tkinter-discuss] What determines the initial position of Tkinter's root and Toplevel() windows?

2010-12-10 Thread python
What determines the initial position of Tkinter's root and
Toplevel() windows?

Under Windows (running Python 2.7), my root window appears to
show up in random positions (usually clustered around the upper
left of my display).

The position of my first Toplevel() window appears to be random
as well. Subsequent Toplevel() windows appear offset from the
position of the first Toplevel() window by a consistent(?) amount
of space. I think the pattern for subsequent Toplevel() window
positions might be described as a "tiled" effect?

Are these Tkinter specific behaviors or OS specific behaviors?

What approach do you take with your window placement:

- accept the default window position as given by Tkinter
- proactively specify a window position
- center your windows on the desktop
- remember and restore window positions (and sizes?) across
sessions
- other

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


Re: [Tkinter-discuss] How do Tkinter's Entry/Text support for Ctrl+X/Ctrl+C/Ctrl+V (cut, copy, paste) work in non-English locales?

2010-12-10 Thread python
Michael,

> >>> e1.event_delete('<>', '')
> >>> e1.event_add('<>', '')

Thank you! That's the *exact* technique I was searching for.

> I'm not sure if this would make sense, though. Aren't these default bindings 
> the same for any locale (at least this is true for germany :)? 

I mistakenly thought that these bindings were localized for each
language. Thanks for correcting me.

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


Re: [Tkinter-discuss] Ttk.Labelframe control label does not change color

2010-12-12 Thread python
Craf,

> Changing the background color ttk.Labelframe control, label does not change 
> color.

I believe this is by design, eg. none of the ttk widgets allow their
foreground or background colors to be changed because these colors are
determined by the system's current color scheme.

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


Re: [Tkinter-discuss] ssh login through Tkinter - problem on windows

2010-12-14 Thread python
Michael,

> pipe = subprocess.Popen(args, stdout=subprocess.PIPE, 
> stderr=subprocess.STDOUT, shell=False)

What happens when you try shell=True?

Also, is there a way to run ssh unbuffered?

What happens when you exit root.mainloop()? Can you try a root.after(
1000, root.quit ) to see if your example works after Tk exits?

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


[Tkinter-discuss] Ideas for user interface to allow users to change order of ttk.Notebook pages/tabs?

2010-12-14 Thread python
I'm using the ttk.Notebook widget to manage a list of open files.
I create and destroy tabs as a user opens and closes files.

I would like to offer my users a way to change the order of the
notebook tabs. Ideally I would like my users to be able to drag
and drop tabs like they do in Firefox, but I can't see a way to
do this with the events exposed by the Notebook widget. Since
drag and drop is not available to us, what do you think might be
an intuitive user (Tkinter/ttk-based) interface for allowing
users to reorder their tabs?

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


[Tkinter-discuss] Change ttk.Notebook tab's font or font height?

2010-12-14 Thread python
Is there a way to change the ttk.Notebook tab's font or font
height?

Use case: I would like to use a named font object for my tab
captions so a user can change the height of the named font and
have the font sizes of all the widgets on a page increase in size
(including the ttk.Notebook tab captions). The user in question
has vision problems.

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


[Tkinter-discuss] ttk.Notebook - how to bind to tab events (tab caption has focus or mouseover)

2010-12-15 Thread python
I'm using the ttk.Notebook widget. What object do I bind to
capture events related to specific tabs?

I would like to trap when a tab caption gets keyboard focus
('') and when the mouse pointer is over a specific tab
caption ('').

I can trap mouse clicks on tabs (, ), but I
can't find a way to determine what tab a user clicked on in the
case of a right click.

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


Re: [Tkinter-discuss] [Fwd: Change ttk.Notebook tab's font or font height?]

2010-12-15 Thread python
Cristian,

> Here: http://code.activestate.com/recipes/541092-tknotebook/
> 
> Here's how to create a class to create notebook. With a little patience can 
> be converted for use with 8.5 tkinter.ttk and Python 3.1

Thank you!

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


Re: [Tkinter-discuss] ttk.Notebook - how to bind to tab events (tab caption has focus or mouseover)

2010-12-15 Thread python
Michael,

Thank you so much for your example!!

Re: Detect mouse events on tabs. The trick for me was understanding how
to use the index method. Your technique below is exactly the solution I
was looking for (I wasn't aware of the '@%d,%d' formatting technique).

index = event.widget.index('@%d,%d' % (event.x, event.y))

Re: Detect when a tab caption has keyboard focus ( or similar).

The <> does not correspond to the tab caption
gaining keyboard focus.

And the notebook widget generates a single  event when it gets
focus.

Is there a way to drill-down to the Tk label controls in the captions
and bind to their  events? Or is there a way to expose the tabs
as actual widgets whose events can be bound to?

Thanks again for all your help in these forums!

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


Re: [Tkinter-discuss] Change ttk.Notebook tab's font or font height?

2010-12-15 Thread python
Michael,

> The following example seems to do what you want, at least unless you change 
> the theme in use
>
> f = tkFont.Font(family='helvetica', size=-12)
> s = ttk.Style()
> s.configure('.', font=f)

That is **exactly** what I was looking for.

Once again, thank you so much for your help.

Tkinter rocks! (who would have thought?!)

Danke sehr!!!

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


[Tkinter-discuss] Very interesting code sample: A Ttk Notebook with close buttons

2010-12-15 Thread python
In researching how to determine when a ttk.Notebook tab caption
has keyboard focus (still no luck), I stumbled across this code
snippet which allows you to add Firefox-like close controls to
your ttk.Notebook tabs. The close controls are added to the tab
components via styles - they are not grafted on widgets that are
place()-ed above controls.

Here's the copy and paste code for Python 3.1; the usual
Tkinter/ttk import statements need to be adjusted for Python 2.7.
http://www.java2s.com/Open-Source/Python/3.1.2-Python/Demo/Demo/t
kinter/ttk/notebook_closebtn.py.htm

Note: You need to supply 3 close button gif files. I created 3
16x16 solid gif files in MS Paint so I could see the code in use.

What is so cool about this example is that it uses the following
methods to "drill-into" the Notebook and child Tab widgets to
really customize the appearance and behavior of these widgets
(capabilities that I didn't think existed in ttk).

style.element_create( ... )
style.layout( ... )
elem = widget.identify(x, y) <--- allows one to examine child
components

I can't admit to understanding this code snippet, but I'm blown
away with the capabilities of ttk.

If anyone figures out this code, I would be curious how difficult
it would be to implement the following Firefox like behaviors:

- only show close buttons on the active tab vs. on all tabs
- show an arrow image above a tabs' left or right edge to
indicate the position of a dragged tab

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


Re: [Tkinter-discuss] ttk.Notebook - how to bind to tab events (tab caption has focus or mouseover)

2010-12-15 Thread python
Michael,

>> Is there a way to drill-down to the Tk label controls in the captions
>> and bind to their  events? Or is there a way to expose the tabs
>> as actual widgets whose events can be bound to?

> I don't think this is possible, it looks like the notebook widget itself
> is one window that catches the  event and decides what to do - draw
> the focus indicator onto the next tab or pass the focus to another window.

> But, a far as I see, at least here with IceWm any time a tab receives the
> keyboard focus it will be selected as well, so maybe you can play around
> with the select mechanism, depending on what exactly you want to achieve.

Thank you for taking the time to investigate this behavior.

I just posted an advanced example of a ttk.Notebook with close controls
on the tabs. Apparently, it is possible to drill down into the child tab
controls of the ttk Notebook using out-of-the-box ttk (without resorting
to tcl magic). I'm studying this example now to see what may be possible
regarding raising a got focus event for individual tab widgets ... as
well as other advanced capabilities as well. Cool stuff!!

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


Re: [Tkinter-discuss] experimental tk program in python3

2010-12-16 Thread python
Dave,

Works in Python 2.7 by changing import statements to:

from Tkinter import *
import ttk

Is there a way to change a frame's border color? (I think this is a
Tkinter limitation, but I'd love to be proven wrong)

I don't think your border width spinner updates the border?

Nice to have additions?

1. A 'Reset' button to reset the form to its original values.

2. A 'Copy to clipboard' option that creates a line of code that matches
the current frame layout and places it on the clipboard.

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


Re: [Tkinter-discuss] experimental tk program in python3

2010-12-17 Thread python
Hi Michael,

> For widgets that don't accept keyboard focus you can use the 
> highlightbackground option to create a colored border (although you cannot 
> add a "3D"-relief this way) ... 

I took your example and added another frame and widgets that gain focus.
Your highlightbackground suggestion only works when there's a single
frame without widgets that can gain focus themselves. Interesting: On my
machine, the highlightbackground appears to work the opposite of its
stated purpose, eg. when button2 has focus, frame 1 shows its
highlightbackground and vice-versa.


from Tkinter import *

root = Tk()
f1 = Frame(root, bg='white', highlightthickness=2,
highlightbackground='red', width=200, height=200) 
f1.pack(padx=100, pady=100, fill='both', expand=1)
Button( f1, text='Button 1' ).pack()

f2 = Frame(root, bg='white', highlightthickness=2,
highlightbackground='green', width=200, height=200) 
f2.pack(padx=100, pady=100, fill='both', expand=1)
Button( f2, text='Button 2' ).pack()

root.mainloop()


I'm going to start a new thread on the topic of creating frames with
custom border colors.

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


[Tkinter-discuss] Techniques for creating the appearance of frames with custom border colors

2010-12-17 Thread python
I understand that Tkinter frames do not have a property that
allows their border color to be customized.

Here are some high level ideas I have on how to create a colored
border effect - any suggestions on best practice appreciated.

1. Turn off the frame's border. Enclose the frame in a parent
frame also without a border. Set the parent frame's background
color to the color of the border you want. Make sure the parent
frame's layout options (grid/pack) match the inner frame's
options.

2. Use a canvas instead of a frame, draw a border using the
create_rectangle( ..., fill="" ), and then
bind to the canvas's (?) event and to delete and redraw
the border every time the canvas resizes.

3. Use a tk.call( ... ) to gain access to the TCL interpreter and
its richer set of capabilies?

Regarding options 2 and 3: Might there be a way to create
non-solid border styles, eg. borders that are composed of dots or
dashes?

Thanks for your ideas,
Malcolm
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] experimental tk program in python3

2010-12-17 Thread python
Michael,

Ah, I see! The trick seems to be:

- don't set a frame's border width or relief properties (or reset them
to 0 and 'flat')
- set highlightcolor=
- set highlightbackground=
- set highlightthickness=

I think that also answers the question I just posted regarding how to
create the appearance of colored frame borders.

Thank you (one answer for 2 questions!)

Regards,
Malcolm


From: "Michael Lange" 

from Tkinter import *

root = Tk()
f1 = Frame(root, bg='white', highlightthickness=2,
highlightbackground='red', highlightcolor='red', width=200, height=200)
f1.pack(padx=100, pady=100, fill='both', expand=1)
Button( f1, text='Button 1' ).pack()

f2 = Frame(root, bg='white', highlightthickness=2,
highlightbackground='green', width=200, height=200)
f2.pack(padx=100, pady=100, fill='both', expand=1)
Button( f2, text='Button 2' ).pack()

root.mainloop()

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


Re: [Tkinter-discuss] Techniques for creating the appearance of frames with custom border colors

2010-12-17 Thread python
> On 2, definitely. Rather than using fill, you could set the
outline color, style, and width (e.g. dash/stipple):
[1]> http://effbot.org/tkinterbook/canvas.htm

Thanks Wayne,

Malcolm

References

1. http://effbot.org/tkinterbook/canvas.htm
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] Techniques for creating the appearance of frames with custom border colors

2010-12-17 Thread python
Michael,

Your code works wonderfully - thank you very much!!

One question: Why did you add your inner frame to the canvas as a window
via c.create_window() vs. just packing the frame?

I tried the frame packing technique per the following code change
(replacing c.createwindow with pack):

f = Frame(c, width=w-2, height=h-2)
# w = c.create_window(1, 1, window=f, anchor='nw')
f.pack() # note: will not work if passed fill='both', expand=1

And the code seemed to work with the following caveats:

- the top row of the rectangle is not displayed (I can't figure this one
out)
- screen redraws seem (subjectively) to be less efficient (yellow
background bleeds through)

Regards,
Malcolm



From: "Michael Lange" 

I don't think there are such options in Tk by default, so 3. probably is
not an option (unless you do very fancy things with ttk styles, but
these
are probably also possible with the ttk module).
With a canvas you can try something like:

from Tkinter import *
root = Tk()
root.geometry('500x500')

c = Canvas(root, bg='yellow', bd=0, highlightthickness=0, takefocus=0)
c.pack(fill='both', expand=1, padx=100, pady=100)
c.update_idletasks()
w, h = c.winfo_width(), c.winfo_height()
r = c.create_rectangle(0, 0, w-1, h-1, outline='red', fill='',
dash=(5,5))
f = Frame(c, width=w-2, height=h-2)
w = c.create_window(1, 1, window=f, anchor='nw')

def foo(event):
w, h = event.width, event.height
event.widget.coords(r, 0, 0, w-1, h-1)
f.configure(width=w-2, height=h-2)
c.bind('', foo)

root.mainloop()

This seems to work ok, I'm not sure if this might break in some
situations though.

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


[Tkinter-discuss] When to use .update() vs. update_idletasks()?

2010-12-17 Thread python
Looking for some advice on when to use .update() vs.
update_idletasks(). Are there use cases that favor the use of one
of these techniques vs. the other? Are there situations where one
of these techniques should always or never be used?

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


[Tkinter-discuss] Stipple use cases and/or examples?

2010-12-17 Thread python
I've seen the term "stipple" mentioned in recent posts. The
Tkinter documentation is woefully short on details here. I've
googled for examples and found very few. For those with the same
question as me, here's one example.
http://infohost.nmt.edu/tcc/help/pubs/tkinter/std-attrs.html
My question is what are typical use cases for stipples and do you
use the built-in gray12...gray75 stipples (are there others?) or
build your own (and why?). If anyone wants to post and example of
a stipple in use, I would appreciate it.

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


[Tkinter-discuss] When to use a Canvas vs. a Frame from a container perspective?

2010-12-17 Thread python
This question is related to using Canvases and Frames as
containers and does not consider the drawing capabilities of the
Canvas widget.

Canvas and Frames are both containers. My understanding is that
both of these containers provide identical layout behaviors via
their pack, grid, and place methods (is this really true?). In
other words, I should be able to replace a Frame with a Canvas
and have identical behavior, correct?

>From a container perspective, would it be correct to describe a
Canvas as an enhanced Frame with the following capabilities?

- the ability to support virtual sizes greater than the visible
display area
- the scrollbar, scroll and viewport features associated with
having a larger virtual display area

One of my points of confusion with Canvas containers is figuring
out what techniques to use for the layout of traditional widgets.
Can I use regular pack and grid placement always, only when a
canvas does not have scrolling, or never? When should one use the
create_window() technique for widget placement?

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


Re: [Tkinter-discuss] When to use .update() vs. update_idletasks()?

2010-12-17 Thread python
> As a rule of thumb I'd say: *never* use update() unless you really need it. 
> If update_idletasks() does the job, it is to be preferred.

Thanks Michael, that's a great tip.

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


Re: [Tkinter-discuss] When to use .update() vs. update_idletasks()?

2010-12-17 Thread python
Michael,

> BTW, for those who want to read more about update() vs. update_idletasks(), 
> there are two pages on the tcl'ers wiki that discuss the potential problems 
> with the update() method in more detail:
> 
> http://wiki.tcl.tk/1252
> http://wiki.tcl.tk/1255

Excellent resources.

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


Re: [Tkinter-discuss] When to use a Canvas vs. a Frame from a container perspective?

2010-12-17 Thread python
Hi Mick,

> I have never heard of packing widgets within a canvas. 

Here's the link that gave me that impression:
http://stackoverflow.com/questions/4080413/python-tkinter-place-a-widget-in-a-canvas-widget


You can easily add widgets to a canvas just like you do any other
container, using pack or grid or place. when you do this, the items will
not scroll when you scroll the canvas because they aren't actually part
of the canvas.

The other choice is to create window objects on the canvas. You do this
with the create_window method of the canvas. The advantage is, this
window becomes part of the canvas and will scroll along with any other
objects on the canvas. The downside is, your only option is absolute
placement and you have to explicitly control the size of the widgets.


BUT: In reviewing the documentation on this page, I see that there are
no pack and grid methods for the Canvas widget:
http://effbot.org/tkinterbook/canvas.htm

> Just use create_window, so there is no automatic placement, you need to 
> handle all placement.

OK. This makes sense. Does the following advice make sense:

The only time one should use a Canvas for a general purpose widget
container is when they need a container that scrolls.

To use a scrollable container one must be prepared to manually position
all widgets using the create_window() method call.

> Note with the following, packing a label within a canvas ... the Label widget 
> in fact REPLACES the canvas in the display rather than being packed within 
> it. I don't know why (try commenting out the d.pack() line) and see the 
> difference).

Interesting example. And I think this makes sense given the fact that
Canvas's don't support pack and grid layouts.

Thanks for your thoughts,

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


Re: [Tkinter-discuss] When to use a Canvas vs. a Frame from a container perspective?

2010-12-17 Thread python
Michael,

> However I agree, it's better to use create_window() to avoid pitfalls like 
> this.

1. So the proper way to use Canvases as containers for traditional
widgets is to manually handle layout and place all widgets via the
create_window() method.

2. The only reason to use a Canvas as a container for traditional
widgets is when you need a scrollable container.

Are those points accurate?

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


Re: [Tkinter-discuss] Off Topic : Tkinter in everyday life

2010-12-18 Thread python
Craf,

> I find a tool Tkinter extremely cool and functional, which I am discovering 
> little by little every day.

Same here!!! I share your enthusiasm for this tool and I'm on a similar
path of discovery (hence all my posts on this mailing list). BTW:
Another good resource for Tkinter help and code snippets is
stackoverflow.com. Search on 'tkinter' or 'ttk'.

> One question that comes to me, is why very few people work with this tool?

My impression is that many, many, many more people use Tkinter than post
on this mailing list :)

I've read where Guido (inventor of Python) has stated that Tkinter is by
far the most popular GUI framework for Python and the number of Tkinter
developers could number in the hundreds of thousands.

With support for tile (ttk) now available in Python 2.7 and 3.1, I
believe Tkinter is on par with its "competitors" in the Python GUI
framework world such as wxPython, pyQt, and pyGUI. Sure, these other
frameworks may have more widgets, but how many of these extra widgets
are required (or actually get used) in real business applications (even
applications where eye candy is preferred)?

I believe that most of eye candy requirements can be met with standard
ttk (and tk) widgets, high quality icon sets, and reasonable choices for
colors, fonts, and padding.

In addition to the benefits mentioned by Michael Lange (reliability,
stability and quick coding), I would also add ease of deployment as a
(business) critical benefit. Tkinter is bundled with all common Python
distributions, so its a deployment detail one doesn't need to worry
about. Tkinter apps can also be easily "frozen" (at least under Windows
where my experience lies). Alternative Python GUI frameworks are often
quite difficult to deploy, add significantly to the deployment footprint
of an application, and are a major source of support issues.

Another benefit of Tkinter vs. other GUI frameworks is that Tkinter is
the only GUI framework available for Python 3.x. (also available in 32
and 64 bit versions).

> Anyone know of companies that use in their development.

AwarePro.com (a startup where I work).

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


[Tkinter-discuss] What do you feel is missing from Tkinter?

2010-12-18 Thread python
This post was inspired by Craf's recent post on "Tkinter in everyday
life".

I'm a recent and enthusiastic convert to Tkinter after having rejected
this toolkit for many years.

After digging into Tkinter and through the very generous help on this
mailing list and elsewhere (stackoverflow.com), I've found that most
things that I thought Tkinter couldn't do are actually very doable.
Perhaps if we share our Tkinter concerns and doubts, we can all
brainstorm ways to fill in missing pieces.

Here's my short list of Tkinter weaknesses that I've struggled with:

1. Drag and drop. In fairness, there's a Tkdnd library and a bunch of
sample code on the internet. I haven't studied the examples I've
collected enough to figure out a simple, reusable way to do this. (Most
of my use cases are simply finding a way for users to re-arrange a row
of widgets packed or grided into a container)

2. Ability to dynamically stretch and image in real-time. What I would
like to do is create widgets with a gradient background where the
background image stretches as the widget itself is resized.

3. Creating scrolling containers (I've been spoiled with Tkinter's
automatic layouts and don't look forward to manually placing widgets).

4. A way to show an auto-complete popup when one types in a Text widget.
There's an example of how to do this in the IDLE source code, I just
haven't looked for it yet.

As you can see, most of these limitations are limitations of my own
learning curve and not limitations of Tkinter itself.

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


Re: [Tkinter-discuss] What do you feel is missing from Tkinter?

2010-12-19 Thread python
Michael,

> A few other things I miss from Tkinter:
> support for image formats other than gif

We use PIL which adds about 700K to our Window distributions. My
understanding is that PIL is cross platform, available for both the 2.x
and 3.x branches of Python and both the 32-bit and 64-bit versions of
Python. Are there problems deploying or using PIL for your customers?
(We're developing for Windows but hope to port to other platforms in the
future)

> The Tk-8.6 beta release however adds a -rotate option to the canvas text item 
> and support for png images, so these issues will be resolved soon :)

Nice!! (although PIL adds many other useful image capabilities)

> built-in tooltips were also nice

I highly recommend the following tooltip library. Easily used, many
capabilities, beautifully rendered. The only limitation I've found that
needs to be addressed is that tooltips are always displayed south east
of a widget. This means that a widget aligned on the far right and/or
bottom of a user's desktop will not be visible.

http://code.activestate.com/recipes/576688/ 

There's also a simpler tooltip approach here:

http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_01.shtml

> a decent html widget

Have you looked at Tkhtml? 
http://www.hwaci.com/sw/tkhtml/

Quote: Tkhtml is a Tcl/Tk widget that displays HTML. Tkhtml is
implemented in C. It is a true widget, not a metawidget implemented
using the Text or Canvas widgets of the Tcl/Tk core. Tkhtml can be used
with Tcl/Tk8.0 or later. The shared libraries use the new stubs
mechanism, so you should be able to load Tkhtml with any version of
"wish" beginning with 8.0.6. (Not sure what any of this really
means).

Python wrapper
http://tix.sourceforge.net/Tixapps/src/Python/TkHtml.py

Its on my todo-list to take a look at this component. Would be curious
to hear if anyone is using this widget with Python (especially a Windows
based version of Python).

> If you don't need a themed one, you can use the Pmw.ScrolledFrame or the 
> Tix.ScrolledWidget, which is included in the standard library and even easier 
> to use than its Pmw counterpart

Thanks for the Tix example. Works well, but now that we're using ttk, it
does look a bit dated. I guess we're spoiled ;)

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


Re: [Tkinter-discuss] What do you feel is missing from Tkinter?

2010-12-19 Thread python
Kevin,

> My gripes with Tk:

> 1. Lack of a cross-platform printing solution. Every other cross-platform 
> toolkit does this, but no one has done it for Tk.

We generate RTF (or HTM) files for output instead of trying to battle
platform specific printing challenges. One advantage of generating RTF
and HTM files is that users get revisable form electronic versions of
their output for free.

> 2. Lack of a modern HTML widget or an easy-to-use, cross-platform way of 
> wrapping one of the major browser platforms (Gecko, Webkit, IE). Lots of 
> partial solutions, but nothing that abstracts the platform differences and 
> presents a single API.

Have you looked at Tkhtml? 
http://www.hwaci.com/sw/tkhtml/

Quote: Tkhtml is a Tcl/Tk widget that displays HTML. Tkhtml is
implemented in C. It is a true widget, not a metawidget implemented
using the Text or Canvas widgets of the Tcl/Tk core. 

Python wrapper
http://tix.sourceforge.net/Tixapps/src/Python/TkHtml.py

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


Re: [Tkinter-discuss] When to use a Canvas vs. a Frame from a container perspective?

2010-12-19 Thread python
Mick,

> I use both Canvas and Text for scrollable containers.
> I use the Canvas when I want pixel accurate placement.
>
> I use a Text widget for more lazy placement (one can place items after each 
> other on a row, and start a new row with a "\n"). One can make spreadsheets 
> by placing rows of entry widgets of equal width. However, with hundreds of 
> widgets in a text widget, I find performance suffers.

I love the idea of creating scrollable containers using Text widgets.
I'll give this technique a try (with your caution about performance for
large number of widgets).

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


[Tkinter-discuss] Anyone using Tkinter for mobile device applications?

2010-12-19 Thread python
Wondering if any of you are using Tkinter for mobile device
applications and if so, what has your experience been like
(tricks, traps, etc)?

By mobile I mean small Linux devices, ipad/iphone, Windows CE or
the new mobile Windows 7 Mobile.

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


  1   2   >