Hi again, i have a gui code here. The button is half size of the main window and to great. Any idea how to make it smaller ?
_____________________________________________________
GTK2.Widget mainwindow,clickcnt,clicker; int clicks;
void click() { clickcnt->set_text("Clicks: "+(++clicks)); }
int main() { GTK2.setup_gtk(); mainwindow=GTK2.Window(GTK2.WindowToplevel); mainwindow->set_title("Click counter"); mainwindow->set_size_request(600, 500); mainwindow->set_position(GTK2.WIN_POS_CENTER); mainwindow->add(GTK2.Vbox(0,10) ->add(clickcnt=GTK2.Label("There have been no clicks yet")) ->add(clicker=GTK2.Button("Click me")) )->show_all(); mainwindow->signal_connect("delete_event",lambda() {exit(0);}); clicker->signal_connect("clicked",click); return -1; }
-- Sent from: http://pike.1058338.n5.nabble.com/Pike-Dev-f4605220.html
You are running into one of the unique (or frustrating depending on your view) behaviors of GTK widgets… By default, buttons and other sorts of widgets will attempt to expand… unless the Vbox is set to limit that, you’ll end up with huge buttons. You probably need to change the settings of the VBox you put the button into.There’s a setting on the VBox widget to set each element to the same size. You can also put the button into a Box of a set size.
Some of the GTK tutorials discuss how to deal with this… I think they call this “box packing”.
Bill
On Jan 27, 2018, at 7:42 PM, Hans Schueren werbung@hans-schueren.de wrote:
Hi again, i have a gui code here. The button is half size of the main window and to great. Any idea how to make it smaller ?
GTK2.Widget mainwindow,clickcnt,clicker; int clicks;
void click() { clickcnt->set_text("Clicks: "+(++clicks)); }
int main() { GTK2.setup_gtk(); mainwindow=GTK2.Window(GTK2.WindowToplevel); mainwindow->set_title("Click counter"); mainwindow->set_size_request(600, 500); mainwindow->set_position(GTK2.WIN_POS_CENTER); mainwindow->add(GTK2.Vbox(0,10) ->add(clickcnt=GTK2.Label("There have been no clicks yet")) ->add(clicker=GTK2.Button("Click me")) )->show_all(); mainwindow->signal_connect("delete_event",lambda() {exit(0);}); clicker->signal_connect("clicked",click); return -1; }
-- Sent from: http://pike.1058338.n5.nabble.com/Pike-Dev-f4605220.html
(For some reason the mail that Bill is replying to doesn't seem to have been imported?)
A simple way is to use "pack_end" instead of "add". Like so:
->pack_end(clicker=GTK2.Button("Click me"),0,0,0)
Thanks.
See you on the water.
-- Sent from: http://pike.1058338.n5.nabble.com/Pike-Dev-f4605220.html
pike-devel@lists.lysator.liu.se