Re: Postscript to pdf

2015-09-23 Thread mithra
On Tuesday, September 22, 2015 at 2:20:56 AM UTC-5, Bala Ji wrote:
> Hello,
> This is my programe : on mac i was able to output ps file but i didn't
> got the pdf file :/
> 
> # -*- coding: utf-8 -*-
> # script lecture_gif.py
> from Tkinter import *
> import tkMessageBox
> import Tkconstants
> import tkFileDialog
> from PIL import ImageTk
> import PIL.Image
> import os, sys
> import subprocess
> 
> 
> def Ouvrir():
> Canevas.delete(ALL) # on efface la zone graphique
> 
> filename = tkFileDialog.askopenfilename(title="Ouvrir une
> image",filetypes=[('gif files','.gif'),('all files','.*')])
> print(filename)
> photo = PhotoImage(file=filename)
> gifdict[filename] = photo  # référence
> print(gifdict)
> 
> Canevas.create_image(0,0,anchor=NW,image=photo)
> Canevas.config(height=photo.height(),width=photo.width())
> 
> Mafenetre.title("Image "+str(photo.width())+" x "+str(photo.height()))
> 
> def insertimage():
> n=tkFileDialog.askopenfilename(filetypes = [("Image Files", ("*.jpg",
> "*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')])
> img = PIL.Image.open(n)
> img = img.resize((229, 253))
> photoimg = ImageTk.PhotoImage(img)
> label = Label(image=photoimg)
> label.image = photoimg # keep a reference!
> Canevas.create_image(65,320,anchor=W,image = photoimg)
> def insertsign():
> n=tkFileDialog.askopenfilename(filetypes = [("Image Files", ("*.jpg",
> "*.gif")),("JPEG",'*.jpg'),("GIF",'*.gif'),('All','*')])
> img = PIL.Image.open(n)
> img = img.resize((300, 100))
> photoimg = ImageTk.PhotoImage(img)
> Canevas.create_image(600,500,anchor=W,image = photoimg)
> Canvas.pack()
> 
> def Fermer():
> Canevas.delete(ALL)
> Mafenetre.title("Image")
> 
> def save():
> Canevas.update()
> Canevas.postscript(file=tkFileDialog.asksaveasfilename(), colormode='color')
> subprocess.call(["ps2pdf", "-dEPSCrop", "test.ps", "test.pdf"])
> 
> # def convert():
> # ps2pdf -dEPSCrop image.ps
> # convert -density 300 PASSPORTQUALITE.ps output.png
> 
> # class TkFileDialogExample(Tkinter.Frame):
> #
> # def __init__(self, root):
> #
> # Tkinter.Frame.__init__(self, root)
> # button_opt = {'fill': Tkconstants.BOTH, 'padx': 5, 'pady': 5}
> # Tkinter.Button(self, text='Save',
> command=self.asksaveasfilename).pack(**button_opt)
> #
> # self.file_opt = options = {}
> # options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
> # options['initialfile'] = 'myfile.txt'
> # options['parent'] = root
> #
> # def asksaveasfilename(self):
> # filename = tkFileDialog.asksaveasfilename(**self.file_opt)
> #
> # if filename:
> # return open(filename, 'w')
> #
> # if __name__=='__main__':
> # root = Tkinter.Tk()
> # TkFileDialogExample(root).pack()
> # root.mainloop()
> def Apropos():
> tkMessageBox.showinfo("A propos","Tutorial")
> 
> def Write():
> def delete():
> e1.delete(0,END)
> e2.delete(0,END)
> e3.delete(0,END)
> e4.delete(0,END)
> e5.delete(0,END)
> e6.delete(0,END)
> Canevas.delete("e1")
> def valider():
> Canevas.create_text(315,200,anchor=W,text="Surname/Nom",fill='Black',font='Arial
> 14')
> Canevas.create_text(315,220,anchor=W,text=e1.get(),fill='Black',font='Arial
> 30',tags ="e1")
> Canevas.create_text(315,250,anchor=W,text="Given
> name/Prénom",fill='Black',font='Arial 14')
> Canevas.create_text(315,270,anchor=W,text=e2.get(),fill='Black',font='Arial
> 30',tags ="e1")
> Canevas.create_text(315,300,anchor=W,text="Fonction/Function",fill='Black',font='Arial
> 14')
> Canevas.create_text(315,320,anchor=W,text=e3.get(),fill='Black',font='Arial
> 30',tags ="e1")
> Canevas.create_text(470,395,anchor=W,text=e4.get(),fill='Black',font='Arial
> 30',tags ="e1")
> Canevas.create_text(500,438,anchor=W,text=e5.get(),fill='Black',font='Arial
> 30',tags ="e1")
> Canevas.create_text(228,503,anchor=W,text=e6.get(),fill='Black',font='Arial
> 30',tags ="e1")
> master = Tk()
> Label(master, text="Surname/Nom").grid(row=0)
> Label(master, text="Given name/Prénom").grid(row=1)
> Label(master, text="Fonction/Function").grid(row=2)
> Label(master, text="Validity Date").grid(row=3)
> Label(master, text="Chef").grid(row=4)
> Label(master, text="Student number").grid(row=5)
> e1 = Entry(master)
> e2 = Entry(master)
> e3 = Entry(master)
> e4 = Entry(master)
> e5 = Entry(master)
> e6 = Entry(master)
> e1.grid(row=0, column=1)
> e2.grid(row=1, column=1)
> e3.grid(row=2, column=1)
> e4.grid(row=3, column=1)
> e5.grid(row=4, column=1)
> e6.grid(row=5, column=1)
> Button(master, text='Ok', command=valider).grid(row=2, column=2,
> sticky=W, pady=4)
> Button(master, text='Delete', command=delete).grid(row=3, column=2,
> sticky=W, pady=4)
> mainloop( )
> 
> # Main window
> Mafenetre = Tk()
> Mafenetre.title("Image")
> 
> # Création d'un widget Menu
> menubar = Menu(Mafenetre)
> 
> menufichier = Menu(menubar,tearoff=0)
> menufichier.add_command(label="Open mask",command=Ouvrir)
> menufichier.add_command(labe

more efficient?

2009-12-21 Thread Zubin Mithra
I have the following two implementation techniques in mind.

def myfunc(mystring):
check = "hello, there " + mystring + "!!!"
print check


OR
structure = ["hello, there",,"!!!"]
def myfunc(mystring):
structure[2] = mystring
output = ''.join(mystring)

i heard that string concatenation is very slow in python; so should i
go for the second approach? could someone tell me why? Would there be
another 'best-practice-style'?
Please help. Thankx in advance!

cheers!!!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: more efficient?

2009-12-22 Thread Zubin Mithra
thank you for your help and support. i`ll keep your advice in mind. :)

cheers!!!
Zubin



On Tue, Dec 22, 2009 at 8:07 PM, Lie Ryan  wrote:
> On 12/22/2009 5:13 PM, Zubin Mithra wrote:
>>
>> I have the following two implementation techniques in mind.
>>
>> def myfunc(mystring):
>>     check = "hello, there " + mystring + "!!!"
>>     print check
>>
>>
>> OR
>> structure = ["hello, there",,"!!!"]
>> def myfunc(mystring):
>>     structure[2] = mystring
>>     output = ''.join(mystring)
>>
>> i heard that string concatenation is very slow in python; so should i
>> go for the second approach? could someone tell me why? Would there be
>> another 'best-practice-style'?
>> Please help. Thankx in advance!
>
> Python's strings are immutable and to concatenate two string the interpreter
> need to copy two whole string into a new string object. This isn't a
> performance problem until you're trying to concatenate a list containing a
> thousand strings:
> ['abc', 'bcd', 'cde', 'def', ...]
> with the naive approach:
> joined = ''
> for s in lst:
>    joined = joined + s
>
> first python will conc. '' and 'abc', copying 0+3 = 3 chars
> then it conc. 'abc' and 'bcd', copying 3+3 = 6 chars
> then it conc. 'abcbcd' and 'cde' copying 6+3 = 9 chars
> then it conc. 'abcbcdcde' and 'def' copying 9+3 = 12 chars
> and so on...
>
> for four 3-letter strings, python copies 3 + 6 + 9 + 12 = 30 chars, instead
> of the minimum necessary 12 chars. It gets worse as the number of strings
> increases.
>
> When you concatenate two 1000-chars large strings, both + and ''.join will
> have to copy 2000 chars. But when you join one thousand 2-chars string
> you'll need to copy 1001000 chars[!] with +.
>
> Now, early optimization *is evil*. Don't start throwing ''.join every here
> and there. The performance by the concatenations won't start to matter until
> you're concatenating a large lists (>40) and + is much more readable than
> ''.join().
>
> When concatenating small number of strings I preferred
> %-interpolation/str.format; it's often much more readable than ''.join and
> +.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


code review

2009-12-23 Thread Zubin Mithra
Hello,

I`m pretty new to developing applications using python and i would
like advance on this script i recently created which helps linux
programmers on the linux terminal. The code is very simple to
understand(i hope) and serves a simple purpose; however i am not sure
if my way of scripting is the right "pythonic" way of doing it.

The package can be found at www.code.google.com/p/pyautorun

I`d love any feedback, ideas and criticism after a code review. Thank
you in advance.

cheers!!!
Zubin Mithra
-- 
http://mail.python.org/mailman/listinfo/python-list


socket programming

2009-12-30 Thread Zubin Mithra
The code snippet i have pasted at,

http://paste.pocoo.org/show/160555/

produces a traceback which also has been pasted at the above link. The
snippet attempts at socket programming using OOPs concepts. Please help.

Thankx in advance
Zubin Mithra
-- 
http://mail.python.org/mailman/listinfo/python-list


PyAutoRun

2010-02-26 Thread Zubin Mithra
Hello,

I have been using python for quite some time; however this is the
first python project i have worked on.

The code is hosted at http://github.com/zubin71/PyAutoRun

The code needs re-factoring and feature additions; i have put up a
TODO list there too. It`d be great if anyone could work on this; i
intend to develop this further(with a bit of help) and will request
for its addition into debian and ubuntu repositories, in time.

Also, any kind of code-review, criticism, is also appreciated.
However, it`d be awesome if you could just fork it at github, pull,
modify and push. :)

Have a nice day!

cheers!!!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list


D-Bus

2010-03-17 Thread Zubin Mithra
Hello,

I have experience writing scripts to connect to the D-Bus interface provided
by different applications but have no experience writing a D-Bus interface
for an application. Could someone point me in the right direction? A
tutorial or a good example would be nice.

Cheers!!!
Zubin Mithra

http://zubin71.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hwy doesn't len(None) return zero ?

2010-06-30 Thread Zubin Mithra
On Thu, Jul 1, 2010 at 12:09 AM, Stef Mientki wrote:

>  hello,
>
> I've lot of functions that returns their result in some kind of tuple /
> list / array,
> and if there is no result, these functions return None.
> Now I'm often what to do something if I've more than 1 element in the
> result.
> So I test:
>
>if len ( Result ) > 1 :
>
> But to prevent exceptions, i've to write ( I often forget)
> if Result and ( len ( Result ) > 1 ) :
>

use
if Result:
   

Checking the length would be a bad idea.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python for web applications

2010-06-30 Thread Zubin Mithra
On Wed, Jun 30, 2010 at 11:34 PM, Wyatt Schwartz wrote:

> Dear Python-List members,
>
> Sorry for asking such a simple (or possibly complicated) question, as I am
> new to Python programming. Anyways, I have read online that many popular
> websites use Python for some of their web-based applications (for example,
> Reddit), and that lead me to wonder how is this done?
>
> Thanks in advance!
>
> I would recommend that you check out the various web-frameworks which are
out there. Django is the framework I use and love, but there are loads out
there.

Have fun!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Composition of functions

2010-06-30 Thread Zubin Mithra
Hello,

>>> y=list(x).reverse()
> >>> print y
> None
>

>>> L = ["a", "b", "c"]
>>> L.reverse()
>>> L
["c", "b", "a"]

As you can see, L.reverse() performs the operation on itself and returns
nothing. Hence, the return type None.

Instead of

y=''.join(list(x).reverse())

you should probably do,

>>> t = list(x).reverse()
>>> y = ''.join(t)

Cheers!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Composition of functions

2010-06-30 Thread Zubin Mithra
> Er, I don't think you thought that one entirely through (/ tried it out):
>
>
My Apologies.

Here is a working one.

 >>> x="123"
>>> t = list(x)
>>> t.reverse()
>>> print ''.join(t)
321


But of course, the method which was suggested earlier is far more elegant.

>>> print ''.join(reversed(list(x)))

Cheers!
Zubin
-- 
http://mail.python.org/mailman/listinfo/python-list


Orphanage Funds

2012-02-11 Thread Jeya Mithra Jeyandran
Hi,


I am Mithra. Me and my friends joined together ti help the
orphanage people after visiting their home once. There are nearly 100
students interested in studies but they dont have enough fund to be
provided for their studies. Please help them by donating as much as
you can. Thanks for your help. Please forward this mail for your
friends.

Please click the following link to donate : http://www.gofundme.com/dij30

Thanks in Advance
-- 
http://mail.python.org/mailman/listinfo/python-list