Dudi Goldenberg | 21 Jun 11:34 2016

Tkinter canvas

Hi,

 

I have this:

 

from Tkinter import *

canvas = Canvas(width = 320, height = 320, bg = 'white')

 

 

Now I have the canvas window, I can add images and add/manipulate text within the window.

 

I can delete the objects with canvas.delete(obj_id), but after all objects are gone, I am still left with the initial window.

 

Canvas.destroy(), canvas.quit() has no effect on it.

 

I even tried to remove the Tkinter modules, but the window is still there.

 

Is there a safe way to get rid of the canvas window?

 

TIA & Regards,

 

Dudi

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss
Daniel Graham | 26 May 12:37 2016
Gravatar

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
> From: Dudi Goldenberg <dudi <at> kolcore.com>
> To: "tkinter-discuss <at> python.org" <tkinter-discuss <at> python.org>
> Subject: [Tkinter-discuss] Add text to desktop
> Message-ID:
> 	<VI1PR05MB18402C1E04E12ABC15B930D1DA400 <at> VI1PR05MB1840.eurprd05.prod.outlook.com>
> 	
> Content-Type: text/plain; charset="us-ascii"
> 
> 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,
> 
> D.
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20160525/968b001f/attachment-0001.html>
> 
> ------------------------------
> 
> Message: 2
> Date: Wed, 25 May 2016 18:28:56 -0500
> From: Bryan Oakley <bryan.oakley <at> gmail.com>
> To: Dudi Goldenberg <dudi <at> kolcore.com>
> Cc: "tkinter-discuss <at> python.org" <tkinter-discuss <at> python.org>
> Subject: Re: [Tkinter-discuss] Add text to desktop
> Message-ID:
> 	<CAKypQnyiVsL5nC_m9yVk9N+ZZJ_0GQKrVwR2-xFa-Nsr9rgqRQ <at> mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
> 
> There is no way to do what you want with tkinter.
> 
> On Wed, May 25, 2016 at 10:56 AM, Dudi Goldenberg <dudi <at> kolcore.com> wrote:
> 
>> 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,
>> 
>> 
>> 
>> D.
>> 
>> 
>> 
>> _______________________________________________
>> Tkinter-discuss mailing list
>> Tkinter-discuss <at> python.org
>> https://mail.python.org/mailman/listinfo/tkinter-discuss
>> 
>> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20160525/661ccd1e/attachment-0001.html>
> 
> ------------------------------
> 
> Message: 3
> Date: Wed, 25 May 2016 23:31:13 +0000
> From: Dudi Goldenberg <dudi <at> kolcore.com>
> To: Bryan Oakley <bryan.oakley <at> gmail.com>
> Cc: "tkinter-discuss <at> python.org" <tkinter-discuss <at> python.org>
> Subject: Re: [Tkinter-discuss] Add text to desktop
> Message-ID:
> 	<VI1PR05MB1840D25F69D940245156449BDA400 <at> VI1PR05MB1840.eurprd05.prod.outlook.com>
> 	
> Content-Type: text/plain; charset="utf-8"
> 
> Is there another method/module/anything that makes this possible??
> 
> D.
> 
> From: Bryan Oakley [mailto:bryan.oakley <at> gmail.com]
> Sent: Thursday, May 26, 2016 2:29
> To: Dudi Goldenberg <dudi <at> kolcore.com>
> Cc: tkinter-discuss <at> python.org
> Subject: Re: [Tkinter-discuss] Add text to desktop
> 
> There is no way to do what you want with tkinter.
> 
> On Wed, May 25, 2016 at 10:56 AM, Dudi Goldenberg <dudi <at> kolcore.com<mailto:dudi <at> kolcore.com>> wrote:
> 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,
> 
> D.
> 
> 
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss <at> python.org<mailto:Tkinter-discuss <at> python.org>
> https://mail.python.org/mailman/listinfo/tkinter-discuss
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20160525/ced97366/attachment.html>
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss <at> python.org
> https://mail.python.org/mailman/listinfo/tkinter-discuss
> 
> 
> ------------------------------
> 
> End of Tkinter-discuss Digest, Vol 143, Issue 1
> ***********************************************
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,

 

D.

 

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss
Stewart Baskin | 29 Apr 16:31 2016

Tkinter multiple font sizes in same text input

Hello,

 

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,

Stew

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss
Mickey Kocic | 21 Apr 16:59 2016
Picon

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.

Mickey
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss
Stefan Richthofer | 5 Apr 19:31 2016
Picon
Picon

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:
https://github.com/Stewori/JyNI/issues/4
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.

Stefan
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.

Thanks!

Bob
Reinis Danne | 5 Feb 20:44 2016
Picon

Debugging non-zero exit code

Hi!

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
Reinis Danne | 4 Feb 13:58 2016
Picon

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

Hi!

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
issue.

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

Regards,
Reinis

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

'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?

TIA,

Ingo

ERROR:

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'

CODE:

from tkinter import *

class Ttoolbar(Frame):

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

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)
         self.pack()
         self.makeWidgets()

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

if __name__ == '__main__':
     Aapp().mainloop()
ingo | 19 Jan 15:56 2016
Picon

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):
         Frame.__init__(self)
         self.master.title('OPML Notebook')
         self._create_panel()

     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.state(['pressed'])
             widget.pressed_index = index

     def _tabbtn_release(self, event):
         x, y, widget = event.x, event.y, event.widget
         if not widget.instate(['pressed']):
             return
         elem =  widget.identify(x, y)
         index = widget.index(" <at> %d,%d" % (x, y))
         if "close" in elem and widget.pressed_index == index:
             widget.forget(index)
             widget.event_generate("<<NotebookClosedTab>>")
         widget.state(["!pressed"])
         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, 
'close.gif'))
         i2 = PhotoImage("img_closeactive", file=os.path.join(imgdir, 
'close_active.gif'))
         i3 = PhotoImage("img_closepressed", file=os.path.join(imgdir, 
'close_pressed.gif'))

         style = ttk.Style()
         style.element_create("close", "image", "img_close",
             ("active", "pressed", "!disabled", "img_closepressed"),
             ("active", "!disabled", "img_closeactive"), border=10, 
sticky='')
         style.layout("ButtonNotebook", [("ButtonNotebook.client", 
{"sticky": "nswe"})])
         style.layout("ButtonNotebook.Tab", [
             ("ButtonNotebook.tab", {"sticky": "nswe", "children":
                 [("ButtonNotebook.padding", {"side": "top", "sticky": 
"nswe",
                                              "children":
                     [("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>", 
self._tabbtn_release)

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

     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__':
     OPMLnotebook().mainloop()

Gmane