예제 #1
0
파일: Text.py 프로젝트: r-owen/RO
    def __init__ (self,
        master,
        helpText = None,
        helpURL = None,
        readOnly = False,
        isCurrent = True,
        useStateTags = False,
    **kargs):
        self.helpText = helpText
        self._readOnly = readOnly
        self._isCurrent = bool(isCurrent)
        
        Tkinter.Text.__init__(self, master, **kargs)

        CtxMenu.CtxMenuMixin.__init__(self, helpURL = helpURL)

        self._prefDict = WdgPrefs.getWdgPrefDict()
        self._sevPrefDict = WdgPrefs.getSevPrefDict()
        
        if self._readOnly:
            Bindings.makeReadOnly(self)
            self["takefocus"] = False

        # set up automatic update for bad background color pref
        self._prefDict["Bad Background"].addCallback(self._updateBGColor, callNow=False)
        
        if not self._isCurrent:
            self._updateBGColor()
        
        if useStateTags:
            for severity, pref in self._sevPrefDict.iteritems():
                if severity == RO.Constants.sevNormal:
                    # normal foreground color is already automatically updated
                    continue
                pref.addCallback(self._updateStateTagColors, callNow=False)
예제 #2
0
    def __init__(self, **kargs):
        """Creates a new application with some standard menus and such
        Returns the root window, just like Tk()
        To use:
            import RO.Wdg
            myApp = RO.Wdg.PythonTk()
            # configure stuff here, e.g. creating new windows, etc.
            myApp.mainloop()

        Keyword arguments:
            All those for Tkinter.Tk(), plus:
            "optionfile": the full path name of an option file
        """

        # first parse PythonTk-specific options
        # but do not try to apply them yet if they require Tk to be initialized
        optionfile = None
        if kargs and kargs.has_key("optionfile"):
            optionfile = kargs["optionfile"]
            del(kargs["optionfile"])

        # basic initialization
        Tkinter.Tk.__init__(self, **kargs)
        
        # if the user supplied an option file, load it
        if optionfile:
            try:
                self.option_readfile(optionfile)
            except Exception as e:
                print("cannot read option file; error:", e)
        
        # create and display a Python script window
        self.pyToplevel = Tkinter.Toplevel()
        self.pyToplevel.geometry("+0+450")
        self.pyToplevel.title("Python")
        pyFrame = PythonWdg.PythonWdg(self.pyToplevel)
        pyFrame.pack(expand=Tkinter.YES, fill=Tkinter.BOTH)
        
        # set up standard bindings
        Bindings.stdBindings(self)
예제 #3
0
파일: Text.py 프로젝트: goodeveryone/awsl
    def __init__(self,
                 master,
                 helpText=None,
                 helpURL=None,
                 readOnly=False,
                 isCurrent=True,
                 useStateTags=False,
                 **kargs):
        self.helpText = helpText
        self._readOnly = readOnly
        self._isCurrent = bool(isCurrent)

        Tkinter.Text.__init__(self, master, **kargs)

        CtxMenu.CtxMenuMixin.__init__(self, helpURL=helpURL)

        self._prefDict = WdgPrefs.getWdgPrefDict()
        self._sevPrefDict = WdgPrefs.getSevPrefDict()

        if self._readOnly:
            Bindings.makeReadOnly(self)
            self["takefocus"] = False

        # set up automatic update for bad background color pref
        self._prefDict["Bad Background"].addCallback(self._updateBGColor,
                                                     callNow=False)

        if not self._isCurrent:
            self._updateBGColor()

        if useStateTags:
            for severity, pref in self._sevPrefDict.iteritems():
                if severity == RO.Constants.sevNormal:
                    # normal foreground color is already automatically updated
                    continue
                pref.addCallback(self._updateStateTagColors, callNow=False)
예제 #4
0
파일: FTPLogWdg.py 프로젝트: r-owen/RO
    def __init__(self,
        master,
        maxTransfers = 1,
        maxLines = 500,
        helpURL = None,
    **kargs):
        Tkinter.Frame.__init__(self, master = master, **kargs)
        self._memDebugDict = {}
        
        self.maxLines = maxLines
        self.maxTransfers = maxTransfers
        self.selFTPGet = None # selected getter, for displaying details; None if none
        
        self.dispList = []  # list of displayed ftpGets
        self.getQueue = []  # list of unfinished (ftpGet, stateLabel, ftpCallback) triples

        self._timer = Timer()
        
        self.yscroll = Tkinter.Scrollbar (
            master = self,
            orient = "vertical",
        )
        self.text = Tkinter.Text (
            master = self,
            yscrollcommand = self.yscroll.set,
            wrap = "none",
            tabs = (8,),
            height = 4,
            width = 50,
        )
        self.yscroll.configure(command=self.text.yview)
        self.text.grid(row=0, column=0, sticky="nsew")
        self.yscroll.grid(row=0, column=1, sticky="ns")
        Bindings.makeReadOnly(self.text)
        if helpURL:
            CtxMenu.addCtxMenu(
                wdg = self.text,
                helpURL = helpURL + "#LogDisplay",
            )
        
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        
        detFrame = Tkinter.Frame(self)
            
        gr = RO.Wdg.Gridder(detFrame, sticky="ew")
        
        self.fromWdg = RO.Wdg.StrEntry(
            master = detFrame,
            readOnly = True,
            helpURL = helpURL and helpURL + "#From",
            borderwidth = 0,
        )
        gr.gridWdg("From", self.fromWdg, colSpan=3)

        self.toWdg = RO.Wdg.StrEntry(
            master = detFrame,
            readOnly = True,
            helpURL = helpURL and helpURL + "#To",
            borderwidth = 0,
        )
        gr.gridWdg("To", self.toWdg, colSpan=2)
        
        self.stateWdg = RO.Wdg.StrEntry(
            master = detFrame,
            readOnly = True,
            helpURL = helpURL and helpURL + "#State",
            borderwidth = 0,
        )
        self.abortWdg = RO.Wdg.Button(
            master = detFrame,
            text = "Abort",
            command = self._abort,
            helpURL = helpURL and helpURL + "#Abort",
        )
        gr.gridWdg("State", self.stateWdg, colSpan=2)
        
        self.abortWdg.grid(row=1, column=2, rowspan=2, sticky="s")
        
        detFrame.columnconfigure(1, weight=1)
        
        detFrame.grid(row=1, column=0, columnspan=2, sticky="ew")
        
        self.text.bind("<ButtonPress-1>", self._selectEvt)
        self.text.bind("<B1-Motion>", self._selectEvt)
        
        self._updAllStatus()
        
        atexit.register(self._abortAll)
예제 #5
0
    def __init__(self,
        master,
        maxTransfers = 1,
        maxLines = 500,
        helpURL = None,
    **kargs):
        Tkinter.Frame.__init__(self, master = master, **kargs)
        self._memDebugDict = {}
        
        self.maxLines = maxLines
        self.maxTransfers = maxTransfers
        self.selHTTPGet = None # selected getter, for displaying details; None if none
        
        self.dispList = []  # list of displayed httpGets
        self.getQueue = []  # list of unfinished (httpGet, stateLabel) tuples
        
        self.yscroll = Tkinter.Scrollbar (
            master = self,
            orient = "vertical",
        )
        self.text = Tkinter.Text (
            master = self,
            yscrollcommand = self.yscroll.set,
            wrap = "none",
            tabs = (8,),
            height = 4,
            width = 50,
        )
        self.yscroll.configure(command=self.text.yview)
        self.text.grid(row=0, column=0, sticky="nsew")
        self.yscroll.grid(row=0, column=1, sticky="ns")
        Bindings.makeReadOnly(self.text)
        if helpURL:
            CtxMenu.addCtxMenu(
                wdg = self.text,
                helpURL = helpURL + "#LogDisplay",
            )
        
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        
        detFrame = Tkinter.Frame(self)
            
        gr = RO.Wdg.Gridder(detFrame, sticky="ew")
        
        self.fromWdg = RO.Wdg.StrEntry(
            master = detFrame,
            readOnly = True,
            helpURL = helpURL and helpURL + "#From",
            borderwidth = 0,
        )
        gr.gridWdg("From", self.fromWdg, colSpan=3)

        self.toWdg = RO.Wdg.StrEntry(
            master = detFrame,
            readOnly = True,
            helpURL = helpURL and helpURL + "#To",
            borderwidth = 0,
        )
        gr.gridWdg("To", self.toWdg, colSpan=2)
        
        self.stateWdg = RO.Wdg.StrEntry(
            master = detFrame,
            readOnly = True,
            helpURL = helpURL and helpURL + "#State",
            borderwidth = 0,
        )
        self.abortWdg = RO.Wdg.Button(
            master = detFrame,
            text = "Abort",
            command = self._abort,
            helpURL = helpURL and helpURL + "#Abort",
        )
        gr.gridWdg("State", self.stateWdg, colSpan=2)
        
        self.abortWdg.grid(row=1, column=2, rowspan=2, sticky="s")
        
        detFrame.columnconfigure(1, weight=1)
        
        detFrame.grid(row=1, column=0, columnspan=2, sticky="ew")
        
        self.text.bind("<ButtonPress-1>", self._selectEvt)
        self.text.bind("<B1-Motion>", self._selectEvt)
        
        self._startNew()
예제 #6
0
    wdg.__ctxMenu = CtxMenu(
        wdg=wdg,
        helpURL=helpURL,
        configFunc=configFunc,
        doTest=doTest,
    )
    return wdg.__ctxMenu


if __name__ == "__main__":
    import Bindings
    import PythonTk
    root = PythonTk.PythonTk()

    # set up standard binding for <<CtxMenu>>
    Bindings.stdBindings(root)

    # add help to a standard Tkinter widget
    stdLabel = Tkinter.Label(text="Standard label")
    addCtxMenu(
        wdg=stdLabel,
        helpURL="http://brokenURL.html",
    )
    stdLabel.pack()

    # create a new label class that automatically has help:
    class HelpLabel(Tkinter.Label, CtxMenuMixin):
        def __init__(self, master, helpURL=None, **kargs):
            Tkinter.Label.__init__(self, master=master, **kargs)
            CtxMenuMixin.__init__(self, helpURL)
예제 #7
0
    def dot(self, other):
        return self.x * other.x + self.y * other.y + self.z * other.z

    def normalize(self):
        l = self.length()
        self.x = self.x / l
        self.y = self.y / l
        self.z = self.z / l
        return self

    def asTuple(self):
        return (self.x, self.y, self.z)

    def __repr__(self):
        return str(self.asTuple())

    def move(self, angle, distance):
        dir = vector3(math.sin(angle), 0, math.cos(angle))
        self += dir * distance
        return self


############################################################################
#
# code to execute
#
############################################################################

Bindings.load(ai_bindings)