Go to advanced search

by paddyg
Sun Sep 13, 2020 8:32 pm
Forum: Python
Topic: How to handle a simple task in Python, that...
Replies: 5
Views: 424

Re: How to handle a simple task in Python, that...

Do you understand that obscure intricate stuff?
Had to chuckle :D

@joan of all people understands it.
by paddyg
Fri Sep 04, 2020 11:28 am
Forum: Python
Topic: Switch running .py instances
Replies: 2
Views: 179

Re: Switch running .py instances

Is there a reason why they need to be different programs?
by paddyg
Fri Sep 04, 2020 11:19 am
Forum: Python
Topic: Cannot find module mbedtls.exceptions in python-mbedtls
Replies: 2
Views: 116

Re: Cannot find module mbedtls.exceptions in python-mbedtls

It looks like you are running python3 but the pip install will have installed the module only for python2. You can use pip3 to install modules for python3. Confusing?
by paddyg
Fri Sep 04, 2020 11:15 am
Forum: Python
Topic: How Do I Install Matplotlib and Numpy on RaspberryPi?
Replies: 3
Views: 153

Re: How Do I Install Matplotlib and Numpy on RaspberryPi?

@fruitoftheloom don't be so hard on the OP about the py2 v py3 confusion. If you google instructions for most python3 only modules you will see that the instructions assume that pip *is* pip3. The RPi foundation is a bit of an outlier here (maybe because of the lack of alacrity of debian, but still ...
by paddyg
Sun Aug 30, 2020 4:32 pm
Forum: Python
Topic: trying to make a game in lcd
Replies: 15
Views: 532

Re: trying to make a game in lcd

Oh well. I did notice that you had a player.update() in your main game loop so I suspect the glitching might still be due to different bits of code trying to update the LCD - which, as you say, probably does take a non-negligible time to do. I think my preferred way of doing it would be with a globa...
by paddyg
Thu Aug 27, 2020 6:55 pm
Forum: Python
Topic: trying to make a game in lcd
Replies: 15
Views: 532

Re: trying to make a game in lcd

@guack - that's really excellent. And well done for getting to grips with git - you'll be a fully fledged coder in no time. After a quick look at your code there are a couple of things I might suggest. a) there's nothing to stop the enemies and players setting the cursor at the same time i.e. the pl...
by paddyg
Mon Aug 24, 2020 3:39 pm
Forum: Python
Topic: trying to make a game in lcd
Replies: 15
Views: 532

Re: trying to make a game in lcd

Ah, that makes sense. You probably do writing to the LCD from your button callback functions running in their own threads at the same time as the lines are updating. You should have some kind of lock. If you post your code, or if it's on github I can make slightly more specific suggestions.
by paddyg
Sat Aug 22, 2020 10:34 pm
Forum: Python
Topic: trying to make a game in lcd
Replies: 15
Views: 532

Re: trying to make a game in lcd

Did you get glitched characters before (you added the enemies)? I would suspect the timing (have you tried compat_mode=True ?) you could try sending characters more slowly. Otherwise maybe long wires picking up stray voltages? Anyway, good luck debugging it.
by paddyg
Sat Aug 22, 2020 2:31 pm
Forum: Python
Topic: trying to make a game in lcd
Replies: 15
Views: 532

Re: trying to make a game in lcd

Oh well done. That's impressive - given my rather garbled suggestions! Making sure there is a gap will depend on how you've set it up. The first idea would be for Enemy.__init__() to look at the last entry in the enemies list and if its x location is next to the end make sure it goes on the same lin...
by paddyg
Sat Aug 22, 2020 7:15 am
Forum: Python
Topic: is it possible to compile a Python program into an executable ?
Replies: 30
Views: 1374

Re: is it possible to compile a Python program into an executable ?

I think that's true. If the objective is to produce a small high efficiency executable then starting with python is probably the wrong place. I still think that isn't an important objective for the job here. WRT the geekbuzz site the only one in the list I've tried is nuitka which didn't produce ver...
by paddyg
Fri Aug 21, 2020 2:15 pm
Forum: Python
Topic: trying to make a game in lcd
Replies: 15
Views: 532

Re: trying to make a game in lcd

Sorry, it was rather thoughtless of me to just introduce list comprehensions like that. It's really the equivalent of def up(self, btn, b1, b2, b3): if self.y == 1 and b1.value == 0 and b2.value == 0 and b3.value == 0: self.y -= 1 ... up.when_pressed = player.up(up, down, left, right) the point is y...
by paddyg
Fri Aug 21, 2020 11:09 am
Forum: Python
Topic: trying to make a game in lcd
Replies: 15
Views: 532

Re: trying to make a game in lcd

Well it *is* a very open question but here are my comments/suggestions to get you started. a) It's a *very* bad idea to call the instance of your Player class 'Player'. Have a read through of PEP8 for conventions for naming variables; but here you are overwriting your class definition. If you tried ...
by paddyg
Wed Aug 19, 2020 2:24 pm
Forum: Python
Topic: Script using guizero does not run properly from desktop shortcut
Replies: 3
Views: 161

Re: Script using guizero does not run properly from desktop shortcut

I would say; just a guess.. but I must have spent hours pulling my hair out over similar problems in the past :? !
by paddyg
Tue Aug 18, 2020 2:24 pm
Forum: Python
Topic: Script using guizero does not run properly from desktop shortcut
Replies: 3
Views: 161

Re: Script using guizero does not run properly from desktop shortcut

