Beispiel #1
0
    def __init__(self,
                 parent,
                 data=None,
                 lines=None,
                 ubis=None,
                 image=None,
                 pars=None,
                 spline=None):
        """
        Data would be your observed g-vectors. Lines will
        be a computed lattice
        """
        Tk.Toplevel.__init__(self, parent)
        self.parent = parent
        if data != None:
            xyz = data.copy()
        else:
            xyz = numpy.array([0, 0, 0])
        self.ps = Tk.StringVar()
        self.ps.set('1.')
        self.pointsize = 1.
        self.npeaks = xyz.shape[0]

        self.o = myOpengl(self, width=400, height=400, double=1)
        self.o.redraw = self.redraw
        self.o.autospin_allowed = 1
        self.o.fovy = 5
        self.o.near = 1e6
        self.o.far = 1e-6
        import math
        self.o.distance = 3.
        #numpy.maximum.reduce(numpy.ravel(xyz))*4 / \
        #            math.tan(self.o.fovy*math.pi/180)
        print type(xyz), xyz.dtype.char, xyz.shape
        self.xyz = xyz
        f = Tk.Frame(self)
        Tk.Button(f, text="Help", command=self.o.help).pack(side=Tk.LEFT)
        Tk.Button(f, text="Reset", command=self.o.reset).pack(side=Tk.LEFT)
        Tk.Button(f, text="Pointsize", command=self.setps).pack(side=Tk.LEFT)
        Tk.Entry(f, textvariable=self.ps).pack(side=Tk.LEFT)
        Tk.Button(f, text="Quit", command=self.goaway).pack(side=Tk.RIGHT)
        self.dataoff = 0
        self.o.pack(side='top', expand=1, fill='both')
        f.pack(side=Tk.BOTTOM, expand=Tk.NO, fill=Tk.X)
        Tk.Label(self, text="Red=[1,0,0] Green=[0,1,0] Blue=[0,0,1]").pack(
            side=Tk.BOTTOM, expand=Tk.NO, fill=Tk.X)
        self.ubis = ubis
        self.color = numpy.ones((xyz.shape[0], 3), numpy.float)
        print self.color.shape
        self.tex = False
        if ubis is not None:
            self.ubis = self.readubis(ubis)
            self.scorecolor(0)
        if pars is not None:
            self.tex = True
            self.readspline(spline)
            self.readprms(pars)
            self.readimage(image)
        self.changedata(xyz)
Beispiel #2
0
from Tkinter import *
from Tkinter import Tk


def calculate(*args):
    try:
        value = float(feet.get())
        meters.set((0.3048 * value * 10000.0 + 0.5) / 10000.0)
    except ValueError:
        pass


root = Tk()
root.title("Feet to Meters")

mainframe = Tk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)

feet = StringVar()
meters = StringVar()

feet_entry = Tk.Entry(mainframe, width=7, textvariable=feet)
feet_entry.grid(column=2, row=1, sticky=(W, E))

Tk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W, E))
Tk.Button(mainframe, text="Calculate", command=calculate).grid(column=3,
                                                               row=3,
                                                               sticky=W)