[Tutor] Removing certain sequences from a string list elements

2012-01-09 Thread Varsha Purohit
Hello,

I have a simple python program where I am comparing two log files and I am
storing the differences in a list. I am programming in python after a long
time so may be I might have not written something very efficient. Please
let me know what alternate solution I can apply for my program.

I am reading each line in the file individually and storing them in a list.
After that i am comparing the two lists and printing out the differences.
But I wanted to know how can I iter through each string in the list and
remove certain sequences like \n and ',' comma. I want to basically
printout a column where it has each element of the list in each row.
It should also avoid priting the time stamp since they will be different
anyway. i want the program as simple as it looks right now.

Input file contains something like this in each line. I have not included
the complete log file.

*MegaMon mfc*
*MFC data:*
*vendorId/deviceId=1000/005b, subVendorId/subDeviceId=1000/9285, OEM=1,
SubOem=1, isRaidKeySecondary=0*
*MFCF: disableSAS=0, maxDisks=0, enableRaid6=1, disableWideCache=0*
*disableRaid5=0, enableSecurity=0, enableReducedFeatureSet=0*
*enableCTIO=0 enableSnapshot=1 enableSSC=1 enableCacheOffload=0*
*maxHANodes=2*


here is the program

def readList1():
f1 = open('mfc_node1.txt',r)
lines = f1.read().split( )
q = []
for line in lines:
if not line in q:
q.append(line)
f1.close()
return q

def readList2():
f = open('mfc_node2.txt',r)
lines = f.read().split( )
p = []
for line in lines:
if not line in p:
p.append(line)
f.close()
return p



if __name__ == __main__:
q = readList1()
#print q
p = readList2()
#print p
newList = []

for x in q:
if x not in p:
newList.append(x)


Here is the part of the output list
['enableCTIO=0,', 'enableSnapshot=1,', 'enableSSC=1,', 'maxHANodes=0\n',
'sasAddr=5123456712345678\nSecondary', 'enableSnapshot=0,', 'enableSSC=0,',
'sasAddr=\nMegaMon', '13:53:14:']

-Varsha
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] PyGame tutorials

2008-03-16 Thread Varsha Purohit
Hello all,
I have learnt python and wxPython. Now i want to learn making games
using pygame engine. Can anyone tellme from where i can learn pygame and
start making basic games using this module. Which version i should download
and is there any user group like this one for pyGame ??

thanks,
-- 
Varsha Purohit
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Finding image statistics

2008-03-03 Thread Varsha Purohit
Yeahh so by doing this i am counting only the difference part since we have
grayscaled the image and assuming it will count only the pixels that evolve
as difference if i use sum2 instead of sum i think  it will give squared
sum which is area... and if i just use count it would count the number of
pixels developed like that... sounds interesting .. thanks for throwing
light for me in right direction

On Sun, Mar 2, 2008 at 4:45 PM, Kent Johnson [EMAIL PROTECTED] wrote:

 Varsha Purohit wrote:
  I am getting this list as an output
 
  [268541.0, 264014.0, 324155.0]

 This is the sum of the values of the red pixels, etc. They are not
 counts, but sums. So if you have an image with the two pixels
 (1, 2, 3), (4, 5, 6) you would get a sum of (5, 7, 9).
 
  Actually in my code i am finding difference between two images and i
  need to count the number of pixels which appear as a difference of these
  two images. These values i m getting as output are little large.

 So you want a count of the number of pixels that differ between the two
 images? Maybe this:

 diff = ImageChops.difference(file1, file2)

 # Convert to grayscale so differences are counted just once per pixel
 diff = ImageOps.grayscale(diff)

 # Convert each difference to 0 or 1 so we can count them
 # Clipping function
 def clip(x):
   return 1 if x = 1 else 0

 # Apply the clipping function
 diff = Image.eval(diff, clip)

 print ImageStat.Stat(diff).sum

 Kent

 
  i m pasting my code again
 
  file1=Image.open(./pics/original.jpg)
  file2=Image.open(val)
  diff = ImageChops.subtract(file1,file2,0.3)
  stat1 = ImageStat.Stat(diff)
 
  count1=stat1.sum
  print count1
  diff.save(./pics/diff+.jpg)
 
  diff.show()
 
  AS you can see i am finding difference of two images which are nearly
  identical. But they have some pixels that are different and i can see
  that in the output image diff.jpg. So i am trying to put this difference
  image in the imagestat and trying to see if i can get to count the
  number of pixels ...




-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Finding image statistics

2008-03-02 Thread Varsha Purohit
Yes i am getting this but i was confused why i am getting 3 values for
count, extrema.. and dats y i couldn't figure out how to find area of those
pixels..

On Sun, Mar 2, 2008 at 9:02 AM, Kent Johnson [EMAIL PROTECTED] wrote:

 Varsha Purohit wrote:
  of this module in this application.
 
  I want to find other image statistics such as finding number of pixels
  which exist after taking difference between two images, getting sum of
  all pixels and area of pixels that are in that image etc.

 I don't think you can get all of that out of ImageStat, it is pretty
 basic.

 In [18]: import Image, ImageStat
 In [19]: i=Image.open('kent.jpg')
 In [21]: s=ImageStat.Stat(i)
 In [23]: s.extrema
 Out[23]: [(0, 255), (0, 255), (0, 251)]
 In [24]: s.count
 Out[24]: [43200, 43200, 43200]
 In [25]: s.mean
 Out[25]: [116.61453703703704, 103.23967592592592, 97.624606481481479]

 etc.

 Kent




-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Finding image statistics

2008-03-02 Thread Varsha Purohit
I am getting this list as an output

[268541.0, 264014.0, 324155.0]

Actually in my code i am finding difference between two images and i need to
count the number of pixels which appear as a difference of these two images.
These values i m getting as output are little large.

i m pasting my code again

file1=Image.open(./pics/original.jpg)
file2=Image.open(val)
diff = ImageChops.subtract(file1,file2,0.3)
stat1 = ImageStat.Stat(diff)

count1=stat1.sum
print count1
diff.save(./pics/diff+.jpg)

diff.show()

