Strang thing in tkinter, and pdb too?

2017-06-11 Thread jfong
I had donwload wdiget-tour-py3.tar.gz examples from this site:
http://www.hullsvle.ch/moodle/mod/resource/view.php?id=6697
and run one of its scripts canvasruler.py, I get stange result.

First, when I run it in the cmd box, although I get a message in the box,
but everything else is fine. The GUI works correctly.

D:\Temp\widget-tour-py3>python canvasruler.py
can't invoke "event" command: application has been destroyed
while executing
"event generate $w <>"
(procedure "ttk::ThemeChanged" line 6)
invoked from within
"ttk::ThemeChanged"

Second, I try to find out where is this message comes from. I insert
a statement "import pdb; pdb.set_trace()" at the source line 33:

33 import pdb; pdb.set_trace()
34 #
35 # Note : to execute the Tk command, I need to create a Toplevel window
36 # I guess I could use the toplevel create in widget.py, buth then this
37 # module would not run stand-alone
38 #
39 temp = Tk()
40 STIPPLE_BITMAP = temp.tk.eval(
41  'image create bitmap @%s' % STIPPLE_BITMAP_FILE )
42 ## Now I can delete the spurious window
43 temp.destroy()
44
45
46 TAB_NORMAL_STYLE = {'fill':'black', 'stipple':''}
47 TAB_INRANGE_STYLE = {'fill':'green', 'stipple':''}
48 TAB_OUTOFRANGE_STYLE = {'fill':'red', 'stipple':STIPPLE_BITMAP}
49
50
51 class RulerCanvas (Canvas):

and run this script under interpreter, it stops at the point correctly and
I can step through to reach the line 51 without seeing that message appear.

D:\Temp\widget-tour-py3>python
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import canvasruler
> d:\work\python\widget-tour-py3\canvasruler.py(39)()
-> temp = Tk()
(Pdb) next
> d:\work\python\widget-tour-py3\canvasruler.py(40)()
-> STIPPLE_BITMAP = temp.tk.eval(
(Pdb) until 51
> d:\work\python\widget-tour-py3\canvasruler.py(51)()
-> class RulerCanvas (Canvas):
(Pdb)

Third, I moved the set_trace() to line 50 and run again. This time I saw that 
message appears in the cmd box.

D:\Temp\widget-tour-py3>python
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import canvasruler
> d:\work\python\widget-tour-py3\canvasruler.py(51)()
-> class RulerCanvas (Canvas):
(Pdb) can't invoke "event" command: application has been destroyed
 while executing
"event generate $w <>"
(procedure "ttk::ThemeChanged" line 6)
invoked from within
"ttk::ThemeChanged"

(Pdb) list
 46 TAB_NORMAL_STYLE = {'fill':'black', 'stipple':''}
 47 TAB_INRANGE_STYLE = {'fill':'green', 'stipple':''}
 48 TAB_OUTOFRANGE_STYLE = {'fill':'red', 'stipple':STIPPLE_BITMAP}
 49
 50 import pdb; pdb.set_trace()
 51  -> class RulerCanvas (Canvas):
 52
 53 def __init__(self, master ):
 54 Canvas.__init__(self, master, width=200+RULER_LENGTH, 
height=100 )
 55 self.draw_ruler()
 56 self.draw_well()
(Pdb)

My problem is why the difference? and how to find out where that message comes 
from?

PS. I also run this test under a Win8.1/64bit machine, get the same result.
PSS. I had scan files in the whole example directory and found there is
 no any file using ttk module.
 
Best Regards,
Jach Fong
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: asyncio Behaviour Difference 3.6 vs 3.5 (Posting On Python-List Prohibited)

2017-06-11 Thread llanitedave
On Sunday, June 11, 2017 at 2:42:41 AM UTC-7, Lawrence D’Oliveiro wrote:
> I tried the following very simple script under both versions 3.5.3 and 3.6.1 
> of Python:
> 
> import sys
> import asyncio
> 
> loop = asyncio.get_event_loop()
> 
> async def idle() :
> while True :
> await asyncio.sleep(1)
> #end while
> #end idle
> 
> loop.create_task(idle())
> loop.run_forever()
> 
> After it starts running, I hit CTRL/C. Under both versions, I get the usual 
> KeyboardInterrupt exception and traceback. However, under 3.5, I also get 
> this:
> 
> Task was destroyed but it is pending!
> task:  
> wait_for=>
> 
> OK, as near as I can tell from the asyncio docs 
> , it makes sense for this 
> message to appear. Yet it does not come up with 3.6. Was it deemed to be too 
> noisy, and too much trouble to silence, so it was quietly dropped?
> 
> Yet according to the 3.6 release notes 
> , the changes to asyncio 
> have been backported to 3.5. So should there be a difference in behaviour 
> between the two?
> 
> I’m running Debian Unstable, so feel free to tell me 3.5.3 is obsolete and 
> there is some later 3.5.x version. ;)


My message in 3.5.3 is somewhat different, running Kubuntu 17.04:

>>> import sys
>>> import asyncio
>>> loop = asyncio.get_event_loop()

