2nd .ui file hal pins not showing
16 Mar 2023 11:21 - 16 Mar 2023 11:51 #266824
by blazini36
2nd .ui file hal pins not showing was created by blazini36
So I made a UI in designer which I'm currently trying to bring back up. It just has a basic Python file at the moment. I made it in 2 parts, a main ui and a config ui, the config ui replaces a frame widget in the main ui when a button is pressed. I had some help getting that to work in Python (I know very little about Python). I'm trying to get the halfiles converted while I wait for a programmer to help with the Python stuff.
Anyway I can load the ui and hit the button and the config ui pops in as it should, however the hal widgets in the config ui are not instantiating pins. The main ui's hal pins are coming up fine. Is there something that needs to be done in the python file to get this 2nd ui's pins to load?
this is pretty much the entirety of the Python file so far.[/code]
Anyway I can load the ui and hit the button and the config ui pops in as it should, however the hal widgets in the config ui are not instantiating pins. The main ui's hal pins are coming up fine. Is there something that needs to be done in the python file to get this 2nd ui's pins to load?
this is pretty much the entirety of the Python file so far.
############################
# **** IMPORT SECTION **** #
############################
import sys
import os
import linuxcnc
from PyQt5 import QtCore, QtWidgets, uic
from qtvcp.widgets.mdi_line import MDILine as MDI_WIDGET
from qtvcp.widgets.gcode_editor import GcodeEditor as GCODE
from qtvcp.widgets.stylesheeteditor import StyleSheetEditor as SSE
from qtvcp.lib.keybindings import Keylookup
from qtvcp.core import Status, Action
# Set up logging
from qtvcp import logger
LOG = logger.getLogger(__name__)
STATUS = Status()
ACTION = Action()
STYLEEDITOR = SSE()
class HandlerClass:
def __init__(self, halcomp,widgets,paths):
self.hal = halcomp
self.w = widgets
self.PATHS = paths
# widgets.CamFrame_Outer.findChildren(QtWidgets.QStackedWidget)
#
def initialized__(self):
camConfigUI = os.path.join(os.path.dirname(self.PATHS.XML), 'ConfigFrame.ui')
genClass, baseClass = uic.loadUiType(camConfigUI)
self.camConfigPanel = baseClass()
form = genClass()
form.setupUi(self.camConfigPanel)
self.stackedPage = self.w.CamFrame_Outer.findChildren(QtWidgets.QStackedWidget)[0]
self.stackedPage.addWidget(self.camConfigPanel)
def __getitem__(self, item):
return getattr(self, item)
def __setitem__(self, item, value):
return setattr(self, item, value)
def ButtonClicked(self):
index = self.stackedPage.currentIndex()
index = 1-index
self.stackedPage.setCurrentIndex(index)
def get_handlers(halcomp,widgets,paths):
return [HandlerClass(halcomp,widgets,paths)]
Also, is there some trick to get the ini file to accept a relative path for the ui file? All my extra hal files and #includes are done with relative paths with no issue.
[code]DISPLAY = qtvcp QtVCP_UI/uifile.ui
Just does not work, must be the exact absolute pathwhich makes development a little annoying
Last edit: 16 Mar 2023 11:51 by blazini36. Reason: clarify subject
Please Log in or Create an account to join the conversation.
16 Mar 2023 13:46 #266836
by Lcvette
Replied by Lcvette on topic 2nd .ui file hal pins not showing
moving, this is a qtvcp ui, probably will get more help from other qtvcp users.
The following user(s) said Thank You: cmorley
Please Log in or Create an account to join the conversation.
17 Mar 2023 00:00 #266869
by blazini36
Replied by blazini36 on topic 2nd .ui file hal pins not showing
Not sure what that means, I'm pretty sure I posted this in qtvcp. Did I click into the wrong forum and not realize it?
Please Log in or Create an account to join the conversation.
17 Mar 2023 01:53 #266877
by cmorley
Replied by cmorley on topic 2nd .ui file hal pins not showing
I would not suggest you build your screen in this way.
You will need to become a Qtvcp programming expert to make this work.
Qtvcp does quite a bit of work in the background to make widgets work seamlessly.
You are circumventing all that work by loading the ui file directly in python.
The technical problem is you need to initialize all the HAL-ified widgets manually after loading the ui. that is why they don't work properly.
There are several way to do what you are doing:
- don't use qtvcp widgets in your config ui
- use the qtvcp widgets but figure out how to initialize them properly.
- use qtvcp's embedding process (if the config stuff is self contained) You end up building two qtvcp panels and embed one into the other. Currently I don't think they can reference each other though.
- build everything in one ui file and get qtvcp to load it.
I'll look into the relative path problem.
You will need to become a Qtvcp programming expert to make this work.
Qtvcp does quite a bit of work in the background to make widgets work seamlessly.
You are circumventing all that work by loading the ui file directly in python.
The technical problem is you need to initialize all the HAL-ified widgets manually after loading the ui. that is why they don't work properly.
There are several way to do what you are doing:
- don't use qtvcp widgets in your config ui
- use the qtvcp widgets but figure out how to initialize them properly.
- use qtvcp's embedding process (if the config stuff is self contained) You end up building two qtvcp panels and embed one into the other. Currently I don't think they can reference each other though.
- build everything in one ui file and get qtvcp to load it.
I'll look into the relative path problem.
Please Log in or Create an account to join the conversation.
17 Mar 2023 08:23 - 17 Mar 2023 08:43 #266893
by blazini36
Replied by blazini36 on topic 2nd .ui file hal pins not showing
Had to backtrack on that post as I reread what you said about embedding. The doc only mentions the ini settings. Ive done this before with custom GladeVCP panels and Gmoccapy but I did not design gmoccapy obviously, just followed the instructions.
Is there some other info on QtVCP embedding from the perspective of you being the person that designed the main and embedded ui's?
Otherwise I'll have to either rely on the programmer to figure out if he can merge the ui files (the above Python script was just some garbage I threw together). Or I'll have to remake it into a single UI, which I'd rather not do manually because the 2nd ui was a pretty extensive configuration ui.
Is there some other info on QtVCP embedding from the perspective of you being the person that designed the main and embedded ui's?
Otherwise I'll have to either rely on the programmer to figure out if he can merge the ui files (the above Python script was just some garbage I threw together). Or I'll have to remake it into a single UI, which I'd rather not do manually because the 2nd ui was a pretty extensive configuration ui.
Last edit: 17 Mar 2023 08:43 by blazini36.
Please Log in or Create an account to join the conversation.
17 Mar 2023 10:28 #266899
by blazini36
Replied by blazini36 on topic 2nd .ui file hal pins not showing
Actually I was able to resolve that pretty easily. I opened both .ui's in designer and copied all of the widgets from the config ui to the main ui on top of a stacked page. Most of it is in a tabbed notebook so there wasn't even that much to copy
Please Log in or Create an account to join the conversation.
17 Mar 2023 18:00 #266926
by cmorley
Replied by cmorley on topic 2nd .ui file hal pins not showing
To try to answer your question about embedding, If your main ui has screen_options in it (and it should) then embedding can be set up to automatically embed with INI entries.
Then other Qtvcp panels can be embedded in to QStacked and QTab widgets.
O also assume you are using linux 2.9
Then other Qtvcp panels can be embedded in to QStacked and QTab widgets.
O also assume you are using linux 2.9
Please Log in or Create an account to join the conversation.
19 Mar 2023 12:22 #267083
by blazini36
Replied by blazini36 on topic 2nd .ui file hal pins not showing
Yeah, I didn't really read the qtvcp doc that great until after I made the UI....I was kind of on a roll once I got the hang of designer. From what I gather Screen_options adds some functionality that gladevcp didn't have. Right now it looks like the hal widgets are doing what I'd expect and as long as that's the case it should be fine, I pretty much just need this one to do what the old one did. Custom stuff was done in hal-python
One thing that's kind of driving me nuts and I'm not sure if it's a qtvcp thing or not. The [DISPLAY] line of the ini must reference the absolute path of the ui, relative is not working at all. I have a buch of #includes and halfiles that are referenced by the relative path in the ini and they all work fine. is there any way to get qtvcp to recognize the relative path to the ui?
One thing that's kind of driving me nuts and I'm not sure if it's a qtvcp thing or not. The [DISPLAY] line of the ini must reference the absolute path of the ui, relative is not working at all. I have a buch of #includes and halfiles that are referenced by the relative path in the ini and they all work fine. is there any way to get qtvcp to recognize the relative path to the ui?
Please Log in or Create an account to join the conversation.
20 Mar 2023 00:56 #267110
by cmorley
Replied by cmorley on topic 2nd .ui file hal pins not showing
What version of linuxcnc are you using?
Please Log in or Create an account to join the conversation.
20 Mar 2023 12:10 #267139
by blazini36
Replied by blazini36 on topic 2nd .ui file hal pins not showing
Working with 2.9 now
Please Log in or Create an account to join the conversation.
Moderators: cmorley
Time to create page: 0.078 seconds