AS you can see i am finding difference of two images which are nearly
identical. But they have some pixels that are different and i can see that
in the output image diff.jpg. So i am trying to put this difference image in
the imagestat and trying to see if i can get to count the number of pixels
...

thanks,


On Sun, Mar 2, 2008 at 9:48 AM, Varsha Purohit [EMAIL PROTECTED]
wrote:

 Yes i am getting this but i was confused why i am getting 3 values for
 count, extrema.. and dats y i couldn't figure out how to find area of those
 pixels..


 On Sun, Mar 2, 2008 at 9:02 AM, Kent Johnson [EMAIL PROTECTED] wrote:

  Varsha Purohit wrote:
   of this module in this application.
  
   I want to find other image statistics such as finding number of pixels
   which exist after taking difference between two images, getting sum of
   all pixels and area of pixels that are in that image etc.
 
  I don't think you can get all of that out of ImageStat, it is pretty
  basic.
 
  In [18]: import Image, ImageStat
  In [19]: i=Image.open('kent.jpg')
  In [21]: s=ImageStat.Stat(i)
  In [23]: s.extrema
  Out[23]: [(0, 255), (0, 255), (0, 251)]
  In [24]: s.count
  Out[24]: [43200, 43200, 43200]
  In [25]: s.mean
  Out[25]: [116.61453703703704, 103.23967592592592, 97.624606481481479]
 
  etc.
 
  Kent
 



 --
 Varsha Purohit,
 Graduate Student




-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] creating list of tuples

2008-02-25 Thread Varsha Purohit
Hello all,
   In my application i have to create a list of tuples. I have a for
loop which will create (x,y) tuple each time it iterates, and i ahve to
store each tuple in a list like

list1= [(x1,y1), (x2,y2).]

any ideas how to do that ???

thanks,

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] creating list of tuples

2008-02-25 Thread Varsha Purohit
I think i got it
i m creating a tuple of 2 elements everytime and i m adding it to a list. i
m creating a new tup everytime and adding it to a list


  for x in file:
value=0
tup = ()
for developerAgent in developers:
#print developerAgent.disutility
value +=developerAgent.disutility
tup = (value,globalVar.cntr)
globalVar.cntr +=1

globalVar.disutilList.append(tup)
  print globalVar.disutilList

i am getting output as what i described...

thanks for the help :)


On Mon, Feb 25, 2008 at 6:52 PM, Kent Johnson [EMAIL PROTECTED] wrote:

 Varsha Purohit wrote:
  Hello all,
 In my application i have to create a list of tuples. I have a for
  loop which will create (x,y) tuple each time it iterates, and i ahve to
  store each tuple in a list like
 
  list1= [(x1,y1), (x2,y2).]
 
  any ideas how to do that ???

 list1 = []
 for ...
   # code to create x and y
   list1.append( (x, y) )

 Note you do need the double parentheses; the inner pair creates a tuple,
 the outer pair is for the function call.

 Kent




-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Question on multithreading

2008-02-23 Thread Varsha Purohit
Hello,
i have a gui program in wxpython where i am spawning two threads. one
for the mainloop of gui and other for some background tasks. I have to stop
the background running thread once its work is done. I am trying to use the
join method but it is giving me an error saying threads cannot be joined as
the thread has just been created... whereas at that point the thread is done
with its job. So i am confused whether i am putting it correctly or not.
also, is there any method called stop() to stop the threadsAlso, i want
to see if the thread is alive or not.. but i donno where should i put the
isAlive() method associated with the thread.. i tried putting it in the code
where thread does execution but apparently it is not the correct
place.

Here is the code...

class GuiScript(threading.Thread):
def __init__(self):
self.run()
def run(self):
app = wx.PySimpleApp()
MainWindow().Show()
app.MainLoop()

class RunScript(threading.Thread):
def run(self):
imFile=test()

and when the stop button is pressed the two threads should stop executing...
so i have written code like this...

def OnCloseWindow(self,event):
GuiScript().Stop()
RunScript().Stop()
self.Destroy()

but seems stop() method is not existing... can anybody guide me pl

thanks,


-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] PIL versus matlab

2008-02-16 Thread Varsha Purohit
Hello All,
   I wanted to know what are the advantages and disadvantages of using
pIL instead of matlab software to deal to image processing.

thanks,

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Problem in saving image file which is modified by ImageEnhance

2008-02-09 Thread Varsha Purohit
Hello All,
 I am using PIL function to change brightness of an image. But i am
getting an error when i am trying to save that image. Here is the code..

import Image
import ImageChops, ImageEnhance
import math, operator

file1 = Image.open(r10001t0.jpg)
file2 = Image.open(r10001t1.jpg)

diff = ImageChops.difference(file1,file2)

enhancer = ImageEnhance.Brightness(diff)


ext = .jpg
enhancer.save(diff1 + ext, JPEG, quality =100)



I am getting error as ImageEnhance doesn't have attribute called save... how
should i save the enhanced image... or alternatively when i am comparing two
images using imagechops i am getting a black back ground... how should i
make it little brighter or use another colour instead of black ???

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor]Imagechop error

2008-02-02 Thread Varsha Purohit
Hello everyone,
I am tryin to use the imagechop module but i am not able to
implement it successfully. I want to compare two images and give the
resultant of the image using difference module. i am tryin to save the
resultant image. But i am getting some wierd error. It gives error in the
line where i have used imagechop.difference and the error is

AttributeError: 'str' object has no attribute 'load'I am unable to
understand what is the problem. Can any one help me understand this
imagechop module ??

import Image
import ImageChops

file1 = Nearest.jpg
file2 = Bilinear.jpg

diff = ImageChops.difference(file1, file2)

ext = .jpg
diff.save(diff + ext, JPEG, quality =100)

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Scrollbars around the image

2008-01-31 Thread Varsha Purohit
Hi All,
I have made a simple panel where i am loading an image from the folder.
I have a button named zoomin. When i press this button a pair of horizontal
and vertical scrollbars should appear on the image panel nearby image. so
that we can see the zoomed image properly. I am trying to use
wx.Scrollbarbut i am not able to fix the scrollbars properly around
the image. I have
not added the scrollbar portion to the button handler in the code below.. i
have just commented out as its not actually working.

