# AddButton function when writing a GUI

**URL:** <https://root-forum.cern.ch/t/addbutton-function-when-writing-a-gui/34640>\
**Category:** Newbie\
**Created:** [June 17, 2019, 5:28am UTC](https://root-forum.cern.ch/t/addbutton-function-when-writing-a-gui/34640 "2019-06-17T05:28:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ReynLieu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/a5b964/32.png) [@ReynLieu](https://root-forum.cern.ch/u/ReynLieu)\
**Post date:** [June 17, 2019, 5:28am UTC](https://root-forum.cern.ch/t/addbutton-function-when-writing-a-gui/34640/1 "2019-06-17T05:28:46Z")

</div>

Hi ROOTers,

I find that the declaration of TControlBar::AddButton() can be like “void TControlBar::AddButton ( const char\* label, const char\* action, const char\* hint = “”, const char\* type = “button”)”  
I wonder what are the other options of the argument “type”. I have no idea where to find such information.

I am to write a GUI so that I can input a number as an argument for another macro and then click a button to run that macro. But I don’t know how to change the plain button into a textbox so that I can set the number. Can I use TControlBar::AddButton() to make it?

Thanks,  
Reyn

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [June 17, 2019, 8:30am UTC](https://root-forum.cern.ch/t/addbutton-function-when-writing-a-gui/34640/2 "2019-06-17T08:30:39Z")

</div>

> [@ReynLieu](#):
>
> Can I use TControlBar::AddButton() to make it?

No, see [TControlBarButton::SetType()](https://root.cern.ch/doc/master/classTControlBarButton.html#a31f95b3bae51fe4b4e5041e49166cbfc).  
If you need complex GUI widgets, you can use the ones in `$(ROOTSYS)\macros\Dialogs.C` or create your own (you can take a look at examples in `$(ROOTSYS)\tutorials\gui`)

---

<div class="post-metadata">

**Author:** ![ReynLieu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/a5b964/32.png) [@ReynLieu](https://root-forum.cern.ch/u/ReynLieu)\
**Post date:** [June 18, 2019, 6:54am UTC](https://root-forum.cern.ch/t/addbutton-function-when-writing-a-gui/34640/3 "2019-06-18T06:54:31Z")

</div>

Thanks. Now I solve this by loading the “Dialog.C” and add a button in my macro to run the GetIntegerDialog function, so as to set value of a variable. (However, this needs two dialog boxes rather than a single one.)

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [June 18, 2019, 7:00am UTC](https://root-forum.cern.ch/t/addbutton-function-when-writing-a-gui/34640/4 "2019-06-18T07:00:04Z")

</div>

Note that you can create your own dialog…

---

<div class="post-metadata">

**Author:** ![ReynLieu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/a5b964/32.png) [@ReynLieu](https://root-forum.cern.ch/u/ReynLieu)\
**Post date:** [June 18, 2019, 7:04am UTC](https://root-forum.cern.ch/t/addbutton-function-when-writing-a-gui/34640/5 "2019-06-18T07:04:11Z")

</div>

Yeah I see. I try to learn about TGWidget and so on, and write a class to accomplish that. Thanks for your help!
