471,338 Members | 1,133 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Tkinter vs. py2exe problem

Having a problem with "compiling" a Tkinter/python program using
py2exe (and pyinstaller, for that matter)...

I have several dialogs that are derived from the tkSimpleDialog.Dialog
class. These work just fine if run through the interpreter. When I
"compile" this with py2exe, I don't see any errors, and when I execute
the resulting program, it "appears" to work fine until I invoke one of
the derived dialogs.

Then, I get the "body" of the dialog, but no "OK" or "Cancel" button,
and I get the following exception:

AttributeError: MyDialog instance has no attribute
'buttonbox'

For reference, MyDialog is declared as follows:
#--------------------------------------------------------------------------------

from Tkinter import *
import tkSimpleDialog
class MyDialog(tkSimpleDialog.Dialog)

#--------------------------------------------------------------------------------

And my setup.py file looks like this:

#--------------------------------------------------------------------------------

from distutils.core import setup
import py2exe

setup(console=['tcgui3.py'])

#--------------------------------------------------------------------------------

I'm invoking py2exe like this:

C:\python setup.py py2exe -p Tkinter -p tkSimpleDialog

??????
Dec 5 '07 #1
5 3257
On Dec 5, 9:50 am, msunde...@gmail.com wrote:
Having a problem with "compiling" a Tkinter/python program using
py2exe (and pyinstaller, for that matter)...

I have several dialogs that are derived from the tkSimpleDialog.Dialog
class. These work just fine if run through the interpreter. When I
"compile" this with py2exe, I don't see any errors, and when I execute
the resulting program, it "appears" to work fine until I invoke one of
the derived dialogs.

Then, I get the "body" of the dialog, but no "OK" or "Cancel" button,
and I get the following exception:

AttributeError: MyDialog instance has no attribute
'buttonbox'

For reference, MyDialog is declared as follows:
#--------------------------------------------------------------------------------

from Tkinter import *
import tkSimpleDialog
class MyDialog(tkSimpleDialog.Dialog)

#--------------------------------------------------------------------------------

And my setup.py file looks like this:

#--------------------------------------------------------------------------------

from distutils.core import setup
import py2exe

setup(console=['tcgui3.py'])

#--------------------------------------------------------------------------------

I'm invoking py2exe like this:

C:\python setup.py py2exe -p Tkinter -p tkSimpleDialog

??????
Oh yeah... if it matters, I'm using Python 2.5.1 on Win XP, and py2exe
v1.4. I get the same problem using pyinstaller, except it doesn't
show the exception - it just fails to display the buttons.
Dec 5 '07 #2
On Dec 5, 9:50 am, msunde...@gmail.com wrote:
Having a problem with "compiling" a Tkinter/python program using
py2exe (and pyinstaller, for that matter)...

I have several dialogs that are derived from the tkSimpleDialog.Dialog
class. These work just fine if run through the interpreter. When I
"compile" this with py2exe, I don't see any errors, and when I execute
the resulting program, it "appears" to work fine until I invoke one of
the derived dialogs.

Then, I get the "body" of the dialog, but no "OK" or "Cancel" button,
and I get the following exception:

AttributeError: MyDialog instance has no attribute
'buttonbox'

For reference, MyDialog is declared as follows:
#--------------------------------------------------------------------------------

from Tkinter import *
import tkSimpleDialog
class MyDialog(tkSimpleDialog.Dialog)

#--------------------------------------------------------------------------------

And my setup.py file looks like this:

#--------------------------------------------------------------------------------

from distutils.core import setup
import py2exe

setup(console=['tcgui3.py'])

#--------------------------------------------------------------------------------

I'm invoking py2exe like this:

C:\python setup.py py2exe -p Tkinter -p tkSimpleDialog

??????
Oh, and it fails when the setup() line in setup.py says
"setup(window=['tcgui3.py'])" as well. Same error.
Dec 5 '07 #3
On Dec 5, 9:50 am, msunde...@gmail.com wrote:
Having a problem with "compiling" a Tkinter/python program using
py2exe (and pyinstaller, for that matter)...

I have several dialogs that are derived from the tkSimpleDialog.Dialog
class. These work just fine if run through the interpreter. When I
"compile" this with py2exe, I don't see any errors, and when I execute
the resulting program, it "appears" to work fine until I invoke one of
the derived dialogs.

Then, I get the "body" of the dialog, but no "OK" or "Cancel" button,
and I get the following exception:

AttributeError: MyDialog instance has no attribute
'buttonbox'

For reference, MyDialog is declared as follows:
#--------------------------------------------------------------------------------

from Tkinter import *
import tkSimpleDialog
class MyDialog(tkSimpleDialog.Dialog)

#--------------------------------------------------------------------------------

And my setup.py file looks like this:

