"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gui/input_elements/combo_list.py" between
relax-4.1.3.src.tar.bz2 and relax-5.0.0.src.tar.bz2

About: relax allows the study of molecular dynamics through the analysis of experimental NMR data. Organic molecules, proteins, RNA, DNA, sugars, and other biomolecules are all supported.

combo_list.py  (relax-4.1.3.src.tar.bz2):combo_list.py  (relax-5.0.0.src.tar.bz2)
############################################################################### ###############################################################################
# # # #
# Copyright (C) 2011-2012 Edward d'Auvergne # # Copyright (C) 2011-2012,2016 Edward d'Auvergne #
# # # #
# This file is part of the program relax (http://www.nmr-relax.com). # # This file is part of the program relax (http://www.nmr-relax.com). #
# # # #
# This program is free software: you can redistribute it and/or modify # # This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by # # it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or # # the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. # # (at your option) any later version. #
# # # #
# This program is distributed in the hope that it will be useful, # # This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of # # but WITHOUT ANY WARRANTY; without even the implied warranty of #
skipping to change at line 30 skipping to change at line 30
############################################################################### ###############################################################################
# Module docstring. # Module docstring.
"""The combo list GUI element.""" """The combo list GUI element."""
# Python module imports. # Python module imports.
from copy import deepcopy from copy import deepcopy
import wx import wx
# relax module imports. # relax module imports.
import dep_check
from graphics import fetch_icon from graphics import fetch_icon
from gui.string_conv import float_to_gui, gui_to_float, gui_to_int, gui_to_str, int_to_gui, str_to_gui from gui.string_conv import float_to_gui, gui_to_float, gui_to_int, gui_to_str, int_to_gui, str_to_gui
from lib.errors import RelaxError from lib.errors import RelaxError
class Combo_list: class Combo_list:
"""The combo list GUI element.""" """The combo list GUI element."""
def __init__(self, parent, sizer, desc, value_type=None, n=1, min_length=1, choices=None, data=None, default=None, evt_fn=None, tooltip=None, divider=None, padding=0, spacer=None, read_only=True, can_be_none=False): def __init__(self, parent, sizer, desc, value_type=None, n=1, min_length=1, choices=None, data=None, default=None, evt_fn=None, tooltip=None, divider=None, padding=0, spacer=None, read_only=True, can_be_none=False):
"""Build the combo box list widget for a list of list selections. """Build the combo box list widget for a list of list selections.
skipping to change at line 171 skipping to change at line 172
# Left padding. # Left padding.
sub_sizer.AddSpacer(self._padding) sub_sizer.AddSpacer(self._padding)
# The description. # The description.
if index == 0: if index == 0:
text = wx.StaticText(self._parent, -1, self._desc, style=wx.ALIGN_LE FT) text = wx.StaticText(self._parent, -1, self._desc, style=wx.ALIGN_LE FT)
sub_sizer.Add(text, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 0) sub_sizer.Add(text, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 0)
# Spacing. # Spacing.
x, y = text.GetSize() x, y = text.GetSize()
sub_sizer.AddSpacer((self._divider - x, 0)) if dep_check.wx_classic:
sub_sizer.AddSpacer((self._divider - x, 0))
else:
sub_sizer.AddSpacer(self._divider - x)
# No description for other rows, so add a blank space. # No description for other rows, so add a blank space.
else: else:
sub_sizer.AddSpacer((self._divider, 0)) if dep_check.wx_classic:
sub_sizer.AddSpacer((self._divider, 0))
else:
sub_sizer.AddSpacer(self._divider)
# The combo box element. # The combo box element.
style = wx.CB_DROPDOWN style = wx.CB_DROPDOWN
if self._read_only: if self._read_only:
style = style | wx.CB_READONLY style = style | wx.CB_READONLY
combo = wx.ComboBox(self._parent, -1, value='', style=style) combo = wx.ComboBox(self._parent, -1, value='', style=style)
combo.SetMinSize((50, 27)) combo.SetMinSize((50, 27))
sub_sizer.Add(combo, 1, wx.ALIGN_CENTER_VERTICAL, 0) sub_sizer.Add(combo, 1, wx.ALIGN_CENTER_VERTICAL, 0)
self._combo_boxes.append(combo) self._combo_boxes.append(combo)
skipping to change at line 220 skipping to change at line 227
# The delete button. # The delete button.
elif index == self._min_length: elif index == self._min_length:
button = wx.BitmapButton(self._parent, -1, wx.Bitmap(fetch_icon('oxy gen.actions.list-remove', "16x16"), wx.BITMAP_TYPE_ANY)) button = wx.BitmapButton(self._parent, -1, wx.Bitmap(fetch_icon('oxy gen.actions.list-remove', "16x16"), wx.BITMAP_TYPE_ANY))
button.SetMinSize((27, 27)) button.SetMinSize((27, 27))
sub_sizer.Add(button, 0, wx.ADJUST_MINSIZE|wx.ALIGN_CENTER_VERTICAL, 0) sub_sizer.Add(button, 0, wx.ADJUST_MINSIZE|wx.ALIGN_CENTER_VERTICAL, 0)
self._parent.Bind(wx.EVT_BUTTON, self._delete, button) self._parent.Bind(wx.EVT_BUTTON, self._delete, button)
# Otherwise empty spacing. # Otherwise empty spacing.
else: else:
sub_sizer.AddSpacer((27, 0)) if dep_check.wx_classic:
sub_sizer.AddSpacer((27, 0))
else:
sub_sizer.AddSpacer(27)
# Right padding. # Right padding.
sub_sizer.AddSpacer(self._padding) sub_sizer.AddSpacer(self._padding)
# Add to the main sizer. # Add to the main sizer.
self._sub_sizers.append(sub_sizer) self._sub_sizers.append(sub_sizer)
self._main_sizer.Add(sub_sizer, 1, wx.EXPAND|wx.ALL, 0) self._main_sizer.Add(sub_sizer, 1, wx.EXPAND|wx.ALL, 0)
# Bind events. # Bind events.
if self._evt_fn: if self._evt_fn:
self._parent.Bind(wx.EVT_COMBOBOX, self._evt_fn, combo) self._parent.Bind(wx.EVT_COMBOBOX, self._evt_fn, combo)
# Tooltip. # Tooltip.
if self._tooltip: if self._tooltip:
if index == 0: if index == 0:
text.SetToolTipString(self._tooltip) text.SetToolTip(wx.ToolTip(self._tooltip))
combo.SetToolTipString(self._tooltip) combo.SetToolTip(wx.ToolTip(self._tooltip))
if index <= 1 and button != None: if index <= 1 and button != None:
button.SetToolTipString(self._tooltip) button.SetToolTip(wx.ToolTip(self._tooltip))
def _delete(self, event): def _delete(self, event):
"""Add a new combo box. """Add a new combo box.
@param event: The wx event. @param event: The wx event.
@type event: wx event @type event: wx event
""" """
# Remove the combo box element from the list. # Remove the combo box element from the list.
self._combo_boxes.pop() self._combo_boxes.pop()
# Destroy the subsizer. # Destroy the subsizer.
sub_sizer = self._sub_sizers.pop() sub_sizer = self._sub_sizers.pop()
sub_sizer.DeleteWindows() sub_sizer.Clear(True)
self._main_sizer.Remove(sub_sizer) self._main_sizer.Remove(sub_sizer)
# Re-perform the window layout. # Re-perform the window layout.
self._parent.Layout() self._parent.Layout()
def GetValue(self): def GetValue(self):
"""Return the value represented by this GUI element. """Return the value represented by this GUI element.
@return: The list of choices. @return: The list of choices.
@rtype: list @rtype: list
 End of changes. 8 change blocks. 
8 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)