Go to advanced search

by MrYsLab
Mon May 25, 2020 10:38 pm
Forum: Python
Topic: How to make a "start and stop" Button?
Replies: 1
Views: 83

Re: How to make a "start and stop" Button?

I don't fully understand your code logic, so I am placing some code below that does what I think you want. The color scheme and fonts probably need to be changed to your liking. Also, you have a loop that is trying to open up 10 recording sessions. I am not familiar with picamera so I am not sure if...
by MrYsLab
Mon May 25, 2020 1:19 pm
Forum: Python
Topic: How do I create popup window with countdown timer (Python kivy)
Replies: 3
Views: 114

Re: How do I create popup window with countdown timer (Python kivy)

Look at the code on this page. This should give you enough information on changing text between windows.
https://stackoverflow.com/questions/611 ... rent-popup
by MrYsLab
Sat May 23, 2020 3:29 pm
Forum: Python
Topic: How do I create popup window with countdown timer (Python kivy)
Replies: 3
Views: 114

Re: How do I create popup window with countdown timer (Python kivy)

I found this example that is running in the main window. You should be able to port this code to the pop up and have it do something similar. https://stackoverflow.com/questions/41937173/kivy-simple-countdown-minute-and-second-timer main.py from kivy.app import App from kivy.uix.label import Label f...
by MrYsLab
Thu May 21, 2020 4:02 pm
Forum: Python
Topic: Get JSON from remote server
Replies: 3
Views: 128

Re: Get JSON from remote server

I have found using WebSockets to be fairly straight forward. I use WebSockets to exchange browser JS messages with Python scripts. Although I have not incorporated WebSockets in a Python web server, perhaps this article will provide some insight: http://cesium-ml.org/blog/2016/07/13/a-pattern-for-we...
by MrYsLab
Sat May 02, 2020 10:21 pm
Forum: Python
Topic: Code examples I2C Read/write to ltc2945 Pigpio/ SMB..
Replies: 1
Views: 77

Re: Code examples I2C Read/write to ltc2945 Pigpio/ SMB..

I have no experience with this device, but I found that when I want to implement an RPi version of code for an i2c device and can't find an RPi implementation, I try to find an Arduino implementation and port it. Here is a link to an Arduino implementation. https://os.mbed.com/users/odtulumbedder/co...
by MrYsLab
Fri May 01, 2020 3:05 pm
Forum: Python
Topic: Creating HTML button that uses Python script
Replies: 4
Views: 204

Re: Creating HTML button that uses Python script

If you wish to use flask (overkill for a simple pushbutton IMHO, and still requires HTML knowledge), here is a great article by my friend Marcelo:
https://towardsdatascience.com/python-w ... 8423cc6f5d

For something simple, IMHO you can't beat remi.
by MrYsLab
Wed Apr 29, 2020 11:45 pm
Forum: Python
Topic: Uninstall Python3 to compile new version from source?
Replies: 3
Views: 184

Re: Uninstall Python3 to compile new version from source?

Why remove anything when you can have multiple versions of Python installed and select anyone at any time. Using pyenv https://realpython.com/intro-to-pyenv/ you can even set things up so that when you enter a directory the desired version of Python is automatically selected.
by MrYsLab
Wed Apr 29, 2020 10:17 pm
Forum: Python
Topic: Creating HTML button that uses Python script
Replies: 4
Views: 204

Re: Creating HTML button that uses Python script

Take a look at remi https://github.com/dddomodossola/remi It should solve your problem without the hassle of HTML, CSS and JavaScript. Pure Python delight!.
by MrYsLab
Wed Apr 29, 2020 8:17 pm
Forum: Python
Topic: How to position an "App" window and make it disappear
Replies: 4
Views: 210

Re: How to position an "App" window and make it disappear

I am not sure if this is what you want, but the following code will center the window on the screen and after 4 seconds hide it. This program does not show the screen after the 4 seconds, so it is still running and needs to be closed. Let's talk about the sleep first. Guizero runs in its own loop th...
by MrYsLab
Sun Apr 26, 2020 7:06 pm
Forum: Python
Topic: Progress bar in python output window
Replies: 13
Views: 379

Re: Progress bar in python output window

from stackoverflow: https://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console Works in python3 for me. # Print iterations progress def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = "\r"): """ Call in a loop to crea...
by MrYsLab
Fri Apr 24, 2020 1:14 pm
Forum: Python
Topic: Touchscreen not detecting on_touch_down in kivy - python
Replies: 1
Views: 92

Re: Touchscreen not detecting on_touch_down in kivy - python

It's been quite a while since I played with this, but if you go to this GitHub page: https://github.com/mrichardson23/rpi-kivy-screen and scroll down to item 13 and begin reading from there, the author explains how to enable touch for kivy on the touch display. I have not tried this with Buster but ...
by MrYsLab
Tue Apr 21, 2020 6:09 pm
Forum: Python
Topic: How to change default pip directory from Python 3 to Python 2.7?
Replies: 12
Views: 307

Re: How to change default pip directory from Python 3 to Python 2.7?

If you need to switch between Python environments, either going back and forth between Python 2 and Python3 or wanting to use a newer version of Python than that installed on your distribution, I have found that using the pyenv tool to be a great tool to manage things and keep environments separate ...
by MrYsLab
Tue Apr 21, 2020 11:34 am
Forum: Python
Topic: Thonny/CLI difference - very much beginner
Replies: 4
Views: 164

