473,223 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Tkinter Dialog box

20
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)

Expand|Select|Wrap|Line Numbers
  1. class Tk(Misc, Wm):
  2.     """Toplevel widget of Tk which represents mostly the main window
  3.     of an appliation. It has an associated Tcl interpreter."""
  4.     _w = '.'
  5.     def __init__(self, screenName=None, baseName=None, className='Tk'):
  6.         """Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will
  7.         be created. BASENAME will be used for the identification of the profile file (see
  8.         readprofile).
  9.         It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
  10.         is the name of the widget class."""
  11.         global _default_root
  12.         self.master = None
  13.         self.children = {}
  14.         if baseName is None:
  15.             import sys, os
  16.             baseName = os.path.basename(sys.argv[0])
  17.             baseName, ext = os.path.splitext(baseName)
  18.             if ext not in ('.py', '.pyc', '.pyo'):
  19.                 baseName = baseName + ext
  20.         self.tk = _tkinter.create(screenName, baseName, className)
  21.         self.tk.wantobjects(wantobjects)
  22.         if _MacOS and hasattr(_MacOS, 'SchedParams'):
  23.             # Disable event scanning except for Command-Period
  24.             _MacOS.SchedParams(1, 0)
  25.             # Work around nasty MacTk bug
  26.             # XXX Is this one still needed?
  27.             self.update()
  28.         # Version sanity checks
  29.         tk_version = self.tk.getvar('tk_version')
  30.         if tk_version != _tkinter.TK_VERSION:
  31.             raise RuntimeError, \
  32.             "tk.h version (%s) doesn't match libtk.a version (%s)" \
  33.             % (_tkinter.TK_VERSION, tk_version)
  34.         # Under unknown circumstances, tcl_version gets coerced to float
  35.         tcl_version = str(self.tk.getvar('tcl_version'))
  36.         if tcl_version != _tkinter.TCL_VERSION:
  37.             raise RuntimeError, \
  38.             "tcl.h version (%s) doesn't match libtcl.a version (%s)" \
  39.             % (_tkinter.TCL_VERSION, tcl_version)
  40.         if TkVersion < 4.0:
  41.             raise RuntimeError, \
  42.             "Tk 4.0 or higher is required; found Tk %s" \
  43.             % str(TkVersion)
  44.         self.tk.createcommand('tkerror', _tkerror)
  45.         self.tk.createcommand('exit', _exit)
  46.         self.readprofile(baseName, className)
  47.         if _support_default_root and not _default_root:
  48.             _default_root = self
  49.         self.protocol("WM_DELETE_WINDOW", self.destroy)
  50.     def destroy(self):
  51.         """Destroy this and all descendants widgets. This will
  52.         end the application of this Tcl interpreter."""
  53.         for c in self.children.values(): c.destroy()
  54.         self.tk.call('destroy', self._w)
  55.         Misc.destroy(self)
  56.         global _default_root
  57.         if _support_default_root and _default_root is self:
  58.             _default_root = None
  59.     def readprofile(self, baseName, className):
  60.         """Internal function. It reads BASENAME.tcl and CLASSNAME.tcl into
  61.         the Tcl Interpreter and calls execfile on BASENAME.py and CLASSNAME.py if
  62.         such a file exists in the home directory."""
  63.         import os
  64.         if os.environ.has_key('HOME'): home = os.environ['HOME']
  65.         else: home = os.curdir
  66.         class_tcl = os.path.join(home, '.%s.tcl' % className)
  67.         class_py = os.path.join(home, '.%s.py' % className)
  68.         base_tcl = os.path.join(home, '.%s.tcl' % baseName)
  69.         base_py = os.path.join(home, '.%s.py' % baseName)
  70.         dir = {'self': self}
  71.         exec 'from Tkinter import *' in dir
  72.         if os.path.isfile(class_tcl):
  73.             self.tk.call('source', class_tcl)
  74.         if os.path.isfile(class_py):
  75.             execfile(class_py, dir)
  76.         if os.path.isfile(base_tcl):
  77.             self.tk.call('source', base_tcl)
  78.         if os.path.isfile(base_py):
  79.             execfile(base_py, dir)
  80.     def report_callback_exception(self, exc, val, tb):
  81.         """Internal function. It reports exception on sys.stderr."""
  82.         import traceback, sys
  83.         sys.stderr.write("Exception in Tkinter callback\n")
  84.         sys.last_type = exc
  85.         sys.last_value = val
  86.         sys.last_traceback = tb
  87.         traceback.print_exception(exc, val, tb)
  88.  

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

Expand|Select|Wrap|Line Numbers
  1. Tkinter(baseName = file_name_path).Label(text=" ").pack()
  2. Tkinter(baseName = file_name_path).Label(text="TEST Dialog Box").pack()
  3. Tkinter(baseName = file_name_path).Label(text=" ").pack()
  4. mainloop()
  5.  
Is it possible to do that?

Thank You
Sep 2 '08 #1
0 3943

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Thomas Nücker | last post by:
Hi! I am creating a dialog-box within my application, using tkinter. The problem is the following: After the dialogbox is started, the main application window comes again to top and the...
3
by: DoubleM | last post by:
Hi, I'm running Python2.3.3c1 on Mandrake 9.1 The following code is designed to bring up a window with a button labeled "popup". Clicking on the popup buttons triggers a secondary window with...
2
by: Stewart Midwinter | last post by:
I would like to link the contents of three OptionMenu lists. When I select an item from the first list (call it continents), the contents of the 2nd list (call it countries) would update. And in...
0
by: Stewart Midwinter | last post by:
I've got a Tkinter app that draws three histograms. At this point I am simulating real data by drawing rectangles whose size is defined by random numbers; in the future there would be real data...
2
by: Irmen de Jong | last post by:
Hi, I'm having trouble with the code below. It's just a regular Tk text widget in which you can type and select text as expected, however the call to tkFileDialog.askopenfilename() seems to screw...
6
by: phil | last post by:
I posted the following yesterday and got no response and did some testing simplifying the circumstances and it appears that deepcopy fails when the object to be copied contains a reference to a...
1
by: Michael Yanowitz | last post by:
Hello: Below I have included a stripped down version of the GUI I am working on. It contains 2 dialog boxes - one main and one settings. It has the following problems, probably all related, that...
3
by: dwelch91 | last post by:
I'm trying unsuccessfully to do something in Tk that I though would be easy. After Googling this all day, I think I need some help. I am admittedly very novice with Tk (I started with it...
5
by: msunderwd | last post by:
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.