def test_widget():
    m = None

    def quit():
        sys.exit()

    def clicked():
        m.updateIO("Clicked at "+time.asctime())

    def ask():
        m.updateIO("Type something in:")
        out = m.readline()

    # create the initial Tk window and immediately withdraw it
    irafutils.init_tk_default_root()

    # make our test window
    top = TKNTR.Toplevel()
    f = TKNTR.Frame(top, width=500, height=300)
    b = TKNTR.Button(f, text='Click Me', command=clicked)
    b.pack(side=TKNTR.LEFT, fill=TKNTR.X, expand=1)
    q = TKNTR.Button(f, text='Buh-Bye', command=quit)
    q.pack(side=TKNTR.LEFT)
    f.pack(side=TKNTR.TOP, fill=TKNTR.X) # , expand=1)
    p = TKNTR.Button(top, text='Prompt Me', command=ask)
    p.pack(side=TKNTR.TOP, fill=TKNTR.X, expand=1)
    fill = TKNTR.Frame(top, height=200, bg="green")
    fill.pack(side=TKNTR.TOP, fill=TKNTR.BOTH, expand=1)
    m = MsgIOWidget(top, 500, "Tiptop")
    m.pack(side=TKNTR.BOTTOM, fill=TKNTR.X)
    for i in range(10):
        t = "Text " + str(i)
        m.updateIO(t)
    m.updateIO("What is your quest?")
    inputValue = m.readline()

    # start
    top.mainloop()
Exemple #2
0
def test_widget():
    m = None

    def quit():
        sys.exit()

    def clicked():
        m.updateIO("Clicked at " + time.asctime())

    def ask():
        m.updateIO("Type something in:")
        out = m.readline()

    # create the initial Tk window and immediately withdraw it
    irafutils.init_tk_default_root()

    # make our test window
    top = TKNTR.Toplevel()
    f = TKNTR.Frame(top, width=500, height=300)
    b = TKNTR.Button(f, text='Click Me', command=clicked)
    b.pack(side=TKNTR.LEFT, fill=TKNTR.X, expand=1)
    q = TKNTR.Button(f, text='Buh-Bye', command=quit)
    q.pack(side=TKNTR.LEFT)
    f.pack(side=TKNTR.TOP, fill=TKNTR.X)  # , expand=1)
    p = TKNTR.Button(top, text='Prompt Me', command=ask)
    p.pack(side=TKNTR.TOP, fill=TKNTR.X, expand=1)
    fill = TKNTR.Frame(top, height=200, bg="green")
    fill.pack(side=TKNTR.TOP, fill=TKNTR.BOTH, expand=1)
    m = MsgIOWidget(top, 500, "Tiptop")
    m.pack(side=TKNTR.BOTTOM, fill=TKNTR.X)
    for i in range(10):
        t = "Text " + str(i)
        m.updateIO(t)
    m.updateIO("What is your quest?")
    inputValue = m.readline()

    # start
    top.mainloop()
Exemple #3
0
# XBM file for cursor is in same directory as this module
_blankcursor = 'blankcursor.xbm'
dirname = os.path.dirname(__file__)
if os.path.isabs(dirname):
    _blankcursor = os.path.join(dirname, _blankcursor)
else:
    # change relative directory paths to absolute
    _blankcursor = os.path.join(os.getcwd(), dirname, _blankcursor)
del dirname

_TK_HAS_NONE_CURSOR = True # assume True until we learn otherwise

if _default_root is None:
    from stsci.tools import irafutils
    _default_root = irafutils.init_tk_default_root()

# This code is needed to avoid faults on sys.exit()
# [DAA, Jan 1998]
# [Modified by RLW to use new atexit module, Dec 2001]

def cleanup():
    try:
        from Tkinter import _default_root, TclError # requires 2to3
        import Tkinter as TKNTR
        try:
            if _default_root: _default_root.destroy()
        except TclError:
            pass
        TKNTR._default_root = None
    except SystemError:
