Learning to work with new QTVCP screens and handler

More
06 Jan 2021 13:39 #194218 by Pro_El
Hello Chris,
I have been trying couple of days (maybe weeks) to implement code in my handler file but with no luck. I am using simple code and i put inside designer widget QGraphicsView. Inside this widget i want to display custom 2d shapes. There are a lot of example on net for this but nothing display for me. I am using PyQt5 to import QT widgets. I am thinking i did not link code with display element on QT Designer properly. Can you guide me thru process to display something (anything) in QGraphicsView so i can see mu faults.

One of many examples i try to put in Handler file


from PyQt5 import QtCore, QtGui, QtWidgets

class MyFirstGuiProgram(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent=parent)
self.setupUi(self)
scene = QtWidgets.QGraphicsScene()
self.graphicsView.setScene(scene)
pen = QtGui.QPen(QtCore.Qt.green)

side = 20

for i in range(16):
for j in range(16):
r = QtCore.QRectF(QtCore.QPointF(i*side, j*side), QtCore.QSizeF(side, side))
scene.addRect(r, pen)


if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
w = MyFirstGuiProgram()
w.show()
sys.exit(app.exec_())


Thanks a lot Chris!

Please Log in or Create an account to join the conversation.

More
06 Jan 2021 14:05 #194223 by cmorley
First when you say you want it in the handler file - I assume you want it in the main GUI. So you need to pick a widget that will accept it.

The sample you posted is a MAIN window so you can't embed it into another widget.

Do you have a main screen that displays or are you adding this to an existing linuxcnc screen?
The following user(s) said Thank You: Pro_El

Please Log in or Create an account to join the conversation.

More
06 Jan 2021 14:18 #194228 by Pro_El
Yes I want to display in my main GUI. I want to add my code to existing linuxcnc screen. I was thinking to use QGraphicsScene and QGraphicsview imported from PyQt5 and display custom 2d forms in Graphicview widget inside Designer ( my linuxcnc screen) If this is possible i would appreciate the help how to do it.


Thanks Chris !!

Please Log in or Create an account to join the conversation.

More
06 Jan 2021 14:32 #194231 by cmorley
So I'm asking what screen you are going to add it to - So I know how to program a sample.
otherwise I can't help :)
The following user(s) said Thank You: Pro_El

Please Log in or Create an account to join the conversation.

More
06 Jan 2021 14:55 #194232 by Pro_El
I am not sure if i understand your question. I am building custom LCNC screen from scratch with LCNC widgets. And i want to add in one side block with custum 2d shapes depends of some importing xml documents. At this moment i just want to find a way to display this custom 2d shapes inside my screen. For start we can call it empty QTVCP screen with automatically generated handler.py file from first start of LCNC. If it need i can attach this two files

Thanks a Lot Chris!

Please Log in or Create an account to join the conversation.

More
06 Jan 2021 15:49 #194237 by cmorley
Ok here is a fairly useless custom screen - but it incorporates a custom graphic scene widget on tab 2

The custom widget is defined in the handler file.

Unzip this folder in your config folder.
change the INI as follows:

[DISPLAY]
DISPLAY = qtvcp custom
Attachments:
The following user(s) said Thank You: Pro_El

Please Log in or Create an account to join the conversation.

More
06 Jan 2021 16:00 #194238 by Pro_El
Is working great.
Now have code to study,

Thanks Chris you and this forum are GREAT!!

Please Log in or Create an account to join the conversation.

More
06 Jan 2021 16:06 #194239 by cmorley
Your welcome.

keep us posted on your work
The following user(s) said Thank You: Pro_El

Please Log in or Create an account to join the conversation.

More
09 Jan 2021 22:40 #194654 by Pro_El
Hello Chris
I'v build screen to dynamically show and create custom rectangles for my automatically saw cutting software.
My next stage is to import *.CSV file and use the data inside the file. It is text file separates with commas. This files is usual generate from software for nesting.
I manage to import this file with FileManager Widget in QTDesigner and see in GcodeDisplay (like in the screenshot attach).
I did not manage to open and see with other widget like FileDialog.
My question is: can i use data inside GcodeDisplay and how can i read and use like my variables,
Or there is other recommended by you method (with other widget or module) so i can import csv file and manage data from the file.

Thanks a lot Chris,



Attachments:

Please Log in or Create an account to join the conversation.

More
09 Jan 2021 23:48 #194658 by cmorley
The gcode editor is fairly specialized to work as a gcode display.
It's possible to display other things but it's all custom work and the widget is not very friendly.
(for instance If type PREFERENCE in the MDI line of qtvcp screens, it will display the preference file.)

I did find this:
stackoverflow.com/questions/15416663/pyq...widget-with-csv-data

I assume it would display a table of the data.

getting the file widgets to return a file path rather then loading directly into the gcode display takes some coding.
fir instance - the file manager:
linuxcnc.org/docs/2.8/html/gui/qtvcp_cod..._file_manager_widget
The following user(s) said Thank You: Pro_El

Please Log in or Create an account to join the conversation.

Moderators: cmorley
Time to create page: 0.131 seconds
Powered by Kunena Forum