thandialogtext.py :  » Business-Application » ThanCad » thancad-0.0.9 » thantkdia » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Business Application » ThanCad 
ThanCad » thancad 0.0.9 » thantkdia » thandialogtext.py
# -*- coding: iso-8859-7 -*-

##############################################################################
# ThanCad 0.0.9 "DoesSomething": 2dimensional CAD with raster support for engineers.
# 
# Copyright (c) 2001-2009 Thanasis Stamos,  August 23, 2009
# URL:     http://thancad.sourceforge.net
# e-mail:  cyberthanasis@excite.com
# 
# 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 (www.gnu.org/licenses/gpl.html).
# 
# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##############################################################################

"""\
ThanCad 0.0.9 "DoesSomething": 2dimensional CAD with raster support for engineers.

This module displays a dialog for the user to enter some text associated with a
ThanCad element.
"""

from Tkinter import Frame,Button,Tk
from p_ggen import prg
import p_gtkuti, p_gtkwid
from thantrans import T


class ThanElemtext(p_gtkuti.ThanDialog3):
    "Dialog for the pen thickness which the elements of a layer are plotted with."

    def __init__(self, master, vals=None, cargo=None, *args, **kw):
        "Extract initial rectification parameters."
  self.thanValsInit = vals           # This is structure not a scalar
  self.thanProj = cargo
  self.__master = master
  kw.setdefault("title", T[u" - "])
#  kw.setdefault("buttonlabels", ("Save and Exit", "Cancel", "Save and Run"))
  p_gtkuti.ThanDialog3.__init__(self, master, *args, **kw)


    def __position(self):
        "Position self."
  w = self.__master
        w.update()
        x = w.winfo_rootx() + 20
        y = w.winfo_rooty() + 15
        self.geometry("%+d%+d" % (x, y))
  del self.__master


    def destroy(self):
        "Break circular references."
        del self.thanHelp, self.thanValsInit, self.thanProj, self.thanValsSaved
  p_gtkuti.ThanDialog3.destroy(self)


    def __del__(self):
        "Say that it is deleted for debugging reasons."
        from p_ggen import prg
        prg("ThanElemtext %s is deleted." % self)


    def body(self, win):
        fra = Frame(win)
  fra.grid(row=0, column=0, sticky="we")
  but = Button(fra, text="Do nothing", background="lightcyan", activebackground="cyan")
  but.grid(row=0, column=0, sticky="w")
  fra.columnconfigure(0, weight=1)

        self.thanHelp = p_gtkwid.ThanScrolledText(win, hbar=False, vbar=True, font=None,
      background="lightyellow", foreground="black", width=80, height=25)
  self.thanHelp.grid(row=1, column=0, sticky="wesn")
  self.thanSet(self.thanValsInit)
  win.columnconfigure(0, weight=1)
  win.rowconfigure(1, weight=1)
  self.thanValsSaved = self.thanValsInit[:]
  self.__position()
  self.unbind("<Return>")
  self.thanTkSetFocus()

    def thanTkSetFocus(self):
        "Sets focus to the command window."
        self.lift()
        self.focus_set()
  self.thanHelp.focus_sette()

    def thanSet(self, vals):
        self.thanHelp.thanSet(vals[1])


    def validate(self, strict=True):
        "Returns true if the value chosen by the user is valid."
  self.result = [None, self.thanHelp.thanGet()]
  return True


    def cancel(self, *args):
        "Ask before cancel."
  if not self.validate(strict=False):   # If anything is wrong, then it must have been changed
      print "cancel: not validated"
      a = p_gtkuti.thanGudAskOkCancel(self, T["Data modified, OK to cancel?"], T["Warning"])
            if not a: return        # Cancel was stopped
  elif self.result != self.thanValsSaved: # If anything is wrong, then it must have been changed
      print self.thanValsSaved
      print self.result
      a = p_gtkuti.thanGudAskOkCancel(self, T["Data modified, OK to cancel?"], T["Warning"])
            if not a: return        # Cancel was stopped
        p_gtkuti.ThanDialog3.cancel(self, *args)


    def doApply(self, *args):
        "Save the data given and run the program."
  ret = p_gtkuti.ThanDialog3.doApply(self)
  if not ret: return
  self.thanValsSaved = self.result


if __name__ == "__main__":
    root = Tk()
    win = ThanElemtext(root, [None, "Dimitra"], cargo=None)
    print win.result
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.