Best way to busy-wait in Python 3 / Gtk+ 3?

2012-10-06 Thread Filip Lamparski
Hello,

I'm writing a simple application which is supposed to display the contents
of the TED RSS feed in a way similar to how the official app works on
Android.
However, the thumbnail loading process takes a long time, so I want to put
it into another process, with the GUI displaying a spinner or a progress
bar until the loading finishes.
I did not do anything with multiprocessing before, so I'm kind of stuck.
Here's my current code from the main runtime script:

from getted.tedtalk import TEDTalkWidgetfrom getted.window import
*from getted.tedlister import GetTEDTalksimport shutilimport osfrom
multiprocessing import Process
def load_ted_talks(twl):
print(Worker: Loading thumbnails)
tl = GetTEDTalks() # Gets list of TED Talks
for t in tl: # Convert TED Talks to widgets
   twl.append(TEDTalkWidget(t))
   print(Worker: {0}/{1} done.format(tl.index(t)+1, len(tl)))
print(Worker: Finished)
def do_quit (sender, e):
print('Quitting / Delete temporary files...')
shutil.rmtree('/tmp/getted')
Gtk.main_quit(sender, e)
def do_onload (sender):
print('Window ready, loading talks...')
talkwlist = []
p = Process(target=load_ted_talks, args=(talkwlist,))
p.start()
sender.populate_ted_talks(talkwlist)
if __name__ == '__main__':
print('Welcome to GetTED.')
getted_window = GetTEDWindow()
if not os.path.exists('/tmp/getted'):
print('Creating a directory for temporary files')
os.makedirs('/tmp/getted') # Create a temp directory for thumbnail files

getted_window.set_title(GetTED)
getted_window.connect('delete-event', do_quit)
getted_window.connect('show', do_onload)
print('Starting GetTED window...')
getted_window.show_all()
Gtk.main()

(Pastebin for those who see HTML here: http://pastebin.com/Afhzh3LD )

(GetTEDTalks is a function; I know this is breaking the convention but I'll
fix that later)

I have created a couple of different versions of load_ted_talks(), but all
of them either failed to load the thumbnails, loaded them but way after the
main process pushed associated widgets for the window to display, or
deadlocked.
If anybody has any suggestion on how can I make the application busy-wait
until the thumbnails finish loading (while keeping the GUI responsive),
then please tell me.

Thanks,
Filip

-- 
_
Filip Lamparski - FB https://www.facebook.com/filip.lamparski -
G+https://plus.google.com/105688569486178456264/posts
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Sortable Treeview

2012-10-06 Thread Rudra Banerjee

Dear friends,
I am trying to make a Treeview sortable. I have managed to get sortable
by any one column, using
GtkTreeSortable *sortable=GTK_TREE_SORTABLE(data-store);
Code:
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable),
ID_YEAR, GTK_SORT_ASCENDING);


which will by default sort by year(or any ID_* that appear last), and
treeview will get that view.
What I am looking for, is make my header clickable to get the sorting,
with initial view completely unsorted.
I only managed to found this information:


but I have no idea how. 
Can you kindly help a bit,

typedef struct _Data
{
  GtkWidget *window;
  GtkListStore *store;
}
Data;

enum
{
  C_TYPE = 0,
  C_NAME,
  C_YEAR,
  C_TITLE,
  NO_COLS
};

enum
  {
ID_TYPE = 0,
ID_NAME,
ID_YEAR,
ID_TITLE
  };

static void
create_gui (Data *data)
{
  GtkWidget *vbox,
*cbutton,
*swindow,
*tree;
  GtkCellRenderer *cell;

  data-window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (data-window), 400, 400);
  g_signal_connect (data-window, destroy, gtk_main_quit, NULL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_add (GTK_CONTAINER (data-window), vbox);

  cbutton = gtk_file_chooser_button_new (Load bib file,
 GTK_FILE_CHOOSER_ACTION_OPEN);
  g_signal_connect (cbutton, file-set, G_CALLBACK (cb_file_set),
data);
  gtk_box_pack_start (GTK_BOX (vbox), cbutton, FALSE, FALSE, 0);

  swindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_box_pack_start (GTK_BOX (vbox), swindow, TRUE, TRUE, 0);

  data-store = gtk_list_store_new (NO_COLS, G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING);

  GtkTreeSortable *sortable=GTK_TREE_SORTABLE(data-store);
/*  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), 
ID_NAME, GTK_SORT_ASCENDING);
*/ 
  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), 
ID_YEAR, GTK_SORT_ASCENDING);

  tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (data-store));
  gtk_container_add (GTK_CONTAINER (swindow), tree);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
   Type, cell,
   text, C_TYPE,
   NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
   Name, cell,
   text, C_NAME,
   NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
   Year, cell,
   text, C_YEAR,
   NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
   Title, cell,
   text, C_TITLE,
   NULL);
  gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tree),TRUE);
  gtk_widget_show_all (vbox);
}


