NiGui
NiGui copied to clipboard
BackgroundColor
I do something like this:
# setup for queryButton
var queryButton = newButton(" Run Query ")
queryButton.fontSize = 18
queryButton.textColor = rgb(30,144,255) # color ok
queryButton.backGroundcolor = rgb(0,255,0) # no effect ?
rightMenuContainer.add(queryButton)
textColor method works for button and labels only other controls eg textBox does not show any text or background color changes at all.
PS.: nigui is really nice and hopefully there will be a comboBox widget I am using it to display output from sql queries. Here running under openSuse Tumbleweed .
As far as I know, the underlying platforms Gtk and WinAPI do not allow to change the background color of a button (resp. it has no effect). This is something which should be mentioned in the upcoming NiGui documentation.
If you want to have a button with a specific background color, you can create a custom control based on the type Button. Here an example implementation of a custom button. The main program has to use newToolbarButton()
instead of newButton()
.
type ToolbarButton* = ref object of Button
proc newToolbarButton*(text = ""): ToolbarButton =
result = new ToolbarButton
result.init()
result.text = text
method handleDrawEvent*(control: ToolbarButton, event: DrawEvent) =
let canvas = event.control.canvas
canvas.areaColor = control.backgroundColor
canvas.textColor = control.textColor
canvas.lineColor = control.textColor
canvas.drawRectArea(0, 0, control.width, control.height)
canvas.drawTextCentered(control.text)
canvas.drawRectOutline(0, 0, control.width, control.height)
Thanks for your feedback :)
Well in Gtk you can do this: https://stackoverflow.com/questions/1706550/gtk-modifying-background-color-of-gtkbutton, and for WinAPI you have this: http://winprog.org/tutorial/dlgfaq.html
Is this issue still up to date?
Yes. Same issue than #152.