Commit f6a15c69 authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

Merge branch '16-cleaning' into 27-save-and-load

parents 37040404 8de6d09b
# System
import sys
import json
......@@ -10,38 +11,101 @@ except:
from PySide import QtGui
from PySide import QtCore
# Qt4 Lib
# App
QApplication = QtGui.QApplication
# Widgets
QWidget = QtGui.QWidget
QVBoxLayout = QtGui.QVBoxLayout
QHBoxLayout = QtGui.QHBoxLayout
QGridLayout = QtGui.QGridLayout
#
QPushButton = QtGui.QPushButton
QMainWindow = QtGui.QMainWindow
QTabWidget = QtGui.QTabWidget
QFont = QtGui.QFont
QLabel = QtGui.QLabel
QLineEdit = QtGui.QLineEdit
QTextEdit = QtGui.QTextEdit
QPlainTextEdit = QtGui.QPlainTextEdit
QAction = QtGui.QAction
QIcon = QtGui.QIcon
QComboBox = QtGui.QComboBox
#
QTabWidget = QtGui.QTabWidget
QPlainTextEdit = QtGui.QPlainTextEdit
QListWidget = QtGui.QListWidget
#
QFileDialog = QtGui.QFileDialog
QMainWindow = QtGui.QMainWindow
# Layout
QVBoxLayout = QtGui.QVBoxLayout
QHBoxLayout = QtGui.QHBoxLayout
QGridLayout = QtGui.QGridLayout
QFormLayout = QtGui.QFormLayout
QListWidget = QtGui.QListWidget
# Font
QFont = QtGui.QFont
# Trigger
QAction = QtGui.QAction
MouseButtonDblClick = QtCore.QEvent.MouseButtonDblClick
# Others
QIcon = QtGui.QIcon
LeftButton = QtCore.Qt.LeftButton
# MatPlotLib
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as QCanvas
# MyPlotLib
from myplotlib import INFO, SPCE, WARN, DBUG, SEVR
from myplotlib import MyAxes, MyFig, MyData, np
from myplotlib.test import FigTest1, readStupidData, readStupidData2
from .mplDesign import MyDesign, AxDesign, FigDesign
from myplotlib import D_DEBUG
# CONSTANTS
DEFAULT_DECLARE_ALIASES = '''
self.aliases = {}
'''
DEFAULT_ADDAXES = '''
ratio = 6./8.
frame = [0.2, 0.15, 0.6, 0.7]
self.add_axes(AxEmptyPlot(self, ratio, frame), 'ax1')
'''
DEFAULT_DECLARE_KEYWORDS = '''
# If you want you can change the color
self.keywords = {'color': 'r'}
'''
DEFAULT_FORMAT_RAWDATA = '''
# Stupid self-made data
self.data = {'xdata': [-1, 1],
'ydata1': [-1, 1],
'ydata2': [1, -1]}
'''
DEFAULT_PLOTTING = '''
# import
from matplotlib.patches import Rectangle
# get keyword
color = self.keywords.get('color', 'r')
# Plot the red lines
self.plot(self.data['xdata'], self.data['ydata1'], color=color)
self.plot(self.data['xdata'], self.data['ydata2'], color=color)
# add text
self.text(-0.45, -0.07, 'Nothing to plot', color='purple')
# add Patch
self.add_patch(Rectangle((-0.5, -0.12), 1.0, 0.21, color='w', zorder=3))
# set x/y-axis to invisible
self.xaxis.set_visible(False)
self.yaxis.set_visible(False)
'''
# Local Import
from .mplDesign import MyDesign, AxDesign, FigDesign
from .pythonHighlighter import PythonHighlighter
from .qMyFigContainer import QMyFigContainer
from .qTabMyAxes import QTabMyAxes
......@@ -52,10 +116,10 @@ from .qMyDesignWidget import QMyDesignWidget
from .qOpenFileWidget import QOpenFileWidget
from .qMyDesignGui import QMyDesignGui
# Import IOs
#import myIOs
from .myIOs import *
from .myAxes import AxActivity
# Import myAxes
#from .myAxes import AxActivity
# import myFigures
# IMPORTS
from . import sys
from . import INFO, SPCE, DBUG
from . import D_DEBUG
# CONFIG
D_NO_VERBOSE = False
#debug = D_DEBUG
debug = True
noverbose = D_NO_VERBOSE
if debug:
prompt = __name__ + ": "
INFO = INFO + prompt
SPCE = SPCE + prompt
DBUG = DBUG + prompt
# WIDGET IMPORTS
from . import QApplication
from . import QMyDesignGui
from . import myIOs
for key in myIOs.__dict__.keys():
if key not in myIOs.__builtins__.keys() and not key.startswith('__'):
print(key)
if not noverbose:
print(INFO + "Welcome by My Design Gui - v0\n")
if debug:
print(DBUG + "You are using python {}.{}.{}".format(sys.version_info[0], sys.version_info[1], sys.version_info[2]))
print(SPCE + "The inline arguments are: " + str(sys.argv) + '\n')
# Create application
app = QApplication(sys.argv)
# Create main window
w = QMyDesignGui()
# Start App
status = app.exec_()
sys.exit(status)
from . import MyAxes
from . import MyFig
DEFAULT_DECLARE_KEYWORDS = '''
self.keywords = {}
'''
DEFAULT_FORMAT_RAWDATA = '''
self.data = {'xdata': [-5, 2],
'ydata': [-2, 4]}
'''
DEFAULT_PLOTTING = '''
self.plot(self.data['xdata'], self.data['ydata'])
'''
from . import DEFAULT_DECLARE_ALIASES
from . import DEFAULT_ADDAXES
from . import DEFAULT_DECLARE_KEYWORDS
from . import DEFAULT_FORMAT_RAWDATA
from . import DEFAULT_PLOTTING
_DEFAULT_DESIGN = {'declareKeywords': DEFAULT_DECLARE_KEYWORDS,
'formatRawData': DEFAULT_FORMAT_RAWDATA,
'plotting': DEFAULT_PLOTTING}
DEFAULT_ADDAXES = '''
#myAxesDesign = self.design.get('MyAxes', _DEFAULT_DESIGN)
ratio = 6./8.
frame = [0.2, 0.15, 0.6, 0.7]
#self.add_axes(AxDesign(self, ratio, frame, design=myAxesDesign), 'ax1')
#self.add_axes(MyAxes0(self, ratio, frame), 'ax1')
'''
DEFAULT_DECLARE_ALIASES = '''
self.aliases = {}
'''
_DEFAULT_FIG_DESIGN = {'declareAliases': DEFAULT_DECLARE_ALIASES,
'addAxes': DEFAULT_ADDAXES}
class MyDesign(dict):
def __init__(self):
......
......@@ -4,19 +4,35 @@
# IMPORT OS -- SHOULD BE DONE THAT WAY TO DETECT THE FUNCTION PROPERLY
import os
from .. import DBUG, SPCE, WARN, D_DEBUG
#debug = D_DEBUG
debug = True
if debug:
prompt = "myIOs.__init__: "
DBUG = DBUG + prompt
SPCE = SPCE + prompt
WARN = WARN + prompt
# LIST OF FILE NAMES IN myIOS/*.py (except *_*.py)
functions = []
for function in os.listdir(os.path.dirname(os.path.abspath(__file__))):
if function[-3:] == '.py' and '_' not in os.path.basename(function):
functions.append(function[:-3])
print(functions)
# PRINT INFOS
if debug:
print(DBUG + "Importing the following function from myIOs:")
for func in functions:
print(SPCE + str(func))
# LOOP OVER FILES AND IMPORT THE FUNCTION
# THIS IS EQUIVALENT TO: FROM .FILE IMPORT FILE
for function in functions:
#module = __import__('mydesigngui.myIOs', globals(), locals(), [function], -1)
module = __import__('mydesigngui.myIOs', globals(), locals(), [function], 0)
subMod = vars(module)[function]
vars()[function] = vars(subMod)[function]
try:
module = __import__('mydesigngui.myIOs', globals(), locals(), [function], 0)
subMod = vars(module)[function]
vars()[function] = vars(subMod)[function]
except:
print(WARN + "The function " + function.__name__ + " could not be loaded...")
......@@ -16,12 +16,12 @@ class QMyDesignTabs(QTabWidget):
super(QMyDesignTabs, self).__init__(parent)
self.figTab = QTabMyFig(self)
self.axesTab = QTabMyAxes("MyAxes0", self)
self.axesTab = QTabMyAxes("AxEmptyPlot", self)
self.dataTab = QTabMyData(self)
self.addTab(self.dataTab, "MyData")
self.addTab(self.figTab, "MyFigure")
self.addTab(self.axesTab, "MyAxes0")
self.addTab(self.axesTab, "AxEmptyPlot")
self.addTab(QWidget(self), "+")
self.setTabEnabled(self.tabBar().count()-1, False)
......
......@@ -15,7 +15,6 @@ PYVERSION = sys.version_info
for key in myIOs.__dict__.keys():
if key not in myIOs.__builtins__.keys() and not key.startswith('__'):
print(myIOs.__dict__[key])
if isinstance(myIOs.__dict__[key], FunctionType):
AVAIL_FUNCTIONS.append(myIOs.__dict__[key])
......
......@@ -14,6 +14,10 @@ from . import QSignal
from . import json
from . import DEFAULT_DECLARE_KEYWORDS
from . import DEFAULT_FORMAT_RAWDATA
from . import DEFAULT_PLOTTING
class QTabMyAxes(QWidget):
......@@ -139,16 +143,3 @@ class QTabMyAxes(QWidget):
self.editDeclareKeywords.setPlainText(declareKeywords)
self.editFormatRawdata.setPlainText(formatRawData)
self.editPlotting.setPlainText(plotting)
DEFAULT_DECLARE_KEYWORDS = '''
self.keywords = {}
'''
DEFAULT_FORMAT_RAWDATA = '''
self.data = {'xdata': [-5, 2],
'ydata': [-2, 4]}
'''
DEFAULT_PLOTTING = '''
self.plot(self.data['xdata'], self.data['ydata'])
'''
......@@ -7,6 +7,8 @@ from . import QTextEdit
from . import QPlainTextEdit
from . import PythonHighlighter
from . import DEFAULT_DECLARE_ALIASES
from . import DEFAULT_ADDAXES
class QTabMyFig(QWidget):
......@@ -48,22 +50,9 @@ class QTabMyFig(QWidget):
functions.update({'addAxes': str(self.editAddAxes.toPlainText())})
return(functions)
def getClassName(self):
name = str(self.editName.text())
return(name)
DEFAULT_DECLARE_ALIASES = '''
self.aliases = {}
'''
DEFAULT_ADDAXES = '''
ratio = 6./8.
frame = [0.2, 0.15, 0.6, 0.7]
self.add_axes(MyAxes0(self, ratio, frame), 'ax1')
'''
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment