Engine information panel
26 Jul 2023 18:45 #276319
by MarkoPolo
Replied by MarkoPolo on topic Engine information panel
I have my own panel, is it possible to apply a separate qss theme file to it? so that it takes precedence over the main qtdragon theme to set the font size independent of the main qtdragon theme. If so, how to do it?
Marek
Marek
Please Log in or Create an account to join the conversation.
26 Jul 2023 21:38 #276327
by cmorley
Replied by cmorley on topic Engine information panel
There is no way to add a second, separate theme file.
The trick is to reference the widget's name in an editted QSS file.
Something like this:
#label1_name, #label2_name {
font: 25pt "Lato Heavy";
}
The trick is to reference the widget's name in an editted QSS file.
Something like this:
#label1_name, #label2_name {
font: 25pt "Lato Heavy";
}
Please Log in or Create an account to join the conversation.
26 Jul 2023 23:06 #276331
by MarkoPolo
Replied by MarkoPolo on topic Engine information panel
Yes, the entries in the main theme file work for me. I wanted to make the appearance of this panel independent of the theme selected in qtdragon, but if it is not possible, then there is no big problem.
Please Log in or Create an account to join the conversation.
27 Jul 2023 16:44 #276385
by cmorley
Replied by cmorley on topic Engine information panel
I found away to add separate stylesheet commands without affecting the original.
If you are using linuxcnc 2.9, QtVCP will support 'user command file'.
We can use this file to add stylesheet commands like this:
Save the above commands in a file in your configuration file named user_file.py
add the command in your INI under [DISPLAY] (change 'pth to file' to the actual path from your home directory)
USER_COMMAND_FILE = ~/path to file/user_file.py
then edit the string to add style sheet commands. The sample will change the manual mode button text size.
Chris
If you are using linuxcnc 2.9, QtVCP will support 'user command file'.
We can use this file to add stylesheet commands like this:
print('\nuser command file found\n')
# needed to instance patch
# reference: https://ruivieira.dev/python-monkey-patching-for-readability.html
import types
# This will be used to override the existing function in the handler class instance
def before_loop__(self):
# record the existing stylesheet
sht = self.w.styleSheet()
# add our changes to the end of the original stylesheet
self.w.setStyleSheet(sht+'''
#label1_name, #label2_name,#manual_mode_button {
font: 25pt "Lato Heavy";
}
''')
# Here we are instance patching the original handler file to add a new
# function that calls our new function (of the same name)
# defined in this file
self.before_loop__ = types.MethodType(before_loop__, self)
Save the above commands in a file in your configuration file named user_file.py
add the command in your INI under [DISPLAY] (change 'pth to file' to the actual path from your home directory)
USER_COMMAND_FILE = ~/path to file/user_file.py
then edit the string to add style sheet commands. The sample will change the manual mode button text size.
Chris
Please Log in or Create an account to join the conversation.
27 Jul 2023 20:44 #276400
by MarkoPolo
Replied by MarkoPolo on topic Engine information panel
Great. The method you came up with works, albeit with a small problem.
I have an entry that in the main qss file works fine, but in the user_file.py file
only the "QLabel#labelinfo_motor_" entries work, while the "QLineEdit" fields do not want to change the font size.
I have no idea why that is.
QLabel#labelinfo_motor_1,
QLabel#labelinfo_motor_2,
QLabel#labelinfo_motor_3,
QLabel#labelinfo_motor_4,
QLabel#labelinfo_motor_5,
QLabel#labelinfo_motor_6,
QLabel#labelinfo_motor_7,
QLabel#labelinfo_motor_8,
QLineEdit#lineEdit_motor_1,
QLineEdit#lineEdit_motor_2,
QLineEdit#lineEdit_motor_3,
QLineEdit#lineEdit_motor_4,
QLineEdit#lineEdit_motor_5,
QLineEdit#lineEdit_motor_6,
QLineEdit#lineEdit_motor_7,
QLineEdit#lineEdit_motor_8{
font: 16pt "Lato Heavy";
}
Another thing, I tried to run user_file.py from my motor_info_handler.py handler file but it somehow doesn't want to work.
I tried to do it so that you don't have to make an entry in the main ini file.
Marek
I have an entry that in the main qss file works fine, but in the user_file.py file
only the "QLabel#labelinfo_motor_" entries work, while the "QLineEdit" fields do not want to change the font size.
I have no idea why that is.
QLabel#labelinfo_motor_1,
QLabel#labelinfo_motor_2,
QLabel#labelinfo_motor_3,
QLabel#labelinfo_motor_4,
QLabel#labelinfo_motor_5,
QLabel#labelinfo_motor_6,
QLabel#labelinfo_motor_7,
QLabel#labelinfo_motor_8,
QLineEdit#lineEdit_motor_1,
QLineEdit#lineEdit_motor_2,
QLineEdit#lineEdit_motor_3,
QLineEdit#lineEdit_motor_4,
QLineEdit#lineEdit_motor_5,
QLineEdit#lineEdit_motor_6,
QLineEdit#lineEdit_motor_7,
QLineEdit#lineEdit_motor_8{
font: 16pt "Lato Heavy";
}
Another thing, I tried to run user_file.py from my motor_info_handler.py handler file but it somehow doesn't want to work.
I tried to do it so that you don't have to make an entry in the main ini file.
Marek
Please Log in or Create an account to join the conversation.
27 Jul 2023 22:06 #276405
by cmorley
Replied by cmorley on topic Engine information panel
I don't know either - QEditLine seem to work for me (bit i'm calling a main screen widget)
try dropping the QEditLine:
self.w.setStyleSheet(sht+'''
#label1_name, #label2_name,#manual_mode_button, #lineEdit_eoffset_count {
font: 25pt "Lato Heavy";
}
''')
yes the embedded panels don't currently do all the same things the main screen does.
It gets pretty complicated at that point and it was outside my idea of use cases.
Though I may be able to make it so you could program the style sheet inside the panel's handler file.
Chris
try dropping the QEditLine:
self.w.setStyleSheet(sht+'''
#label1_name, #label2_name,#manual_mode_button, #lineEdit_eoffset_count {
font: 25pt "Lato Heavy";
}
''')
yes the embedded panels don't currently do all the same things the main screen does.
It gets pretty complicated at that point and it was outside my idea of use cases.
Though I may be able to make it so you could program the style sheet inside the panel's handler file.
Chris
Please Log in or Create an account to join the conversation.
28 Jul 2023 01:31 #276417
by cmorley
Replied by cmorley on topic Engine information panel
I pushed a bit of code to 2.9/master, if you compile your code we could try some other tricks.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
28 Jul 2023 19:46 #276476
by MarkoPolo
Replied by MarkoPolo on topic Engine information panel
It still didn't want to work as it should, I managed to do it a little differently, probably in the simplest way possible. In my handler file "motor_info_handler.py" I just added this entry and it works as I wanted.
self.w.setStyleSheet('''
IndicatedPushButton{
font: 10pt "Lato Heavy";
}
QLabel{
font: 10pt "Lato Heavy";
}
#labelinfo_motor_1,
#labelinfo_motor_2,
#labelinfo_motor_3,
#labelinfo_motor_4,
#labelinfo_motor_5,
#labelinfo_motor_6,
#labelinfo_motor_7,
#labelinfo_motor_8,
#lineEdit_motor_1,
#lineEdit_motor_2,
#lineEdit_motor_3,
#lineEdit_motor_4,
#lineEdit_motor_5,
#lineEdit_motor_6,
#lineEdit_motor_7,
#lineEdit_motor_8{
font: 16pt "Lato Heavy";
}
''')
The downside is that it does not inherit anything from the main style, each element must be defined.
The advantage is simplicity, and you don't have to restart qtdragon after changing the style like before.
Marek
self.w.setStyleSheet('''
IndicatedPushButton{
font: 10pt "Lato Heavy";
}
QLabel{
font: 10pt "Lato Heavy";
}
#labelinfo_motor_1,
#labelinfo_motor_2,
#labelinfo_motor_3,
#labelinfo_motor_4,
#labelinfo_motor_5,
#labelinfo_motor_6,
#labelinfo_motor_7,
#labelinfo_motor_8,
#lineEdit_motor_1,
#lineEdit_motor_2,
#lineEdit_motor_3,
#lineEdit_motor_4,
#lineEdit_motor_5,
#lineEdit_motor_6,
#lineEdit_motor_7,
#lineEdit_motor_8{
font: 16pt "Lato Heavy";
}
''')
The downside is that it does not inherit anything from the main style, each element must be defined.
The advantage is simplicity, and you don't have to restart qtdragon after changing the style like before.
Marek
Please Log in or Create an account to join the conversation.
Moderators: cmorley
Time to create page: 0.163 seconds