in your app are any of the paths to images or other resources relative. You could try making them absolute paths or add a line to your shell script to cd to the directory where your terminal start worked. It could well be a completely unrelated problem - might be easier to spot if the code was avail...
by paddyg
Tue Aug 18, 2020 12:19 pm
Forum: Python
Topic: is it possible to compile a Python program into an executable ?
Replies: 30
Views: 1374

Re: is it possible to compile a Python program into an executable ?

...returning to the OPs question and later clarification! I would suggest that for the kind of application they're looking at (monitoring hard disks in the background) uncompiled python would be fine. The overhead is tiny if the application is dormant most of the time. IMO it's not worth thinking ab...
by paddyg
Tue Aug 18, 2020 7:22 am
Forum: Python
Topic: Create a random list for playback in vlc
Replies: 7
Views: 325

Re: Create a random list for playback in vlc

Well that was the error in your original post and the subject of my solution. Did you try that?
hint you are doing the equivalent of Popen(['a', ['b', 'c', 'd'], 'f']) and it's expecting Popen(['a', 'b', 'c', 'd', 'f']) which you can do by Popen(['a'] + ['b', 'c', 'd'] + ['f'])
by paddyg
Mon Aug 17, 2020 10:31 pm
Forum: Python
Topic: How to set-up buttons long/short press to work with IF statements
Replies: 2
Views: 126

Re: How to set-up buttons long/short press to work with IF statements

I think you have to set when_held to a function that will fire when the button has been held for 3s see https://gpiozero.readthedocs.io/en/stable/faq.html?highlight=when_held#how-do-i-use-button-when-pressed-and-button-when-held-together. Very approximately (check the documentation for function argu...
by paddyg
Sat Aug 15, 2020 7:19 pm
Forum: Python
Topic: Accessing variables outside the function
Replies: 8
Views: 365

Re: Accessing variables outside the function

Maybe post the full code of the script giving the error EDIT - Appologies, just looked at this thread on computer (as opposed to phone) and see that you have indeed posted the full code. And as Gordon says the issue is because you are trying to read the value of lol before it has been created. lol +...
by paddyg
Sat Aug 15, 2020 1:47 pm
Forum: Python
Topic: Create a random list for playback in vlc
Replies: 7
Views: 325

Re: Create a random list for playback in vlc

you can do this kind of thing is python a = ['file1.mp4', 'file2.mp4', 'file3.mp4'] b = ['cvlc'] + a + ['--play-and-exit'] which will make a single list that you can probably pass to Popen; doing what you did will make a list with the second entry a sublist, and Popen probably won't like that (hence...
by paddyg
Sat Aug 15, 2020 1:31 pm
Forum: Python
Topic: Accessing variables outside the function
Replies: 8
Views: 365

Re: Accessing variables outside the function

It's probably not possible for us to figure this out for you because the code you posted 'conjured up' a sense instance from nowhere and you didn't mention any error messages from that. i.e. I very much suspect that there is some previous code that is causing or contributing to the problem - to do w...
by paddyg
Fri Jul 31, 2020 7:01 am
Forum: Other projects
Topic: Picture Frame: From basic to more advanced
Replies: 9
Views: 680

Re: Picture Frame: From basic to more advanced

I put some stuff up here. Not sure if it clarifies it or not. http://paddywwoof.github.io/pi3d_book/_ ... index.html

Paddy

PS matrices, vectors and linear algebra are really quite lovely when you get into 3D graphics!
by paddyg
Thu Jul 30, 2020 2:16 pm
Forum: Other projects
Topic: Picture Frame: From basic to more advanced
Replies: 9
Views: 680

Re: Picture Frame: From basic to more advanced

OK, I'm glad you asked me that. And you did say you had a maths degree... The way 3D objects are rendered to the screen is essentially done by matrices. Generally speaking there is a transformation matrix Mt that moves the object vertices in space then a camera matrix Mc that effectively also moves ...
by paddyg
Thu Jul 30, 2020 12:12 pm
Forum: Graphics programming
Topic: Pi3D - Embedding Display in Tkinter Window
Replies: 19
Views: 1515

Re: Pi3D - Embedding Display in Tkinter Window

;) but you are right there probably ought to be an explicit warning if code looks for an instance of Display and there isn't one! Like "you are running this before a Display has been created, are you sure?" Hopefully the issue trying to re-run pi3d within the same python process is relatively simple...
by paddyg
Wed Jul 29, 2020 10:09 pm
Forum: Graphics programming
Topic: Pi3D - Embedding Display in Tkinter Window
Replies: 19
Views: 1515

Re: Pi3D - Embedding Display in Tkinter Window

You don't need to worry about using the default centrally installed pi3d, adding the sys.path.insert before import pi3d works fine (That's why it's inserted at position 1 so it comes before anything else that might have pi3d in it too (the first entry in the list has to be left for reasons I can't r...
by paddyg
Wed Jul 29, 2020 2:12 pm
Forum: Graphics programming
Topic: Pi3D - Embedding Display in Tkinter Window
Replies: 19
Views: 1515

Re: Pi3D - Embedding Display in Tkinter Window

It seems odd that *anything* works if x11 isn't running the windows etc. Also lines 361 to 405 in destroy() are common to all platforms so not likely to be x11 v Wayland issue. It would be nice if pi3d just worked under Wayland but I'm not holding my breath... What do you get if you $ loginctl then ...

Go to advanced search