Python Forum

Full Version: RPi 3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

Hi, could you help me at a point which is I'm confused.
I'll do a new project. Before I give information about it, I'll write materials what I need to use.

-HC-SR04 Ultrasonic Range Finder
-NodeMCU ESP8266 Wi-Fi Module
-Raspberry Pi B Model
-GPS Module with RTK

In this project, my aim is that:
1) take and measure distance from ultrasonic range finder
2) provide internet connection between NodeMCU Wifi module and Raspberry Pi
3) show distance on the Raspi Lcd Screen
4) take data from GPS
5) embed a map
6) assemble Distance & GPS.
7) all of the system should present with GUI.

On my project, I use ultrasonic sensor and NodeMCU ESP8266. Code was written on Arduino for sensor. NodeMCU communicates Wi-Fi. I got data from sensor through NodeMCU (via Wi-Fi). Arduino code connects to TCP/IP Protocol. For example, if you write IP Address on web page, you can see distance value.

I got received data from HTTP Webpage. Raspberry GUI / Screen should show us “distance value” like HTTP Web Page.

Until here, everything is OK. I want to use Raspberry Pi 3 How is it possible? Or, I want to show distance value from sensor on Raspberry Pi 3 with LCD Screen. How is it execute/display? I want to embed all of them to Raspberry Pi 3.

What should I do for Raspberry Pi 3 with Graphical User Interface (GUI) on my project?

Can I use Phyton ?

Quote:Can I use Phyton ?
Python has a built in (or loadable) GUI package, tkinter which is capable of displaying your data.
There are fancier GUI packages available, but tkinter should be sufficient for what you want to display.
So, yes you can use python.
(Mar-06-2019, 08:29 PM)Larz60+ Wrote: [ -> ]
Quote:Can I use Phyton ?
Python has a built in (or loadable) GUI package, tkinter which is capable of displaying your data.
There are fancier GUI packages available, but tkinter should be sufficient for what you want to display.
So, yes you can use python.

Thank you for your help. Is Tkinter enough for GPS? For example: embedding a map.
Yes, would need Canvas and PhotoImage

tkinter documentstion:
Yes, you can use tkinter.PhotoImage on a tkinter.Canvas
reference (pdf available): http://infohost.nmtedu/tcc/help/pubs/tki...index.html
reference: https://docs.python.org/3/library/tk.html
tutorial see: https://www.python-course.eu/tkinter_canvas.php

----------------------------------------------

wxpython: https://wxpython.org/
documentation: https://docs.wxpython.org/
gallery: https://docs.wxpython.org/gallery.html
demo: https://github.com/wxWidgets/wxPython/tree/master/demo

----------------------------------------------

pyQt5:
documentation: http://pyqt.sourceforge.net/Docs/PyQt5/
Qt5 Gallery: https://doc.qt.io/qt-5/gallery.html
Qt5 (need conversion to pyqt5) examples: https://doc.qt.io/qt-5/qtexamples.html
python tutorial for image: https://pythonspot.com/pyqt5-image/
(Mar-07-2019, 05:16 PM)Larz60+ Wrote: [ -> ]Yes, would need Canvas and PhotoImage

pyQt5:
documentation: http://pyqt.sourceforge.net/Docs/PyQt5/
Qt5 Gallery: https://doc.qt.io/qt-5/gallery.html
Qt5 (need conversion to pyqt5) examples: https://doc.qt.io/qt-5/qtexamples.html
python tutorial for image: https://pythonspot.com/pyqt5-image/

I installed PyQt5, but i should develop my project on an IDE. Which interface program should do I use? QT designer is not free.
(Mar-11-2019, 03:07 PM)bescf Wrote: [ -> ]QT designer is not free.
It's free install with pyqt5-tools.
pip install pyqt5-tools
Then i can start it from anywhere with designer,as Python is in my Path.
C:\1
λ designer
[Image: mtUW02.jpg]
designer create .ui files that can be converted,or as in example under dynamically load the .ui files by using the uic in PyQt5.
from PyQt5 import uic, QtWidgets
import sys
 
class Ui(QtWidgets.QDialog):
    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('SomeUi.ui', self)
        self.show()
 
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    window = Ui()
    sys.exit(app.exec_()) 

