Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 2nd, 2008, 02:50 PM
Newbie
 
Join Date: Jun 2008
Location: Montreal, Canada
Posts: 9
Default Tkinter Dialog box

Hello.

My script run fine within python but not in my program(SDS/2 wich is a software like Autocad). The problem is I got an error when the time comes to read the line14 to 19. (Source code come from Tkinter.py)

Code:
class Tk(Misc, Wm):
    """Toplevel widget of Tk which represents mostly the main window
    of an appliation. It has an associated Tcl interpreter."""
    _w = '.'
    def __init__(self, screenName=None, baseName=None, className='Tk'):
        """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will
        be created. BASENAME will be used for the identification of the profile file (see
        readprofile).
        It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
        is the name of the widget class."""
        global _default_root
        self.master = None
        self.children = {}
        if baseName is None:
            import sys, os
            baseName = os.path.basename(sys.argv[0])
            baseName, ext = os.path.splitext(baseName)
            if ext not in ('.py', '.pyc', '.pyo'):
                baseName = baseName + ext
        self.tk = _tkinter.create(screenName, baseName, className)
        self.tk.wantobjects(wantobjects)
        if _MacOS and hasattr(_MacOS, 'SchedParams'):
            # Disable event scanning except for Command-Period
            _MacOS.SchedParams(1, 0)
            # Work around nasty MacTk bug
            # XXX Is this one still needed?
            self.update()
        # Version sanity checks
        tk_version = self.tk.getvar('tk_version')
        if tk_version != _tkinter.TK_VERSION:
            raise RuntimeError, \
            "tk.h version (%s) doesn't match libtk.a version (%s)" \
            % (_tkinter.TK_VERSION, tk_version)
        # Under unknown circumstances, tcl_version gets coerced to float
        tcl_version = str(self.tk.getvar('tcl_version'))
        if tcl_version != _tkinter.TCL_VERSION:
            raise RuntimeError, \
            "tcl.h version (%s) doesn't match libtcl.a version (%s)" \
            % (_tkinter.TCL_VERSION, tcl_version)
        if TkVersion < 4.0:
            raise RuntimeError, \
            "Tk 4.0 or higher is required; found Tk %s" \
            % str(TkVersion)
        self.tk.createcommand('tkerror', _tkerror)
        self.tk.createcommand('exit', _exit)
        self.readprofile(baseName, className)
        if _support_default_root and not _default_root:
            _default_root = self
        self.protocol("WM_DELETE_WINDOW", self.destroy)
    def destroy(self):
        """Destroy this and all descendants widgets. This will
        end the application of this Tcl interpreter."""
        for c in self.children.values(): c.destroy()
        self.tk.call('destroy', self._w)
        Misc.destroy(self)
        global _default_root
        if _support_default_root and _default_root is self:
            _default_root = None
    def readprofile(self, baseName, className):
        """Internal function. It reads BASENAME.tcl and CLASSNAME.tcl into
        the Tcl Interpreter and calls execfile on BASENAME.py and CLASSNAME.py if
        such a file exists in the home directory."""
        import os
        if os.environ.has_key('HOME'): home = os.environ['HOME']
        else: home = os.curdir
        class_tcl = os.path.join(home, '.%s.tcl' % className)
        class_py = os.path.join(home, '.%s.py' % className)
        base_tcl = os.path.join(home, '.%s.tcl' % baseName)
        base_py = os.path.join(home, '.%s.py' % baseName)
        dir = {'self': self}
        exec 'from Tkinter import *' in dir
        if os.path.isfile(class_tcl):
            self.tk.call('source', class_tcl)
        if os.path.isfile(class_py):
            execfile(class_py, dir)
        if os.path.isfile(base_tcl):
            self.tk.call('source', base_tcl)
        if os.path.isfile(base_py):
            execfile(base_py, dir)
    def report_callback_exception(self, exc, val, tb):
        """Internal function. It reports exception on sys.stderr."""
        import traceback, sys
        sys.stderr.write("Exception in Tkinter callback\n")
        sys.last_type = exc
        sys.last_value = val
        sys.last_traceback = tb
        traceback.print_exception(exc, val, tb)

So, I want to be able to provide the baseName variable in these lines of code to override lines below from 14 to 19.

Code:
Tkinter(baseName = file_name_path).Label(text=" ").pack()
Tkinter(baseName = file_name_path).Label(text="TEST Dialog Box").pack()
Tkinter(baseName = file_name_path).Label(text=" ").pack()
mainloop()
Is it possible to do that?

Thank You
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles