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
(Continue reading)

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)
(Continue reading)

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
(Continue reading)

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

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

--

-- 
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
Jeff Hultquist | 22 Dec 18:04 2015

winfo_id on OS/X

I am trying to use tkinter with the Panda3D  (panda3d.org)  graphics library.  I want to position a graphics window into a tkinter frame.  

Attached below is some sample code that uses the frame.winfo_id() as the argument to Panda3D’s setParentWindow method.

This works on Linux and Windows, but seg-faults on OS/X.   It appears the winfo_id is not valid on OS/X.

How can we get a proper handle for the parenting of the 3d view into a tkinter frame?

FWIW, there is a thread is ongoing on the Panda3D forum, but the answer seems to lie deep inside tkinter.

Many thanks.

----------------------------------

from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties
import Tkinter

base = ShowBase(windowType='none')
base.startTk()

frame = base.tkRoot
frame.update()

id = frame.winfo_id()
width = frame.winfo_width()
height = frame.winfo_height()

props = WindowProperties()
props.setParentWindow(id)
props.setOrigin(0, 0)
props.setSize(width, height)

base.makeDefaultPipe()
base.openDefaultWindow(props=props)   # —— on OS/X, we segfault here

scene = base.loader.loadModel("environment")
scene.reparentTo(base.render)

base.run()

----------------------------------



_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss
Alexander Uvizhev | 28 Nov 22:28 2015
Picon

Tkinter on OS X generates excessive event on non-US input sequence

Hi,
I've found that Tkinter on Mac OS X somehow incorrectly works with events when bound sequence hit on non-US
keyboard layout.
I use Russian keyboard layout along with English and I'm trying now to arrange Undo/Redo shortcuts to work
correctly independent of layout. Under Linux everything works fine from the box. Under OS X it seems like a
bug and when I hit <Command-Cyrillic_ya> which is the same physical keys as <Command-z> tkinter sends
excessive KeyPress event.
Here is the test code.
================
from tkinter import *

class TkExample(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.pack()
        text = Text(self)
        text.pack()
        text.bind('<KeyPress>', self.on_kp)
        text.bind('<<Undo>>', self.on_undo)

    def on_kp(self, event):
        print('CHAR:', event.char)

    def on_undo(self, event):
        print('UNDO')

if __name__ == '__main__':
    root = Tk()
    TkExample(root)
    root.mainloop()
================

When I run the app and hit <Command-z> I get this output:
CHAR:
UNDO

But if I hit <Command-Cyrillic_ya> I see this:
CHAR:  
CHAR: z
UNDO

Under Linux in both cases I get the same output (1).

Can anyone explain this? Maybe this is not a bug?

--

-- 
Alexander Uvizhev
uvizhe <at> yandex.ru
Robert Greschke | 16 Nov 23:18 2015

Re: JPEGs

Oops. Didn't hit the Reply All.

> On 2015-11-16, at 12:39, Robert Greschke <bob <at> passcal.nmt.edu> wrote:
> 
> 
>> On 2015-11-16, at 12:14, Michael Lange <klappnase <at> web.de> wrote:
>> 
>> Hi,
>> 
>> On Mon, 16 Nov 2015 11:50:44 -0700
>> Robert Greschke <bob <at> passcal.nmt.edu> wrote:
>> 
>>> Why can't I go
>>> 
>>> Pic = PhotoImage(file = "./lp.jpg")
>>> 
>>> ?
>>> 
>>> Are JPEGs not popular enough yet, or am I missing something? This is
>>> one of the craziest restrictions to Tkinter I can think of. I wish I
>>> knew how to fix it, but I just ain't smart enough.
>>> 
>>> No, I don't want to use PIL. I'd like to make imbedded help that is
>>> just simple text-picture-text-picture, instead of just text. Yes, the
>>> pictures could be PNGs, but, again, are JPEGs just not popular enough,
>>> or is it a licensing thing of some sort?
>> 
>> reading https://en.wikipedia.org/wiki/JPEG#Patent_issues I figure that
>> it might be the latter.
>> If you don't want to use PIL, maybe tkimg is an option for you? If not I
>> am afraid you will have to stick with PNGs or GIFs.
>> 
>> Best regards
>> 
>> Michael
>> 
> 
> Yup, looks like it. (Cool article.) I guess Dick the Butcher had the right idea. :)
> 
> I can do PNGs for the help pictures, but I guess I'll just have to suck it up and use PIL for my extracurricular
project -- extracting artwork from music and video files and making thumbnails. Darn it. 
> 
> How come PIL can get away with it?
> 
> Thanks!
> Bob
> 
> 
Robert Greschke | 16 Nov 19:50 2015

JPEGs

Why can't I go

Pic = PhotoImage(file = "./lp.jpg")

?

Are JPEGs not popular enough yet, or am I missing something? This is one of the craziest restrictions to
Tkinter I can think of. I wish I knew how to fix it, but I just ain't smart enough.

No, I don't want to use PIL. I'd like to make imbedded help that is just simple text-picture-text-picture,
instead of just text. Yes, the pictures could be PNGs, but, again, are JPEGs just not popular enough, or is
it a licensing thing of some sort?

Bob
Aivar Annamaa | 31 Oct 10:52 2015
Picon

Linux compile Python with (Active)Tcl 8.6

I'm trying to compile Python 3.5.0 on CentOS 6 with Tcl 8.6. I did

./configure --with-tcltk-includes=I/opt/ActiveTcl-8.6/include --with-tcltk-libs=L/opt/ActiveTcl-8.6/libs --prefix=/home/aivar/localpython
After installing, IDLE -> Help -> About shows me that I'm using Tk 8.5.7.

What could have gone wrong?

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss
Bob Greschke | 15 Oct 18:17 2015

Does someone here work on Apple's OSX Tkinter?

I thought I picked that up in some batch of messages, but now I can't find the thread that gave me that idea.

Anyway...

www.passcal.nmt.edu/~bob/unlinked/images/twolines.tiff

The call in the Button widget is text="Start/Restart\nBreak", but the box doesn't grow to encompass the
two lines of text. It's been like this for years. We always have to use our own Python/Tkinter installation
(here at work) because of this.

Bob

Gmane