GLADE Signals IN and OUT - Buttons won't work.

More
8 years 10 months ago #103743 by newbynobi
if you want to use python, try this:
Code:
image = gtk.Image() file = "TheNameOfYourGraficsFile.png" filepath = os.path.join(IMAGEDIR, file) image.set_from_file(filepath) btn = gtk.Button() btn.__name__ = "The Name of your button" btn.connect("clicked", your_signal, btn.__name__) btn.add(image) btn.show_all()

IMAGEDIR = the dir where you have placed you images
If you want also text on your button, use btn = gtk.Button("The Text on the Button")
btn.__name__ = "The Name of your button" not needed, I use that very often to check witch button did send the signal.
btn.show_all() di not use btn.show(), because than the image will not been shown.

Norbert

Please Log in to join the conversation.

More
8 years 10 months ago #103751 by Askjerry
Norbert - This only gives me more questions right now... because I am not yet familiar with where the instructions go to place the code or how to set up the relative path for the imagedir.

Attachment not found



As you can see... for each configuration file, I have two subdirectories, ./ROUTINES and ./IMAGES where the .ngc routines and images used in panels and splash screen live. In this case we would be working on GLADE Panel (1.1) in the CONFIG directory.

The code you described above... i presume it would be placed into the subdirectory with the machine.ini and refer to the subdirectory ./IMAGES yes?

Also... are the images placed, centered, or trimmed? In other words, if I made an image that looked like brushed aluminum that was larger than the current button... would it center and trim that image... or expand the button to fit? If the image were smaller... would it center it, zoom it to fit, or attempt to shrink the button? If the image had to be the exact size, i would need to screen capture the current button, then use GIMP or INKSCAPE to measure it and produce an image specific to that size button.... I just need to know how to handle it.

For now... I will presume that the image must be the same size as the button I want to change... and I will presume this image will live in the ./IMAGES folder.

I can take a screen shot and copy a button... in this case, the x-minus button from panel.glade.

Attachment not found



I can bring it into GIMP, then decorate it like this... and save it as button1a.png to be imported...

Attachment not found



So then I would take your code...
Code:
image = gtk.Image() file = "button1a.png" filepath = os.path.join("./IMAGES", file) image.set_from_file(filepath) btn = gtk.Button() btn.x-minus= "x-minus" btn.connect("clicked", your_signal, btn.x-minus) btn.add(image) btn.show_all()

So then... WHERE does this modified code go?
...and how do I let machine.ini know to run it??

let's say I called it "panel_graphics.py" and put it in the same directory as the machine.ini then I presume I either need to add a line to panel.glade or machine.ini to find it... which one? How?

Thanks,
Jerry

Please Log in to join the conversation.

More
8 years 10 months ago #103804 by newbynobi
Hallo Jerry,

your idea is right. How do you load your panel? With the code to load the panel in the ini file you can add a hal file and also a python handler file. You may take a look in gmoccapy/gmoccapy-plasma, as in this config a do use python handler files.

If you post your config, i may take a closer look and help with basic code.
According to my knowledge it is possible to shring and zoom images to fit certain space, but that is a little bit more code and you will need a pixbuffer for that.
Would be something like
Code:
import gtk pixbuf = gtk.gdk.pixbuf_new_from_file('/path/to/the/image.png') then scale it: pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR) Then, if you want use it in a gtk.Image, crate the widget and set the image from the pixbuf. image = gkt.Image() image.set_from_pixbuf(pixbuf) Or maybe in a direct way: image = gtk.image_new_from_pixbuf(pixbuf)
Norbert

Please Log in to join the conversation.

More
8 years 10 months ago #103806 by cmorley
you can do the same thing right from the glade editor -which is easier.
if you are going to use python though then you can have the image change if it's a toggle button.

Chris M

Please Log in to join the conversation.

More
8 years 10 months ago #103868 by Askjerry
I will see if I can find a simple SIM in my samples... and if I can... I'll add a simple GLADE panel to it... and supply a couple of image files. Then if one of you experts can make the changes... I'll see how they work and should be able to tinker from there. It may take me a day or two to get this uploaded... but I'll get that attachment posted.

Thanks in advance.
Jerry

Please Log in to join the conversation.

More
8 years 9 months ago #104072 by Askjerry
In order to not clutter this topic with button decoration, I started a topic and included a nice SIMULATED machine configuration that you can download to play with. ( LINK HERE )

Hopefully you can show me where/how to include the code so that I can get some of the colors and soforth as I have done with the pyVCP panels.

Thanks in advance.
Jerry

Please Log in to join the conversation.

More
7 years 4 months ago #138004 by dangu85
This button thing makes me mad. I created a simple gui with one led, one button and a slider to test things out and it doesn't work.... linuxcnc exits with error thinking the signal of the jog-slider does not exist in the gui. Without the hal directive in postgui.hal file, program starts correctly. I really don't n know what i'm doing wrong...:(
Files are generated by stepconf wizard for me. Link here:

Attachment not found

Please Log in to join the conversation.

More
7 years 4 months ago #138005 by cmorley
what is the exact error message?

Chris M

Please Log in to join the conversation.

More
7 years 4 months ago #138012 by dangu85
Pin gladevcp.jog-speed does not exist

Attachment not found

Please Log in to join the conversation.

More
7 years 4 months ago #138013 by cmorley
You have used a gtkHscale for your jog slider. That widget does not make HAL pins.
You need to use a HAL_hscale.

Chris M

Please Log in to join the conversation.

Time to create page: 0.071 seconds
Powered by Kunena Forum