Re: the scaling of pics in pygame

2008-04-02 Thread Ramsey Nasser
Isn't PIL best suited for things like this?

The resize function should do what you're looking for:
http://www.pythonware.com/library/pil/handbook/image.htm

On Wed, Apr 2, 2008 at 6:59 AM,  [EMAIL PROTECTED] wrote:
 On Apr 1, 9:44 pm, Jimmy [EMAIL PROTECTED] wrote:
   Hi, everyone
  
   I am using Pygame to write a small program. I tried to load a .jpg
   picture into
   the screen, however, the size of the pic doesn't fit into the window
   properly. Can
   anyone tell me how to scale the picture into the window?

  You might get a quicker answer at pygame.org - check the mailing list
  and/or docs.



  --
  http://mail.python.org/mailman/listinfo/python-list




-- 
nasser
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: convert pdf to png

2007-12-24 Thread Ramsey Nasser
On Dec 24, 2007 7:53 AM, Carl K [EMAIL PROTECTED] wrote:
 I need to take the take the pdf output from reportlab and create a preview 
 image
 for a web page.  so png or something.  I am sure ghostscript will be involved.
 I am guessing PIL or ImageMagic ?

 all sugestions welcome.

 Carl K
 --
 http://mail.python.org/mailman/listinfo/python-list


PIL's support for pdf files is write only, so thats out of the question.

I just tried ImageMagik from the console and it converted a pdf into
png in a snap, so that seems to be your best bet.

-- 
nasser
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to generate pdf file from an html page??

2007-12-16 Thread Ramsey Nasser
On Dec 16, 2007 7:26 PM, Zentrader [EMAIL PROTECTED] wrote:
 Sorry, I read that backwards.  I do it the opposite of you.  Anyway a
 google for html to pdf python turns up a lot of hits.  Again, no
 reason to reinvent the wheel.

 --
 http://mail.python.org/mailman/listinfo/python-list


Like Zentrader said, theres no reason to reinvent the wheel. An HTML
to PDF converter is no trivial task. You would essentially have to
implement an HTML layout engine that outputs PDF files. Not only does
that mean you would have to programatically produce a PDF file, but it
means you would have to parse and correctly render HTML and CSS
according to accepted web standards, the W3C's specifications. This
has proved difficult to do and get right in practice, as is evident
from the browser compatibility issues that continue to plague the web.

Theres a package called Prince that's supposed to do an excellent job.
Check it out:

http://www.princexml.com/

Its layout engine surpasses some browsers in terms of compatibility
with web standards. I don't think its free for commercial use, though,
so this might depend on what exactly you're trying to do.

An alternative idea it to wait for Firefox 3 to come out. If I'm not
mistaken, it will feature a new version of the Gecko layout engine
which will use Cairo for all its rendering. Coincidently, Cairo can be
made to output PDF files. So, you may be able to hack something
together.

-- 
nasser
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Get()

2007-12-15 Thread Ramsey Nasser
The grid method of these widgets returns None. When you say something like:

ent = Entry(root, fg = '#3a3a3a', bg = 'white', relief =
'groove').grid(row = 0, padx = 3, pady = 3)

You're actually assigning the value of the last method on the right
hand side (in this case, grid) to the variable on the left hand side
(in this case ent). Since grid returns None, ent is set to None, and
the insert function fails.

What you want to do is replace your GUI initialization code with
something like this:

ent = Entry(root, fg = '#3a3a3a', bg = 'white', relief = 'groove')
ent.grid(row = 0, padx = 3, pady = 3)

button = Button(root, text = Remember, command = insert, relief =
'groove', fg = '#3a3a3a')
button.grid(row = 0, column = 1, padx = 3, pady = 3)

box = Listbox(root, bg = '#ebe9ed', relief = 'groove')
box.grid(row = 2, columnspan = 2, sticky = W+E, padx = 3)

