Re: ScrolledWindow e IconView
"Juan C. Olivares" <[email protected]> Fri, 6 May 2011 01:06:52 -0400
| Newsgroups | gmane.comp.gnome.mono.hispano |
|---|---|
| Message-ID | <[email protected]> |
Juan Carlos:
Tengo algunas dudas con tu código. Por ejemplo, estás invocando al Build al
final de tu método. Si usas el diseñador de MonoDevelop, deberías llamar a
Build antes.
Acá va un ejemplo mínimo de cómo usar ScrolledWindow:
Application.Init ();
var w = new Window ("Test");
w.DeleteEvent += delegate { Application.Quit (); };
var sw = new ScrolledWindow ();
var hbox = new HBox (true, 5);
for (int i = 1; i <= 50; i++)
hbox.PackStart (new Label ("Label " + i));
sw.AddWithViewport (hbox);
w.Add (sw);
w.ShowAll ();
Application.Run ();
Notarás que cuando agregas el widget hbox al ScrolledWindow debes utilizar
AddWithViewport.
Suerte y cuéntanos si puedes solucionar el problema.
2011/5/5 Juan Carlos Ferrández <[email protected]>
> Buenas. Tengo una ventana más ancha que alta (alargada de izquierda a
> derecha, pero nada alta), con un ScrolledWindow y dentro de esta, un
> IconView. El caso es que ScrolledWindow, por mucho que yo le diga, no
> consigo que haga scroll de izquierda a derecha, en lugar de arriba a abajo.
>
> Necesito hacer un scroll de imágenes de izquierda a derecha, pero parece
> que
> el iconview sólo me deja de arriba a abajo. Alguna idea?
>
> El código es el siguiente:
>
> using System;
> using System.IO;
> using Gtk;
>
> public partial class MainWindow : Gtk.Window
> {
> const int COL_DISPLAY_NAME = 1;
> const int COL_PIXBUF = 2;
>
> DirectoryInfo parent = new DirectoryInfo ("/home/bio/Imágenes");
> ListStore store;
>
> public MainWindow () : base(Gtk.WindowType.Toplevel)
> {
> VBox vbox = new VBox (false, 0);
> Add (vbox);
>
> ScrolledWindow sw = new ScrolledWindow();
> sw.ShadowType = ShadowType.EtchedIn;
> sw.SetPolicy(PolicyType.Automatic, PolicyType.Automatic);
> vbox.PackStart (sw, true, true, 0);
>
> // Create the store and fill it with the contents of '/'
> store = CreateStore ();
> FillStore ();
>
> IconView iconView = new IconView (store);
> iconView.SelectionMode = SelectionMode.Single;
> iconView.TextColumn = COL_DISPLAY_NAME;
> iconView.PixbufColumn = COL_PIXBUF;
>
> iconView.ItemActivated += new ItemActivatedHandler
> (OnItemActivated);
> sw.Add (iconView);
> //vbox.PackStart(iconView, true, true, 0);
> iconView.GrabFocus ();
>
>
>
> Build ();
> ShowAll();
> }
>
> Gdk.Pixbuf GetIcon (string name)
> {
> return Gtk.IconTheme.Default.LoadIcon (name, 48,
> (IconLookupFlags) 0);
> }
>
> ListStore CreateStore ()
> {
> // path, name, pixbuf, is_dir
> ListStore store = new ListStore (typeof (string), typeof
> (string), typeof (Gdk.Pixbuf), typeof (bool));
>
> store.SetSortColumnId (COL_DISPLAY_NAME,
> SortType.Ascending);
>
> return store;
> }
>
> void FillStore ()
> {
> // first clear the store
> store.Clear ();
>
> // Now go through the directory and extract all the file
> information
> if (!parent.Exists)
> return;
>
> foreach (FileInfo file in parent.GetFiles ())
> {
> if (!file.Name.StartsWith (".") && file.Extension ==
> ".jpg")
> store.AppendValues (file.FullName, "", new
> Gdk.Pixbuf(file.FullName), false);
> }
> }
>
> void OnItemActivated (object sender, ItemActivatedArgs a)
> {
>
> }
>
> protected void OnDeleteEvent (object sender, DeleteEventArgs a)
> {
> Application.Quit ();
> a.RetVal = true;
> }
> }
>
> Un Saludo
> JC
>
> --
> View this message in context:
> http://monohispano.2299865.n2.nabble.com/ScrolledWindow-e-IconView-tp6333393p6333393.html
> Sent from the MonoHispano mailing list archive at Nabble.com.
> _______________________________________________
> Mono-hispano mailing list
> [email protected]
> https://listas.hispalinux.es/mailman/listinfo/mono-hispano
>
--
Atte,
Juan Cristóbal Olivares
*La disposición a admirar, casi a adorar, a los ricos y poderosos y a ....
descuidar a las personas más pobres … es la mayor y más universal causa de
corrupción de nuestros sentimientos morales (**Adam Smith)*
_______________________________________________
Mono-hispano mailing list
[email protected]
https://listas.hispalinux.es/mailman/listinfo/mono-hispano