Re: [Tutor] PDF and Python
Hi, If you only want to convert text files, this tool I wrote may be even easier than using ReportLab: http://sourceforge.net/projects/xtopdf It is based on ReportLab. You can use it both as a standalone command-line tool, to convert a single text file to PDF. Run PDFWriter.py. You can easily modify the code to convert more than one file, or just write a shell script / .BAT/.CMD file to call it in a loop). You can also use it progammatically from your Python programs. Both procedural and object-oriented versions are available. Look at WritePDF.py and PDFWriter.py. Look at PDFBook.py for an example of usage of this tool to create a simple PDF book from a set of text files representing chapters. HTH Az --- Jason Child <[EMAIL PROTECTED]> wrote: > Hey there. Does anyone know of a way to output PDFs > with python? I have some > data that I have processed from a series of > textfiles that I would like to > provide PDF format reports for.. > > Jason Christopher Child > > Computer Network Services Professionals > Tech Support > 505-986-1669 > 1-877-321-9165 > [EMAIL PROTECTED] > > VOZ Online > VOIP Install Tech > 505-428-7500 > 1-877-428-7550 > > ___ > Tutor maillist - [EMAIL PROTECTED] > http://mail.python.org/mailman/listinfo/tutor > __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Vpython
Hey, that's pretty good. Tried it out. VPython is cool too. --- "Jacob S." <[EMAIL PROTECTED]> wrote: > > > I was wondering were can I find some Vpython > graphics program codes that > are readily available. > > I have 2 that I am proud of. > > A simple function grapher > Usage: > >0.125*x**2 > > Graphs y = 1/8*x**2 > > >y = 1/x > > Graphs y = 1/x > > >clear > > Clears display window > > >r = t**2 > > Graphs polar function r = t**2 > > >remove lines > > Removes all axes, including polar axes, should a > polar function be graphed > after > > >return lines > > Returns all lines, so that they appear when > appropriate. > > >x = sin(x**2)+log(x**2) > > Graphs the function... > > > -- > > from __future__ import division > from visual import * > import os > from math import * > ja = 0 > > def start(): > for objects in scene.objects: > objects.visible = 0 > scene.title = "Function Grapher by Jacob, Inc." > tem = raw_input('Are you on a desktop, or a > notebook? ') > if tem == 'desktop': > scene.x = 365 > if tem == 'notebook': > scene.x = 574 > scene.visible=1 > scene.exit=0 > scene.userspin = 0 > scene.range=(10,10,1) > scene.background=(1,1,1) > global xaxis > global yaxis > xaxis = curve(color=color.black) > xaxis.append(pos=(100,0,0)) > xaxis.append(pos=(-100,0,0)) > yaxis = curve(color=color.black) > yaxis.append(pos=(0,100,0)) > yaxis.append(pos=(0,-100,0)) > global radiusaxis > global radiusaxis2 > radiusaxis = > curve(pos=[(-100,-100),(100,100)],color=color.black) > radiusaxis2 = > curve(pos=[(-100,100),(100,-100)],color=color.black) > radiusaxis.visible = 0 > radiusaxis2.visible = 0 > > start() > y = 3 > m = 0 > t = 0 > d = 1 > print """\ > List of Commands: > clear > quit > remove lines > return lines > > Function Syntax: > var = funct a,b > where var = what > and funct = f(what) > and a,b = range > """ > > print 'Please type in functions in below. ' > while y != "": > lists=[] > y = raw_input('>') > if y == 'clear': > scene.visible=0 > start() > print "-"*36 > continue > elif y == 'quit': > scene.visible = 0 > del scene > break > elif y == 'remove lines': > a = [radiusaxis,radiusaxis2,xaxis,yaxis] > for x in a: > x.visible = 0 > d = 0 > continue > elif y == 'return lines': > a = [radiusaxis,radiusaxis2,xaxis,yaxis] > for x in a: > x.visible = 1 > d = 1 > continue > if y.count('=') == 1: > y = y.split(' = ') > type = y[0].lower() > y = y[1] > y = y.replace("y","x") > if type == 'r': > y = y.replace('x','t') > if d == 1: > radiusaxis.visible = 1 > radiusaxis2.visible = 1 > else: > type = 'y' > y = y.split(" ") > if len(y) > 1: > pass > else: > if type == 'r': > y.append('0,5*pi') > else: > y.append('-10,10') > range = y[1] > y = y[0] > range = range.split(",") > min = float(eval(range[0])) > max = float(eval(range[1])) > lists.append(curve(color=(1,0,1))) > x = min > if type == 'y' or type == 'x': > radiusaxis.visible = 0 > radiusaxis2.visible = 0 > while x >= min and x <= max: > x = x+0.005 > try: > if eval(y) <= 15 and eval(y) >= -15: > if type == 'y': > > lists[-1].append(pos=(x,eval(y),0)) > elif type == 'x': > > lists[-1].append(pos=(eval(y),x,0)) > else: > > lists.append(curve(color=(1,0,1))) > except: > pass > elif type == 'r': > m = 'eval(y)*cos(t)' > n = 'eval(y)*sin(t)' > t = min > while t >= min and t <= max: > try: > > lists[-1].append(pos=(eval(m),eval(n),0)) > except: > lists.append(curve(color=(1,0,1))) > t = t+0.005 > > > ___ > Tutor maillist - [EMAIL PROTECTED] > http://mail.python.org/mailman/listinfo/tutor > __ Do you Yahoo!? Send holiday email and support a worthy cause. Do good. http://celebrity.mail.yahoo.com ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] A better way to do it.
Hi Jacob, Since your class derives from Frame, check Frame for methods to change the title. If that doesn't work, try this: Tkinter is based on Tk (which works with TCL). So try posting your question on comp.lang.tcl. You can do this via Google Groups: groups.google.com. You need to register once, its free. HTH Az --- "Jacob S." <[EMAIL PROTECTED]> wrote: > Okay, here's the code. > > I am completely open to suggestions as this is my > first dabbling in Tk. > Please look over it when you have time. > > I have a couple of questions. > 1) How do I change the title of the window? > 2) Why does a window pop up saying something like > error, the memory could > not be "read". I'm running > Windows XP, the script window disappears, and > everything, just this message > pops up. > > > Jacob Schmidt > > > - > from Tkinter import * > import tkMessageBox > import os > from filecmp import cmpfiles > > class Copying: > def __init__(self,action,var,err): > self.action = action > self.pri = var > self.err = err > > self.j = os.path.join > self.r = os.path.isdir > self.e = os.path.isfile > > > > # These are the default values for the > directories. To make it > simpler you could... ## > ## pseudo > ## self.usbdrive = remote folder > ## self.desktop = localer folder > > > dirlist = os.listdir("c:\\") > if 'Jacob Laptop' in dirlist: > self.usbdrive = 'E:\\Working Python > Programs' > self.desktop = 'C:\\documents and > settings\\jacob\\desktop\\Working Python Programs' > elif 'Home Computer' in dirlist: > self.usbdrive = 'F:\\Working Python > Programs' > self.desktop = 'C:\\documents and > settings\\owner\\desktop\\Working Python Programs' > elif 'Sissy Computer' in dirlist: > self.usbdrive = '' ## Need to fill in > self.desktop = '' ## Need to fill in > elif 'Michael Laptop' in dirlist: > self.usbdrive = 'E:\\Working Python > Programs' > self.desktop = 'C:\\documents and > settings\\michael\\desktop\\Working Python Programs' > elif 'Office Computer' in dirlist: > self.usbdrive = 'D:\\Working Python > Programs' > self.desktop = > 'C:\\windows\\desktop\\Working Python Programs' > elif 'School Auction Laptop' in dirlist: > self.usbdrive = '' ## Need to fill in > self.desktop = > 'C:\\windows\\desktop\\Working Python Programs' > else: > print 'Hey you need to put a folder in > this computer!. ' > print '''Folders include: > Jacob Laptop > Home Computer > Sissy Computer > Michael Laptop > Office Computer > School Auction Laptop > ''' > folder = raw_input('Which computer is > this? ') > folder = "C:\\"+folder > os.mkdir(folder) > self.usbdrive = raw_input('What is the > usb drive on this > computer? ') > self.desktop = raw_input('What is the > desktop on this computer? > ') > > # > # # > if not os.path.exists(self.desktop): > os.mkdir(self.desktop) > m = > {'receiving':self.receiving,'sending':self.sending} > m[self.action]() > > > def copyfile(self,src,des): > x = open(src,'rb').read() > y = open(des,'wb') > y.write(x) > y.close() > > > def receiving(self): > chiplist = os.listdir(self.usbdrive) > pclist = os.listdir(self.desktop) > filechange = > cmpfiles(self.usbdrive,self.desktop,chiplist)[1] > tot = 0 > for x in chiplist: > if x not in pclist: > filechange.append(x) > for x in filechange: > fullname = self.j(self.usbdrive,x) > if self.e(fullname): > > self.copyfile(fullname,self.j(self.desktop, x)) > self.pri.set("Copying %s." % x) > self.err.insert(END,"%s copied from > chip to computer.\n" % > x) > tot = tot + 1 > elif self.r(fullname): > self.err.insert(END,"%s is a > directory. It has not been > copied.\n" % fullname) > self.err.insert(END,"%s file(s) > copied.\n"%tot) > self.pri.set("") > pclist.sort() > chiplist.sort() > newlist = [x for x in pclist if x not in > chiplist] > for x in newlist: > if > tkMessageBox.askokcancel('Delete?',"Do you wish to > delete %s? > " % x): > filename = self.j(self.desktop, x) > if