LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-28-2019, 06:15 PM   #1
RickM
LQ Newbie
 
Registered: Jan 2019
Posts: 24

Rep: Reputation: Disabled
Javascript - 2 buttons in a window


I can't find out how to do this anywhere

Can someone modify the following code so I get two buttons in a window?

Thankyou

const Gtk = imports.gi.Gtk;

Gtk.init(null);

const header = new Gtk.HeaderBar();
header.set_title("GJS");
header.set_subtitle("An app made with GJS");
header.set_show_close_button(true);

const window = new Gtk.Window();
window.window_position = Gtk.WindowPosition.CENTER;
window.connect('destroy', Gtk.main_quit);
window.set_default_size(350, 70);
window.set_titlebar(header);
window.border_width = 10;

window.add(new Gtk.Button({ label: "Hello GJS" }));
window.show_all ();

Gtk.main();
 
Old 01-28-2019, 07:23 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Asking others to write or modify your code is not an acceptable use of the Programming forum.

It would be better if you could explain what the example code is supposed to do, how it is failing to work as desired and what you have tried in order to fix it.

Please review the Site FAQ for guidance in posting your questions and general forum usage. Especially, read the link in that page, How To Ask Questions The Smart Way. The more effort you put into understanding your problem and framing your questions, the better others can help!
 
Old 01-28-2019, 07:33 PM   #3
RickM
LQ Newbie
 
Registered: Jan 2019
Posts: 24

Original Poster
Rep: Reputation: Disabled
the code successfully puts one button into a window but nowhere can I find out how to put two buttons in a window

It is extremely simple but I am new and can find nowhere that this is explained
 
Old 01-29-2019, 08:54 AM   #4
RickM
LQ Newbie
 
Registered: Jan 2019
Posts: 24

Original Poster
Rep: Reputation: Disabled
and 12 hours later by trial and error I made it work - sure wish there was some web place to teach such basics

const Gtk = imports.gi.Gtk;

Gtk.init(null);

const header = new Gtk.HeaderBar();
header.set_title("GJS");
header.set_subtitle("An app made with GJS");
header.set_show_close_button(true);

const window = new Gtk.Window();
window.window_position = Gtk.WindowPosition.CENTER;
window.connect('destroy', Gtk.main_quit);
window.set_default_size(350, 70);
window.set_titlebar(header);
window.border_width = 10;

// Create the grid
let grid = new Gtk.Grid ();

// Create the widgets inside the grid
let button1 = new Gtk.Button ({ label: "Button 1" });

let button2 = new Gtk.Button ({ label: "Button 2" });
//button1.connect ("clicked", _clickHandler.bind());

// Assemble the grid
window.add (grid);
grid.attach (button1, 1, 1, 1, 1);
grid.attach_next_to (button2, button1, Gtk.PositionType.RIGHT, 1, 1);

//window.add(new Gtk.Button({ label: "Hello GJS" }));
window.show_all ();

Gtk.main();
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript: enter key handling with multiple submit buttons? BrianK Programming 2 09-18-2007 12:50 PM
Mouse back and forward buttons are interpreted as buttons 2 and 3 (MX610) jot-87 Linux - Hardware 1 08-06-2007 11:12 AM
Help binding mouse buttons to keyboard buttons Eckstona Linux - Hardware 6 09-24-2006 07:28 AM
Javascript - what to use rather than window.close() then window.open() davee Programming 2 04-11-2005 08:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration