Daniel Graham | 26 May 12:37 2016

Re: Tkinter-discuss Digest, Vol 143, Issue 1

On osx you can use geektool.

> On May 25, 2016, at 9:04 PM, tkinter-discuss-request <at> python.org wrote:
> Send Tkinter-discuss mailing list submissions to
> 	tkinter-discuss <at> python.org
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://mail.python.org/mailman/listinfo/tkinter-discuss
> or, via email, send a message with subject or body 'help' to
> 	tkinter-discuss-request <at> python.org
> You can reach the person managing the list at
> 	tkinter-discuss-owner <at> python.org
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tkinter-discuss digest..."
> Today's Topics:
>   1. Add text to desktop (Dudi Goldenberg)
>   2. Re: Add text to desktop (Bryan Oakley)
>   3. Re: Add text to desktop (Dudi Goldenberg)
> ----------------------------------------------------------------------
> Message: 1
> Date: Wed, 25 May 2016 15:56:08 +0000
(Continue reading)

Dudi Goldenberg | 25 May 17:56 2016

Add text to desktop

Hello list,


What would be the best way to add some text over the desktop background image, with no window and no frame?


Font, size and colors needs to be controlled, some of the text will come from updated variables.


I managed to get the text to display, but always boxed In a frame…


TIA & Regards,




Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
Stewart Baskin | 29 Apr 16:31 2016

Tkinter multiple font sizes in same text input



Thank you in advance for your assistance with this query. I would like to produce multiple font sizes on the same line. For example:


## mg/l


I know how to assign the font type/size, but am unable to do this twice (only the second text and font size appear in the window).


Is it possible to assign multiple font sizes to the same line in Tkinter?


Thank you,


Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
Mickey Kocic | 21 Apr 16:59 2016

Re: standard tkinter command set

Could you provide me with a link to the list of the standard tkinter/tcl command set? I had to put up with the snarkoids at Stack Overflow before one (unintentionally!) informed me that the Text widget has its own native bindings for cut, copy and paste, and that i had wasted time wrapping them in my application. Before I go through that again I'd like to be properly informed about the features.

Thanks for all replies.

Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
Stefan Richthofer | 5 Apr 19:31 2016

Help/advice needed for Tkinter related JyNI issue

Hello everybody,

I am the author of the JyNI-project (www.jyni.org) which aims to support native CPython extensions in Jython.
Some basic Tkinter stuff is known to work with JyNI on Linux, but unfortunately hangs on OSX:
In this thread we collected everything we know about this issue so far.
The issue is rather strange in the sense that the sample works well on Linux, while it hangs on OSX. Briefly
speaking, on OSX TCL/TK does not produce a particular event the loop is waiting for and does not display the
window. However logging suggests that calls to TCL/TK API are identical between Linux and OSX runs, so we
are really stuck here in finding out what is different on Linux (our current logging does not cover
function argument values though).
I think there must be something subtle JyNI is doing wrong and that only manifests on OSX. (Running with
CPython the sample succeeds on that system.)
Any advise how I can find the reason for the missing event would be helpful. My usual divide and conquer
debugging approach struggles here because I don't know enough about TCL/TK to trace the cause for the
issue through its API. Is there something like an internal log of TCL accessible? Or a way to see the events
processed by TCL_DoOneEvent?

Thanks in advance for any helpful hint.

Bob Greschke | 11 Feb 00:30 2016

Transferring tags from one Text() to another

I write stuff to a Text() and some words and lines are different colors or are links (binds) using Tags. I can
Text().get(0.0, END), get all of the text, then insert that in another Text() to make a copy, but how do I
get/transfer the other "formatting" info? The binds aren't real important, but the different colored
text would be nice.


Reinis Danne | 5 Feb 20:44 2016

Debugging non-zero exit code


I'm trying to debug why BKChem prints '0' and exits with exit
code 1. As far as I can tell that is not directly in the app.
I tried to debug it with gdb, but it tried (and failed) to start
the app again after I have pressed the close button, so I didn't
get any useful info out of it. How could I debug this issue?

The application setup code is in bkchem.py and the main class is
in main.py. To test:
$ git clone https://gitlab.com/bkchem/bkchem.git
$ cd bkchem
$ git submodule init
$ git submodule update
$ python bkchem/bkchem.py

Should work with Python 2 and 3.

Any tips how to deal with this would be appreciated. Also it
would be great if someone could review the tkinter setup sequence.

Reinis Danne | 4 Feb 13:58 2016

Moving object on page leaves afterimage on Python 3 but not on 2


I'm porting a chemistry drawing program BKChem [1] to Python 3
using the shared codebase between versions 2 and 3. It is working
fine on Python 2, but if I run it with Python 3 I have an issue
with redrawing the page.

The issue is that if I move an object by mouse then it leaves an
image of the object in the old place while moving the object to
the new place (Python 3). There is no such afterimage with Python
2. Similar effect can be achieved if object is deleted or its
creation is undoed - object is removed, but lines remain. It
seems that text is updated correctly, only bonds (lines) have the

Any ideas where the bug might be and how to debug it? As far as I
understand the moving of the object and updating the drawing is
up to tkinter or the underlying tk. It could be an issue with the
app losing track of the object, but in that case it wouldn't
create new lines (if I drag and drop an object several times,
several afterimages remain, but not 100% of the time; usually the
very first move works, but later ones produce the afterimages).
So I think it is a lower level issue.