import wx

class ComboBox(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title, size=(450, 470))

panel = wx.Panel(self, -1, (75, 20), (100, 127), style=
wx.SUNKEN_BORDER)
self.picture = wx.StaticBitmap(panel)
self.picture.SetBitmap(wx.Bitmap('srk.jpg'))
panel.SetBackgroundColour(wx.WHITE)



wx.Button(self, 1, 'Close', (80, 220))
wx.Button(self, 2, 'Zoomin', (80, 280))
self.Bind(wx.EVT_BUTTON, self.OnClose, id=1)
self.Bind(wx.EVT_BUTTON, self.OnZoom, id=2)


self.Centre()
self.ShowModal()
self.Destroy()

def OnClose(self, event):
self.Close()

def OnZoom(self, event):
##sw = wx.ScrolledWindow(panel)
##sw.SetScrollbars(20, 20, 155, 40)
##sw.Scroll(50,10)
 self.Close()

app = wx.App()
ComboBox(None, -1, 'picture box')
app.MainLoop()


But can please anybody suggest me how should i go ahead and solve this
problem ??


-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Question on multithreading

2008-01-29 Thread Varsha Purohit
Hello friends,
I hve a GUI where i have start button and stop button. When i press
start button one thread is created and it is executing some background task
and when i press stop button that thread is stopped/killed. These two things
are working properly. But i have to implement pause button in my GUI. When i
press pause the thread execution should come to a halt and after that it
should be resumed when i press pause again or may be i can implement some
other button.

Does anybody have an example where they have implemented this kind of
threading concept ??

any help is apreciated,

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Calling python from a c program

2008-01-20 Thread Varsha Purohit
Hi,
   I just read about how to call python from a c program. This is the
function for that

int main()
{
 Py_Initialize();
PyRun_SampleString(print 76);
Py_Finalize();

return 0;
}


But i am getting an error of header file. python.h not found. Can anybody
tell me where can i get this header file ?? And how can i call the python
interpreter screen from c program ??

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Calling python from a c program

2008-01-20 Thread Varsha Purohit
I got the python.h file but i am getting linking errors for my program

On Jan 20, 2008 1:18 AM, Varsha Purohit [EMAIL PROTECTED] wrote:

 Hi,
I just read about how to call python from a c program. This is the
 function for that

 int main()
 {
  Py_Initialize();
 PyRun_SampleString(print 76);
 Py_Finalize();

 return 0;
 }


 But i am getting an error of header file. python.h not found. Can anybody
 tell me where can i get this header file ?? And how can i call the python
 interpreter screen from c program ??

 --
 Varsha Purohit,
 Graduate Student




-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Calling python from a c program