This way ent, button and box get set to their respective widgets, the
grid method does its thing and the insert function works as expected.

-- 
nasser
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any way to program custom syntax to python prompt? I want to edit matrices.

2007-12-11 Thread Ramsey Nasser
On 11 Dec 2007 04:14:09 GMT, Stargaming [EMAIL PROTECTED] wrote:
 On Mon, 10 Dec 2007 16:54:08 -0800, mosi wrote:

  Python matrices are usually defined with numpy scipy array or similar.
  e.g.
  matrix1 = [[1, 2], [3, 4], [5, 6]]
  I would like to have easier way of defining matrices, for example:
  matrix = [1, 2; 3, 4; 5, 6]
 
  matrix =
  [ 1, 2;
3, 4;
5, 6;]
 
  Any ideas how could this be done? The ; sign is reserved, the [ ] is
  used for lists.

I think mosi was looking to dynamically modify the syntax of Python
itself, as opposed to working around the existing syntax. This
includes things like messing with reserved symbols and keywords.

The interpreter is compiled with these definitions built in, so to
change them would conceivably require a recompile. If this is the
case, then mosi may be out of luck.  Then again, people have done some
interesting dynamic modifications to the interpreter during runtime
without recompiling. Psyco is the best example of this that comes to
mind. Maybe someone more versed in Psyco-esque interpreter voodoo
would be able to help.

-- 
nasser
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: project - trivia game

2007-12-04 Thread Ramsey Nasser
Shawn,

First of all, next time try and isolate the problem yourself and send
a short snippet of code demonstrating the behavior you're having
trouble with. This makes it easier for other people to understand what
is going on and help you in a more focused way.

On Dec 5, 2007 2:43 AM, Shawn Minisall [EMAIL PROTECTED] wrote:
 For my final project, I'm trying to do a GUI based game similar to are

which GUI toolkit are you using?

 you smarter then a 5th grader.  I've been working on it and am stuck
 with some code someone helped me with to randomize the A,B,C,D letters
 that the correct answer is assigned too.  The code that does this is
 highlighted in bold and the code that assigns it to a variable is also
 in bold so I can test it in the console window.  Problem is, it's always
 stuck at letter A and doesn't always give the correct answer.  The
 correct answer is always position 1 in my make math question list.
 Could someone please help?

Your randomization code works. There are two issues that are causing
your problem, though.

1. You provide no mechanism to keep track of what answers are
correct. In the whole program, there is no notion of whether an
answer is right or wrong. So you can't expect to get the correct
answer to a question without telling the machine which one it is.
Although it may start out at position 1, this is lost after
randomization.

2. Your program is hardcoded to always pick letter A

pResult = (currentScreen[0].getText())
print pResult

cResult = (currentScreen[2].getText())
print cResult

Following the definition of drawQuestion, currentScreen[0] will
contain entchoice which has text 'A', and currentScreen[2] will always
contain answer A and the first answer in the list, regardless of
whether or not it is correct (again, the machine has no way of
knowing). I'm not completely sure what you're trying to do here
(pResult, cResult...problemResult, correctResult?), so some more
explanation would help.

Also, some general comments:

#Picks random question
qNum = randrange(0, len(currentList))
qList = currentList[qNum]

can be replaced with

qList = choice(currentList)

(you would have to replace currentList.pop(qNum) with
currentList.remove(qList) )

aList = []
tmpList = qList[1:5]

#Randomizes answers
while(len(tmpList)  0):
   rNum = randrange(0, len(tmpList))
   aList.append(tmpList[rNum])
   tmpList.pop(rNum)

can be replaced with

aList = qList[1:5]
shuffle(aList)

 thanks

 BTW, to whoever asked me why I don't use functions b4, I'm using them
 now that I've learned how to... :P ;)

Probably a good idea :)

Good luck with everything
-- 
nasser
-- 
http://mail.python.org/mailman/listinfo/python-list