To test:
$ git clone https://gitlab.com/bkchem/bkchem.git
$ cd bkchem
$ git submodule init
$ git submodule update
$ python3 bkchem/bkchem.py


[1] https://gitlab.com/bkchem/bkchem
ingo | 23 Jan 10:05 2016

'connect' widget classes in an application

In the code below I get the error below.
I'm trying to create a class for several widgets and make the "interact" 
within a main Frame. Can't figure it out (lack of programming 
experience) and couldn't find an eye opening example.

I understand that the toolbar has no way to access the txt in the 
editor, how do I make it so?




Exception in Tkinter callback
Traceback (most recent call last):
   File "\Python35-32\lib\tkinter\__init__.py", line 1549, in __call__
     return self.func(*args)
   File "twoclass.py", line 10, in <lambda>
     command=lambda: self.txt.insert(END, 'Button pressed.\n')
AttributeError: 'Ttoolbar' object has no attribute 'txt'


from tkinter import *

class Ttoolbar(Frame):

     def __init__(self, parent=None):
         Frame.__init__(self, parent)
         self.btn = Button(
             command=lambda: self.txt.insert(END, 'Button pressed.\n')

class Eedit(Text):

     def __init__(self, parent=None):
         txt = Text.__init__(self, parent)
         self.pack(fill='both', expand=Y)

class Aapp(Frame):

     def __init__(self, parent=None):
         Frame.__init__(self, parent)

     def makeWidgets(self):
         tb = Ttoolbar().pack(side=TOP, fill=X)
         ed = Eedit().pack()

if __name__ == '__main__':
ingo | 19 Jan 15:56 2016

Lost images on tabs ttk.notebook

I'm trying to create a simple tabbed editor and merged two examples 
found on the web. One of those is the one with the closing images on the 
tabs. In the proces of understanding I somehowe lost the images on the 
tabs but not the fuctionality of clicking on the right position of the tabs.

What is going wrong?

TIA, Ingo

import os
from tkinter import *
from tkinter import ttk

class OPMLnotebook(Frame):

     def __init__(self):
         self.master.title('OPML Notebook')

     def _tabbtn_press(self, event):
         x, y, widget = event.x, event.y, event.widget
         elem = widget.identify(x, y)
         index = widget.index(" <at> %d,%d" % (x, y))
         if "close" in elem:
             widget.pressed_index = index

     def _tabbtn_release(self, event):
         x, y, widget = event.x, event.y, event.widget
         if not widget.instate(['pressed']):
         elem =  widget.identify(x, y)
         index = widget.index(" <at> %d,%d" % (x, y))
         if "close" in elem and widget.pressed_index == index:
         widget.pressed_index = None

     def _create_panel(self):

         imgdir = os.path.join(os.path.dirname(__file__), 'img')
         i1 = PhotoImage("img_close", file=os.path.join(imgdir, 
         i2 = PhotoImage("img_closeactive", file=os.path.join(imgdir, 
         i3 = PhotoImage("img_closepressed", file=os.path.join(imgdir, 

         style = ttk.Style()
         style.element_create("close", "image", "img_close",
             ("active", "pressed", "!disabled", "img_closepressed"),
             ("active", "!disabled", "img_closeactive"), border=10, 
         style.layout("ButtonNotebook", [("ButtonNotebook.client", 
{"sticky": "nswe"})])
         style.layout("ButtonNotebook.Tab", [
             ("ButtonNotebook.tab", {"sticky": "nswe", "children":
                 [("ButtonNotebook.padding", {"side": "top", "sticky": 
                     [("ButtonNotebook.label", {"side": "left", 
"sticky": ''}),
                     ("ButtonNotebook.close", {"side": "left", "sticky": 

         self.bind_class("TNotebook", "<ButtonPress-1>", 
self._tabbtn_press, True)
         self.bind_class("TNotebook", "<ButtonRelease-1>", 

         nb = ttk.Notebook(width=400, height=400, style="ButtonNotebook")
         nb.pressed_index = None
         nb.pack(fill='both', expand=1)

     def _create_text_tab(self, nb):
         frame = Frame(nb)
         txt = Text(frame, wrap=WORD, width=40, height=10)
         vscroll = Scrollbar(frame, orient=VERTICAL, command=txt.yview)
         txt['yscroll'] = vscroll.set
         vscroll.pack(side=RIGHT, fill=Y)
         txt.pack(fill='both', expand=Y)
         nb.add(frame, text='Text Editor', underline=0)

if __name__ == '__main__':
Kevin Walzer | 26 Dec 03:19 2015

Accelerator keys cross-platform

I'm porting a Tkinter application from Mac to Windows and I need a 
cross-platform way to implement accelerator keys for menu entries. In 
Tcl, this is very simple:

  -accelerator "$Command-C"

where $Command can be set to "Command" or "Control" depending on the 

Python does not have as flexible a string substitution as Tcl, so I'm 
looking for a Pythonic way to do this. Most examples I've seen load 
entirely separate menus depending on the platform, and I'd rather avoid 
duplicating code that way.  Any suggestions or examples that anyone can 


Kevin Walzer
Code by Kevin/Mobile Code by Kevin