Can ttk radiobuttons be made to have style Toolbutton by default? - radio-button

I can set Toolbutton style for individual radiobuttons:
#!/bin/sh
# \
exec /usr/bin/wish "$0" "$#"
set X11 /usr/X11/include/X11/bitmaps
image create bitmap LeftImage -file "$X11/left_ptr"
image create bitmap RightImage -file "$X11/right_ptr"
ttk::radiobutton .left -variable Foo -image LeftImage -style Toolbutton
ttk::radiobutton .right -variable Foo -image RightImage
pack .left .right
But I can't figure out how to make them all have Toolbutton style by default, ie, without having to specify it for every one separately.

You can style 'TRadiobutton', which is the default style for radio buttons.

Related

Codename one Radio Buttons in a ButtonGroup

#Shai According to the image below got from CleanMordern Project.
how can I style my radio buttons using CSS to look exactly as Shai did his,
and also make actions on each button to show different container when pressed
ButtonGroup barGroup = new ButtonGroup();
RadioButton all = RadioButton.createToggle("All", barGroup);
all.setUIID("SelectBar");
RadioButton featured = RadioButton.createToggle("Featured", barGroup);
featured.setUIID("SelectBar");
RadioButton popular = RadioButton.createToggle("Popular", barGroup);
popular.setUIID("SelectBar");
RadioButton myFavorite = RadioButton.createToggle("My Favorites", barGroup);
myFavorite.setUIID("SelectBar");
Label arrow = new Label(res.getImage("news-tab-down-arrow.png"), "Container");
add(LayeredLayout.encloseIn(
GridLayout.encloseIn(4, all, featured, popular, myFavorite),
FlowLayout.encloseBottom(arrow)
));
You can open the theme file in the designer tool and just copy the styling from there. I implemented this using image backgrounds to keep some pixels free for the arrow on the bottom.
If you look at the theme you will see I just placed a background image that's solid red on top and has a white bottom. Then I have a separate "arrow" image which is animated with the code to the selected button on every click. Everything else is just colors and fonts which is trivial.

Not able to set the Backcolor of label as Transparent

Using properties of "label" not able to set the backcolor as transparent ... when i select the color transparent from the option which is showing some color as backcolor, if transparent works properly must show background instead of some colors. please help
If you add a control at design time when setting the background to transparent it 'displays' the background of the form not the control on which it was placed unless that control is a container such as a panel.
2 options:
1 place the label on a panel and the label then displays the panel background (which can be a picture if that is what you are trying to do)
2 place the label programatically i.e.
dim Label1 As New Label
Control.Controls.Add(Label1)
Label1.BackColor = Color.Transparent

Radio button clicked twice in row return error

I am using 5 radio buttons which when invoked it creates new widgets that are specific to each button. However, once widgets are created you cannot have the same widget created with the same path name or an error is displayed. The radio buttons are able to be clicked more than once which creates the error mentioned before. Is there anyway to either restrict pressing the same radio button twice in a row or keep the window from trying to be recreated?
use [winfo exists]. something like this:
radiobutton .r1 -text 1 -value 1 -variable radiovalue -command make_widget
radiobutton .r2 -text 2 -value 2 -variable radiovalue -command make_widget
pack .r1 .r2
proc make_widget {} {
global radiovalue
set name .widget_$radiovalue
if {[winfo exists $name]} {
puts "$name already exists"
} else {
pack [label $name -text $name]
}
}
You could disable the radio button that is pressed until another is pressed or you could delete the existing set of widgets if any before creating any.

Button width - wrap content (Sencha touch 2)

How can I set button width to wrap content?
Default html button wraps content, but default sencha button use all width of parent.
Next question. If button width wraps content, how to align button?
Thanks
As far as I know, there is no Ext.Button config like textWrap: true in Sencha Touch 2. But you can try a work-around. Normally you can use width and height config to set absolute size of the button, and minWidth, maxWidth or minHeight, maxHeight for the lowerbound and upperbound of width and height, you should combine them with CSS styles of your text.
About alignment: Ext.Button is just like other Ext components, if it belongs to a parent container, then the config centered:true should align it to the center of the parent container.

Titanium: How to remove background of Search bar?

How can I remove the background of search bar ? I tried by changing background color but it also changes cancel button's color !!!
Thanks...
The best alternative to this is creating a custom search bar with Ti.UI.textField and Ti.UI.button. Add them both to a view and customize it as you please. Finally, just add an event listener to the button click, and voila!
Take a look at this Module: https://github.com/viezel/NappUI
It extends the properties for several UI Elements, including SearchBar, here is the list.
SearchField BackgroundImage
Custom Cancel button
barColor - background gradient of the button. (similar to navbar)
color - color of the button title
title - change the default Cancel text
font - set the font of the button
Appearance of the keyboard
Disable the search icon
To install it, I recommend you to use the new gitTio command line, this will automatically download the module, install it on the modules folder on Application Support folder and add the proper config line on tiapp.xml.
gittio install -g dk.napp.ui
And here is an example of a SearchBar using the new properties enabled by this Module
var searchBar = Ti.UI.createSearchBar({
searchFieldBackgroundImage:"searchbg.png",
showsScopeBar:true,
scopeButtonTitles:["hello", "yes"],
customCancel:{
barColor:"#333",
color:"#ddd",
title:"Hit me",
font:{
fontSize:16,
fontWeight:"bold",
fontFamily:"Georgia"
}
},
appearance:Titanium.UI.KEYBOARD_APPEARANCE_ALERT,
barColor:"transparent",
disableSearchIcon:true //disables the search icon in the left side
});
If you are talking about the gradient blue, I removed it on my app with:
var searchBox = Ti.UI.createSearchBar({
barColor: '#eee'
});
Hope this helps.
Unfortunately 'barColor' doesn't work. Ti seems to change the color by changing the opacity or hue or something. DannyM's workaround is the best.
I must have wasted a zillion hours making sense of Titanium's background colors, background images, bar colors and their active/inactive cousins.
Conclusion: "Free" software is costly if you count the time you waste on silly bugs and lack of useful documentation.