Example #1
0
    def upload(self, obj):
        " called when 'Upload' button pressed"
        chdir(GB.P.projdir)
        self.uploadable = []
        notfound = []
        for item in uploadfiles:
            new = []
            value = item[-1].get()  # get the StringVar's value
            value.strip()
            itype = item[3]  # text, binary or string
            if value == "":
                continue
            if itype == 'string':
                new = item[:4]
                new.append(value)
            elif itype == 'text_file' or itype == 'binary':
                if not os.path.exists(value):
                    txt = item[2] + " : " + value
                    notfound.append(txt)
                else:
                    new = item[:4]
                    new.append(value)

            if len(new) > 0: self.uploadable.append(new)

        # window to show which files were not found
        if notfound:
            self.errw = spiderGUtils.newWindow("Files not found")
            if self.errw == 0: return

            nf = Frame(self.errw, relief=GG.frelief, borderwidth=GG.brdr)
            Label(nf, text="The following files could not be located").pack(
                side='top')
            for item in notfound:
                Label(nf, text=item).pack(side='top', padx=4, pady=2)
            nf.pack(side='top', fill='x', expand=1)

            fb = Frame(self.errw,
                       background=GG.bgd01,
                       relief=GG.frelief,
                       borderwidth=GG.brdr)
            b = Button(fb, text="Upload the rest", command=self.go_upload)
            b.pack(side='left', padx=4, pady=4)
            c = Button(fb, text="Cancel", command=self.errw.destroy)
            c.pack(side='right', padx=4, pady=4)
            fb.pack(side='bottom', fill='x', expand=1)

        elif len(self.uploadable) > 0:
            self.go_upload()
        else:
            self.master.destroy()
Example #2
0
def startTree(win=None, ddir=None):
    if win == None:
        win = spiderGUtils.newWindow("File Viewer")
        
    if ddir == None:
        ddir = GB.P.projdir
    if not os.path.exists(ddir):
        GB.errstream("cannot find %s" % ddir)
        return
    else:
        os.chdir(ddir)
        ddir = os.getcwd()
        
    icondict = makeIcons()
    tv = TreeViewer(win, icondict, ddir)
Example #3
0
def startTree(win=None, ddir=None):
    if win == None:
        win = spiderGUtils.newWindow("File Viewer")

    if ddir == None:
        ddir = GB.P.projdir
    if not os.path.exists(ddir):
        GB.errstream("cannot find %s" % ddir)
        return
    else:
        os.chdir(ddir)
        ddir = os.getcwd()

    icondict = makeIcons()
    tv = TreeViewer(win, icondict, ddir)
Example #4
0
    def upload(self, obj):
        " called when 'Upload' button pressed"
        chdir(GB.P.projdir)
        self.uploadable = []
        notfound = []
        for item in uploadfiles:
            new = []
            value = item[-1].get()   # get the StringVar's value
            value.strip()
            itype = item[3]   # text, binary or string
            if value == "":
                continue
            if itype == 'string':
                new = item[:4]
                new.append(value)
            elif itype == 'text_file' or itype == 'binary':
                if not os.path.exists(value):
                    txt = item[2] + " : " + value
                    notfound.append(txt)
                else:
                    new = item[:4]
                    new.append(value)

            if len(new) > 0: self.uploadable.append(new)

        # window to show which files were not found
        if notfound:           
            self.errw = spiderGUtils.newWindow("Files not found")
            if self.errw == 0: return

            nf = Frame(self.errw, relief=GG.frelief, borderwidth=GG.brdr)
            Label(nf, text="The following files could not be located").pack(side='top')
            for item in notfound:
                Label(nf, text=item).pack(side='top', padx=4, pady=2)
            nf.pack(side='top', fill='x', expand=1)
                
            fb = Frame(self.errw, background=GG.bgd01, relief=GG.frelief, borderwidth=GG.brdr)
            b = Button(fb, text="Upload the rest",
                       command=self.go_upload)
            b.pack(side='left', padx=4, pady=4)
            c = Button(fb, text="Cancel", command=self.errw.destroy)
            c.pack(side='right', padx=4, pady=4)
            fb.pack(side='bottom', fill='x', expand=1)
            
        elif len(self.uploadable) > 0:
            self.go_upload()
        else:
            self.master.destroy()
Example #5
0
    def __init__(self, **kwargs):
        keywords = kwargs.keys()
        self.kwargs = kwargs

        if "wintitle" in keywords:
            wt = kwargs["wintitle"]
        elif "title" in keywords:
            wt = kwargs["title"]
        else:
            wt = "Spire form"
        self.top = spiderGUtils.newWindow(wt)
        if self.top == 0: return

        self.child_windows = []
        # not actually child windows, but windows created by this app

        if GG.prefs.balloonHelp:
            self.balloon = spiderGUtils.myPmwBalloon(self.top)
        else:
            self.balloon = 0

        self.processargs()

        self.ftop = self.mktopFrame()
        self.sf = Pmw.ScrolledFrame(self.top,
                                    horizflex='expand',
                                    vertflex='expand',
                                    vscrollmode='dynamic')
        self.fmain = self.sf.interior()
        self.mkMainFrame()

        self.fbut = self.mkbuttonFrame()

        # pack the frames and check the resulting size.
        self.ftop.pack(side='top', fill='x', expand=0)
        self.fbut.pack(side='bottom', fill='x', expand=0)
        self.sf.pack(side='top', fill='both', expand=1)
        self.top.update_idletasks()
        self.adjustSize()
Example #6
0
    def __init__(self, **kwargs):
        keywords = kwargs.keys()
        self.kwargs = kwargs
        
        if "wintitle" in keywords:
            wt = kwargs["wintitle"]
        elif "title" in keywords:
            wt = kwargs["title"]
        else:
            wt = "Spire form"
        self.top = spiderGUtils.newWindow(wt)
        if self.top == 0:return

        self.child_windows = []
        # not actually child windows, but windows created by this app

        if GG.prefs.balloonHelp:
            self.balloon = spiderGUtils.myPmwBalloon(self.top)
        else: self.balloon = 0

        self.processargs()

        self.ftop = self.mktopFrame()
        self.sf = Pmw.ScrolledFrame(self.top,
                                    horizflex='expand',
                                    vertflex='expand',
                                    vscrollmode='dynamic')
        self.fmain = self.sf.interior()
        self.mkMainFrame()
        
        self.fbut = self.mkbuttonFrame()

        # pack the frames and check the resulting size.
        self.ftop.pack(side='top', fill='x', expand=0)
        self.fbut.pack(side='bottom', fill='x', expand=0)
	self.sf.pack(side='top', fill='both', expand=1)
	self.top.update_idletasks()
	self.adjustSize()
Example #7
0
    def __init__(self, database):
        self.db = database
        title = "Load files into %s" % self.db.databaseName
        master = spiderGUtils.newWindow("Database upload")
        if master == 0: return
        self.master = master
        p = 4  # spacer

        for item in uploadfiles:
            default = item[4]
            if len(default) > 0 and not self.hasAnyExtension(default):
                item[4] = default + "." + GB.P.dataext

        f0 = Frame(master, background=GG.bgd01, relief=GG.frelief, borderwidth=GG.brdr)
        title = "The following files and values will be written to %s" % self.db.databaseName
        Label(f0, text=title, background=GG.bgd01).pack(side='top', padx=4, pady=4)
        f0.pack(side='top', fill='x', expand=1)
            
        f1 = Frame(master, relief=GG.frelief, borderwidth=GG.brdr)
        row = 0
        for item in uploadfiles:
            prompt = item[2]
            _type = item[3]
            default = item[4]
            var = StringVar()
            item.append(var)
            
            if _type == "string":
                dblabel = Label(f1, text=prompt+":")
                dbentry = Entry(f1, textvariable=var)
                dblabel.grid(row=row, column=0, padx=p, pady=p, sticky='e')
                dbentry.grid(row=row, column=1, padx=p, pady=p, sticky='ew')
                
            elif _type == "text_file":
                var.set(default)
                dblabel = Button(f1, text=prompt+":", anchor='e',
                                 command=Command(self.getfile, item))
                dbentry = Entry(f1, textvariable=var)
                dblabel.grid(row=row, column=0, padx=p, pady=p, sticky='ew')
                dbentry.grid(row=row, column=1, padx=p, pady=p, sticky='ew')
                spiderGUtils.seeEntry(dbentry)
            elif _type == "binary":
                var.set(default)
                dblabel = Button(f1, text=prompt+":", anchor='e',
                                 command=Command(self.getfile, item))
                dbentry = Entry(f1, textvariable=var)
                dblabel.grid(row=row, column=0, padx=p, pady=p, sticky='ew')
                dbentry.grid(row=row, column=1, padx=p, pady=p, sticky='ew')
                spiderGUtils.seeEntry(dbentry)
            else:
                spiderGUtils.displayError("%s : unrecognized type, must be ",\
                                          "string, text_file or binary" % _type)

            row = row + 1

        f1.grid_columnconfigure(1, weight=1)
                
        f1.pack(side='top', fill='x', expand=1)

        fb = Frame(master, background=GG.bgd01, relief=GG.frelief, borderwidth=GG.brdr)
        b = Button(fb, text="Upload now",
                   command=Command(self.upload, uploadfiles))
        b.pack(side='left', padx=p, pady=p)
        c = Button(fb, text="Cancel", command=master.destroy)
        c.pack(side='right', padx=p, pady=p)
        fb.pack(side='bottom', fill='x', expand=1)