#--------------------------------------------------------------------------------

from distutils.core import setup
import py2exe

setup(console=['tcgui3.py'])

#--------------------------------------------------------------------------------

I'm invoking py2exe like this:

C:\python setup.py py2exe -p Tkinter -p tkSimpleDialog

??????
Nevermind. I fixed it. I had a tkSimpleDialog.py in my local
directory that was typed in from an introductory text.

Apparently this was confusing Python. Removing that file, and letting
it find the tkSimpleDialog from Tk makes it work.

Thanks, anyway.
Dec 5 '07 #4
On Dec 5, 10:07 am, msunde...@gmail.com wrote:
On Dec 5, 9:50 am, msunde...@gmail.com wrote:
Having a problem with "compiling" a Tkinter/python program using
py2exe (and pyinstaller, for that matter)...
I have several dialogs that are derived from the tkSimpleDialog.Dialog
class. These work just fine if run through the interpreter. When I
"compile" this with py2exe, I don't see any errors, and when I execute
the resulting program, it "appears" to work fine until I invoke one of
the derived dialogs.
Then, I get the "body" of the dialog, but no "OK" or "Cancel" button,
and I get the following exception:
AttributeError: MyDialog instance has no attribute
'buttonbox'
For reference, MyDialog is declared as follows:
#--------------------------------------------------------------------------------
from Tkinter import *
import tkSimpleDialog
class MyDialog(tkSimpleDialog.Dialog)
#--------------------------------------------------------------------------------
And my setup.py file looks like this:
#--------------------------------------------------------------------------------
from distutils.core import setup
import py2exe
setup(console=['tcgui3.py'])
#--------------------------------------------------------------------------------
I'm invoking py2exe like this:
C:\python setup.py py2exe -p Tkinter -p tkSimpleDialog
??????

Nevermind. I fixed it. I had a tkSimpleDialog.py in my local
directory that was typed in from an introductory text.

Apparently this was confusing Python. Removing that file, and letting
it find the tkSimpleDialog from Tk makes it work.

Thanks, anyway.
Ummm... Un-nevermind. I didn't fix it. It's still complaining.
Dec 5 '07 #5
On Dec 5, 10:46 am, msunde...@gmail.com wrote:
On Dec 5, 10:07 am, msunde...@gmail.com wrote:
On Dec 5, 9:50 am, msunde...@gmail.com wrote:
Having a problem with "compiling" a Tkinter/python program using
py2exe (and pyinstaller, for that matter)...
I have several dialogs that are derived from the tkSimpleDialog.Dialog
class. These work just fine if run through the interpreter. When I
"compile" this with py2exe, I don't see any errors, and when I execute
the resulting program, it "appears" to work fine until I invoke one of
the derived dialogs.
Then, I get the "body" of the dialog, but no "OK" or "Cancel" button,
and I get the following exception:
AttributeError: MyDialog instance has no attribute
'buttonbox'
For reference, MyDialog is declared as follows:
#--------------------------------------------------------------------------------
from Tkinter import *
import tkSimpleDialog
class MyDialog(tkSimpleDialog.Dialog)
#--------------------------------------------------------------------------------
And my setup.py file looks like this:
#--------------------------------------------------------------------------------
from distutils.core import setup
import py2exe
setup(console=['tcgui3.py'])
#--------------------------------------------------------------------------------
I'm invoking py2exe like this:
C:\python setup.py py2exe -p Tkinter -p tkSimpleDialog
??????
Nevermind. I fixed it. I had a tkSimpleDialog.py in my local
directory that was typed in from an introductory text.
Apparently this was confusing Python. Removing that file, and letting
it find the tkSimpleDialog from Tk makes it work.
Thanks, anyway.

Ummm... Un-nevermind. I didn't fix it. It's still complaining.
Okay, here's a sample program that fails:

#------------------------------------------------------------------
#!/usr/bin/python

from Tkinter import *
import tkSimpleDialog

class MyDialog(tkSimpleDialog.Dialog):
def body(self, master):
Label(master, text="Label").grid()

def apply(self):
print "OK"

if __name__ == "__main__":
root = Tk()
md = MyDialog(root)
mainloop()

#--------------------------------------------

And here's the setup file I'm using with py2exe:

#--------------------------------------------
from distutils.core import setup
import py2exe

opts = {
"py2exe": {
"includes":"tkSimpleDialog"
}
}

setup(windows=['hellogui.py'], options=opts)

#--------------------------------------------

Can't make it any simpler than that... I'm so confused!
Dec 5 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Anthony Baxter | last post: by
1 post views Thread by | last post: by
reply views Thread by Robin Becker | last post: by
15 posts views Thread by flyingisfun1217 | last post: by
1 post views Thread by maryannj | last post: by
1 post views Thread by Alex Bryan | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.