Go to advanced search

by Sleep Mode zZ
Thu Sep 18, 2014 4:02 am
Forum: Python
Topic: Pygame Download & Install
Replies: 1
Views: 18955

Re: Pygame Download & Install

Last time I followed Croston's instructions with success:
http://www.raspberrypi.org/forums/viewt ... me#p284266

Report the errors that you get with the commands and I'm sure that someone can figure out the problem.
by Sleep Mode zZ
Wed Sep 17, 2014 12:21 am
Forum: Troubleshooting
Topic: SOLVED - rpi-update problems
Replies: 5
Views: 1680

Re: SOLVED - rpi-update problems

I think I have had the same problem several times. The upgrade process got stuck at the point of "Removing 'diversion of /boot/bootcode.bin to /usr/share/rpikernelhack/bootcode.bin by rpikernelhack'". Then the computer becomes unresponsive and the screen freezes. I wait for several minutes but at so...
by Sleep Mode zZ
Mon Sep 08, 2014 12:28 pm
Forum: Python
Topic: GUI in Python
Replies: 22
Views: 6615

Re: GUI

Unfortunately I'm not familiar with these libraries at all and cannot test the program. On a quick inspection it seems that LCD_QUEUE is a queue where you put items into it with LCD_QUEUE.put and get items with LCD_QUEUE.get. If you want to display what you put into the queue, probably the best thin...
by Sleep Mode zZ
Mon Sep 08, 2014 11:54 am
Forum: Python
Topic: GUI in Python
Replies: 22
Views: 6615

Re: GUI

I'm not quite sure what you are asking. You can render any string to a surface and then blit it into the screen. In the example program it is a int typed variable (frame_number) that is changed to a string and then rendered. If you have the content of your queue in strings (or something that can be ...
by Sleep Mode zZ
Mon Sep 08, 2014 11:30 am
Forum: Python
Topic: GUI in Python
Replies: 22
Views: 6615

Re: GUI