>>> async def idle():
... while True:
... await asyncio.sleep(1)
... #end while
... #end idle
... 
>>> loop.create_task(idle())
:1>>
>>> loop.run_forever()
^CTraceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/asyncio/base_events.py", line 421, in run_forever
self._run_once()
  File "/usr/lib/python3.5/asyncio/base_events.py", line 1388, in _run_once
event_list = self._selector.select(timeout)
  File "/usr/lib/python3.5/selectors.py", line 445, in select
fd_event_list = self._epoll.poll(timeout, max_ev)
KeyboardInterrupt
As yu can see, I get the  "Task pending coro=https://mail.python.org/mailman/listinfo/python-list


Re: Strang thing in tkinter, and pdb too?

2017-06-11 Thread Terry Reedy

On 6/11/2017 10:06 PM, [email protected] wrote:

I had donwload wdiget-tour-py3.tar.gz examples from this site:
http://www.hullsvle.ch/moodle/mod/resource/view.php?id=6697
and run one of its scripts canvasruler.py, I get stange result.

First, when I run it in the cmd box, although I get a message in the box,
but everything else is fine. The GUI works correctly.

 D:\Temp\widget-tour-py3>python canvasruler.py
 can't invoke "event" command: application has been destroyed
 while executing
 "event generate $w <>"
 (procedure "ttk::ThemeChanged" line 6)
 invoked from within
 "ttk::ThemeChanged"


I have seen this too.  It is not specific to any python/tkinter code, 
but is specific to exiting with some things destroyed and something not.

This must be coming from tcl or tk, not python or tkinter.


Second, I try to find out where is this message comes from. I insert
a statement "import pdb; pdb.set_trace()" at the source line 33:

 33 import pdb; pdb.set_trace()
 34 #
 35 # Note : to execute the Tk command, I need to create a Toplevel window
 36 # I guess I could use the toplevel create in widget.py, buth then this
 37 # module would not run stand-alone
 38 #
 39 temp = Tk()
 40 STIPPLE_BITMAP = temp.tk.eval(
 41  'image create bitmap @%s' % STIPPLE_BITMAP_FILE )
 42 ## Now I can delete the spurious window
 43 temp.destroy()
 44
 45
 46 TAB_NORMAL_STYLE = {'fill':'black', 'stipple':''}
 47 TAB_INRANGE_STYLE = {'fill':'green', 'stipple':''}
 48 TAB_OUTOFRANGE_STYLE = {'fill':'red', 'stipple':STIPPLE_BITMAP}
 49
 50
 51 class RulerCanvas (Canvas):

and run this script under interpreter, it stops at the point correctly and
I can step through to reach the line 51 without seeing that message appear.

 D:\Temp\widget-tour-py3>python
 Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 
bit (Intel)] on win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import canvasruler
 > d:\work\python\widget-tour-py3\canvasruler.py(39)()
 -> temp = Tk()
 (Pdb) next
 > d:\work\python\widget-tour-py3\canvasruler.py(40)()
 -> STIPPLE_BITMAP = temp.tk.eval(
 (Pdb) until 51
 > d:\work\python\widget-tour-py3\canvasruler.py(51)()
 -> class RulerCanvas (Canvas):
 (Pdb)

Third, I moved the set_trace() to line 50 and run again. This time I saw that 
message appears in the cmd box.

 D:\Temp\widget-tour-py3>python
 Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 
bit (Intel)] on win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import canvasruler
 > d:\work\python\widget-tour-py3\canvasruler.py(51)()
 -> class RulerCanvas (Canvas):
 (Pdb) can't invoke "event" command: application has been destroyed
  while executing
 "event generate $w <>"
 (procedure "ttk::ThemeChanged" line 6)
 invoked from within
 "ttk::ThemeChanged"

 (Pdb) list
  46 TAB_NORMAL_STYLE = {'fill':'black', 'stipple':''}
  47 TAB_INRANGE_STYLE = {'fill':'green', 'stipple':''}
  48 TAB_OUTOFRANGE_STYLE = {'fill':'red', 'stipple':STIPPLE_BITMAP}
  49
  50 import pdb; pdb.set_trace()
  51  -> class RulerCanvas (Canvas):
  52
  53 def __init__(self, master ):
  54 Canvas.__init__(self, master, width=200+RULER_LENGTH, 
height=100 )
  55 self.draw_ruler()
  56 self.draw_well()
 (Pdb)

My problem is why the difference? and how to find out where that message comes 
from?

PS. I also run this test under a Win8.1/64bit machine, get the same result.
PSS. I had scan files in the whole example directory and found there is
  no any file using ttk module.


Right.  I got this with IDLE tests before using ttk.  Good luck tracing 
this to its origin.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Strang thing in tkinter, and pdb too?

2017-06-11 Thread jfong
Terry Reedy於 2017/06/12 UTC+8 12:04:18PM wrote:
> Right.  I got this with IDLE tests before using ttk.  Good luck tracing 
> this to its origin.

A little progress. If I remove temp.destroy() at line 34 then that message is 
gone. hmm...trying to find another way of doing it:-)

--Jach Fong
-- 
https://mail.python.org/mailman/listinfo/python-list