Report this post

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Sortable Treeview

2012-10-06 Thread Rudra Banerjee

Dear friends,
I am trying to make a Treeview sortable. I have managed to get sortable by any 
one column, using
GtkTreeSortable *sortable=GTK_TREE_SORTABLE(data-store);
Code:
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable),
    ID_YEAR, GTK_SORT_ASCENDING);


which will by default sort by year(or any ID_* that appear last), and treeview 
will get that view.
What I am looking for, is make my header clickable to get the sorting, with 
initial view completely unsorted.
I only managed to found this information:


but I have no idea how. 
Can you kindly help a bit,

typedef struct _Data
{
  GtkWidget *window;
  GtkListStore *store;
}
Data;

enum
{
  C_TYPE = 0,
  C_NAME,
  C_YEAR,
  C_TITLE,
  NO_COLS
};

enum
  {
    ID_TYPE = 0,
    ID_NAME,
    ID_YEAR,
    ID_TITLE
  };

static void
create_gui (Data *data)
{
  GtkWidget *vbox,
    *cbutton,
    *swindow,
    *tree;
  GtkCellRenderer *cell;

  data-window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (data-window), 400, 400);
  g_signal_connect (data-window, destroy, gtk_main_quit, NULL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_add (GTK_CONTAINER (data-window), vbox);

  cbutton = gtk_file_chooser_button_new (Load bib file,
 GTK_FILE_CHOOSER_ACTION_OPEN);
  g_signal_connect (cbutton, file-set, G_CALLBACK (cb_file_set), data);
  gtk_box_pack_start (GTK_BOX (vbox), cbutton, FALSE, FALSE, 0);

  swindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_box_pack_start (GTK_BOX (vbox), swindow, TRUE, TRUE, 0);

  data-store = gtk_list_store_new (NO_COLS, G_TYPE_STRING, G_TYPE_STRING,
    G_TYPE_STRING, G_TYPE_STRING);

  GtkTreeSortable *sortable=GTK_TREE_SORTABLE(data-store);
/*  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), 
    ID_NAME, GTK_SORT_ASCENDING);
*/ 
  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(sortable), 
    ID_YEAR, GTK_SORT_ASCENDING);

  tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (data-store));
  gtk_container_add (GTK_CONTAINER (swindow), tree);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
   Type, cell,
   text, C_TYPE,
   NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
   Name, cell,
   text, C_NAME,
   NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
   Year, cell,
   text, C_YEAR,
   NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree), -1,
   Title, cell,
   text, C_TITLE,
   NULL);
  gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tree),TRUE);
  gtk_widget_show_all (vbox);
}
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Sortable Treeview

2012-10-06 Thread David Nečas
On Sun, Oct 07, 2012 at 12:25:22AM +0100, Rudra Banerjee wrote:
 What I am looking for, is make my header clickable to get the sorting,
 with initial view completely unsorted.

Then look at List Store in gtk-demo.  It demonstrates this clearly.

Yeti

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: [Pixman] debuging wxruby

2012-10-06 Thread Søren Sandmann
Svend Haugaard Sørensen s...@demosophia.net writes:

 The top of the stack dump look like this.

 #0  0xb47a6d9d in _pixman_lookup_composite_function (toplevel=0x80be750, 
 op=PIXMAN_OP_SRC, 
 src_format=262144, src_flags=1043063, mask_format=0, mask_flags=8192, 
 dest_format=PIXMAN_a8r8g8b8, dest_flags=34032255, out_imp=0xbfffb82c, 
 out_func=0xbfffb828)
 at 
 /var/tmp/portage/x11-libs/pixman-0.26.0/work/pixman-0.26.0/pixman/pixman-utils.c:74

A crash at this point suggests that something is broken with thread
local storage on your setup. When you compiled pixman, which type of
thread local storage was detected by the configure script?


Søren
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

destroy a widget while keeping the window with Glade

2012-10-06 Thread Frank Cox
I've just started playing with Glade and once again I'm wondering if I'm using
the wrong approach to get stuff done, since I can't find anything that tells me
how to do this.

So far, I've been creating a main window for the program and simply creating and
destroying boxes and widgets within that window as different menu options are
selected.

Here is a simple example.

I have a window with a box in it, which in turn contains a button.

Now I want to be able to click on that button and destroy the box without
destroying the window, then create a new box and a new button within the
existing window.

I can do this easily enough by writing the code to do the layout myself, but I
don't see a way to do a Glade layout that can accomplish this.



-- 
MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com
www.creekfm.com - FIFTY THOUSAND WATTS of POW WOW POWER!
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list