2008-01-20 Thread Varsha Purohit
I am gettng following linking errors

  [Linker error] undefined reference to `_imp__Py_Initialize'
  [Linker error] undefined reference to `PyRun_SampleString'
  [Linker error] undefined reference to `_imp__Py_Finalize'

I think i need to set the path to the linker... may be i need to pass
linking options of python to the c compiler... but wat are those options :(
??

On Jan 20, 2008 7:16 AM, Alan Gauld [EMAIL PROTECTED] wrote:


 Varsha Purohit [EMAIL PROTECTED] wrote

I just read about how to call python from a c program.

 Where did you read it? There are several sources of info
 on embedding Python in C, some better than others.

  And how can i call the python interpreter screen
  from c program ??

 You don't call the python interpreter screen
 (ie the  prompt) from C you call the interpreter itself.
 The interactive interpreter is a C program in its own right.

 You could write your own fairly easily or you could use
 the PyShell GUI component that is part of the wxPython
 package.

 But usually you just want to interpret some Python
 commands much as you did in your example.

 HTH,

 --
 Alan Gauld
 Author of the Learn to Program web site
 http://www.freenetpages.co.uk/hp/alan.gauld

 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor




-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] interview questions

2008-01-19 Thread Varsha Purohit
Thanks for the input. ACtualy i just started programming in python since aug
2007 and i m doing my masters research on it. So i learnt python in quite
less amount of time. But otherwise i am good in c and c++. I am giving my
first interview in python so i dont know what kind of questions they might
ask me. So i wanted to have some list of quiestions which would give me an
idea as how should i prepare for python and wxpython.

On Jan 19, 2008 3:38 AM, Remco Gerlich [EMAIL PROTECTED] wrote:

 Hi.

 I've interviewed people for a project in which we used Perl. Most of us
 already on the team hadn't used Perl before that project, but we learned it
 pretty quickly, so we knew that that was quite possible. Before the
 interview we would have seen their CV, and decided we wanted to speak to
 them, so any language specific questions in the interview (or programming
 questions generally) would be to check if they really had the level they
 claimed.

 Some people said in their letter, I don't know Perl yet but I do know X
 and Y, I can program, and I expect to be able to learn Perl. That was fine
 by us, we did ask them things about how they'd do things in X and Y, and
 general problems of Web programming, how would they go about learning a
 language - but we didn't grill them on their Perl.

 Then there were those who claimed they were good at Perl. Even though we
 weren't specifically looking for great Perl programmers, if they claim to be
 great... these very often failed at pretty simple stuff, they really were
 just beginners. Not actually worse at Perl than the other candidates, but
 they had claimed more.

 So, be honest :-) Then it doesn't matter much what they ask, since you
 have the level of Python knowledge that you claimed.

 Remco Gerlich

 On Jan 19, 2008 3:09 AM, Varsha Purohit  [EMAIL PROTECTED] wrote:

  Hello All,
 I have an interview in python program development. Can i know
  some interview questions in python ? If you know any website where i can
  refer that would be helpful.
 
  thanks,
  --
  Varsha Purohit,
  Graduate Student
  ___
  Tutor maillist  -  Tutor@python.org
  http://mail.python.org/mailman/listinfo/tutor
 
 



-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Pointers in python ??

2008-01-19 Thread Varsha Purohit
Hello All,
Does python has concept of pointers like c/cpp ?? If yes how.. can
anyone give me a small example to how we can use pointers in python.

thanks,
-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] interview questions

2008-01-18 Thread Varsha Purohit
Hello All,
   I have an interview in python program development. Can i know some
interview questions in python ? If you know any website where i can refer
that would be helpful.

thanks,
-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Interview questions in python and wxpython

2008-01-18 Thread Varsha Purohit
Hello All,
   I have an interview in python program development. Can i know some
interview questions in python ? If you know any website where i can refer
that would be helpful.

thanks,

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Comparing two images using PIL

2008-01-16 Thread Varsha Purohit
Hello Everyone,
I have an application where i am comparing two images(jpg) which are
almost identical but have little difference. I wanted to mark the difference
with a different colour to highlight the region which is different from 1st
image. Can you tell me if there is any image funciton in PIL which will help
me to calculate the differences between two different JPEG images.

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Zoom in and zoom out capability

2008-01-09 Thread Varsha Purohit
Hello All,
In my program i have a gui where i am showing an image on the panel.
I want to implement zoom in and zoom out functions using wxpython and PIL. I
am tryin to find in PIL if there is any functionality like that. I want the
user to select either of the button and when they click on the image panel
it shd accordingly zoomin or zoom out. Or may be once user selects an area
inside the image where he wants to zoom in and see. Lemme know if anybody
came across this kind of implementation.

Any help is appreciated.

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Zoom in and zoom out capability

2008-01-09 Thread Varsha Purohit
Hi Alan,
 Yeah i read about them. i tried using the resize function but i was
having difficulty with clarity of the image. I had asked similar thing in
another post. I didnt get any satisfying answer for that. Tried
imagefilterhttp://www.pythonware.com/library/pil/handbook/imagefilter.htmeven
thats not workin out properly. :(

Well in my application i need to make a button which when pressed should
zoom in the image so i was wondering how can i implement it i mean how
should i present the image with more size in a fixed size image panel. Any
ideas.. i am even plannin to implement a slider which will zoom in and out
the image accordingly..



-
Varsha

On Jan 9, 2008 12:11 PM, Alan Gauld [EMAIL PROTECTED] wrote:


 Varsha Purohit [EMAIL PROTECTED] wrote

  I want to implement zoom in and zoom out functions using wxpython
  and PIL. I
  am tryin to find in PIL if there is any functionality like that.

 A few minutes browsing the PIL documentation leads
 me to think there are. Try reading about crop and resize and
 maybe thumbnail.

 Between them these should just about cover your needs I think.

 HTH,


 --
 Alan Gauld
 Author of the Learn to Program web site
 http://www.freenetpages.co.uk/hp/alan.gauld


 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Pil image related question -- resending message without attachments

2008-01-05 Thread Varsha Purohit
Hello All,
  I am actually working on a project which deals with image processing.
I just used pil function to resize the image into the dimensions i want. i
was able to resize the image but the clarity of the new image is not good.
Can anyone suggest which other functions i should use to improve the
clarity. I am attaching the code and sending the images in the attachment.
Can anyone suggest me how to do it ?

import Image

imageFile = srk.jpg #original small image

im1 = Image.open(imageFile)

width = 680
height = 420

im2 = im1.resize((width,height), Image.NEAREST)
im3 = im1.resize ((width,height), Image.BICUBIC)

#images get saved in c drive with jpg extensions
ext = .jpg
im2.save(C:/nearest + ext)
im3.save(C:/Bicubic + ext)

print files are saved



-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [wxPython-users] Dynamically loading images on the panel of GUI

2007-12-02 Thread Varsha Purohit
hello everyone,
i made a small applicatin where i need to display an image on a
panel. and then when i press the read button it should read another image
and display it on the same panel. Its working but i have to press the read
button two times then only its working

import wx
import os

APP_SIZE_X = 700
APP_SIZE_Y = 300


class MainWindow(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,Agent-Based Model of Residential
Development, size = (APP_SIZE_X, APP_SIZE_Y))

self.panel = wx.Panel(self,-1)
self.imageFile = r10001t0.asc.jpg  # provide a diff file name in
same directory/path
self.bmp = wx.Image(self.imageFile,wx.BITMAP_TYPE_JPEG
).ConvertToBitmap()
wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120))

button42 = wx.Button(self.panel, -1, Read, pos=(240,20))
self.Bind(wx.EVT_BUTTON, self.OnRead,button42)

def OnRead(self,event):
self.imageFile1=DSCN3378.jpg # you have to provide a diff image
file name
self.bmp = wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG
).ConvertToBitmap()
wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120))


app = wx.PySimpleApp()
MainWindow().Show()
app.MainLoop()

Load two different jpeg images.
-- 
Varsha
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [wxPython-users] Dynamically loading images on the panel of GUI

2007-12-02 Thread Varsha Purohit
This problem is getting solved if i use the Refresh function in the button
handler. But I have a function where i am generating Jpeg images dynamically
in a separate script. And i need to load these images on GUI as soon as they
start generating. They have common names like xyz1.jpeg and xyz2.jpeg. And i
need to start loading images one after another on the gui panel when they
are created. these images are created one after another with a particular
time delay(not constant). So i have to check when they are created, and i
should load them on gui. So how should i communicate to the gui that image
has been created and it should load the image ?


On Dec 2, 2007 4:29 PM, Varsha Purohit [EMAIL PROTECTED] wrote:

 hello everyone,
 i made a small applicatin where i need to display an image on a
 panel. and then when i press the read button it should read another image
 and display it on the same panel. Its working but i have to press the read
 button two times then only its working

 import wx
 import os

 APP_SIZE_X = 700
 APP_SIZE_Y = 300


 class MainWindow(wx.Frame):
 def __init__(self):
 wx.Frame.__init__(self,None,-1,Agent-Based Model of Residential
 Development, size = (APP_SIZE_X, APP_SIZE_Y))

 self.panel = wx.Panel(self,-1)
 self.imageFile = r10001t0.asc.jpg  # provide a diff file name in
 same directory/path
 self.bmp = 
 wx.Image(self.imageFile,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
 wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120))

 button42 = wx.Button(self.panel, -1, Read, pos=(240,20))
 self.Bind(wx.EVT_BUTTON, self.OnRead ,button42)

 def OnRead(self,event):
 self.imageFile1=DSCN3378.jpg # you have to provide a diff image
 file name
 self.bmp = 
 wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()

 self.obj = wx.StaticBitmap(self.panel, -1, self.bmp, (20,20),
 (80,120))
 self.obj.Refresh()

 app = wx.PySimpleApp()
 MainWindow().Show()
 app.MainLoop()

 Load two different jpeg images.
 --
 Varsha




-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [wxPython-users] passing file name from one script to the GUI class

2007-12-02 Thread Varsha Purohit
hello All,
 I am attaching two scripts. One is readfile.py which is a gui script
where there is a image display panel and a button. Now what i want is when i
click on the button, then it should call a function which is there in second
script clases_calling.py which basically passes the second image file name
to the readfile and it should call imagetobit function of the gui script and
display the passed imagefile name. I am getting runtime errors

thanks
-- 
Varsha Purohit,
Graduate Student
from readfile import MainWindow
import os

class funct:
def func_call(self):
imagename = r10001t0.asc.jpg
newImage = imagetobit(imagename)

import wx
import os
import IO
import clases_calling
APP_SIZE_X = 700
APP_SIZE_Y = 300

developerData = developers.txt
class MainWindow(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,Agent-Based Model of Residential 
Development, size = (APP_SIZE_X, APP_SIZE_Y))
##panel = wx.Panel(self,-1)
##wx.StaticText(panel,-1,first,(35,20))
##self.txtBox1 = wx.TextCtrl(panel,-1,pos=(60,20),size=(30,20))
##
##wx.StaticText(panel,-1,sec,(95,20))
##self.txtBox2 = wx.TextCtrl(panel,-1,pos=(120,20),size=(30,20))
##
##wx.StaticText(panel,-1,third,(155,20))
##self.txtBox3 = wx.TextCtrl(panel,-1,pos=(185,20),size=(30,20))
self.panel = wx.Panel(self,-1)
self.imageFile = r10001t0.asc.jpg
self.bmp = 
wx.Image(self.imageFile,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120))

button42 = wx.Button(self.panel, -1, Read, pos=(240,20))
self.Bind(wx.EVT_BUTTON, self.OnRead,button42)

def OnRead(self,event):
clases_calling.func_call(self)
##self.imageFile1=DSCN3378.jpg
##self.bmp = 
wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
##self.obj = wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), 
(80,120))
##self.obj.Refresh()
##batch_data = IO.readDevelopers(developerData)
##for model_run in batch_data:
##for rec in batch_data[model_run]:
##self.txtBox1.write(rec.pop(0))
##self.txtBox2.write(rec.pop(0))
##self.txtBox3.write(rec.pop(0))
##self.Destroy()

def imagetobit(imagename):
self.imageFile1=imagename
self.bmp = 
wx.Image(self.imageFile1,wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
self.obj = wx.StaticBitmap(self.panel, -1, self.bmp, (20,20), (80,120))
self.obj.Refresh()

app = wx.PySimpleApp()
MainWindow().Show()
app.MainLoop()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [wxPython-users]How to avoid the traces of frame or panel window

2007-11-28 Thread Varsha Purohit
Hello Everyone,
 I created a simple frame, but when i move the frame or any panel
window i get traces of the windows all over which makes the screen look
shabby. How can i avoid getting them ? sample code for a panel is


# simple.py

import wx

app = wx.App()

frame = wx.Frame(None, -1, 'simple.py')
frame.Show()

app.MainLoop()


what should i add in the above code to not get the traces of the window.
Also, i have another problem, whenever i execute any wxpython program
inorder to execute it again i have to close all the programs including the
shell and then restart python otherwise i get like 25lines of some stupid
error messages having no link to the program. I have to close all python
programs again !!! Does anybody now why i am getting this

thanks,
-- 
Varsha Purohit
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [wxPython-users] How to save file name of file openedfromwx.FileDialog ?

2007-11-20 Thread Varsha Purohit
Hello Alan,

What i want is i just need a file picker to chooose the file and
display the file name in the text box. I need to open about 4 files
like that. That is the front end work. In the back end i am making a
list variable to which i have to send the information about the
selected files. And that list is read and files are opened in another
script. So, i guess i need to improve the code more to choose the
file, display just the file information and may be send whole file
path to the list.  I need to work more on that i guess.Thanks for
reminding me...

-Varsha


On Nov 18, 2007 1:03 AM, Alan Gauld [EMAIL PROTECTED] wrote:

 Varsha Purohit [EMAIL PROTECTED] wrote

 I note that you got it wotking but just to clarify...

 I am actually calling the binding function and then writing it
  into the text value...

  class ScrolledWindow(wx.Frame):
 def __init__(self, parent, id, title):
 txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20))
 name = self.Bind(wx.EVT_BUTTON, self.OnOpen, button11)
 txt1.write(name)

 The Bind function does not execute the handler method
 it simply registers it within wxPython for future use when
 the button event is triggered. The return value from Bind
 is not the return value of the method being bound.

 The method only gets called when the button is pressed,
 thats why you have to put the write() call in the event
 handler itself.

 HTH,

 --
 Alan Gauld
 Author of the Learn to Program web site
 http://www.freenetpages.co.uk/hp/alan.gauld


 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [wxPython-users] How to save file name of file opened from wx.FileDialog ?

2007-11-17 Thread Varsha Purohit
Hello Everyone,
In my application i need to select a file using open dialog
box. And then i dont need to open the file. I just need to display the
name of the selected file in a text control. And then open the file in
later part of the program.  But i am not able to get the file name and
display it in the text control. Here is the sample code.

import wx
import os

Fname = '' #Global variable to hold the file name.
class ScrolledWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(350, 300))
panel = wx.Panel(self, -1)
txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20))
button11 = wx.Button(panel, -1, Open, pos=(200,100))
self.Bind(wx.EVT_BUTTON, self.OnOpen, button11)
txt1.write(Fname)

self.Centre()
self.Show()

def OnOpen(self,event):
self.dirname = ''
dlg = wx.FileDialog(self, Choose a file, self.dirname,,
*.*, wx.OPEN)
if dlg.ShowModal()==wx.ID_OK:
self.filename=dlg.GetFilename()
Fname = self.filename
self.dirname=dlg.GetDirectory()
dlg.Destroy()

app = wx.App()
ScrolledWindow(None, -1, 'Aliens')
app.MainLoop()


Any help is appreciated

thanks,
-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [wxPython-users] How to save file name of file opened fromwx.FileDialog ?

2007-11-17 Thread Varsha Purohit
Hi Alan,
I am actually calling the binding function and then writing it
into the text value... i tried using simple print in the openfile
function and it shows the filename. I am trying to return the file
name value but even that is not responding...

class ScrolledWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(350, 300))
panel = wx.Panel(self, -1)
txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20))
button11 = wx.Button(panel, -1, Open, pos=(200,100))
name = self.Bind(wx.EVT_BUTTON, self.OnOpen, button11)
txt1.write(name)

self.Centre()
self.Show()

def OnOpen(self,event):
self.dirname = ''
dlg = wx.FileDialog(self, Choose a file, self.dirname,,
*.*, wx.OPEN)
if dlg.ShowModal()==wx.ID_OK:
self.filename=dlg.GetFilename()
Fname = self.filename
self.dirname=dlg.GetDirectory()
#f=open(os.path.join(self.dirname, self.filename),'r')
#self.control.SetValue(f.read())
   # self.txt1.WriteText(Fname)
f.close()

dlg.Destroy()
return Fname

app = wx.App()
ScrolledWindow(None, -1, 'Aliens')
app.MainLoop()

I donno the alternative to this now... :(

On Nov 17, 2007 3:35 PM, Alan Gauld [EMAIL PROTECTED] wrote:

 Varsha Purohit [EMAIL PROTECTED] wrote

  later part of the program.  But i am not able to get the file name
  and
  display it in the text control. Here is the sample code.
 
  Fname = '' #Global variable to hold the file name.

 You don't need this since its stored in self.filename.

  class ScrolledWindow(wx.Frame):
 def __init__(self, parent, id, title):
 txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20))

 If you want to write to it you need to store it in the object so this
 should be self.txt1

 txt1.write(Fname)

 You can't write the filename yet as it hasn't been fetched

 
 def OnOpen(self,event):
 self.dirname = ''
 dlg = wx.FileDialog(self, Choose a file, self.dirname,,
  *.*, wx.OPEN)
 if dlg.ShowModal()==wx.ID_OK:
 self.filename=dlg.GetFilename()

 Here you get the filename but don't write it to the text control

 HTH,

 Alan G.


 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor




-- 
Varsha Purohit
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [wxPython-users] How to save file name of file opened from wx.FileDialog ?

2007-11-17 Thread Varsha Purohit
HI Alan,
Thanks for suggestion its working now

import wx
import os

class ScrolledWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(350, 300))
panel = wx.Panel(self, -1)
self.txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20))
self.button11 = wx.Button(panel, -1, Open, pos=(200,100))
self.button11.Bind(wx.EVT_BUTTON, self.OnOpen)

self.Centre()
self.Show()

def OnOpen(self,event):
self.dirname = ''
dlg = wx.FileDialog(self, Choose a file, self.dirname,,
*.*, wx.OPEN)
if dlg.ShowModal()==wx.ID_OK:
self.filename=dlg.GetFilename()
   self.dirname=dlg.GetDirectory()

self.txt1.write(self.filename)
dlg.Destroy()


app = wx.App()
ScrolledWindow(None, -1, 'Aliens')
app.MainLoop()

On Nov 17, 2007 12:44 PM, Varsha Purohit [EMAIL PROTECTED] wrote:
 Hello Everyone,
 In my application i need to select a file using open dialog
 box. And then i dont need to open the file. I just need to display the
 name of the selected file in a text control. And then open the file in
 later part of the program.  But i am not able to get the file name and
 display it in the text control. Here is the sample code.

 import wx
 import os

 Fname = '' #Global variable to hold the file name.
 class ScrolledWindow(wx.Frame):
 def __init__(self, parent, id, title):
 wx.Frame.__init__(self, parent, id, title, size=(350, 300))
 panel = wx.Panel(self, -1)
 txt1 = wx.TextCtrl(panel, -1, pos=(30, 100), size=(150, 20))
 button11 = wx.Button(panel, -1, Open, pos=(200,100))
 self.Bind(wx.EVT_BUTTON, self.OnOpen, button11)
 txt1.write(Fname)

 self.Centre()
 self.Show()

 def OnOpen(self,event):
 self.dirname = ''
 dlg = wx.FileDialog(self, Choose a file, self.dirname,,
 *.*, wx.OPEN)
 if dlg.ShowModal()==wx.ID_OK:
 self.filename=dlg.GetFilename()
 Fname = self.filename
 self.dirname=dlg.GetDirectory()
 dlg.Destroy()

 app = wx.App()
 ScrolledWindow(None, -1, 'Aliens')
 app.MainLoop()


 Any help is appreciated

 thanks,
 --
 Varsha Purohit,
 Graduate Student

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [wxPython-users] Displaying filename of open dialog box

2007-11-14 Thread Varsha Purohit
Hello,
  I am new to wxPython. I have made an application where i created
a button which opens the file from a directory. I created a static
text box near the button. I want to display the filename of file which
is opened using this open button. How can i read the file opened and
put that text in the static text box???

thanks,
-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [wxPython-users] Loading default values for text box and choice

2007-11-14 Thread Varsha Purohit
Hello,
I wanted to know how to load text box with the default value

Eg. In these lines there is a static text and a text box created ...
and if i want to load value '3' in the text box how can i do that ??

wx.StaticText(panel, -1, Random Seed, (550,200))
 wx.TextCtrl(panel,-1,pos=(620,200),size=(50,20))

and also in the Choice box

simpleList2 = ['Unbiased Attitude ','Biased Attitude']
wx.Choice(panel, -1, (670,570),choices=simpleList2)

if i want to load the first value of simplelist2 in the choice box by
default when the application runs...



thanks in advance,

-- 
Varsha Purohit,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] File format conversion

2007-11-13 Thread Varsha Purohit
Hello Alan,
 It is a file having colour data grid.. just like any simple ascii
file and i need to manipulate the numbers with colours. But at this
stage i am not much bothered with colurs i can associate it with
simple RGB value for all different numbers. ex. of such simple file
can be like this..
ncols 4
nrows 4
xllcorner 392800
yllcorner 5376340
cellsize  55
NODATA_value  -
9 3 7 3
8 3 2 7
3 2 1 3
3 7 3 2


and i need to associate each pixel of the image with this data in the
ascii... Did that help ??

thanks,
Varsha

On Nov 12, 2007 1:06 AM, Alan Gauld [EMAIL PROTECTED] wrote:

 Varsha Purohit [EMAIL PROTECTED] wrote

In one application i want to convert format of ascii file to
  binary file.

 That depends entirely on what the ASCII file contains.
 Is it a comma separated list of RGB values? Or is it
 a uuencode of the binary data? Or something else...

  And using that binary file in a function of PIL i can
  convert it to an image file.

 Depending on the formatting you may not need PIL,
 but it all depends on what the ASCII contains.

  So i wanted to know how to convert the
  file format in python... is it possible by Numpy ??

 You may only need one of the encode/decode libraries
 for something like uuencoding or maybe the struct module
 will do if its just raw bitmap data.

  other alternative to convert an ascii into an bitmap image directly
  in
  PIL without Numpy??

 Yes you can always do it manually but it all depends
 on the format of the data.

 --
 Alan Gauld
 Author of the Learn to Program web site
 http://www.freenetpages.co.uk/hp/alan.gauld


 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [wxPython-users] Executing a python script in WxPython

2007-11-13 Thread Varsha Purohit
Hello,
  I have an application where i need to run a python script from
wxpython gui. I am calling the script from the button click event. And
the moment button is pressed the python script should be executed.

thanks,
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [wxPython-users] Executing a python script in WxPython

2007-11-13 Thread Varsha Purohit
Thanks for the help its working now !!!

On Nov 13, 2007 7:34 PM, Kent Johnson [EMAIL PROTECTED] wrote:
 Varsha Purohit wrote:
  Hello,
I have an application where i need to run a python script from
  wxpython gui. I am calling the script from the button click event. And
  the moment button is pressed the python script should be executed.

 If you can import the script and call the required function that is the
 simplest approach. If you have to run the script as from the command
 line then use os.system or subprocess.Popen.

 Kent
 
  thanks,
  Varsha Purohit,
  Graduate Student

  ___
  Tutor maillist  -  Tutor@python.org
  http://mail.python.org/mailman/listinfo/tutor
 





-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] File format conversion

2007-11-11 Thread Varsha Purohit
Hello All,
   In one application i want to convert format of ascii file to
binary file. And using that binary file in a function of PIL i can
convert it to an image file. So i wanted to know how to convert the
file format in python... is it possible by Numpy ?? And is there any
other alternative to convert an ascii into an bitmap image directly in
PIL without Numpy??

thanks,

-- 
Varsha
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Difference between Perl and Python

2007-11-04 Thread Varsha Purohit
Hello everyone,
   I wanted to know what are the differences between perl and
python, since both of them are scripting languages...

thanks
-- 
Varsha,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Formbuffer question in PIL

2007-10-13 Thread Varsha Purohit
Hello all,
  I need some help in using formbuffer function in PIL. Does anybody
have sample program related to this ?
thanks,
-- 
Varsha
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Formbuffer question in PIL

2007-10-13 Thread Varsha Purohit
oops.. i wanted to ask about frombuffer which is in image library of PIL. I
read the documentation but wanted a small sample program to understand its
function...

On 10/13/07, Varsha Purohit [EMAIL PROTECTED] wrote:

 Hello all,
   I need some help in using formbuffer function in PIL. Does anybody
 have sample program related to this ?
 thanks,
 --
 Varsha




-- 
Varsha Purohit,
Graduate Student,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] printing bitmap image dynamically reading data inwxpython

2007-10-01 Thread Varsha Purohit
Hi Alan,

  Thanks for the response. Its not a home work problem its actually a task i
need to complete as i am tryin to make some tool which will be helpful to
use as a script in arcgis. i kinda got some clue will surely ask help if i
get stuck somewhere coz i know its difficult to put down in words of what i
wanna do :(

thanks,
Varsha


On 10/1/07, Alan Gauld [EMAIL PROTECTED] wrote:

 Varsha Purohit [EMAIL PROTECTED] wrote

  I want to create a wxpython program where i am reading a list
  having
  integer values like [1,2,3,4]. and i need to display the output
  value as
  bitmap image which shd be coloured after reading the values. Like
  1=red,
  2=yellow, 3=orange etc and it displays the output in colours at
  proper
  coordinates by matching values of the array.

 Sounds like a fun project.
 Have you any plans on how to go about it?
 Are you having problems? Or are you just sharing your excitement
 at the challenge?

  I need to make a script file for arcgis tool which converts the
  ascii data to a coloured bitmap image at given coordinates.

 I dunno much about arcgis but again it sounds like a reasonable
 thing to do.

 Let us know how you get on. If you run into problems ask
 questions we might be able to help. However since it seems
 to be a homework type exercise we can't solve it for you.

 HTH,

 --
 Alan Gauld
 Author of the Learn to Program web site
 http://www.freenetpages.co.uk/hp/alan.gauld


 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] printing bitmap image dynamically reading data in wxpython

2007-09-30 Thread Varsha Purohit
Hello All,

 I want to create a wxpython program where i am reading a list having
integer values like [1,2,3,4]. and i need to display the output value as
bitmap image which shd be coloured after reading the values. Like 1=red,
2=yellow, 3=orange etc and it displays the output in colours at proper
coordinates by matching values of the array. I need to make a script file
for arcgis tool which converts the ascii data to a coloured bitmap image at
given coordinates.

thanks,
-- 
Varsha Purohit,
Graduate Student,
San Diego State University
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] creating image from a given data in wxpython

2007-09-30 Thread Varsha Purohit
Hi All,
I basically wanna create a bitmap image in python. This will be
basically in pixels. X and y coordinates will be specified in the program
and python should create an image by matching the colours. I came across a
function called wx.ImageFromData which book claims that it creates a bitmap
image in pixels. But i am not getting proper implementation of this function
on net...

thanks,,
Varsha
On 9/30/07, Varsha Purohit [EMAIL PROTECTED] wrote:

 Hello All,

  I want to create a wxpython program where i am reading a list having
 integer values like [1,2,3,4]. and i need to display the output value as
 bitmap image which shd be coloured after reading the values. Like 1=red,
 2=yellow, 3=orange etc and it displays the output in colours at proper
 coordinates by matching values of the array. I need to make a script file
 for arcgis tool which converts the ascii data to a coloured bitmap image at
 given coordinates.

 thanks,
 --
 Varsha Purohit,
 Graduate Student,
 San Diego State University




-- 
Varsha Purohit,
Graduate Student,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor]Help needed to read Ascii file in wxPython

2007-09-27 Thread Varsha Purohit
Hello everyone,
  I need  a basic tutorial which can help me in reading or writing ascii
grid file

thanks in advance,

-- 
Varsha Purohit,
Graduate Student,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor]Help needed to read Ascii file in wxPython

2007-09-27 Thread Varsha Purohit
Hi Kent,

I am writing a program basically in python gui to open a file and display
its content. File contains ascii data... here is an example of that.
a text file having info like this

ncols 4
nrows 4
xllcorner 392800
yllcorner 5376340
cellsize  55
NODATA_value  -
9 3 7 3
8 3 2 7
3 2 1 3
3 7 3 2

it has predefined rows and colns... i know similar program in simple python
but wanna figure out how to do that in wxpython...

thanks,
Varsha

On 9/27/07, Kent Johnson [EMAIL PROTECTED] wrote:

 Varsha Purohit wrote:
  Hello everyone,
I need  a basic tutorial which can help me in reading or writing
  ascii grid file

 What is an ascii grid file? Reading and writing text files should be
 covered in any Python tutorial, find one you like here:
 http://wiki.python.org/moin/BeginnersGuide/NonProgrammers

 Kent




-- 
Varsha Purohit,
Graduate Student,
San Diego State University
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Reading/Writing Ascii text file

2007-09-17 Thread Varsha Purohit
Hello friends,

  I wanted a link or tutorial to help me understand how to read or write
ascii text file in python. with and without using Numpy. If you have any
example that would also help me understand better.

thanks,
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] printing value returning from a Class

2007-09-13 Thread Varsha Purohit
Hello friends,,
  I have a problem in displaying data  which i have invoked from
class. City is the name of the class which i havent displayed here. There is
another script using that class. It has a function name setCities which
takes a text file as argument. Text file contains name of the city, x and y
location. there are 4 datas in 4 different lines. Code is as follows.

import City

def setCities(inFile):
# puts city.txt content into City class objects
# the field order of input file is: name x y   x, y are integers. data
are in newlines.
f = open(inFile, 'r')
body = f.readlines()
f.close()
cities = []  # list of cities
for row in body:
cityData = row.strip().split()
cityName = cityData[0]
cityX = cityData[1]
cityY = cityData[2]
newCity = City(cityName, cityX, cityY)  # city class is invoked
cities.append(newCity)
return cities


abc = setCities(C:\MS\sem5\Lab2_scripts\cities.txt)  # setCities function
will return the array with values read from the file.
print abc

I am getting output like
[city.City instance at 0x023E82D8, city.City instance at 0x023E8300, 
city.City instance at 0x023E8350, city.City instance at 0x023E83C8]

I want the data and not the instance... what should i do ??


-- 
Varsha Purohit,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Varsha Purohit
Hello,
Suppose i have a 2D list(grid) like

grid = [[1,1,2,7,6,9],\
  [,9,1,1,1,9,1],\
  [8,1,2,0,0,4],\
  [1,4,1,1,8,5]]

how can i access to all the elements of the list from column no. 5.

output should be like [6,9,0,8]...

thanks,-
Varsha Purohit,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Accessing Values of specific column in a 2D list or array

2007-09-02 Thread Varsha Purohit
Hello,
Suppose i have a 2D list(grid) like

grid = [[1,1,2,7,6,9],\
  [,9,1,1,1,9,1],\
  [8,1,2,0,0,4],\
  [1,4,1,1,8,5]]

how can i access to all the elements of the list from column no. 5.

output should be like [6,9,0,8]...

thanks,-
Varsha Purohit,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [tutor] Difference between index and find in manipulating strings

2007-09-02 Thread Varsha Purohit
Hello,
  i have again very basic question in python string management.

I am not able to understand how find and index works and what do they
actually return.

 line = this is varsha
 print line.find(is)
2
 print line.rfind(is)
5
 print line.rfind(varsha)
8
 print line.index(varsha)
8

what does 2 in first line signifies... and why rfind gave 5 as an output...

can anybody pls explain me what exactly is interpreter tryin to return.

-- 
Varsha Purohit,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [tutor] Difference between index and find in manipulating strings

2007-09-02 Thread Varsha Purohit
 Thanks guys it was really helpful i m just a beginner in python start
to program since two days back. So finding little difficulty with some
concepts.

On 9/2/07, Ricardo Aráoz [EMAIL PROTECTED] wrote:

 Varsha Purohit wrote:
  Hello,
i have again very basic question in python string management.
 
  I am not able to understand how find and index works and what do they
  actually return.
 
  line = this is varsha
  print line.find(is)
  2
  print line.rfind(is)
  5
  print line.rfind(varsha)
  8
  print line.index(varsha)
  8
 
  what does 2 in first line signifies... and why rfind gave 5 as an
 output...
 
  can anybody pls explain me what exactly is interpreter tryin to
 return.
 
 Sure.
 The 2 in first line means the string 'is' begins in line[2] that would
 be the 'is' in 'this' (remember line's first character 't' is line[0]).
 OTOH rfind looks for the first appearance of 'is' in line but starting
 from the right, that would be the word 'is' which starts at line[5].
 As there is only one occurrence of 'varsha' in line both methods, find
 and rfind will give the same answer : 8.

 From Python 2.5 documentation :

 index( sub[, start[, end]])
 Like find(), but raise ValueError when the substring is not found.



 HTH




-- 
Varsha Purohit,
Graduate Student,
San Diego State University
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor