Gå til innhold

GTKmm, enkel ABC-løser, 3 entry, 1 button?


Anbefalte innlegg

Hei!

 

Jeg er altså ny med GTKmm og vil lage det programmet jeg lager når jeg skal lære noe nytt, altså en ABC løser. Dette gjelder forsovidt rammeverk og språk, uansett.

Nok om det, Gtk::Window er en container men kan bare ha en widget, altså man må planlegge hele layouten før man starter å programmerere. Jeg har lagde enkle programmer med bare Entry og bare med Button.

 

Nå trenger jeg altså 3 entry, gjerne med en label over som sier hvilken verdi som skal inn i entryen under.

Under entryene er det altså en knapp/button.

 

Det blir vel omtrent slik:

 

label label label

entry entry entry

Button

 

Dette er lettere sagt enn gjort, jeg har sett på baseclasen til "container" og andre widget.

Jeg fikk også til eventgreiene, så det er inne.

Har brukt det før... men denne måten å skrive GUI er ikke prøvd før.

 

Håper på litt hjelp her.

Takk på forhånd! :)

 

Edit:

 

Jeg bruker Gtk::Table, den ser bra ut, men den er jo helt umulig å bruke.

Kan noen forklare meg paramterene?

Endret av rat911
Lenke til kommentar
Videoannonse
Annonse

Jeg tror det er like så greit å bruke hbox og vbox istedenfor table. For eksempel en vbox delt i to deler: topp og button. Så deler du toppen i tre med en hbox som kan inneholde en hbox eller vbox for hver label og entry.

 

Har du prøvd Glade? Det er enklere.

Endret av tsg1zzn
Lenke til kommentar

Har sett på glade ja, men vil klare dette også.

Kan du hjelpe og tolke følgende tekst:

 

Adding widgets

 

To place a widget into a box, use the following method:

 

void Gtk::Table::attach(Gtk::Widget& child,

                        guint left_attach, guint right_attach,

                        guint top_attach, guint bottom_attach,

                        guint xoptions = Gtk::FILL | Gtk::EXPAND,

                        guint yoptions = Gtk::FILL | Gtk::EXPAND,

                        guint xpadding = 0, guint ypadding = 0);

 

The first argument is the widget you wish to place in the table.

 

The left_attach and right_attach arguments specify where to place the widget, and how many boxes to use. For example, if you want a button in the lower-right cell of a 2 x 2 table, and want it to occupy that cell only, then left_attach would be 1, right_attach 2, top_attach 1, and bottom_attach 2. If, on the other hand, you wanted a widget to take up the entire top row of our 2 x 2 table, you'd set left_attach = 0, right_attach = 2, top_attach = 0, and bottom_attach = 1.

 

xoptions and yoptions are used to specify packing options and may be bitwise ORed together to allow multiple options. These options are:

 

Gtk::FILL

 

    If the table box is larger than the widget, and Gtk::FILL is specified, the widget will expand to use all the room available.

Gtk::SHRINK

 

    If the table widget is allocated less space than it requested (because the user resized the window), then the widgets will normally just disappear off the bottom of the window. If Gtk::SHRINK is specified, the widgets will shrink with the table.

Gtk::EXPAND

 

    This will cause the table to expand to use up anyremaining space in the window.

 

The padding arguments work just as they do for pack_start().

 

 

Update:

 

Var enklere enn jeg trodde, ting må være super-high-tech oppi hodet mitt, noen ganger er faktisk ting ganske enkelt.

Ganske genialt egentlig. :D

Endret av rat911
Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...