up with PyGUI!
anton muhin
antonmuhin at rambler.ru
Thu Sep 23 06:44:52 EDT 2004
Hans Nowak wrote:
> I'm not sure what you mean. One known issue is, that there is some
> redundancy when creating a control and adding it to its parent:
>
> b = Button(parent, ...)
> parent.AddComponent(b, ...)
>
> I am thinking of ways to make this simpler. One possible solution would
> be to accept a 'layout' parameter:
>
> b = Button(parent, ..., layout={'expand': 'both', 'border': 2})
>
> ....but I'm not sure that actually makes things simpler or more readable.
>
> It's also possible to do something like this:
>
> parent.Add(some_control, parameters_for_control, parameters_for_layout)
>
> I think this is rather ugly, and I don't like the mixing of control
> constructor parameters and layout parameters. Aside from that, it's
> sometimes useful or necessary to use the control before it's added to
> the parent. Consider:
>
> from wax import *
>
> class MainFrame(Frame):
>
> def Body(self):
> b1 = Button(self, text="b1")
> b1.Size = (40, 40)
> self.AddComponent(b1)
>
> b2 = Button(self, text="b2")
> self.AddComponent(b2)
> b2.Size = (40, 40)
>
> self.Pack()
>
> app = Application(MainFrame)
> app.Run()
>
I beg your pardon for possibly stupid comment---I haven't practice GUI
programming for a long time, especially in Python. However I mostly
prefer declarative approach for the problems like that. Therefore,
wouldn't it be interesting to describe the structure with class and
metaclass mechanism, like:
class MainFrame(FrameDescription):
class b1(ButtonDescription):
size = (40, 40)
text = "b1"
etc.
with the best regards,
anton.
More information about the Python-list
mailing list