Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Simple graphics in a GUI

Subject: Simple graphics in a GUI

From: Bethany

Date: 7 Apr, 2009 13:30:03

Message: 1 of 4

I need to create a flashing circle in a GUI, and want to know what my options are. This need for some sort of simple graphic to occur within a GUI keeps arising as I program stimulus experiments for a research lab.

So far, I have only been able to create pushbuttons and use the Cdata property with .bmp images I create. This works well (I have my flashing circle all ready to go), but with one problem: I cannot get rid of the rectangular outline of the pushbutton, so the image always appears in a box and not on a simple background, which can be distracting to subjects.

Does anyone know how to make this outline invisible (without making the button invisible, of course)? What about other options for displaying graphics within a GUI?

thanks in advance,
Bethany

Subject: Simple graphics in a GUI

From: Jonathan

Date: 8 Apr, 2009 13:12:02

Message: 2 of 4

"Bethany " <bmoore33.omit@gmail.com> wrote in message <grfkgr$t3v$1@fred.mathworks.com>...
> I need to create a flashing circle in a GUI, and want to know what my options are. This need for some sort of simple graphic to occur within a GUI keeps arising as I program stimulus experiments for a research lab.
>
> So far, I have only been able to create pushbuttons and use the Cdata property with .bmp images I create. This works well (I have my flashing circle all ready to go), but with one problem: I cannot get rid of the rectangular outline of the pushbutton, so the image always appears in a box and not on a simple background, which can be distracting to subjects.
>
> Does anyone know how to make this outline invisible (without making the button invisible, of course)? What about other options for displaying graphics within a GUI?
>
> thanks in advance,
> Bethany

Bethany-

You have asked a relatively broad question, but I will do my best to help you out on this one.

Is there any particular reason why you are placing the imagedata on a pushbutton? It seems as though you are trying to display the bitmap image (I'm assuming the circle image) and somehow have the user be able to click on it? A better solution would probably be to use an axes and display the imagedata on the axis using imshow/imagesc/image etc. To do this:

1) Load image data using imread for your bitmap
2) Create axes
3) Create image with axes as parent (imagesc(imdata,'parent',axesHandle))
4) You can use "axis image" to get your scaling on the axes correct
5) If you want, you can use "set(axesHandle,'visible','off')" so that you don't see the axes (this would get rid of any borders around the circle image)
6) Set a button down callback for the image ( set(imageHandle,'ButtonDownFcn',@mouseClickCallback))
7) Then create the function mouseClickCallback and have it do whatever you need the pushbutton you used to do.

As far as flashing, I am not sure exactly what you want, i would recommend changing the "visible" property of the image to on/off for blinking on/off.

I hope that this helps somewhat. If you can clarify a little bit maybe we will be able to help you out a little more.

-Jonathan

Subject: Simple graphics in a GUI

From: Bethany

Date: 10 Apr, 2009 14:04:01

Message: 3 of 4

Jonathan,

Thanks for the reply! I actually don't need the user to click on the image; I really just want to display something "arbitrary" on the GUI (i.e. not one of UIcontrol options), and often I want to animate it in some way. This has come up several times, hence the broad question.

I'm not sure why I didn't use an axis - I guess because I usually need the image to be small, it didn't occur to me. (I've usually used these to display larger graphs.) That sounds like the solution, though. I will give that a go and see how it works!

Thanks again,
Bethany

Subject: Simple graphics in a GUI

From: Bethany

Date: 14 Apr, 2009 13:42:02

Message: 4 of 4

Axes worked beautifully - thanks!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us