- Posts: 4739
- Thank you received: 2
Toggle Button Label
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
-
Less
More
8 years 1 month ago #117820
by Todd Zuercher
Toggle Button Label was created by Todd Zuercher
Is there an easy way to make the label on a button reflect the sate of the button. For exampl how would you make a button that says On when pressed and Off when released?
Please Log in to join the conversation.
8 years 1 month ago #117822
by Grotius
Replied by Grotius on topic Toggle Button Label
Hi Todd,
In python my code to change the picture on the button, in fact i have a 3 state button :
Red = external emergency, Orange = internal emergency, Green = machine on.
self.widgets.machine_on_button.set_image(self.widgets.red)
self.widgets.machine_on_button.set_image(self.widgets.green)
self.widgets.machine_on_button.set_image(self.widgets.orange)
In your case the basic code can be : Togglebutton1.set_image(red)
My pictures are located in share/linuxcnc, this because this is in the python code :
imagedir = os.path.join(BASE, "share", "linuxcnc")
In glade you can attach a picture to a button. In your case a ON picture and a OFF picture.
Good luck !!
It you have problem's post your python code and glade file.
If you separate this button in the GNU image manipulation program, it cerntainly will work.
You can make very beautifull screen desig's with this feature.
If you want to make a black screen design :
self.settings = gtk.settings_get_default()
self.settings.set_property("gtk-theme-name", "Adwaita-dark")
In python my code to change the picture on the button, in fact i have a 3 state button :
Red = external emergency, Orange = internal emergency, Green = machine on.
self.widgets.machine_on_button.set_image(self.widgets.red)
self.widgets.machine_on_button.set_image(self.widgets.green)
self.widgets.machine_on_button.set_image(self.widgets.orange)
In your case the basic code can be : Togglebutton1.set_image(red)
My pictures are located in share/linuxcnc, this because this is in the python code :
imagedir = os.path.join(BASE, "share", "linuxcnc")
In glade you can attach a picture to a button. In your case a ON picture and a OFF picture.
Attachment not found
Good luck !!
It you have problem's post your python code and glade file.
If you separate this button in the GNU image manipulation program, it cerntainly will work.
You can make very beautifull screen desig's with this feature.
Attachment not found
If you want to make a black screen design :
self.settings = gtk.settings_get_default()
self.settings.set_property("gtk-theme-name", "Adwaita-dark")
Please Log in to join the conversation.
8 years 1 month ago #117834
by cmorley
Replied by cmorley on topic Toggle Button Label
If you are using linuxcnc's gladevcp = you can use a hal_light_button
Chris M
Chris M
Please Log in to join the conversation.
8 years 1 month ago #117856
by Grotius
Replied by Grotius on topic Toggle Button Label
Hi Chris,
Hhaa.. whoehoe.
I have never tried this. But indeed. It's the most easyest way. Perfect.
Hhaa.. whoehoe.
I have never tried this. But indeed. It's the most easyest way. Perfect.
Attachment not found
Attachment not found
Please Log in to join the conversation.
- Todd Zuercher
- Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 4739
- Thank you received: 2
8 years 1 month ago #117857
by Todd Zuercher
Replied by Todd Zuercher on topic Toggle Button Label
Thank you Chris that is exactly what I wanted.
Please Log in to join the conversation.
Time to create page: 0.095 seconds
