"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gui/input_elements/sequence.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.

sequence.py  (relax-4.1.3.src.tar.bz2):sequence.py  (relax-5.0.0.src.tar.bz2)
############################################################################### ###############################################################################
# # # #
# Copyright (C) 2012,2014 Edward d'Auvergne # # Copyright (C) 2012,2014,2019 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.
"""Module containing a set of special GUI elements to be used in the relax wizar ds.""" """Module containing a set of special GUI elements to be used in the relax wizar ds."""
# Python module imports. # Python module imports.
import wx import wx
import wx.lib.mixins.listctrl import wx.lib.mixins.listctrl
# relax module imports. # relax module imports.
import dep_check
from graphics import fetch_icon from graphics import fetch_icon
from gui.input_elements.combo_list import Combo_list from gui.input_elements.combo_list import Combo_list
from gui.fonts import font from gui.fonts import font
from gui.misc import add_border from gui.misc import add_border
from gui.string_conv import float_to_gui, gui_to_float, gui_to_int, gui_to_list, gui_to_py, gui_to_str, gui_to_tuple, int_to_gui, list_to_gui, py_to_gui, str_to _gui, tuple_to_gui from gui.string_conv import float_to_gui, gui_to_float, gui_to_int, gui_to_list, gui_to_py, gui_to_str, gui_to_tuple, int_to_gui, list_to_gui, py_to_gui, str_to _gui, tuple_to_gui
from lib.check_types import is_list from lib.check_types import is_list
from lib.errors import RelaxError from lib.errors import RelaxError
from status import Status; status = Status() from status import Status; status = Status()
class Sequence: class Sequence:
skipping to change at line 163 skipping to change at line 164
text = wx.StaticText(parent, -1, desc, style=wx.ALIGN_LEFT) text = wx.StaticText(parent, -1, desc, style=wx.ALIGN_LEFT)
text.SetFont(font.normal) text.SetFont(font.normal)
sub_sizer.Add(text, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 0) sub_sizer.Add(text, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 0)
# The divider. # The divider.
if not divider: if not divider:
raise RelaxError("The divider position has not been supplied.") raise RelaxError("The divider position has not been supplied.")
# Spacing. # Spacing.
x, y = text.GetSize() x, y = text.GetSize()
sub_sizer.AddSpacer((divider - x, 0)) if dep_check.wx_classic:
sub_sizer.AddSpacer((divider - x, 0))
else:
sub_sizer.AddSpacer(divider - x)
# The input field. # The input field.
self._field = wx.TextCtrl(parent, -1, '') self._field = wx.TextCtrl(parent, -1, '')
self._field.SetMinSize((50, height_element)) self._field.SetMinSize((50, height_element))
self._field.SetFont(font.normal) self._field.SetFont(font.normal)
sub_sizer.Add(self._field, 1, wx.ADJUST_MINSIZE|wx.ALIGN_CENTER_VERT ICAL, 0) sub_sizer.Add(self._field, 1, wx.ADJUST_MINSIZE|wx.ALIGN_CENTER_VERT ICAL, 0)
# Read-only. # Read-only.
if read_only: if read_only:
self._field.SetEditable(False) self._field.SetEditable(False)
colour = parent.GetBackgroundColour() colour = parent.GetBackgroundColour()
self._field.SetOwnBackgroundColour(colour) self._field.SetOwnBackgroundColour(colour)
# A little spacing. # A little spacing.
sub_sizer.AddSpacer(5) sub_sizer.AddSpacer(5)
# The edit button. # The edit button.
button = wx.BitmapButton(parent, -1, wx.Bitmap(fetch_icon('oxygen.ac tions.edit-rename', "16x16"), wx.BITMAP_TYPE_ANY)) button = wx.BitmapButton(parent, -1, wx.Bitmap(fetch_icon('oxygen.ac tions.edit-rename', "16x16"), wx.BITMAP_TYPE_ANY))
button.SetMinSize((height_element, height_element)) button.SetMinSize((height_element, height_element))
button.SetToolTipString("Edit the values.") button.SetToolTip(wx.ToolTip("Edit the values."))
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)
parent.Bind(wx.EVT_BUTTON, self.open_dialog, button) parent.Bind(wx.EVT_BUTTON, self.open_dialog, button)
# Right padding. # Right padding.
sub_sizer.AddSpacer(padding) sub_sizer.AddSpacer(padding)
# Add to the main sizer. # Add to the main sizer.
sizer.Add(sub_sizer, 1, wx.EXPAND|wx.ALL, 0) sizer.Add(sub_sizer, 1, wx.EXPAND|wx.ALL, 0)
# Spacing below the widget. # Spacing below the widget.
if spacer == None: if spacer == None:
sizer.AddStretchSpacer() sizer.AddStretchSpacer()
else: else:
sizer.AddSpacer(spacer) sizer.AddSpacer(spacer)
# Tooltip. # Tooltip.
if tooltip: if tooltip:
text.SetToolTipString(tooltip) text.SetToolTip(wx.ToolTip(tooltip))
self._field.SetToolTipString(tooltip) self._field.SetToolTip(wx.ToolTip(tooltip))
# Set the default value. # Set the default value.
if self.default is not None: if self.default is not None:
self._field.SetValue(self.convert_to_gui_seq(self.default)) self._field.SetValue(self.convert_to_gui_seq(self.default))
# Initialise the combo list input field. # Initialise the combo list input field.
elif self.element_type == 'combo_list': elif self.element_type == 'combo_list':
# Translate the read_only flag if None. # Translate the read_only flag if None.
if read_only == None: if read_only == None:
read_only = False read_only = False
skipping to change at line 505 skipping to change at line 509
title = "Edit the %s values." % name title = "Edit the %s values." % name
# Set up the dialog. # Set up the dialog.
wx.Dialog.__init__(self, parent, id=-1, title=title) wx.Dialog.__init__(self, parent, id=-1, title=title)
# Initialise some values # Initialise some values
self.width = self.SIZE[0] - 2*self.BORDER self.width = self.SIZE[0] - 2*self.BORDER
# Set the frame properties. # Set the frame properties.
self.SetSize(self.SIZE) self.SetSize(self.SIZE)
self.Centre() if not dep_check.wx_classic and status.show_gui:
self.Centre()
self.SetFont(font.normal) self.SetFont(font.normal)
# The main box sizer. # The main box sizer.
main_sizer = wx.BoxSizer(wx.VERTICAL) main_sizer = wx.BoxSizer(wx.VERTICAL)
# Pack the sizer into the frame. # Pack the sizer into the frame.
self.SetSizer(main_sizer) self.SetSizer(main_sizer)
# Build the central sizer, with borders. # Build the central sizer, with borders.
sizer = add_border(main_sizer, border=self.BORDER, packing=wx.VERTICAL) sizer = add_border(main_sizer, border=self.BORDER, packing=wx.VERTICAL)
skipping to change at line 599 skipping to change at line 604
except TypeError: except TypeError:
if self.seq_type == 'list': if self.seq_type == 'list':
values = [values] values = [values]
elif self.seq_type == 'tuple': elif self.seq_type == 'tuple':
values = (values,) values = (values,)
# Loop over the entries. # Loop over the entries.
for i in range(len(values)): for i in range(len(values)):
# Fixed dimension sequences - set the values of the pre-created list . # Fixed dimension sequences - set the values of the pre-created list .
if not self.variable_length: if not self.variable_length:
self.sequence.SetStringItem(i, 1, self.convert_to_gui(values[i]) if dep_check.wx_classic:
) self.sequence.SetStringItem(i, 1, self.convert_to_gui(values
[i]))
else:
self.sequence.SetItem(i, 1, self.convert_to_gui(values[i]))
# Variable dimension sequences - append the item to the end of the b lank list. # Variable dimension sequences - append the item to the end of the b lank list.
else: else:
# The first element already exists. # The first element already exists.
if i != 0: if i != 0:
# First add the index+1. # First add the index+1.
self.sequence.InsertStringItem(i, int_to_gui(i+1)) if dep_check.wx_classic:
self.sequence.InsertStringItem(i, int_to_gui(i+1))
else:
self.sequence.InsertItem(i, int_to_gui(i+1))
# Then set the value. # Then set the value.
self.sequence.SetStringItem(i, 1, self.convert_to_gui(values[i]) if dep_check.wx_classic:
) self.sequence.SetStringItem(i, 1, self.convert_to_gui(values
[i]))
else:
self.sequence.SetItem(i, 1, self.convert_to_gui(values[i]))
def add_buttons(self, sizer): def add_buttons(self, sizer):
"""Add the buttons to the sizer. """Add the buttons to the sizer.
@param sizer: A sizer object. @param sizer: A sizer object.
@type sizer: wx.Sizer instance @type sizer: wx.Sizer instance
""" """
# Create a horizontal layout for the buttons. # Create a horizontal layout for the buttons.
button_sizer = wx.BoxSizer(wx.HORIZONTAL) button_sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(button_sizer, 0, wx.ALIGN_CENTER|wx.ALL, 0) sizer.Add(button_sizer, 0, wx.ALIGN_CENTER|wx.ALL, 0)
# The non-fixed sequence buttons. # The non-fixed sequence buttons.
if self.variable_length: if self.variable_length:
# The add button. # The add button.
button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Add") button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Add")
button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-add- relax-blue', "22x22"), wx.BITMAP_TYPE_ANY)) button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-add- relax-blue', "22x22"), wx.BITMAP_TYPE_ANY))
button.SetFont(font.normal) button.SetFont(font.normal)
button.SetToolTipString("Add an item to the list.") button.SetToolTip(wx.ToolTip("Add an item to the list."))
button.SetMinSize(self.SIZE_BUTTON) button.SetMinSize(self.SIZE_BUTTON)
button_sizer.Add(button, 0, wx.ADJUST_MINSIZE, 0) button_sizer.Add(button, 0, wx.ADJUST_MINSIZE, 0)
self.Bind(wx.EVT_BUTTON, self.add_element, button) self.Bind(wx.EVT_BUTTON, self.add_element, button)
# Spacer. # Spacer.
button_sizer.AddSpacer(20) button_sizer.AddSpacer(20)
# The delete button. # The delete button.
button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Delete") button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Delete")
button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-remo ve', "22x22"), wx.BITMAP_TYPE_ANY)) button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-remo ve', "22x22"), wx.BITMAP_TYPE_ANY))
button.SetFont(font.normal) button.SetFont(font.normal)
button.SetToolTipString("Delete the last item.") button.SetToolTip(wx.ToolTip("Delete the last item."))
button.SetMinSize(self.SIZE_BUTTON) button.SetMinSize(self.SIZE_BUTTON)
button_sizer.Add(button, 0, wx.ADJUST_MINSIZE, 0) button_sizer.Add(button, 0, wx.ADJUST_MINSIZE, 0)
self.Bind(wx.EVT_BUTTON, self.delete, button) self.Bind(wx.EVT_BUTTON, self.delete, button)
# Spacer. # Spacer.
button_sizer.AddSpacer(20) button_sizer.AddSpacer(20)
# The delete all button. # The delete all button.
button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Delete all") button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Delete all")
button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.edit-dele te', "22x22"), wx.BITMAP_TYPE_ANY)) button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.edit-dele te', "22x22"), wx.BITMAP_TYPE_ANY))
button.SetFont(font.normal) button.SetFont(font.normal)
button.SetToolTipString("Delete all items.") button.SetToolTip(wx.ToolTip("Delete all items."))
button.SetMinSize(self.SIZE_BUTTON) button.SetMinSize(self.SIZE_BUTTON)
button_sizer.Add(button, 0, wx.ADJUST_MINSIZE, 0) button_sizer.Add(button, 0, wx.ADJUST_MINSIZE, 0)
self.Bind(wx.EVT_BUTTON, self.delete_all, button) self.Bind(wx.EVT_BUTTON, self.delete_all, button)
# Spacer. # Spacer.
button_sizer.AddSpacer(20) button_sizer.AddSpacer(20)
# The Ok button. # The Ok button.
button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Ok" ) button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Ok" )
button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.dialog-ok', " 22x22"), wx.BITMAP_TYPE_ANY)) button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.dialog-ok', " 22x22"), wx.BITMAP_TYPE_ANY))
skipping to change at line 680 skipping to change at line 694
@keyword event: The wx event. @keyword event: The wx event.
@type event: wx event @type event: wx event
""" """
# The next index. # The next index.
next = self.sequence.GetItemCount() next = self.sequence.GetItemCount()
# Add a new row with the index at the start. # Add a new row with the index at the start.
if self.variable_length: if self.variable_length:
self.sequence.InsertStringItem(next, int_to_gui(next+1)) if dep_check.wx_classic:
self.sequence.InsertStringItem(next, int_to_gui(next+1))
else:
self.sequence.InsertItem(next, int_to_gui(next+1))
# Add a new empty row. # Add a new empty row.
else: else:
self.sequence.InsertStringItem(next, str_to_gui('')) if dep_check.wx_classic:
self.sequence.InsertStringItem(next, str_to_gui(''))
else:
self.sequence.InsertItem(next, str_to_gui(''))
def add_list(self, sizer): def add_list(self, sizer):
"""Set up the list control. """Set up the list control.
@param sizer: A sizer object. @param sizer: A sizer object.
@type sizer: wx.Sizer instance @type sizer: wx.Sizer instance
""" """
# The control. # The control.
self.sequence = Sequence_list_ctrl(self) self.sequence = Sequence_list_ctrl(self)
skipping to change at line 722 skipping to change at line 742
sizer.Add(self.sequence, 1, wx.ALL|wx.EXPAND, 0) sizer.Add(self.sequence, 1, wx.ALL|wx.EXPAND, 0)
# The fixed dimension sequence - add all the rows needed. # The fixed dimension sequence - add all the rows needed.
if not self.variable_length: if not self.variable_length:
for i in range(self.dim): for i in range(self.dim):
# Add a new row. # Add a new row.
self.add_element() self.add_element()
# Add a title to the first column. # Add a title to the first column.
if self.titles: if self.titles:
self.sequence.SetStringItem(i, 0, str_to_gui(self.titles[i]) if dep_check.wx_classic:
) self.sequence.SetStringItem(i, 0, str_to_gui(self.titles
[i]))
else:
self.sequence.SetItem(i, 0, str_to_gui(self.titles[i]))
# Otherwise add numbers starting from 1. # Otherwise add numbers starting from 1.
else: else:
self.sequence.SetStringItem(i, 0, int_to_gui(i+1)) if dep_check.wx_classic:
self.sequence.SetStringItem(i, 0, int_to_gui(i+1))
else:
self.sequence.SetItem(i, 0, int_to_gui(i+1))
def close(self, event): def close(self, event):
"""Close the window. """Close the window.
@param event: The wx event. @param event: The wx event.
@type event: wx event @type event: wx event
""" """
# Close the window. # Close the window.
self.Close() self.Close()
 End of changes. 16 change blocks. 
19 lines changed or deleted 45 lines changed or added

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