Re: Thonny/CLI difference - very much beginner

Just to clarify, there are 2 ways to run python from the CLI. One is by simply typing python3 (or python for Python2). This invokes python in an interactive mode, known as the REPL (the READ-EVALUATE-PRINT Loop). The second is to run a program from the CLI. If the name of the file below is add.py th...
by MrYsLab
Mon Apr 20, 2020 8:37 pm
Forum: Python
Topic: Thonny/CLI difference - very much beginner
Replies: 4
Views: 164

Re: Thonny/CLI difference - very much beginner

I am assuming that when you ran the example outside of thonny you did so in the Python REPL. That is you started python by typing in the python or python 3 in the command line and then entered import example example.add(4,5.5) and then hit enter. The REPL prints it results to the console. Thonny is ...
by MrYsLab
Mon Apr 20, 2020 7:56 am
Forum: Python
Topic: Oled interactive menu in python
Replies: 1
Views: 117

Re: Oled interactive menu in python

by MrYsLab
Sun Apr 19, 2020 8:54 pm
Forum: Python
Topic: Python Tkinter and GPIO
Replies: 5
Views: 192

Re: Python Tkinter and GPIO

The problem that the OP is having is not simply controlling GPIO from tkinter, but it is an autostart issue. There are many methods of performing autostart and again, the method you are using is not described within the problem statement. Here are some links that may help you solve your issue: https...
by MrYsLab
Sun Apr 19, 2020 2:40 pm
Forum: Python
Topic: Python Tkinter and GPIO
Replies: 5
Views: 192

Re: Python Tkinter and GPIO

It is very difficult to provide help because there is very little information provided. Could you please: 1. Provide your code (using code tags) 2. If you are trying to start your application from boot, what method are you using? 3. If you are getting exceptions in your code, provide the exception t...
by MrYsLab
Sun Apr 19, 2020 10:30 am
Forum: Python
Topic: Error using ImageMagick in python
Replies: 2
Views: 93

Re: Error using ImageMagick in python

There are several discussions about this on the web. Just google "error/cache.c/OpenPixelCache". Several articles discuss how to configure the ImageMagick cache limits. I have not done this myself, but it looks like a good starting point.
by MrYsLab
Fri Apr 17, 2020 2:16 pm
Forum: Python
Topic: Issues with setting up an alarm with datetime and ranges
Replies: 36
Views: 1116

Re: Issues with setting up an alarm with datetime and ranges

You are correct, you need to move the LED call above the while statement: led = LED(16) while True: t = datetime.now() hournow = str(t.hour) minnow = str(t.minute) secnow = str(t.second) You may also need to do a pip install of rpi.gpio, pigpio, and gpiozero if you are working in a new Python enviro...
by MrYsLab
Thu Apr 16, 2020 10:51 pm
Forum: Scratch
Topic: PWM support for scratch 3?
Replies: 2
Views: 365

Re: PWM support for scratch 3?

Take a look at https://mryslab.github.io/s3-extend/. It supports PWM for the RPi.
by MrYsLab
Thu Apr 16, 2020 5:10 pm
Forum: Python
Topic: Issues with setting up an alarm with datetime and ranges
Replies: 36
Views: 1116

Re: Issues with setting up an alarm with datetime and ranges

The only thing I would caution about is that if you replace the current version of Python, the version of Raspbian you are running may have dependencies upon the originally installed version of Python. I used to recompile and reinstall Python as new versions came out and never had an issue, but usin...
by MrYsLab
Thu Apr 16, 2020 1:13 pm
Forum: Python
Topic: Issues with setting up an alarm with datetime and ranges
Replies: 36
Views: 1116

Re: Issues with setting up an alarm with datetime and ranges

I just installed pyenv on Raspbian Buster without issue. The article I provided the link to is somewhat lengthy, but installing is rather easy. Read the article, but I will summarize what I have done: 1. sudo apt-get update 2. sudo apt-get upgrade 3. sudo apt-get install -y make build-essential libs...
by MrYsLab
Thu Apr 16, 2020 5:47 am
Forum: Python
Topic: Issues with setting up an alarm with datetime and ranges
Replies: 36
Views: 1116

Re: Issues with setting up an alarm with datetime and ranges

There is a tool called pyenv that allows one to have multiple versions of Python available to use on your computer. It allows you to configure a directory to automatically select a specific Python interpreter version just by cd'ing into a directory set up for that interpreter. I believe that it will...
by MrYsLab
Tue Apr 14, 2020 12:31 am
Forum: Python
Topic: Issues with setting up an alarm with datetime and ranges
Replies: 36
Views: 1116

Re: Issues with setting up an alarm with datetime and ranges

The "best approach" is very subjective. My rule of thumb is to write something so that it is easiest for others to understand and for me to maintain. If I need to improve the code for faster execution time, then I use the best approach I can find and document the heck out of it if that approach is s...
by MrYsLab
Mon Apr 13, 2020 6:22 pm
Forum: Python
Topic: Issues with setting up an alarm with datetime and ranges
Replies: 36
Views: 1116

Re: Issues with setting up an alarm with datetime and ranges

I modified your program somewhat. The first problem is that the while loop was never exited and therefore nothing prints. Also, the values returned by datetime.now are integers and you can't take a length of an integer, so I converted those values to strings. Hopefully this is helpful. from datetime...

Go to advanced search