Exemple #4
0
    def __init__(self, windowName, manager):

        gki.GkiKernel.__init__(self)
        self.name = 'Tkplot'
        self._errorMessageCount = 0
        self._slowraise = 0
        self._toWriteAtNextClear = None
        self.irafGkiConfig = gki._irafGkiConfig
        self.windowName = windowName
        self.manager = manager

        # redraw table ignores control functions
        self.redrawFunctionTable = self.functionTable[:]
        for opcode in self._controlOps:
            self.redrawFunctionTable[opcode] = None

        # Create the root window as required, but hide it
        irafutils.init_tk_default_root()
        # note size is just an estimate that helps window manager place window
        self.top = tkinter.Toplevel(visual='best', width=600, height=485)
        # Read the epar options database file
        optfile = "epar.optionDB"
        try:
            self.top.option_readfile(os.path.join(os.curdir, optfile))
        except tkinter.TclError:
            try:
                self.top.option_readfile(os.path.join(userWorkingHome,
                                                      optfile))
            except tkinter.TclError:
                self.top.option_readfile(os.path.join(pyrafDir, optfile))
        self.top.title(windowName)
        self.top.iconname(windowName)
        self.top.protocol("WM_DELETE_WINDOW", self.gwdestroy)
        self.makeMenuBar()
        self.makeGWidget()
        self.makeStatus()
        self.gwidget.redraw = self.redraw
        self.gwidget.pack(side=tkinter.TOP, expand=1, fill=tkinter.BOTH)
        self.gwidget.bind('<Enter>', self.focusOnGwidget)  # if mouse enters gw

        self.colorManager.setColors(self.gwidget)
        self.wcs = irafgwcs.IrafGWcs()
        self.linestyles = gki.IrafLineStyles()
        self.hatchfills = gki.IrafHatchFills()
        self.textAttributes = gki.TextAttributes()
        self.lineAttributes = gki.LineAttributes()
        self.fillAttributes = gki.FillAttributes()
        self.markerAttributes = gki.MarkerAttributes()

        self.StatusLine = gki.StatusLine(self.top.status, self.windowName)
        self.history = [(self.gkibuffer, self.wcs, "", self.getHistory())]
        self._currentPage = 0
        # Master page variable, pageVar, any change to it is watched & acted on
        self.pageVar = tkinter.IntVar()
        self.pageVar.set(self._currentPage)
        # _setPageVar is callback for changes to pageVar
        self.pageVar.trace('w', self._setPageVar)
        # Also hold a var just for the # of the selected page button: bttnVar
        # This one causes no events when it is set!
        self.bttnVar = tkinter.IntVar()
        self.bttnVar.set(0)
        windowID = self.gwidget.winfo_id()
        self.flush()
        if sys.platform != 'darwin':  # this step is unneeded on OSX
            wutil.setBackingStore(windowID)
Exemple #5
0
# XBM file for cursor is in same directory as this module
_blankcursor = 'blankcursor.xbm'
dirname = os.path.dirname(__file__)
if os.path.isabs(dirname):
    _blankcursor = os.path.join(dirname, _blankcursor)
else:
    # change relative directory paths to absolute
    _blankcursor = os.path.join(os.getcwd(), dirname, _blankcursor)
del dirname

_TK_HAS_NONE_CURSOR = True  # assume True until we learn otherwise

if _default_root is None:
    from stsci.tools import irafutils
    _default_root = irafutils.init_tk_default_root()

# This code is needed to avoid faults on sys.exit()
# [DAA, Jan 1998]
# [Modified by RLW to use new atexit module, Dec 2001]


def cleanup():
    try:
        from tkinter import _default_root, TclError
        import tkinter
        try:
            if _default_root:
                _default_root.destroy()
        except TclError:
            pass
Exemple #6
0
    def __init__(self, windowName, manager):

        gki.GkiKernel.__init__(self)
        self.name = 'Tkplot'
        self._errorMessageCount = 0
        self._slowraise = 0
        self._toWriteAtNextClear = None
        self.irafGkiConfig = gki._irafGkiConfig
        self.windowName = windowName
        self.manager = manager

        # redraw table ignores control functions
        self.redrawFunctionTable = self.functionTable[:]
        for opcode in self._controlOps:
            self.redrawFunctionTable[opcode] = None

        # Create the root window as required, but hide it
        irafutils.init_tk_default_root()
        # note size is just an estimate that helps window manager place window
        self.top = TKNTR.Toplevel(visual='best',width=600,height=485)
        # Read the epar options database file
        optfile = "epar.optionDB"
        try:
            self.top.option_readfile(os.path.join(os.curdir,optfile))
        except TKNTR.TclError:
            try:
                self.top.option_readfile(os.path.join(userWorkingHome,optfile))
            except TKNTR.TclError:
                self.top.option_readfile(os.path.join(pyrafDir,optfile))
        self.top.title(windowName)
        self.top.iconname(windowName)
        self.top.protocol("WM_DELETE_WINDOW", self.gwdestroy)
        self.makeMenuBar()
        self.makeGWidget()
        self.makeStatus()
        self.gwidget.redraw = self.redraw
        self.gwidget.pack(side=TKNTR.TOP, expand=1, fill=TKNTR.BOTH)
        self.gwidget.bind('<Enter>', self.focusOnGwidget) # if mouse enters gw

        self.colorManager.setColors(self.gwidget)
        self.wcs = irafgwcs.IrafGWcs()
        self.linestyles = gki.IrafLineStyles()
        self.hatchfills = gki.IrafHatchFills()
        self.textAttributes = gki.TextAttributes()
        self.lineAttributes = gki.LineAttributes()
        self.fillAttributes = gki.FillAttributes()
        self.markerAttributes = gki.MarkerAttributes()

        self.StatusLine = gki.StatusLine(self.top.status, self.windowName)
        self.history = [(self.gkibuffer, self.wcs, "", self.getHistory())]
        self._currentPage = 0
        # Master page variable, pageVar, any change to it is watched & acted on
        self.pageVar = TKNTR.IntVar()
        self.pageVar.set(self._currentPage)
        # _setPageVar is callback for changes to pageVar
        self.pageVar.trace('w', self._setPageVar)
        # Also hold a var just for the # of the selected page button: bttnVar
        # This one causes no events when it is set!
        self.bttnVar = TKNTR.IntVar()
        self.bttnVar.set(0)
        windowID = self.gwidget.winfo_id()
        self.flush()
        if sys.platform != 'darwin': # this step is unneeded on OSX
            wutil.setBackingStore(windowID)