# -*- coding: iso-8859-1 -*- # #------------------------------------------------------------------------------- # Code_Saturne version 1.3 # ------------------------ # # # This file is part of the Code_Saturne User Interface, element of the # Code_Saturne CFD tool. # # Copyright (C) 1998-2007 EDF S.A., France # # contact: saturne-support@edf.fr # # The Code_Saturne User Interface is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # The Code_Saturne User Interface is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with the Code_Saturne Kernel; if not, write to the # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA # #------------------------------------------------------------------------------- """ This module defines the main application classes for the generic Tk GUI. This GUI provides a simple way to display independante pages, in order to put informations in the XML document, which reflets the treated case. This module defines the following classes: - StatusBar - StudyIdBar - BaseTkGUI """ #------------------------------------------------------------------------------- # Library modules import #------------------------------------------------------------------------------- import os, sys, string import Tix from Tkconstants import * import tkColorChooser, tkFileDialog, tkMessageBox #------------------------------------------------------------------------------- # Application modules import #------------------------------------------------------------------------------- from Common import * import XMLengine from XMLinitialize import * from XMLmodel import * import Toolbox as Tool import Dialog import Tree import Pages.WelcomePage as Welcome import Pages.IdentityAndPathes as Identity #------------------------------------------------------------------------------- # Licence #------------------------------------------------------------------------------- licence =""" GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. """ #------------------------------------------------------------------------------- # Status Bar #------------------------------------------------------------------------------- class StatusBar: """ This class provides a simple way to show that the application is busy doing something. It does this by changing the cursor to a watch and changing the color of the 'registered' widgets to red. It keeps track of how many times the 'busy' method has been called and does the 'right thing' if the state is already busy. """ def __init__(self, master): """ Draw the statusbar. """ self.master = master.fr3 self.label = Tix.Label(self.master, bd=1, relief=SUNKEN, wraplength=600, justify=LEFT, font=fS) self.label.form(padx=3, pady=3, left=0, right='%90') ## self.label = Tix.Label(self.master, bd=1, relief=SUNKEN, ## wraplength=600, width=85, ## justify=LEFT, font=fS) ## self.label.pack(side=LEFT, padx=3, pady=3) ## self.b1 = Tix.Button(self.frame, bd=0, text='H') ## self.b1.pack(side=RIGHT) ## self.b2 = Tix.Button(self.frame, bd=0, text='B') ## self.b2.pack(side=RIGHT) if not hasattr (self, 'is_busy'): self.is_busy = 0 self.orig_bg = wm['bg'] def set(self, format, *args): """ Display some informations. """ self.label.config(text = format % args) self.label.update_idletasks() def clear(self): """ Erase the text. """ self.label.config(text = "") self.label.update_idletasks() def busy(self): """ Show that the application is busy doing something. If already busy simply incremement a counter. """ if self.is_busy: self.is_busy = self.is_busy + 1 return self.orig_bg = self.label.cget('background') self.label.config(background='red', cursor='watch') self.master.config(cursor='watch') self.label.update_idletasks() self.is_busy = 1 def force_idle(self): """ Force the status bar to be idle. Typically used when an exception is hit. """ if self.is_busy: self.is_busy = 0 self.label.config(background=self.orig_bg, cursor="") self.master.config(cursor="") def idle(self): """ Application is idle, restore the GUI if the count of busy calls is zero if not decrement counter. """ if self.is_busy: self.is_busy = self.is_busy - 1 if not self.is_busy: self.label.config(background=self.orig_bg, cursor="") self.master.config(cursor="") #------------------------------------------------------------------------------- # Study identity zone #------------------------------------------------------------------------------- class StudyIdBar: """ This class provides a set of widget which allow to identify the current case. It diplays the names of the study and the case, and the name of the xml file. """ def __init__(self, master): """ Draw the StudyIdBar. Create the widgets for study and XML file identification. """ self.master = master.fr1.fr5 self.text = Tool.Text() self.tab = '\t\t' t = self.text f = [0]*3 self.l = [0]*6 for i,tx in [ (0, t.STUDY_NAME ), (1, t.CASE_NAME ), (2, t.XML_NAME ) ]: # Left labels # self.l[i] = Tix.Label(self.master, text=tx, font=fI) self.l[i].grid(row=i, column=0, pady=2, padx=5, sticky=W) # Right frames # f[i] = Tix.Frame(self.master, bd=2, relief=GROOVE) f[i].grid(row=i, column=1, pady=1, sticky=W) # Labels in right frames # self.l[i+3] = Tix.Label(f[i], text=self.tab, font=fI, padx=3, bg=wm['identity']) self.l[i+3].pack() def set(self, **args): """ Display some informations. """ self.l[3].config(text = args['study']) self.l[4].config(text = args['case']) try: self.l[5].config(text = os.path.basename(args['file'])) except: pass def clear(self): """ Erase the text. """ for i in range(3,6): self.l[i].config(text=self.tab) #------------------------------------------------------------------------------- # Main application #------------------------------------------------------------------------------- class BaseTkGUI: """ This is the main application, creates the main GUI and controls everything. """ def __init__(self, master, cmd_case, cmd_lang, matisse, batch_window, batch_file, tree_window, read_only): self.master = master self.root = Tix.Toplevel(master) self.batch = batch_window self.batch_file = batch_file self.tree_w = tree_window self.read_o = read_only # Main window configuration. # self.x_win = SCREEN_X_PIXEL self.y_win = SCREEN_Y_PIXEL g = '%dx%d+%d+%d' % ( DISPLAY_WIDTH , DISPLAY_HEIGHT , SCREEN_X_PIXEL , SCREEN_Y_PIXEL ) self.root.geometry(g) self.root.protocol('WM_DELETE_WINDOW', self.quitAll) self.root.wm_positionfrom('user') #self.root.minsize(700,550) # Background color. # try: self.bg = self.master.tk.call('tix', 'option', 'get', 'background') except: self.bg = wm['bg'] # Path for tree icons (folders and files). # self.master.tk.call('tix', 'addbitmapdir', PIC_PATH) # Fonts. # Tool.setupFontDefault(self.root) ## self.font = Tix.StringVar() ## self.size = Tix.IntVar() ## self.font.set(wm['font']) ## self.size.set(wm['fontsize']) # Language variable declaration and initialization. # self.lang = Tix.StringVar() if cmd_lang: Tool.GuiParam.lang = cmd_lang self.lang.set(Tool.GuiParam.lang) self.text = Tool.Text() self.root.winfo_toplevel().title(self.text.GUI_TITLE) self.root.iconname(self.text.GUI_TITLE) # Initialize the beep switch to the default value. # self.beep = Tix.StringVar() self.beep.set(Tool.GuiParam.beep) # Set the global variable matisse position # Tool.GuiParam.matisse = matisse # Initialize variables concerning the display of the pages. # self._initPage() # GUI layout # self._buildGUI() if self.tree_w == False: self.myTree.tree.pack_forget() # Is there any information about the case in the command line. # if cmd_case == "new case": self.openNewCase() elif cmd_case: self.uploadPreviousCase(cmd_case) if self.read_o == True: self.b4.config(state=DISABLED) def _initPage(self): """ Initialize variables concerning the display of the pages. """ self.mousePointedEntry = None self.selectedEntry = None self.currentEntry = None def initializeBatchRunningWindow(self): """ Initialize variables concerning the display of batchrunning. """ from Pages.IdentityAndPathes import IdentityAndPathesModel self.IdPthMdl = IdentityAndPathesModel(self.case) fic = self.IdPthMdl.getXmlFileName() if not fic: f = os.getcwd() if os.path.basename(f) == 'DATA': f = os.path.dirname(f) self.IdPthMdl.setCasePath(f) else : file_dir = os.path.split(fic)[0] if file_dir: self.IdPthMdl.setCasePath(os.path.split(file_dir)[0]) if not os.path.basename(file_dir) == 'DATA': self.IdPthMdl.setCasePath(file_dir) else: file_dir = os.path.split(os.getcwd())[0] self.IdPthMdl.setCasePath(file_dir) for p,rep in [('data_path','DATA'), ('resu_path','RESU'), ('user_src_path','FORT'), ('scripts_path','SCRIPTS')]: self.IdPthMdl.setPathI(p,file_dir + '/' + rep) self.IdPthMdl.setPathI('mesh_path',os.path.abspath(os.path.split(file_dir)[0] + '/' + 'MAILLAGE')) self.case['computer'] = 'station' self.case['batchScript'] = {'cluster': '', 'station': self.batch_file} self.case['backupBatchScript'] = {'cluster': 'no', 'station': 'yes'} del IdentityAndPathesModel self.updateStudyId() def resizeWin(self): """ Gives to the window its first size. """ g = '%dx%d+%d+%d' % (DISPLAY_WIDTH, DISPLAY_HEIGHT, self.x_win, self.y_win ) self.root.geometry(g) def refreshWin(self): """ Refresh the main window. """ self.stbar.busy() self.root.update() self.stbar.idle() def quitAll(self, event=None): """ Closes the application. """ self.stbar.busy() if hasattr(self, 'case') and Tool.GuiParam.saved == "no": ans = Dialog.askyesno(self.Fr, title=self.text.WARNING, image='pan_exit.gif', text=self.text.EXIT) else: ans = 'yes' if ans == 'no' : self.stbar.force_idle() return else: self.root.destroy() self.master.destroy() self.root.quit sys.exit(0) def eraseCase(self): """ Erase the case and the case without any question. Use this function only for deleting the case if any problem occurs at the case upload. For other reasons, it's better to use the method : self.deleteCase(). """ self.stbar.busy() # Delete the previous case # if hasattr(self, 'case'): self.myTree.delAttr() delattr(self, 'case') # Update the ToolBar # self.b4.config(state=DISABLED) self.b5.config(state=DISABLED) self.b6.config(state=DISABLED) self.stbar.idle() def deleteCase(self): """ This function delete the current if exists. return 'yes' if it is OK for deleting case, return 'no' if the case is not deleted. """ # Is there a current case? # if hasattr(self, 'case') and Tool.GuiParam.saved == "no": t = self.text ans = Dialog.askyesno(self.Fr, title=t.WARNING, text=t.NO_SAVE) else: ans = 'yes' # Delete the previous case # if ans == 'yes': self.eraseCase() return ans def openNewCase(self, event=None): """ Instanciate a new saturne case. We verify if there is a previous case, and its status. """ t = self.text self.stbar.busy() self.stbar.set(t.NEW_CASE) if self.deleteCase() == 'yes': self.myTree.setWhiteFiles() self.myTree.closeTreeFolder() # Instantiate a new case # self.case = XMLengine.Case() XMLinit(self.case) # Update the ToolBar # if self.read_o == False: self.b4.config(state=NORMAL) self.b5.config(state=NORMAL) self.b6.config(state=DISABLED) self._initPage() self.currentEntry ='envirt/identi' self.displayNewPage(self.currentEntry) self.myTree.openSingleFolder('envirt') if self.tree_w == True: self.myTree.addAttr(self.case) configureTree(self.myTree.tree, self.case) self.stbar.clear() self.stbar.force_idle() def openCase(self, file_name): """ Open a case. """ t = self.text # Restart the Tree Navigator layout # self.myTree.setWhiteFiles() self.myTree.closeTreeFolder() # Instantiate a new case # try: self.case = XMLengine.Case(file_name) XMLinit(self.case) except: Dialog.Error(self.Fr, title=t.ERROR, text=t.XML_ERR) self.eraseCase() return # Cleaning the '\n' and '\t' from file_name # self.case.xmlCleanAllBlank(self.case.xmlRootNode()) #print self.case.toString() #print self.case # Update the ToolBar # if self.read_o == False: self.b4.config(state=NORMAL) self.b5.config(state=NORMAL) self.b6.config(state=NORMAL) # Update the case and the StudyIdBar # self.case['xmlfile'] = file_name self._initPage() # Update the Tree Navigator layout # if self.batch == True: self.initializeBatchRunningWindow() self.currentEntry ='managt/batch' self.displayNewPage(self.currentEntry) if self.tree_w == True: self.myTree.openSingleFolder('managt') else: self.currentEntry ='envirt/identi' self.displayNewPage(self.currentEntry) if self.tree_w == True: self.myTree.openSingleFolder('envirt') if self.tree_w == True: self.myTree.addAttr(self.case) configureTree(self.myTree.tree, self.case) def openPreviousCase(self, event=None): """ Open a previous case. """ t = self.text self.stbar.busy() self.stbar.set(t.OLD_CASE) file_name = "" tk_fopen = tkFileDialog.askopenfilename if hasattr(self, 'case') and os.path.isdir(self.case['data_path']): dir = self.case['data_path'] else: dir = os.getcwd() if os.path.isdir(dir + "/../DATA"): dir = dir + "/../DATA" file_name = tk_fopen (title="Open XML file.", initialdir=dir, filetypes=[("SaturneGUI case files", "*.xml"), ("All files", "*")]) if file_name and self.deleteCase() == 'yes': self.openCase(file_name) self.stbar.clear() self.stbar.force_idle() def reloadFile(self): """ Reload the current XML file, ask YES/NO when this file is not saved. """ t = self.text self.stbar.busy() self.stbar.set(t.RELOAD_F) file_name = self.case['xmlfile'] if self.deleteCase() == 'yes': self.openCase(file_name) self.stbar.clear() self.stbar.force_idle() def uploadPreviousCase(self, file_name): """ Upload a XML file when the GUI starting with the name of file in the arguments line. """ t = self.text self.stbar.busy() self.stbar.set(t.OLD_CASE) # Verify that the given file name exists # if os.path.isfile(file_name): self.openCase(file_name) else: Dialog.Warning(self.Fr, title=t.WARNING, text=t.WRONG_FILE) self.stbar.clear() self.stbar.force_idle() def openXterm(self, event=None): """ Open an xterm window. """ self.stbar.busy() if hasattr(self, 'case'): os.system('cd ' + self.case['case_path'] + ' && xterm -sb &') else: os.system('xterm -sb&') self.stbar.idle() def displayCase(self, event=None): """ Simple tool wich print on the current terminal the contents of the case. """ self.stbar.busy() if hasattr(self, 'case'): print self.case self.stbar.idle() def updateStudyId(self): """ Update the Study Identity. """ node = self.case.root() self.study.clear() self.study.set(study = node.xmlGetAttribute('study'), case = node.xmlGetAttribute('case'), file = self.case['xmlfile']) def saveCase(self, event=None): """ This method save the current case. """ t = self.text self.stbar.busy() self.stbar.set(t.SAVE_CASE) if hasattr(self,'case') and self.case['new'] == "yes": tk_fsave = tkFileDialog.asksaveasfilename file = tk_fsave(title="Save SaturneGUI data file", initialdir=self.case['data_path'], defaultextension=".xml", filetypes=[("SaturneGUI case files", "*.xml"), ("All files", "*")]) self.case['xmlfile'] = string.join(string.split(file, " "),"_") if hasattr(self,'case') and self.case['xmlfile'] != "": file = self.case['xmlfile'] self.case['xmlfile'] = string.join(string.split(file, " "),"_") self.updateStudyId() self.b6.config(state=NORMAL) self.case.xmlSaveDocument() self.stbar.clear() self.stbar.force_idle() def saveCaseAs(self, event=None): """ This method save the current case with a asked name. """ t = self.text self.stbar.busy() self.stbar.set(t.SAVE_CASE) if hasattr(self,'case'): tk_fsave = tkFileDialog.asksaveasfilename file = tk_fsave(title="Save SaturneGUI data file", initialdir=self.case['data_path'], defaultextension=".xml", filetypes=[("SaturneGUI case files", "*.xml"), ("All files", "*")]) self.case['xmlfile'] = string.join(string.split(file, " "),"_") if self.case['xmlfile'] != "": self.updateStudyId() self.b6.config(state=NORMAL) self.case.xmlSaveDocument() self.stbar.clear() self.stbar.force_idle() def reloadGUI(self): """ Update the GUI display. """ # Update the main GUI # self.root.fr1.destroy() self.root.fr2.destroy() self.root.fr3.destroy() self.balloon.destroy() self._buildGUI() # Update the ToolBar # if hasattr(self, 'case'): if self.read_o == False: self.b4.config(state=NORMAL) self.b5.config(state=NORMAL) if self.case['new'] == "no": self.b6.config(state=NORMAL) # Update the StudyIdBar and the TreeNavigator # self.updateStudyId() if self.tree_w == True: self.myTree.addAttr(self.case) configureTree(self.myTree.tree, self.case) def changeLanguage(self, event=None): """ Update the language. """ # Update the new language # Tool.GuiParam.lang = self.lang.get() # New instance of Text() # self.text = Tool.Text() # Update text and label of the main GUI # self.reloadGUI() self.root.winfo_toplevel().title(self.text.GUI_TITLE) self.root.iconname(self.text.GUI_TITLE) def setSound(self, event=None): """ Switch on/off the error beep. """ Tool.GuiParam.beep = self.beep.get() #TODELETE ## def setFont(self, event=None): ## """ ## """ ## wm['font'] = self.font.get() ## wm['fontsize'] = self.size.get() ## # Update the main GUI ## # ## Tool.setupFontDefault(self.root) ## self.reloadGUI() #TODELETE def setRootBgColor(self, event=None): """ Choose and set a background color from a GUI color chooser. """ t = self.text new_col = tkColorChooser.askcolor(title=t.BGCOLOR, initialcolor=self.bg) if not new_col[1]: return self.bg = new_col[1] self.root.config(bg=self.bg) import WmDefault WmDefault.setup(self.root) WmDefault.addoptions(self.root, {'bg': self.bg}) WmDefault.addoptions(self.root, {'background': self.bg}) WmDefault.addoptions(self.root, {'menubackground': self.bg}) WmDefault.addoptions(self.root, {'highlightbackground': self.bg}) # Update color of the main GUI # self.reloadGUI() def reload_modules(self, event=None): """ This function reloads all the currently loaded modules, and then update the GUI. Only the 'Base.Common' module can not be reloaded. This method does not work very good with the module Main.py. """ self.stbar.busy() msg = "Warning: This reloads all the currently loaded modules. "\ "This is a feature useful only for developers. You might "\ "see funny behaviour for already instantiated objects.\n\n"\ "Are you sure you want to do this?" ans = Dialog.askyesno(self.Fr, title=self.text.WARNING, image='danger.gif', text=msg) if ans == 'yes': Tool.reload_all_modules() Tool.setupFontDefault(self.root) self.changeLanguage() self.stbar.force_idle() def reload_page(self, event=None): """ This function reloads the current loaded page, and the update the GUI. """ self.stbar.busy() msg = "Warning: This reloads all the current loaded page. "\ "This is a feature useful only for developers. You might "\ "see funny behaviour for already instantiated objects.\n\n"\ "Are you sure you want to do this?" if self.currentEntry: ans = Dialog.askyesno(self.Fr, title=self.text.WARNING, image='danger.gif', text=msg) if ans == 'yes': Tool.reload_current_page() self.displayNewPage( self.currentEntry ) self.stbar.force_idle() def displayAbout(self, event=None): """ The About dialog window shows: - title - version - developpers (with contacts) """ self.stbar.busy() Dialog.About(self.Fr) self.stbar.idle() def displayLicence(self, event=None): """ The About dialog window shows: - title - version - developpers (with contacts) """ self.stbar.busy() print "licence actuelle utilisée :",licence self.stbar.idle() def displayCSManual(self, event=None): """ """ self.stbar.busy() t = self.text error = 0 if os.system('which info_cs') == "": tkMessageBox.warning(t.USER_CSMANUAL, t.MSG_NO_INFO_CS) error = 1 if not error: os.system('info_cs user') self.stbar.idle() def displayECSManual(self, event=None): """ """ self.stbar.busy() t = self.text error = 0 if os.system('which info_cs') == "": tkMessageBox.warning(t.USER_ECSMANUAL, t.MSG_NO_INFO_CS) error = 1 if not error: os.system('info_cs ecsmu') self.stbar.idle() def displayCSKernel(self, event=None): """ """ self.stbar.busy() t = self.text error = 0 if os.system('which info_cs') == "": tkMessageBox.warning(t.USER_CSMANUAL, t.MSG_NO_INFO_CS) error = 1 if not error: os.system('info_cs noyau') self.stbar.idle() def displayECSInfos(self, event=None): """ """ self.stbar.busy() t = self.text error = 0 if os.system('which info_cs') == "": tkMessageBox.warning(t.USER_CSMANUAL, t.MSG_NO_INFO_CS) error = 1 if not error: os.system('info_cs ecsmi') self.stbar.idle() def _fileMenu(self): """ Create the file menu button. """ t = self.text # menubutton on the Menubar # mb1 = Tix.Menubutton(self.root.fr1.fr3, text=t.FILE, underline=0) mb1.pack(side=LEFT) # list of choice when user clicks on the menubutton # filemenu = Tix.Menu(mb1) filemenu.add_command(label=t.OPEN, command=self.openPreviousCase, accelerator='Ctrl+O', underline=0) filemenu.add_command(label=t.NEW_FILE, command=self.openNewCase, accelerator='Ctrl+N', underline=0) filemenu.add_separator() filemenu.add_command(label=t.SAVE, command=self.saveCase, accelerator='Ctrl+S', underline=0) filemenu.add_command(label=t.SAVE_AS, command=self.saveCaseAs, underline=2) if self.read_o == True: index = filemenu.index(t.SAVE) filemenu.entryconfigure(index, state=DISABLED) index = filemenu.index(t.SAVE_AS) filemenu.entryconfigure(index, state=DISABLED) filemenu.add_separator() filemenu.add_command(label=t.QUIT, command=self.quitAll, accelerator='Ctrl+Q', underline=0) mb1.config(menu=filemenu) # binding the accelerators # self.root.bind_all("", self.openPreviousCase) self.root.bind_all("", self.openNewCase) if self.read_o == False: self.root.bind_all("", self.saveCase) else: self.root.bind_all("", self.saveCase) self.root.bind_all("", self.quitAll) def _toolMenu(self): """ Create the tool menu button. """ t = self.text # menubutton on the Menubar # mb4 = Tix.Menubutton(self.root.fr1.fr3, text=t.TOOLS, underline=0) mb4.pack(side=LEFT) # list of choice when user clicks on the menubutton # toolmenu = Tix.Menu(mb4) toolmenu.add_command(label=t.OPENXTERM, command=self.openXterm, accelerator='Ctrl+T', underline=0) toolmenu.add_separator() toolmenu.add_command(label=t.CASE_DISPLAY, command=self.displayCase, accelerator='Ctrl+P', underline=0) toolmenu.add_separator() toolmenu.add_command(label=t.RELOAD_ALL_MOD, command=self.reload_modules, accelerator='Ctrl+A', underline=0) toolmenu.add_command(label=t.RELOAD_PAGE, command=self.reload_page, accelerator='Ctrl+R', underline=1) mb4.config(menu=toolmenu) # binding the accelerators # self.root.bind_all("", self.openXterm) self.root.bind_all("", self.displayCase) self.root.bind_all("", self.reload_modules) self.root.bind_all("", self.reload_page) def _optionMenu(self): """ Create the option menu button. """ t = self.text # menubutton on the Menubar # mb2 = Tix.Menubutton(self.root.fr1.fr3, text=t.OPTION, underline=1) mb2.pack(side=LEFT, padx=3) # list of choice when user clicks on the menubutton # optmenu = Tix.Menu(mb2) submenu1 = Tix.Menu(optmenu) submenu1.add_radiobutton(label=t.FRENCH, variable=self.lang, value='fr', command=self.changeLanguage, underline=0) submenu1.add_radiobutton(label=t.ENGLISH, variable=self.lang, value='en', command=self.changeLanguage, underline=0) optmenu.add_cascade(label=t.LANGUAGE, underline=0, menu=submenu1) optmenu.add_separator() submenu2 = Tix.Menu(optmenu) submenu2.add_radiobutton(label=t.ON, variable=self.beep, value='on', command=self.setSound, underline=0) submenu2.add_radiobutton(label=t.OFF, variable=self.beep, value='off', command=self.setSound, underline=1) optmenu.add_cascade(label=t.SOUND,underline=0, menu=submenu2) optmenu.add_separator() optmenu.add_command(label=t.BGCOLOR, command=self.setRootBgColor, underline=0) #TODELETE ## optmenu.add_separator() ## submenu3 = Tix.Menu(optmenu) ## for font in ('courrier', 'helvetica', 'lucida', 'tahoma', 'times'): ## submenu3.add_radiobutton(label=font, ## variable=self.font, value=font, ## underline=0, command=self.setFont) ## optmenu.add_cascade(label="Font", underline=0, menu=submenu3) ## submenu4 = Tix.Menu(optmenu) ## for size in ('8', '9'): ## submenu4.add_radiobutton(label=size, ## variable=self.size, value=int(size), ## underline=0, command=self.setFont) ## for size in ('10', '11', '12', '13', '14', '15', '16'): ## submenu4.add_radiobutton(label=size, ## variable=self.size, value=int(size), ## underline=1, command=self.setFont) ## optmenu.add_cascade(label="Font size", underline=5, menu=submenu4) #TODELETE mb2.config(menu=optmenu) def _helpMenu(self): """ Create the help menu button. """ t = self.text # menubutton on the Menubar # mb3 = Tix.Menubutton(self.root.fr1.fr3, text=t.HELP, underline=0) mb3.pack(side=RIGHT) # list of choice when user clicks on the menubutton # helpmenu = Tix.Menu(mb3) helpmenu.add_command(label=t.ABOUT, command=self.displayAbout, underline=0) helpmenu.add_command(label=t.LICENCE, command=self.displayLicence, underline=0) helpmenu.add_separator() submenu1 = Tix.Menu(helpmenu) submenu1.add_command(label=t.USER_CS, underline=0, command=self.displayCSManual, accelerator='F1') submenu1.add_command(label=t.USER_ECS, underline=0, command=self.displayECSManual, accelerator='F2') submenu1.add_command(label=t.USER_CS_KERNEL, underline=0, command=self.displayCSKernel, accelerator='F3') submenu1.add_command(label=t.USER_ECS_INFOS, underline=0, command=self.displayECSInfos, accelerator='F4') helpmenu.add_cascade(label=t.USER_MANUAL, underline=0, menu=submenu1) mb3.config(menu=helpmenu) # binding the accelerators if a pdf reader is available # if os.system('which info_cs') != "" : self.root.bind_all("", self.displayCSManual) self.root.bind_all("", self.displayECSManual) self.root.bind_all("", self.displayCSKernel) self.root.bind_all("", self.displayECSInfos) else: index = helpmenu.index(END) helpmenu.entryconfigure(index, state=DISABLED) def _makeMenusBar(self): """ Create the main window menus bar. """ self._fileMenu() self._toolMenu() self._optionMenu() self._helpMenu() def _makeToolsBar(self): """ Create the main window toolbar. """ t = self.text self.img2 = Tix.PhotoImage(file=PIC_PATH+'opennew.gif') b2 = Tix.Button(self.root.fr1.fr4, image=self.img2, relief=FLAT, command=self.openNewCase) b2.pack(side=LEFT, padx=1, pady=0) self.balloon.bind_widget(b2, balloonmsg=t.NEW_CASE, statusmsg=t.NEW_CASE2) self.img3 = Tix.PhotoImage(file=PIC_PATH+'openold.gif') b3 = Tix.Button(self.root.fr1.fr4, image=self.img3, relief=FLAT, command=self.openPreviousCase) b3.pack(side=LEFT, padx=1, pady=0) self.balloon.bind_widget(b3, balloonmsg=t.OLD_CASE, statusmsg=t.OLD_CASE2) self.img4 = Tix.PhotoImage(file=PIC_PATH+'save.gif') self.b4 = Tix.Button(self.root.fr1.fr4, image=self.img4, relief=FLAT, state=DISABLED, command=self.saveCase) self.b4.pack(side=LEFT, padx=1, pady=0) self.balloon.bind_widget(self.b4, balloonmsg=t.SAVE_CASE, statusmsg=t.SAVE_CASE2) self.img6 = Tix.PhotoImage(file=PIC_PATH+'reload.gif') self.b6 = Tix.Button(self.root.fr1.fr4, image=self.img6, relief=FLAT, state=DISABLED, command=self.reloadFile) self.b6.pack(side=LEFT, padx=1, pady=0) self.balloon.bind_widget(self.b6, balloonmsg=t.RELOAD_F) self.img5 = Tix.PhotoImage(file=PIC_PATH+'printcase.gif') self.b5 = Tix.Button(self.root.fr1.fr4, image=self.img5, relief=FLAT, state=DISABLED, command=self.displayCase) self.b5.pack(side=LEFT, padx=1, pady=0) self.balloon.bind_widget(self.b5, balloonmsg=t.CASE_DISPLAY) self.img1 = Tix.PhotoImage(file=PIC_PATH+'resize.gif') b1 = Tix.Button(self.root.fr1.fr4, image=self.img1, relief=FLAT, command=self.resizeWin) b1.pack(side=LEFT, padx=1, pady=0) self.balloon.bind_widget(b1, balloonmsg=t.RESIZE) self.img8 = Tix.PhotoImage(file=PIC_PATH+'refresh.gif') b8 = Tix.Button(self.root.fr1.fr4, image=self.img8, relief=FLAT, command=self.refreshWin) b8.pack(side=LEFT, padx=1, pady=0) self.balloon.bind_widget(b8, balloonmsg=t.REFRESH) self.img7 = Tix.PhotoImage(file=PIC_PATH+'exit.gif') b7 = Tix.Button(self.root.fr1.fr4, image=self.img7, relief=FLAT, command=self.quitAll) b7.pack(side=LEFT, padx=1, pady=0) self.balloon.bind_widget(b7, balloonmsg=t.QUIT) def infoLogo(self, event=None): """ Debugging method """ # TODO: message from voyager print "Salut !" def displayPopup(self, event=None): """ Debugging method """ t = self.text print Dialog.dirselect(self.Fr, stbar=self.stbar, default=self.case['case_path']) ## ans = Dialog.askyesno(self.Fr, title=self.text.WARNING, ## image='pan_exit.gif', text=self.text.EXIT) ## ans = Dialog.askyesno(self.Fr, title=t.WARNING, text=t.NO_SAVE) ## Dialog.Error(self.Fr, title=t.ERROR, text=t.XML_ERR) def _displayLogo(self): """ Display the picture in the top left corner on the main window. """ self.img = Tix.PhotoImage(file = PIC_PATH+'saturne.gif') w, h = self.img.width(), self.img.height() saturne = Tix.Label(self.root.fr1.fr2, bg='black', width=w, height=h, relief=FLAT, image=self.img) saturne.pack(side=LEFT, fill=BOTH) saturne.bind("", self.infoLogo) saturne.bind("", self.displayPopup) def _buildGuiHead(self): """ Fill the head of the main window (Icon, Menusbar, Toolsbar, Study and case identification). """ self.root.fr1.fr2 = Tix.Frame(self.root.fr1, bd=2, relief=RAISED) self.root.fr1.fr2.pack(fill=BOTH, side=LEFT) self._displayLogo() self.root.fr1.fr3 = Tix.Frame(self.root.fr1, bd=2, relief=Tix.RAISED) self.root.fr1.fr3.pack(fill=X) self._makeMenusBar() self.root.fr1.fr4 = Tix.Frame(self.root.fr1, relief=FLAT) self.root.fr1.fr4.pack(fill=X) self._makeToolsBar() self.root.fr1.fr5 = Tix.Frame(self.root.fr1, bd=2, relief=RIDGE) self.root.fr1.fr5.pack(fill=X) self.study = StudyIdBar(self.root) def _buildPanedWindow(self): """ Separate the working area into two panes. """ t = self.text self.root.fr2.pane = Tix.PanedWindow(self.root.fr2, handlebg=self.bg, orientation=HORIZONTAL) self.root.fr2.p1 = self.root.fr2.pane.add('list', size=TREE_WIDTH) self.root.fr2.p2 = self.root.fr2.pane.add('text', min=70) if self.tree_w == False: self.root.fr2.pane.paneconfigure('list', size=10) g = '%dx%d+%d+%d' % ( 480 , 680 , SCREEN_X_PIXEL , SCREEN_Y_PIXEL ) self.root.geometry(g) self.myTree = Tree.TreeNavigator(self.root) self.myTree.tree.config(browsecmd=self.selectEntry) self.myTree.tree.config(command=self.selectEntry) self.balloon.bind_widget(self.myTree.tree.hlist, statusmsg=t.MSG_TREE) self.root.fr2.p2.fr = Tix.ScrolledWindow(self.root.fr2.p2, relief=FLAT, scrollbar="auto") self.root.fr2.p2.fr.pack(expand=1, fill=BOTH, padx=4, pady=6) self.Fr = self.root.fr2.p2.fr.window self.Fr.myPage = None self.root.fr2.pane.pack(side=TOP, padx=2, pady=1, fill=BOTH, expand=1) if self.currentEntry: self.displayNewPage(self.currentEntry) folder = string.split(self.currentEntry,'/')[0] self.myTree.openSingleFolder(folder) else: self.displayWelcomePage() def _buildGUI(self): """ Building the basic GUI. """ self.root.fr1 = Tix.Frame(self.root, relief=FLAT) self.root.fr1.pack(fill=X, side=TOP) self.root.fr3 = Tix.Frame(self.root, relief=RAISED, bd=1) self.root.fr3.pack(fill=X, side=BOTTOM) self.root.fr2 = Tix.Frame(self.root, relief=FLAT) self.root.fr2.pack(side=TOP, fill=BOTH, expand=1, padx=1, pady=2) # Draw the Status Bar # self.stbar = StatusBar(self.root) # Create the balloon widget and associate it with the widgets # that we want to provide tips for: # self.balloon = Tix.Balloon(self.root, statusbar=self.stbar.label, bd=1, bg='black') self._buildGuiHead() self._buildPanedWindow() def displayNewPage(self, entry=None): """ This methode enables to display a new page when the TreeNavigator send the order. It calls a function from the Toolbox module. """ self.stbar.busy() # Destroy the previous Page # for w in self.Fr.winfo_children(): w.destroy() # Color in green the requested Page entry # self.myTree.setGreenFile(entry) self.Fr.myPage = Tool.displaySelectedPage(self.root, entry, self.case, self.stbar, self.study, self.myTree) self.stbar.idle() def displayWelcomePage(self): """ This calls the Welcome (and the default) page. This page is opened when no case is loading. """ self.stbar.busy() for w in self.Fr.winfo_children(): w.destroy() self.Fr.myPage = Welcome.WelcomePage(self.Fr) self.stbar.idle() def selectEntry(self, entry=None): """ Browsecmd: Every single Clik on the Button1 of the mouse send TWO signal to the GUI the first one when man push the button, and the second one when the button gets back. Command: Every double-Click and Return send only ONE signal to the GUI. There is a rule for the page display: when a folder has a file-child, this folder don't have any associated page, when a folder has no file-child, if has a page to display. """ # Change the image for the folder (open or close) # self.myTree.folderStatus(entry) # If there is a case, we hide and show corresponding files and folders. # if hasattr(self, 'case') and self.tree_w == True: configureTree(self.myTree.tree, self.case) self.selectedEntry = self.mousePointedEntry self.mousePointedEntry = entry if (self.selectedEntry == self.mousePointedEntry and self.currentEntry != self.mousePointedEntry): # If the entry is a folder, we do nothing # if entry in self.myTree.leaves.parents_key: pass # We verify if a case is in memory # elif not hasattr (self, 'case'): t = self.text Dialog.ShowInfo(self.Fr, title=t.WARNING, text=t.NO_XML) # We verify if the case path is correct # elif hasattr(self, 'case') and self.case['relevant_subdir'] == "no": t = self.text Dialog.ShowInfo(self.Fr, title=t.WARNING, text=t.MSG_SUBDIR) self.myTree.selectTreeEntry(self.currentEntry) else: self.currentEntry = entry self.displayNewPage(entry) #------------------------------------------------------------------------------- # Application start #------------------------------------------------------------------------------- def startGUI(): """ Returns a BaseTkGUI Window. This is to be used when using SaturneGUI from the Python interpreter. """ if not Tix._default_root: root = Tix.Tk() import Base.Toolbox Base.Toolbox.setupWmDefault(root, "") root.withdraw() top = Tix.Toplevel(root) top.withdraw() myGUI = BaseTkGUI(top, "", "") root.mainloop() #------------------------------------------------------------------------------- # End #-------------------------------------------------------------------------------