"Fossies" - the Fresh Open Source Software Archive  

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

file.py  (relax-4.1.3.src.tar.bz2):file.py  (relax-5.0.0.src.tar.bz2)
############################################################################### ###############################################################################
# # # #
# Copyright (C) 2012,2014 Edward d'Auvergne # # Copyright (C) 2012,2014,2016,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 31 skipping to change at line 31
# 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
from wx.lib import scrolledpanel from wx.lib import scrolledpanel
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.filedialog import RelaxFileDialog from gui.filedialog import RelaxFileDialog
from gui.fonts import font from gui.fonts import font
from gui.misc import add_border, open_file from gui.misc import add_border, open_file
from gui.string_conv import gui_to_list, gui_to_str, list_to_gui, str_to_gui from gui.string_conv import gui_to_list, gui_to_str, list_to_gui, str_to_gui
from lib.errors import RelaxError from lib.errors import RelaxError
from status import Status; status = Status() from status import Status; status = Status()
class File_element: class File_element:
"""A single file element for the multiple file input GUI element.""" """A single file element for the multiple file input GUI element."""
skipping to change at line 107 skipping to change at line 108
self.field.SetMinSize((-1, height_element)) self.field.SetMinSize((-1, height_element))
self.field.SetFont(font.normal) self.field.SetFont(font.normal)
sub_sizer.Add(self.field, 1, wx.EXPAND|wx.ADJUST_MINSIZE|wx.ALIGN_CENTER _VERTICAL, 0) sub_sizer.Add(self.field, 1, wx.EXPAND|wx.ADJUST_MINSIZE|wx.ALIGN_CENTER _VERTICAL, 0)
# A little spacing. # A little spacing.
sub_sizer.AddSpacer(width_spacer) sub_sizer.AddSpacer(width_spacer)
# The file selection button. # The file selection button.
button = wx.BitmapButton(self.parent, -1, wx.Bitmap(fetch_icon('oxygen.a ctions.document-open', "16x16"), wx.BITMAP_TYPE_ANY)) button = wx.BitmapButton(self.parent, -1, wx.Bitmap(fetch_icon('oxygen.a ctions.document-open', "16x16"), wx.BITMAP_TYPE_ANY))
button.SetMinSize((height_element, height_element)) button.SetMinSize((height_element, height_element))
button.SetToolTipString("Select the file.") button.SetToolTip(wx.ToolTip("Select the file."))
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.select_file, button) self.parent.Bind(wx.EVT_BUTTON, self.select_file, button)
# File preview. # File preview.
if preview: if preview:
# A little spacing. # A little spacing.
sub_sizer.AddSpacer(width_spacer) sub_sizer.AddSpacer(width_spacer)
# The preview button. # The preview button.
button = wx.BitmapButton(self.parent, -1, wx.Bitmap(fetch_icon('oxyg en.actions.document-preview', "16x16"), wx.BITMAP_TYPE_ANY)) button = wx.BitmapButton(self.parent, -1, wx.Bitmap(fetch_icon('oxyg en.actions.document-preview', "16x16"), wx.BITMAP_TYPE_ANY))
button.SetMinSize((height_element, height_element)) button.SetMinSize((height_element, height_element))
button.SetToolTipString("Preview") button.SetToolTip(wx.ToolTip("Preview"))
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.preview_file, button) self.parent.Bind(wx.EVT_BUTTON, self.preview_file, button)
# Right padding. # Right padding.
sub_sizer.AddSpacer(padding) sub_sizer.AddSpacer(padding)
# Add the sizer to the main sizer. # Add the sizer to the main sizer.
self.sizer.Add(sub_sizer, 1, wx.ALL|wx.EXPAND, 0) self.sizer.Add(sub_sizer, 1, wx.ALL|wx.EXPAND, 0)
# Add spacing. # Add spacing.
skipping to change at line 245 skipping to change at line 246
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, default) self._field = wx.TextCtrl(parent, -1, default)
self._field.SetMinSize((-1, height_element)) self._field.SetMinSize((-1, height_element))
self._field.SetFont(font.normal) self._field.SetFont(font.normal)
sub_sizer.Add(self._field, 1, wx.ADJUST_MINSIZE|wx.ALIGN_CENTER_VERTICAL , 0) sub_sizer.Add(self._field, 1, wx.ADJUST_MINSIZE|wx.ALIGN_CENTER_VERTICAL , 0)
# The file selection object. # The file selection object.
obj = RelaxFileDialog(parent, field=self._field, message=message, defaul tFile=default, wildcard=wildcard, style=style) obj = RelaxFileDialog(parent, field=self._field, message=message, defaul tFile=default, wildcard=wildcard, style=style)
# A little spacing. # A little spacing.
sub_sizer.AddSpacer(5) sub_sizer.AddSpacer(5)
# The file selection button. # The file selection button.
button = wx.BitmapButton(parent, -1, wx.Bitmap(fetch_icon('oxygen.action s.document-open', "16x16"), wx.BITMAP_TYPE_ANY)) button = wx.BitmapButton(parent, -1, wx.Bitmap(fetch_icon('oxygen.action s.document-open', "16x16"), wx.BITMAP_TYPE_ANY))
button.SetMinSize((height_element, height_element)) button.SetMinSize((height_element, height_element))
button.SetToolTipString("Select the file.") button.SetToolTip(wx.ToolTip("Select the file."))
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, obj.select_event, button) parent.Bind(wx.EVT_BUTTON, obj.select_event, button)
# File preview. # File preview.
if preview: if preview:
# A little spacing. # A little spacing.
sub_sizer.AddSpacer(5) sub_sizer.AddSpacer(5)
# The preview button. # The preview button.
button = wx.BitmapButton(parent, -1, wx.Bitmap(fetch_icon('oxygen.ac tions.document-preview', "16x16"), wx.BITMAP_TYPE_ANY)) button = wx.BitmapButton(parent, -1, wx.Bitmap(fetch_icon('oxygen.ac tions.document-preview', "16x16"), wx.BITMAP_TYPE_ANY))
button.SetMinSize((height_element, height_element)) button.SetMinSize((height_element, height_element))
button.SetToolTipString("Preview") button.SetToolTip(wx.ToolTip("Preview"))
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.preview_file, button) parent.Bind(wx.EVT_BUTTON, self.preview_file, button)
# Right padding. # Right padding.
sub_sizer.AddSpacer(padding) sub_sizer.AddSpacer(padding)
# Add to the main sizer (followed by stretchable spacing). # Add to the main sizer (followed by stretchable spacing).
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))
def Clear(self): def Clear(self):
"""Special method for clearing or resetting the GUI element.""" """Special method for clearing or resetting the GUI element."""
# Clear the value from the TextCtrl. # Clear the value from the TextCtrl.
self._field.Clear() self._field.Clear()
def GetValue(self): def GetValue(self):
"""Special method for returning the value of the GUI element. """Special method for returning the value of the GUI element.
skipping to change at line 404 skipping to change at line 408
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, default) self._field = wx.TextCtrl(parent, -1, default)
self._field.SetMinSize((-1, height_element)) self._field.SetMinSize((-1, height_element))
self._field.SetFont(font.normal) self._field.SetFont(font.normal)
sub_sizer.Add(self._field, 1, wx.ADJUST_MINSIZE|wx.ALIGN_CENTER_VERTICAL , 0) sub_sizer.Add(self._field, 1, wx.ADJUST_MINSIZE|wx.ALIGN_CENTER_VERTICAL , 0)
# The file selection object. # The file selection object.
obj = RelaxFileDialog(parent, field=self._field, message=message, defaul tFile=default, wildcard=wildcard, style=style) obj = RelaxFileDialog(parent, field=self._field, message=message, defaul tFile=default, wildcard=wildcard, style=style)
# 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.action s.document-open', "16x16"), wx.BITMAP_TYPE_ANY)) button = wx.BitmapButton(parent, -1, wx.Bitmap(fetch_icon('oxygen.action s.document-open', "16x16"), wx.BITMAP_TYPE_ANY))
button.SetMinSize((height_element, height_element)) button.SetMinSize((height_element, height_element))
button.SetToolTipString("Choose the file(s).") button.SetToolTip(wx.ToolTip("Choose the file(s)."))
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 (followed by stretchable spacing). # Add to the main sizer (followed by stretchable spacing).
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))
def Clear(self): def Clear(self):
"""Special method for clearing or resetting the GUI element.""" """Special method for clearing or resetting the GUI element."""
# Clear the value from the TextCtrl. # Clear the value from the TextCtrl.
self._field.Clear() self._field.Clear()
def GetValue(self): def GetValue(self):
"""Special method for returning the value of the GUI element. """Special method for returning the value of the GUI element.
skipping to change at line 609 skipping to change at line 616
title = "Multiple %s selection." % name title = "Multiple %s selection." % 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 694 skipping to change at line 702
""" """
# 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 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-rela x-blue', "22x22"), wx.BITMAP_TYPE_ANY)) button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-add-rela x-blue', "22x22"), wx.BITMAP_TYPE_ANY))
button.SetFont(font.normal) button.SetFont(font.normal)
button.SetToolTipString("Add a file selection item to the list.") button.SetToolTip(wx.ToolTip("Add a file selection 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, " Del ete") button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Del ete")
button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-remove', "22x22"), wx.BITMAP_TYPE_ANY)) button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.list-remove', "22x22"), wx.BITMAP_TYPE_ANY))
button.SetFont(font.normal) button.SetFont(font.normal)
button.SetToolTipString("Delete the last file selection item.") button.SetToolTip(wx.ToolTip("Delete the last file selection 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, " Del ete all") button = wx.lib.buttons.ThemedGenBitmapTextButton(self, -1, None, " Del ete all")
button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.edit-delete', "22x22"), wx.BITMAP_TYPE_ANY)) button.SetBitmapLabel(wx.Bitmap(fetch_icon('oxygen.actions.edit-delete', "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 810 skipping to change at line 818
self.Close() self.Close()
def delete(self, event=None): def delete(self, event=None):
"""Remove the last file selection item from the list. """Remove the last file selection item from the list.
@keyword event: The wx event. @keyword event: The wx event.
@type event: wx event @type event: wx event
""" """
# Destroy the last subsizer. # Destroy the last subsizer.
self.elements[-1].sizer.DeleteWindows() self.elements[-1].sizer.Clear(True)
self.element_sizer.Remove(self.elements[-1].sizer) self.element_sizer.Remove(self.elements[-1].sizer)
# Destroy the Python structures. # Destroy the Python structures.
self.elements.pop() self.elements.pop()
# If the list is empty, start again with a single blank element. # If the list is empty, start again with a single blank element.
if not len(self.elements): if not len(self.elements):
self.add_element() self.add_element()
# Redraw. # Redraw.
skipping to change at line 832 skipping to change at line 840
def delete_all(self, event=None): def delete_all(self, event=None):
"""Remove all file selection items from the list. """Remove all file selection items from the list.
@keyword event: The wx event. @keyword event: The wx event.
@type event: wx event @type event: wx event
""" """
# Destroy the subsizer. # Destroy the subsizer.
for i in range(len(self.elements)): for i in range(len(self.elements)):
self.elements[i].sizer.DeleteWindows() self.elements[i].sizer.Clear(True)
self.element_sizer.Remove(self.elements[i].sizer) self.element_sizer.Remove(self.elements[i].sizer)
# Destroy all Python structures. # Destroy all Python structures.
del self.elements del self.elements
# Reset the elements, starting again with a single blank element. # Reset the elements, starting again with a single blank element.
self.elements = [] self.elements = []
self.add_element() self.add_element()
# Redraw. # Redraw.
 End of changes. 17 change blocks. 
18 lines changed or deleted 26 lines changed or added

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