[Glade-users] how to create a sudoku gui



On Tue, Dec 20, 2011 at 1:04 AM, karthik s <suryak at live.com> wrote:


Date: Mon, 19 Dec 2011 23:08:35 +0900
Subject: Re: [Glade-users] how to create a sudoku gui
From: tristan.van.berkom at gmail.com
To: suryak at live.com
CC: glade-users at lists.ximian.com


Hi,
There are few ways you could make such a UI.

GTK+ menuing system has a grid mode which might be interesting to use,
using a grid-like menu might make it easier to use and more portable to
a handheld (or touchscreen) environment.

If you want to use an entry and go back and forth from
keyboard/mouse-finger
input... you will have to police the entry content quite a bit, make
sure it only
accepts numeric input and only allow a single character at a time,
probably
by selecting the current character (if any) at all times that the
entry is focused.

To force the entry size, set the "width-chars" property of GtkEntry to
a reasonable
value like 1 (otherwise you will always require a hard coded minimum width
for
the entry).

Cheers,
-Tristan



On Mon, Dec 19, 2011 at 9:01 PM, karthik s <suryak at live.com> wrote:
I am done with command line interface of sudoku solver. Now, I am onto
GUI
building. I am absolutely new to GUI and so to glade. (I use C)

Well, I created a frame and on it dropped a 'table' container of 9-by-9
size. Now, I am trying to put a 'text entry' control in each container.
The 'Text Entry's' I have created are very long (horizontally very
long).
How do I reduce its size so as to look like a sudoku gui.

As you might have already aware of how exactly a sudoku gui looks like,
so
please help me on this. How do I make it?
Also do know that I am still a student and not a professional who can
handle
Linux Kernel.

I hope you will help me


Thanks
surya

_______________________________________________
Glade-users maillist ?- ?Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users


I designed the basic structure of GUI for my sudoku solver. So, here are the
following things I am unable to do now

1. I could fixed the maximum length of input to 1 but how should I make it
only for int

You have to connect to "key-press-event" signal, make sure you read
up on how to handle signal callbacks because you need to use the
right signature.

Grepping the web will help you... search for input/entry validation


2. There are 2 buttons at the bottom which I created using "horizontal
panes" and button widgets.
The problem here is, as soon as I close and reopen the project, those
positions of buttons are changing. One is turning down to smaller and other
bigger. I had to readjust them every time.. how to fix it?

The paned widget has some object properties which might be useful,
if you need your application to save where the user previously had
the paned window positioned, that means you need some level of
session management.

i.e. when your program quits, or a short time after the paned window
position changes, you should save it to a file or database (GConf/GSettings ?)
and load that to setup the position again at startup time.


3. How to generate C code for this project? and how to link it to my source
file.

You never ever generate C code for a project.

To load your project use the following code:

#include <gtk/gtk.h>

int
main (int argc, char *argv[])
{
   GtkBuilder *builder;
   GtkWidget *window;

   gtk_init (&argc, &argv);

   builder = gtk_builder_new ();
   gtk_builder_add_from_file (builder, "/path/to/glade/file.glade", NULL);

   window = gtk_builder_get_object (builder,
"the-name-you-gave-to-the-toplevel-window");

   /* here you can fetch all the widgets you actually need to use...
and call g_signal_connect(),
      alternatively you can use the signals assigned in your glade
file by calling gtk_builder_connect_signals() */

   gtk_widget_show (window);

   gtk_main ();

   return 0;
}

And that will build your interface for you dynamically.

Furthermore, if you dont want to manage where the file is installed,
you can just convert
the glade file to a C header file as a string constant and just pass
that directly to
gtk_builder_load_from_data() instead of using gtk_builder_load_from_file().

Cheers,
       -Tristan



This is how I want my project should work:

- The input function has an 9 by 9 array, all entries should be taken into
it as soon as I click "submit"
- 0 should be taken in place of empty 'text entry'
- After submitting, my code gives output which has to be shown there
- Input entry numbers should be in colored and shown in bold format.


Thanks

_______________________________________________
Glade-users maillist ?- ?Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]