- Posts: 5
- Thank you received: 0
Couldn't get the WARNING icon in LcncDialog
1 year 6 months ago #325379
by millikari
Couldn't get the WARNING icon in LcncDialog was created by millikari
Hi, I had a little trouble displaying the warning icon in a LcncDialog widget. I think it's caused by setting the default to INFO icon before checking WARNING and CRITICAL (dialog_widget.py in master 0fda49f):
Changing the sequence of the statements lets me choose also the WARNING icon.
Sorry, have some problems formatting the code passage in my message
Code:
# convert text descriptions to actual icons
if icon == 'QUESTION': icon = QMessageBox.Question
elif icon == 'INFO' or isinstance(icon,str): icon = QMessageBox.Information
elif icon == 'WARNING': icon = QMessageBox.Warning
elif icon == 'CRITICAL': icon = QMessageBox.Critical
self.setIcon(icon)
Changing the sequence of the statements lets me choose also the WARNING icon.
Code:
# convert text descriptions to actual icons
if icon == 'QUESTION': icon = QMessageBox.Question
elif icon == 'WARNING': icon = QMessageBox.Warning
elif icon == 'CRITICAL': icon = QMessageBox.Critical
elif icon == 'INFO' or isinstance(icon,str):icon = QMessageBox.Information
self.setIcon(icon)
Sorry, have some problems formatting the code passage in my message
Please Log in to join the conversation.
- snowgoer540
- Offline
- Platinum Member
-
Less
More
- Posts: 2580
- Thank you received: 0
1 year 6 months ago #325408
by snowgoer540
Replied by snowgoer540 on topic Couldn't get the WARNING icon in LcncDialog
It might be helpful to know how you are calling it?
Please Log in to join the conversation.
1 year 6 months ago #325424
by millikari
Replied by millikari on topic Couldn't get the WARNING icon in LcncDialog
Yes, I call it by connecting STATUS 'general' message and the ACTION.CALL_DIALOG:
A LcncDialog widget with matching launch-ID is defined in the ui-file. I have already checked whether the value of the 'icon'-variable is set correctly right before the statement I have shown in my first post (first code box). It's all fine. Looking at the original code, I think, because 'icon' is an instance of string in all cases, the 'WARNING' and 'CRITICAL' cases can never be reached. So I changed the sequence in order to give WARNING and CRITICAL also a chance getting active. Am I right with my consideration or have i missed something?
Code:
if STATUS.machine_is_on():
mess = {'NAME':'UNHOME_MSG', 'ID':'UNHOME_DIALOG',
'MESSAGE':'Really want to Un-Home?', 'TYPE':'YESNO', 'ICON':'WARNING'}
ACTION.CALL_DIALOG(mess)
A LcncDialog widget with matching launch-ID is defined in the ui-file. I have already checked whether the value of the 'icon'-variable is set correctly right before the statement I have shown in my first post (first code box). It's all fine. Looking at the original code, I think, because 'icon' is an instance of string in all cases, the 'WARNING' and 'CRITICAL' cases can never be reached. So I changed the sequence in order to give WARNING and CRITICAL also a chance getting active. Am I right with my consideration or have i missed something?
Please Log in to join the conversation.
- snowgoer540
- Offline
- Platinum Member
-
Less
More
- Posts: 2580
- Thank you received: 0
1 year 6 months ago #325431
by snowgoer540
Replied by snowgoer540 on topic Couldn't get the WARNING icon in LcncDialog
I made a few minutes to take a look at this tonight.
I do see the behavior you describe, although the order is not the root cause.
In this line: github.com/LinuxCNC/linuxcnc/blob/bd9034...ialog_widget.py#L201
it's this part that is causing issue:
The icon value is set correctly to 'WARNING' on the go-in, but because but because icon is of type str, the second condition "isinstance(icon, str)" evaluates to True, and therefore never gets to check for 'WARNING'.
Perhaps it’s meant to be a catch all, in that case I agree it should move to last, but I want Chris to weigh in before I change it as I'm not quite sure of the purpose (if typo should we tell the user there’s a typo?).
I do see the behavior you describe, although the order is not the root cause.
In this line: github.com/LinuxCNC/linuxcnc/blob/bd9034...ialog_widget.py#L201
Code:
elif icon == 'INFO' or isinstance(icon,str): icon = QMessageBox.Information
it's this part that is causing issue:
Code:
isinstance(icon,str)
The icon value is set correctly to 'WARNING' on the go-in, but because but because icon is of type str, the second condition "isinstance(icon, str)" evaluates to True, and therefore never gets to check for 'WARNING'.
Perhaps it’s meant to be a catch all, in that case I agree it should move to last, but I want Chris to weigh in before I change it as I'm not quite sure of the purpose (if typo should we tell the user there’s a typo?).
Please Log in to join the conversation.
1 year 6 months ago #325445
by cmorley
Replied by cmorley on topic Couldn't get the WARNING icon in LcncDialog
Yes its a catchall that should be at the end.
I think I added warning and critical after the others and didn't think of the logic.
Good eye gents!
I think I added warning and critical after the others and didn't think of the logic.
Good eye gents!
Please Log in to join the conversation.
- snowgoer540
- Offline
- Platinum Member
-
Less
More
- Posts: 2580
- Thank you received: 0
1 year 6 months ago #325486
by snowgoer540
Replied by snowgoer540 on topic Couldn't get the WARNING icon in LcncDialog
Please Log in to join the conversation.
Time to create page: 0.275 seconds
