ouilles / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

Pyscripter 2.5.3 denies the exit() request of Tkinter programs generated with SpecTCL, on Windows #772

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install Python 2.7.6 on Windows
2. Install Pyscripter 2.5.3
3. Install SpecTCL ( http://www.sourceforge.net/projects/spectcl )
4. Call SpecTCL. A minimal GUI is created. Save this GUI as 
"spectcl_helloworld.ui". It does not matter if you add contents, so a button 
with manually added "exit()" callback code does not work too. 
5. SpecTCL creates the files "spectcl_helloworld.py" ( may be executed ) and 
"spectcl_helloworld" ( is not intended for execution ).
6. Load and execute a Pyton script "spectcl_helloworld.py", with Pyscripter on 
Windows
7. Press on the [x] button of the window frame

What is the expected output? What do you see instead?
Expected: 
- The Python program closes, the TCL GUI interface disappears - as it is true 
if I do it by Command.com shell
Instead: 
- The python program is closed ( so the Pyscripter is active again, especially 
the Python interpreter window ), but the TCL GUI interface stays on the desktop 
screen.
- To make the TCL GUI interface disappear, I must quit Pyscripter.
- If I try to call and exit a classical, more simple TCL application 
"hellotcl.py", Pyscripter works properly and deletes the TCL GUI interface. So 
there is something wrong with the generated code of SpecTCL, what Pyscripter 
does not like...

What version of the product are you using? On what operating system?
OS: Windows 8.1
Python: 2.7.6
Product: Pyscripter 2.5.3

Please provide any additional information below.

*** spectcl_helloworld.ui ***

# GUIBUILDER FILE Build 146
# Created: 2014-06-08 09:35:37 by GUI Builder Build 146
language tkinter 8.4
widget {Tk frame} f {
    geometry min_column {40 40}
    geometry min_row {40 40}
    geometry pad_column {0 0}
    geometry pad_row {0 0}
    geometry resize_column {0 0}
    geometry resize_row {0 0}
    geometry weight_column {0 0}
    geometry weight_row {0 0}
    data GROUP Tk
    data ID {}
    data MASTER {}
    data TYPE {Tk frame}
    data level 0
}

Automatically generated code:
*** spectcl_helloworld.py ***

""" spectcl_helloworld.py --

 UI generated by GUI Builder Build 146 on 2014-06-08 09:35:37 from:
    C:/Users/Public/projects/python_testing_pybehave/codebreaker_v9_spectcl/spectcl_helloworld.ui
 This file is auto-generated.  Only the code within
    '# BEGIN USER CODE (global|class)'
    '# END USER CODE (global|class)'
 and code inside the callback subroutines will be round-tripped.
 The 'main' function is reserved.
"""

from Tkinter import *
from spectcl_helloworld_ui import Spectcl_helloworld

# BEGIN USER CODE global

# END USER CODE global

class CustomSpectcl_helloworld(Spectcl_helloworld):
    pass

    # BEGIN CALLBACK CODE
    # ONLY EDIT CODE INSIDE THE def FUNCTIONS.

    # END CALLBACK CODE

    # BEGIN USER CODE class

    # END USER CODE class

def main():
    # Standalone Code Initialization
    # DO NOT EDIT
    try: userinit()
    except NameError: pass
    root = Tk()
    demo = CustomSpectcl_helloworld(root)
    root.title('spectcl_helloworld')
    try: run()
    except NameError: pass
    root.protocol('WM_DELETE_WINDOW', root.quit)
    root.mainloop()

if __name__ == '__main__': main()

*** spectcl_helloworld_ui.py ***

""" spectcl_helloworld_ui.py --

 UI generated by GUI Builder Build 146 on 2014-06-08 09:35:37 from:
    C:/Users/Public/projects/python_testing_pybehave/codebreaker_v9_spectcl/spectcl_helloworld.ui
THIS IS AN AUTOGENERATED FILE AND SHOULD NOT BE EDITED.
The associated callback file should be modified instead.
"""

import Tkinter
import os # needed for relative image paths

# Using new-style classes: create empty base class object
# for compatibility with older python interps
#if sys.version_info < (2, 2):
#    class object:
#        pass

class Spectcl_helloworld(object):
    _images = [] # Holds image refs to prevent GC
    def __init__(self, root):

        # Widget Initialization

        # Geometry Management

        # Resize Behavior
        root.grid_rowconfigure(1, weight = 0, minsize = 40, pad = 0)
        root.grid_rowconfigure(2, weight = 0, minsize = 40, pad = 0)
        root.grid_columnconfigure(1, weight = 0, minsize = 40, pad = 0)
        root.grid_columnconfigure(2, weight = 0, minsize = 40, pad = 0)

*** This helloworld.py is terminated properly with Pyscripter, for comparison 
***

from Tkinter import *

root = Tk()
w = Label(root, text="Hello World")
w.pack()
root.mainloop()

Original issue reported on code.google.com by rolf.hem...@gmail.com on 8 Jun 2014 at 7:54

GoogleCodeExporter commented 9 years ago
One obvious workaround is
to replace

    root.protocol('WM_DELETE_WINDOW', root.quit)

by

    root.protocol('WM_DELETE_WINDOW', root.destroy)

but this would be a change in a section of code which is named

    # Standalone Code Initialization
    # DO NOT EDIT

and of course it does not explain why root.quit() does not work when called 
from Pyscripter.

Sincerly
Rolf

Original comment by rolf.hem...@gmail.com on 8 Jun 2014 at 12:00