Hi,

Am Sonntag, den 04.12.2005, 02:20 +0100 schrieb Fabian Sturm:
> Hi! 
> 
> thanks for your reply!
> 
> On Sat, 2005-12-03 at 18:55 +0100, Jakub Piotr Cłapa wrote:
> 
> > > 2. I can't hide any of the widgets. E.g. a call to
> > > self.__cal_label.hide() does not hide the label
> 
> Okay I found the problem to this, I used mainwindow.show_all()
> in the test case. This had the effect that I could no longer hide the
> time controls. 
> But unfortunately this behaviour is different from what is done in the c
> code! I am really lost with this one! 
> Why are the widgets in the c code not shwown by the call to show_all??

Because they use some stupid workaround to make "all" not mean "all". I
suggest you use show() on the widgets you want to see and be over with
(and not use "show_all" at all).

> 
> > > 3. The c version of the widget had two different constructors, as far as
> > > I understood is this impossible in python, so how do you cope with it.

Which ones ?

from reading the C header file at 01:47 am in the night (so don't quote
me on that, it might be gibberish) I deduce :

GtkWidget *gnome_date_edit_new            (time_t the_time,
                                           gboolean show_time,
                                           gboolean use_24_format);
GtkWidget *gnome_date_edit_new_flags      (time_t the_time,
                                           GnomeDateEditFlags flags);

I would suggest you to drop both and make the stuff properties instead
(as far as possible). Most of the stuff is a bad idea to pass and you
should get the GnomeDateEditFlags from the locale (Localization
settings) of the user that is logged in, "hardcoded".

> > 
> > You add keyword arguments to __init__ and check them on runtime or

^^^
that is overloading. 


>  (my 
> > own idea; not sure if it's Harmful(TM)) add a class method returning an 
> > instance.

nice idea, but depends on the actual constructors of the original
version if it is worth the complexity of it all... As I have looked them
up now, don't bother with them. Get rid of them, use properties. 

Also, they actually do the same. I think the one is a backwards
compability hook for the other:

i.e. gnome_date_edit_new actually calls gnome_date_edit_new_flags (I
didn't check that, too late to read C code :)).

> 
> I dont' like the idea, since the two keywords would mean the same thing
> and it would be unclear which one to fill out, or even both...

yeah, but I don't think you understood him correctly. It's better if you
don't use it because it leads to weird code. Trusting you to take that
advice seriously ("kwargs = bad code"), I show you what it is:

def foobar(**args):
  if "hello" in args:
    print "hello args: ", args["hello"]

  if "bar" in args:
    print "bar args: ", args["bar"]

>>> foobar(hello = "foo")
hello args: foo

>>> foobar(bar = "baz")
bar args: bar

>>> foobar("baz")
(I have no clue in hell what that causes... let me try... aha :))
TypeError: foobar() takes exactly 0 arguments (1 given)

For the calendar thing, just make the constructor take no args. Nobody
will pass any to a widget either way (they are usually not instantiated
manually, so...).

> So overloading would be the best, if possible.

see above. that _is_ overloading.

> How do others handle this?

Stuff like constructor overloading feels just weird [in python.
Everywhere else too? I think I managed to ignore it in C++ somehow - as
long as they do the same ;)] 

> 
> Finally I have attached the new state of the widget, it already is
> useable, even so I have not yet added the set_property, get_property
> stuff. Some help / demo code with this part would also be very cool.
> 
> Anyways this version can already be tested for functionality and bugs!
> 
> Thanks a lot, Fabian

Nice :)

Thanks for your work :)

There are a few nitpicky things I want to note:
Space the widgets apart. See the Gnome HIG (Human Interface Guidelines).
Basically, what I want to get at is: don't make users feel
clausthrophobic :) (there is set_border_width on any widget - not so
helpful in that case, set_spacing on any container - use it on the hbox,
value 7 or something - can't remember, look it up to be safe)

If your gtk version is new enough, don't use OptionMenu, use
gtk.ComboBox. Or, now that I see what that uses it for, use a
MenuToolButton.

The only thing you should use pixel units for is for borders and
spacing. Don't do set_size_request(), rather say:

- for the gtk.Entry: use set_max_length() to set the max length in
characters

You might want to use:

self.__date_button.connect("clicked", self.select_clicked_cb)

def select_clicked_cb(self, widget):
  dialog = gtk.Dialog...( widget.get_toplevel_widget())
  dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
  dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
  response = dialog.run()
  dialog.destroy()

  if response == gtk.RESPONSE_OK:
    ....

If there is stuff I have not covered, ask me again, I might have
overlooked :)


cheers,
   Danny


_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to