Here is a small sample program of writing text to the display: import pygame, sys WINDOWWIDTH = 620 WINDOWHEIGHT = 480 FONT_SIZE = 50 FONT_COLOR = (255,255,255) BG_COLOR = (0,0,0) POSITION = (int(WINDOWWIDTH/2.0), int(WINDOWHEIGHT/2.0)) pygame.init() screen = pygame.display.set_mode((WINDOWWIDTH, WI...
by Sleep Mode zZ
Sun Sep 07, 2014 11:27 pm
Forum: Beginners
Topic: How do I install pygame
Replies: 3
Views: 775

Re: How do I install pygame

Pygame is already installed for python (Python 2) and should work fine. If you are using python3 (Python 3) you have to install it. There is not any ready-made package for that so it will be a more complicated process than using apt-get. You can find instructions somewhere on this forum.
by Sleep Mode zZ
Tue Sep 02, 2014 2:02 am
Forum: Python
Topic: displaying a .jpg image on screen
Replies: 25
Views: 18368

Re: displaying a .jpg image on screen

Generally speaking, I think that it would be best to copy-paste the whole program here, unless it is very long, because it can be that you are introducing or fixing bugs when partially copying and pasting from your code. Also, the best way for us to inspect the code would be to try to run it - but t...
by Sleep Mode zZ
Sun Aug 31, 2014 8:22 am
Forum: Python
Topic: displaying a .jpg image on screen
Replies: 25
Views: 18368

Re: displaying a .jpg image on screen

In addition to what elParaguayo said about indentation, it seems that when quitting the program, you are trying to fill the pygame screen with black. Maybe you expect that the black screen will stay on after pygame stops? Won't happen :) The black screen - that probably will not have time to appear ...
by Sleep Mode zZ
Sun Aug 31, 2014 1:54 am
Forum: Python
Topic: pygame transforming images
Replies: 3
Views: 922

Re: pygame transforming images

Of course. You have the dimensions of the image and you have the dimensions of the screen. The rest should be very simple math.
by Sleep Mode zZ
Sun Aug 31, 2014 12:32 am
Forum: Python
Topic: displaying a .jpg image on screen
Replies: 25
Views: 18368

Re: displaying an image on screen

Then you can simplify it: import pygame, sys pygame.init() screen = pygame.display.set_mode((700,500)) pygame.mouse.set_visible(False) image = pygame.image.load("picture01.jpg") image = pygame.transform.scale(image, (700,500)) screen.blit(image, (0 , 0)) clock = pygame.time.Clock() pygame.display.up...
by Sleep Mode zZ
Sat Aug 30, 2014 4:06 am
Forum: Python
Topic: displaying a .jpg image on screen
Replies: 25
Views: 18368

Re: displaying an image on screen

Although the previous version did not show any significant cpu use on my desktop computer, it does blit the image and update the whole screen 30 times every second. So here I moved the the blitting and updating to be done only when the image is switched to the next one: import pygame, sys pygame.ini...
by Sleep Mode zZ
Sat Aug 30, 2014 3:36 am
Forum: Python
Topic: displaying a .jpg image on screen
Replies: 25
Views: 18368

Re: displaying an image on screen

A simple example with an event loop (no exception handling when loading the pictures): import pygame, sys pygame.init() screen = pygame.display.set_mode((700,500)) images = [] images.append(pygame.image.load("picture01.jpg")) images.append(pygame.image.load("picture02.jpg")) show = 0 clock = pygame....
by Sleep Mode zZ
Sat Aug 30, 2014 3:05 am
Forum: Python
Topic: displaying a .jpg image on screen
Replies: 25
Views: 18368

Re: displaying an image on screen

so to summarize so far. it works, but has a loading delay.. (i guess pygame takes 3 or so seconds to load a 600x600 photo?) If you tried only to load one picture, the "loading delay" will have more to do with the time that Python and Pygame takes loading and starting up than with the time loading a...
by Sleep Mode zZ
Tue Aug 26, 2014 12:10 pm
Forum: Python
Topic: GUI in Python
Replies: 22
Views: 6615

Re: GUI

Thanks for your reply Sleep. I know where I have to put the calls of the functions what I don't know exactly is what I've to write inside each function to achieve that clicking in the image will be the same that pushing the button on the lcd. Any help please? Because the function used only reads th...
by Sleep Mode zZ
Mon Aug 25, 2014 10:04 pm
Forum: Python
Topic: GUI in Python
Replies: 22
Views: 6615

Re: GUI

I need some help please. Finally I've decided to do it like a pygame. My project uses the script of python of Sheldon: http://usualpanic.com/2013/05/raspberry-pi-plate-internet-radio/ Now I want to control it at the same time with the lcd or with the gui. I've created a code that shows a photo of t...
by Sleep Mode zZ
Wed Aug 20, 2014 10:14 am
Forum: Python
Topic: Statement ok in IDLE shell, but not in script
Replies: 13
Views: 2152

Re: Statement ok in IDLE shell, but not in script

This works in both Python 2 and Python 3. import time time.sleep(5) I'm guessing that the syntax error that you get is not because of any fault in the callling of time.sleep() but something is wrong before that call. The syntax error would mean that the interpreter did not expect a function call the...
by Sleep Mode zZ
Tue Aug 12, 2014 8:19 pm
Forum: Python
Topic: Pygame - user config
Replies: 4
Views: 954

Re: Pygame - user config

action2function[key2action[pygame.key.name(event.key)]]() So, in the loop you get the name of the key pressed from pygame. Then look it up in key2action dictionary. Then with the item returned from the key2action dictionary you use it as a key to get an item from the action2function dictionary. Tha...
by Sleep Mode zZ
Tue Aug 12, 2014 6:02 pm
Forum: Python
Topic: Pygame - user config
Replies: 4
Views: 954

Re: Pygame - user config

It would be better if you could post the code. Otherwise people can only speculate on what could be wrong. Configuring the controls should not have any effect unless you are reconfiguring them (and doing some calculations continually) during the gaming. The effective way would be to replace some def...
by Sleep Mode zZ
Sat Jun 28, 2014 3:47 am
Forum: Python
Topic: KEYDOWN and KEYUP events using Pygame without a window
Replies: 16
Views: 11132

Re: KEYDOWN and KEYUP events using Pygame without a window

http://www.pygame.org/wiki/HeadlessNoWindowsNeeded?parent=CookBook Not in a position to test this but might be useful. Dave. Some posts indicate that the keyboard events won't work with the dummy driver: http://www.raspberrypi.org/forums/viewtopic.php?f=32&t=46096#p363390 http://www.raspberrypi.org...
by Sleep Mode zZ
Fri Jun 27, 2014 11:24 am
Forum: Python
Topic: KEYDOWN and KEYUP events using Pygame without a window
Replies: 16
Views: 11132

Re: KEYDOWN and KEYUP events using Pygame without a window

Python's curses module should be able to do what you want.
by Sleep Mode zZ
Mon Apr 14, 2014 9:22 am
Forum: Python
Topic: Pygame audio problem in terminal
Replies: 1
Views: 513

Re: Pygame audio problem in terminal

Maybe the same issue as here?
by Sleep Mode zZ
Sun Mar 23, 2014 3:03 pm
Forum: Python
Topic: Quick time.sleep(????) question.
Replies: 6
Views: 1775

Re: Quick time.sleep(????) question.

Ant232 wrote: One question for future reference. How did you know it was a string? Does it become a string when Python reads the textfile?
The readline() method reads a line from a textfile and returns it as a string.
by Sleep Mode zZ
Sun Mar 23, 2014 2:18 pm
Forum: Python
Topic: Quick time.sleep(????) question.
Replies: 6
Views: 1775

Re: Quick time.sleep(????) question.

When printed it seems to be a float but in reality it is a string. You have to convert the string to a float using the built-in float() function.
by Sleep Mode zZ
Sat Mar 22, 2014 4:05 am
Forum: Beginners
Topic: Audio problem
Replies: 2
Views: 653

Re: Audio problem

Your program quits right after it has started to play the sound. Pygame won't keep the program alive just because a sound is still playing. I'm not sure why it does that when started from Idle. (I don't use Idle.) To hear the sound, add a time.sleep() command at the end of the of the program: import...

Go to advanced search