Quote:I got received data from HTTP Webpage. Raspberry GUI / Screen should show us “distance value” like HTTP Web Page.
What should I do for Raspberry Pi 3 with Graphical User Interface (GUI) on my project?
I would have used Flask as web-UI and not GUI for this.
Look at this this post,where i link to some stuff with IoT and Flask
(Mar-11-2019, 03:53 PM)snippsat Wrote: [ -> ]
pip install pyqt5-tools
İmage

Thanks for your help, i installed .
Quote:Then i can start it from anywhere with designer,as Python is in my Path.
C:\1
λ designer
İmage

I cant reached using this way, but i searched detailedly in site-packages path. Then I run successfully QT Designer, thanks again.

Quote:designer create .ui files that can be converted,or as in example under dynamically load the .ui files by using the uic in PyQt5.
from PyQt5 import uic, QtWidgets
import sys
 
class Ui(QtWidgets.QDialog):
    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('SomeUi.ui', self)
        self.show()
 
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    window = Ui()
    sys.exit(app.exec_()) 

I dont understand what you mean here. (I'm beginner about Python. This may be a reason)
Where should i apply this code ? I tried CMD and it gave ineffability.
İmage


Quote:I would have used Flask as web-UI and not GUI for this.
Look at this this post,where i link to some stuff with IoT and Flask
I have to access TCP/IP protocol so i should get data from HTTP. Actually, This is not possible with QT designer ? Also, I prefer gui because i should represent this data to user.
Quote:designer create .ui files that can be converted,or as in example under dynamically load the .ui files by using the uic in PyQt5.
from PyQt5 import uic, QtWidgets
import sys
 
class Ui(QtWidgets.QDialog):
    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('SomeUi.ui', self)
        self.show()
 
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    window = Ui()
    sys.exit(app.exec_()) 

Quote:I dont understand what you mean here. (I'm beginner about Python. This may be a reason)
Where should i apply this code ? I tried CMD and it gave ineffability.
İmage
Now i can understand more clear. I make a project, and save on my documents .ui
But i should see form of code, so project should be converted. I want to ask how i do this for file being "pyqtdesigner.ui". Which lines should be changed?
None of your images works get 403.
(Mar-12-2019, 12:31 PM)bescf Wrote: [ -> ]But i should see form of code, so project should be converted. I want to ask how i do this for file being "pyqtdesigner.ui". Which lines should be changed?
There is pyuic5 which convert .iu to .py
C:\1
λ pyuic5 my.ui -o my_app.py
So i need to add the last bit after if __name__ == '__main__':
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'my.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
import sys

class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(400, 300)
        self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(30, 240, 341, 32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.radioButton = QtWidgets.QRadioButton(Dialog)
        self.radioButton.setGeometry(QtCore.QRect(60, 100, 82, 17))
        self.radioButton.setObjectName("radioButton")

        self.retranslateUi(Dialog)
        self.buttonBox.accepted.connect(Dialog.accept)
        self.buttonBox.rejected.connect(Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
        self.radioButton.setText(_translate("Dialog", "RadioButton"))

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    firstgui =  QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(firstgui)
    firstgui.show()
    sys.exit(app.exec_())
This run my.ui directly.
from PyQt5 import uic, QtWidgets
import sys

class Ui(QtWidgets.QDialog):
    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('my.ui', self)
        self.show()

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    window = Ui()
    sys.exit(app.exec_())
Quote:I have to access TCP/IP protocol so i should get data from HTTP. Actually, This is not possible with QT designer ? Also, I prefer gui because i should represent this data to user.
Yes you can get data and put into PyQt5 designer,i just mention that i would choose web UI create with Flask.
I have moved more away from GUI and now doing most stuff it needed with web-app.
Getting data from HTTP has a more natural conntion to a web-app,but if want to do GUI that will work to.
(Mar-12-2019, 01:39 PM)snippsat Wrote: [ -> ]There is pyuic5 which convert .iu to .py
C:\1
λ pyuic5 my.ui -o my_app.py

This method can not be correct for me, it gave an error. I tried another solution.
İmage


++I guess that you shared python codes with me to show how happened coding with convert .ui to .py :)

Quote:Yes you can get data and put into PyQt5 designer.
I understand. But i'm confused about course of events. I mean that step of project.
- creating a project and working on .ui file
- coding and changing on .py file

Which step is first ? Or how i follow for getting data and showing user dynamically?
Pages: 1 2