Toggle Button Label

  • Todd Zuercher
  • Todd Zuercher's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
20 Sep 2018 20:42 #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 or Create an account to join the conversation.

More
20 Sep 2018 20:56 - 20 Sep 2018 21:05 #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")
Attachments:
Last edit: 20 Sep 2018 21:05 by Grotius.

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

More
21 Sep 2018 02:13 #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
The following user(s) said Thank You: Todd Zuercher, tommylight, Grotius

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

More
21 Sep 2018 19:52 #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.
Attachments:

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

  • Todd Zuercher
  • Todd Zuercher's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
21 Sep 2018 20:50 #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 or Create an account to join the conversation.

Moderators: HansU
Time to create page: 0.106 seconds
Powered by Kunena Forum