mailRe: r10620 - /branches/bieri_gui/gui_bieri/about.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on February 03, 2010 - 01:29:
Hi,

I'm again just playing here to learn a bit about the GUI coding
concepts.  But now that I've switched to the powerful wx.PaintDC GDI
object (http://zetcode.com/wxpython/gdi/), this problem is gone.  It
doesn't look great yet, but have a look at the about widget now.  Some
very interesting things can be built with this, see
http://zetcode.com/wxpython/customwidgets/ for example.  Using this,
the relax controller could be made much more powerful as we can make
our own specialised widgets for displaying progress.

Regards,

Edward



On 3 February 2010 00:35, Michael Bieri <michael.bieri@xxxxxx> wrote:
Hi Edward

I had a look at the about relax panel. I would suggest to add a button
for closing the dialog. the problem with this coding is that if you
click on the image, nothing will happen. Only clicking to the background
will close the dialog. You could also just add the closing function to
all elements.

Cheers
 Michael

edward@xxxxxxxxxxxxx schrieb:
Author: bugman
Date: Tue Feb  2 20:10:11 2010
New Revision: 10620

URL: http://svn.gna.org/viewcvs/relax?rev=10620&view=rev
Log:
Expanded the relax about dialog.

This includes concepts of size, background colours, boarders, binding left 
click events, and
building the core of the dialog.  Most code is in the base class.


Modified:
    branches/bieri_gui/gui_bieri/about.py

Modified: branches/bieri_gui/gui_bieri/about.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/about.py?rev=10620&r1=10619&r2=10620&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/about.py (original)
+++ branches/bieri_gui/gui_bieri/about.py Tue Feb  2 20:10:11 2010
@@ -25,6 +25,9 @@
 from os import sep
 import wx

+# relax module imports.
+from version import version
+
 # relax GUI module imports.
 from paths import IMAGE_PATH

@@ -41,6 +44,16 @@
 class About_base(wx.Dialog):
     """The about dialog base class."""

+    # The background colour.
+    colour = None
+
+    # Dimensions.
+    dim_x = 400
+    dim_y = 100
+
+    # Spacer size (px).
+    spacer_size = 0
+
     def __init__(self, *args, **kwds):
         """Build the dialog."""

@@ -50,8 +63,67 @@
         # Execute the base class __init__() method.
         super(About_base, self).__init__(*args, **kwds)

+        # The total size.
+        self.total_x = self.dim_x + 2*self.spacer_size
+        self.total_y = self.dim_y + 2*self.spacer_size
+        self.SetMinSize((self.total_x, self.total_y))
+
+        # Set a background.
+        self.set_background()
+
+        # Build the boarder and get the central sizer.
+        self.sizer = self.build_boarders()
+
+        # An array of objects to bind events to.
+        self.obj_list = [self]
+
+        # Build the core.
+        self.build_core()
+
         # Let the dialog be closable with a left button click.
-        self.Bind(wx.EVT_LEFT_DOWN, self.close, self)
+        self.bind()
+
+
+    def bind(self):
+        """Bind the left button click to all objects."""
+
+        # Loop over the objects.
+        for obj in self.obj_list:
+            self.Bind(wx.EVT_LEFT_DOWN, self.close, obj)
+
+
+    def build_boarders(self):
+        """Build the boarder layout and return the central sizer.
+
+        @return:    The central sizer object.
+        @rtype:     wx.BoxSizer instance
+        """
+
+        # The horizontal, vertical, and central sizers.
+        sizer_hori = wx.BoxSizer(wx.HORIZONTAL)
+        sizer_vert = wx.BoxSizer(wx.VERTICAL)
+        sizer_cent = wx.BoxSizer(wx.VERTICAL)
+
+        # Fix the size of the central sizer.
+        sizer_cent.SetMinSize((self.dim_x, self.dim_y))
+
+        # Fill the dialog with the horizontal sizer.
+        self.SetSizer(sizer_hori)
+
+        # The left and top spacers.
+        sizer_hori.AddSpacer(self.spacer_size)
+        sizer_vert.AddSpacer(self.spacer_size)
+
+        # Pack the sizers together.
+        sizer_hori.Add(sizer_vert)
+        sizer_vert.Add(sizer_cent)
+
+        # The right and bottom spacers.
+        sizer_hori.AddSpacer(self.spacer_size)
+        sizer_vert.AddSpacer(self.spacer_size)
+
+        # Return the central sizer.
+        return sizer_cent


     def close(self, event):
@@ -68,15 +140,78 @@
         event.Skip()


+    def set_background(self):
+        """Build a background for the dialog."""
+
+        # Set a single colour.
+        if self.colour:
+            self.SetBackgroundColour(self.colour)
+
+

 class About_relax(About_base):
     """The about relax dialog."""

+    # The relax background colour.
+    colour = '#e5feff'
+
+    # Dimensions.
+    dim_x = 400
+    dim_y = 600
+
+    # Spacer size (px).
+    spacer_size = 10
+
     def __init__(self, *args, **kwds):
         """Build the dialog."""

         # Execute the base class __init__() method.
         super(About_relax, self).__init__(*args, **kwds)
+
+
+    def add_relax_logo(self, sizer):
+        """Add the relax logo to the sizer.
+
+        @param sizer:   The sizer element to pack the logo into.
+        @type sizer:    wx.Sizer instance
+        """
+
+        # The logo.
+        logo = wx.StaticBitmap(self, -1, 
wx.Bitmap(IMAGE_PATH+'ulysses_shadowless_400x168.png', wx.BITMAP_TYPE_ANY))
+
+        # Pack the logo into the sizer.
+        sizer.Add(logo)
+
+        # Return the logo.
+        return logo
+
+
+    def add_title(self, sizer):
+        """Add the relax title (name and version) to the sizer.
+
+        @param sizer:   The sizer element to pack the title into.
+        @type sizer:    wx.Sizer instance
+        """
+
+        # The text.
+        title = wx.StaticText(self, -1, 'relax ' + version, 
style=wx.Centre)
+
+        # Pack in the title.
+        sizer.Add(title)
+
+
+    def build_core(self):
+        """Construct the core of the about dialog."""
+
+        # Add some vertical spacing.
+        self.sizer.AddSpacer(30)
+
+        # Add the relax name and version.
+        self.add_title(self.sizer)
+
+        # Add the relax logo.
+        logo = self.add_relax_logo(self.sizer)
+        self.obj_list.append(logo)





_______________________________________________
relax (http://nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits



_______________________________________________
relax (http://nmr-relax.com)

This is the relax-devel mailing list
relax-devel@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel




Related Messages


Powered by MHonArc, Updated Wed Feb 03 01:40:08 2010