Re: [pygtk] Splitting things up

2010-06-28 Thread Neil Dugan
Elver Loho wrote:
> Hi!
> 
> I'm a PyGTK newbie.
> 
> I built a small (less than 1k lines) PyGTK-based application back in
> 2006 that used SQLObject and was basically a simple GUI for editing
> things in a MySQL database table. It was a mixed experience for me. On
> the one hand designing a GUI with Glade was damn great and getting
> things done with PyGTK was surprisingly easy even back then. (I've
> noticed that you've improved a lot in this department over the years!
> Nice!) On the other hand the whole application ended up being a single
> file, with all of the GUI stuff being done in a single, insanely large
> class.
> 
> Is there a good design solution for splitting the window controller
> into multiple chunks?
> 
> For example, I've been doing some iPhone programming recently and on
> the iPhone each application consists of a ton of different UIViews.
> Each UIView could take up either the whole screen or just a part of
> it. And many UIViews come with a UIViewController, which is a nice way
> of implementing view-specific behavior. So, for example, you could
> build a small form consisting of two classes, one inheriting from
> UIView and the other from UIViewController. Then you can easily reuse
> that form elsewhere, as part of a larger view, while keeping its
> internal logic in those two classes and only communicating with the
> bits outside of it when it makes sense.
> 
> Is there a way of doing something like this with Glade and PyGTK?
> 
> The project I'm trying to build right now will have multiple windows,
> but almost all of them have a shared component: a database browser
> panel consisting of basic controls (back, forward, current record ID,
> number of records, go-to-record text box and button, search box) and
> I'd like to put the implementation of this panel into a separate Glade
> file and a separate Python class, then include it as a component in
> different parts of the application.
> 
> What would be the best way of doing that?
> 
> 
> Best,
> Elver
> 

Personally I don't use glade much.  But here is my 2 cents worth.

What you need to do is learn more about python classes, you can do 
almost anything with them.

Another handy thing to learn about is creating custom gtk+ signals for 
your gtk sub-classes.  So you can 'connect' to them.  Used right they 
can make your sub-classes much easier to code and use.

Take any shared code, put that into its own class and just import it 
into any modules that need it.

You could also put each of your windows into its own class (in its own 
file)

I think it would be a good idea to create a new class for your 
database panel in a separate file.  Using some gsignals to signal when 
the forward/backwards etc. buttons have been pressed.

Plus take any gtk widget or dialog that has any resonable amount of 
code associated with it.. sub class it and put all the code for 
handling that widget in that new class.  Depending on the size of the 
resulting class you can ether leave it in the same file or put in a 
new file.

Also you can take the other stuff like your database handling code 
into its own class.

Look for groups of functions, that handle similar objects or do 
similar jobs and put them in there own classes.

Regards Neil.





___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] Splitting things up

2010-06-28 Thread Elver Loho
On 28 June 2010 12:54, Roberto Cavada  wrote:
> Il 06/28/2010 10:54 AM, Elver Loho ha scritto:
>
>> Is there a good design solution for splitting the window controller
>
>> into multiple chunks?
>
>
> You may have a look to gtkmvc:
> http://sourceforge.net/apps/trac/pygtkmvc/wiki

Not sure I like pygtkmvc. There's a bit too much magic going on for my taste.
Kiwi seems nicer, but what PyGTK/Glade-only options do I have for
splitting the UI into parts?

Best,
Elver

elver.l...@gmail.com
+372 5661 6933
http://elver.wordpress.com/
skype: elver.loho
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


Re: [pygtk] Splitting things up

2010-06-28 Thread Roberto Cavada
Il 06/28/2010 10:54 AM, Elver Loho ha scritto:

> Is there a good design solution for splitting the window controller

> into multiple chunks?


You may have a look to gtkmvc:
http://sourceforge.net/apps/trac/pygtkmvc/wiki
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] Splitting things up

2010-06-28 Thread Elver Loho
Hi!

I'm a PyGTK newbie.

I built a small (less than 1k lines) PyGTK-based application back in
2006 that used SQLObject and was basically a simple GUI for editing
things in a MySQL database table. It was a mixed experience for me. On
the one hand designing a GUI with Glade was damn great and getting
things done with PyGTK was surprisingly easy even back then. (I've
noticed that you've improved a lot in this department over the years!
Nice!) On the other hand the whole application ended up being a single
file, with all of the GUI stuff being done in a single, insanely large
class.

Is there a good design solution for splitting the window controller
into multiple chunks?

For example, I've been doing some iPhone programming recently and on
the iPhone each application consists of a ton of different UIViews.
Each UIView could take up either the whole screen or just a part of
it. And many UIViews come with a UIViewController, which is a nice way
of implementing view-specific behavior. So, for example, you could
build a small form consisting of two classes, one inheriting from
UIView and the other from UIViewController. Then you can easily reuse
that form elsewhere, as part of a larger view, while keeping its
internal logic in those two classes and only communicating with the
bits outside of it when it makes sense.

Is there a way of doing something like this with Glade and PyGTK?

The project I'm trying to build right now will have multiple windows,
but almost all of them have a shared component: a database browser
panel consisting of basic controls (back, forward, current record ID,
number of records, go-to-record text box and button, search box) and
I'd like to put the implementation of this panel into a separate Glade
file and a separate Python class, then include it as a component in
different parts of the application.

What would be the best way of doing that?


Best,
Elver

elver.l...@gmail.com
+372 5661 6933
http://elver.wordpress.com/
skype: elver.loho
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/