Skip to content

Commit

Permalink
Merge branch 'develop' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
UmSenhorQualquer committed Jan 30, 2019
2 parents 97ef1da + 7561689 commit cb4e9ba
Show file tree
Hide file tree
Showing 22 changed files with 310 additions and 135 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Pyforms is a Python 2.7.x and 3.x cross-enviroment framework to develop GUI appl
### It offers
* A Python layer of Desktop forms, based on PyQt, OpenGL and other libraries.
* A Python layer that allow applications to run on Desktop GUI, Web and terminal without requiring code modifications.
* A group of rules and methodologies that help the developer maintaining his code short, clean, reusable and readable.
* A group of rules and methodologies that help the developer maintain short, clean, reusable and readable.

![Diagram](https://raw.githubusercontent.com/UmSenhorQualquer/pyforms/v3.0/docs/pyforms.png?raw=true "Screen")

Expand Down
11 changes: 11 additions & 0 deletions docs/source/getting-started/the-basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ Try now:
#Use the sign '=' for a vertical splitter
#Use the signs '||' for a horizontal splitter
.. note::

In the name of each tab use the format **a:Tab1** and **b:Tab2** to define the order of the tabs. Example:

.. code::
self.formset = [ {
'a:Tab1':['_firstname','||','_middlename','||','_lastname'],
'b:Tab2':['_fullname']
}
## **Add a main menu**
***************************
Expand Down
2 changes: 1 addition & 1 deletion pyforms_gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__author__ = "Ricardo Ribeiro"
__credits__ = ["Ricardo Ribeiro"]
__license__ = "MIT"
__version__ = "4.0.10"
__version__ = "4.0.11"
__maintainer__ = "Ricardo Ribeiro"
__email__ = "ricardojvr@gmail.com"
__status__ = "Development"
Expand Down
7 changes: 6 additions & 1 deletion pyforms_gui/appmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,19 @@ def execute_test_file(myapp):
exec(code, global_vars, local_vars)


def start_app(ClassObject, geometry=None, stylesheet=None):
def start_app(ClassObject, geometry=None, stylesheet=None, user_settings=None):
from confapp import conf

app = QApplication(sys.argv)

conf += 'pyforms_gui.settings'
if user_settings:
conf += user_settings

mainwindow = StandAloneContainer(ClassObject)

if hasattr( conf, 'PYFORMS_MAIN_WINDOW_ICON_PATH'):
mainwindow.setWindowIcon(QIcon(conf.PYFORMS_MAIN_WINDOW_ICON_PATH))

myapp = mainwindow.centralWidget()

Expand Down
29 changes: 20 additions & 9 deletions pyforms_gui/basewidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,27 +375,38 @@ def input_int(self, msg, title='', default=0, min=-2147483647, max=2147483647):
else:
return None


def question(self, msg, title=None, buttons=['no', 'yes']):
btns = None
for btn in buttons:
if btn.lower()=='cancel':
if btn.lower() == 'cancel':
b = QMessageBox.Cancel
elif btn.lower()=='no':
elif btn.lower() == 'no':
b = QMessageBox.No
elif btn.lower()=='yes':
elif btn.lower() == 'yes':
b = QMessageBox.Yes
elif btn.lower() == 'no_all':
b = QMessageBox.NoToAll
elif btn.lower() == 'yes_all':
b = QMessageBox.YesToAll

if btns is None:
btns=b
else: btns |= b
btns = b
else:
btns |= b

m = QMessageBox(QMessageBox.Question, title, msg, btns)
reply = m.exec_()

if reply==QMessageBox.Cancel: return 'cancel'
elif reply==QMessageBox.No: return 'no'
elif reply==QMessageBox.Yes: return 'yes'
if reply == QMessageBox.Cancel:
return 'cancel'
elif reply == QMessageBox.No:
return 'no'
elif reply == QMessageBox.Yes:
return 'yes'
elif reply == QMessageBox.NoToAll:
return 'no_all'
elif reply == QMessageBox.YesToAll:
return 'yes_all'

return None

Expand Down
14 changes: 9 additions & 5 deletions pyforms_gui/controls/control_combo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from pyforms_gui.controls.control_base import ControlBase

class ValueNotSet: pass

class ControlCombo(ControlBase, QWidget):
"""This class represents a wrapper to the combo box"""
Expand Down Expand Up @@ -65,9 +66,10 @@ def clear(self):
self._value = None
self._combo.clear()

def add_item(self, label, value=None):
def add_item(self, label, value=ValueNotSet):
self._addingItem = True
if value is not None:

if value is not ValueNotSet:
if not (value in self._items.values()):
self._combo.addItem(label)
else:
Expand All @@ -78,7 +80,7 @@ def add_item(self, label, value=None):
if self._items == {}:
firstValue = True

if value is None:
if value is ValueNotSet:
self._items[str(label)] = label
else:
self._items[str(label)] = value
Expand Down Expand Up @@ -233,6 +235,8 @@ def _editTextChanged(self, text):
def _currentIndexChanged(self, index):
if not self._addingItem:
item = self._combo.currentText()
if len(item) >= 1:
ControlBase.value.fset(self, self._items[str(item)])
item = str(item)

if item in self._items:
ControlBase.value.fset(self, self._items[ str(item) ] )
self.current_index_changed_event(index)
12 changes: 7 additions & 5 deletions pyforms_gui/controls/control_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pyforms_gui.utils.tools as tools


from AnyQt import uic
from AnyQt import uic, _api
from AnyQt.QtWidgets import QFileDialog


Expand All @@ -18,20 +18,22 @@ def init_form(self):
control_path = tools.getFileInSameDirectory(__file__, "fileInput.ui")
self._form = uic.loadUi(control_path)
self._form.pushButton.clicked.connect(self.click)
self.form.label.setText(self._label)
self.form.lineEdit.editingFinished.connect(self.finishEditing)
self._form.pushButton.setIcon(conf.PYFORMS_ICON_FILE_OPEN)
super(ControlDir, self).init_form()


def click(self):
value = QFileDialog.getExistingDirectory(self.parent, self._label, self.value)
value = QFileDialog.getExistingDirectory(self.parent, self._label)

if _api.USED_API == _api.QT_API_PYQT5:
"""if _api.USED_API == _api.QT_API_PYQT5:
value = value[0]
elif _api.USED_API == _api.QT_API_PYQT4:
value = str(value)
value = str(value)"""

if value and len(value)>0: self.value = value
if value and len(value)>0:
self.value = value

def finishEditing(self):
"""Function called when the lineEdit widget is edited"""
Expand Down
12 changes: 9 additions & 3 deletions pyforms_gui/controls/control_event_timeline/TimelinePointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,21 @@ def __init__(self, position, parent):
self._position = position
self._parent = parent

def draw(self, painter, showvalues=False):
def draw(self, painter, showvalues=False, highlight=False):
"""
:param painter:
:param showvalues:
:return:
"""
painter.setPen(QColor(0, 255, 0))
painter.setBrush(QColor(0, 255, 0))
if highlight:
painter.setPen(QColor(0, 150, 150))
painter.setBrush(QColor(0, 150, 150))
else:
painter.setPen(QColor(0, 255, 0))
painter.setBrush(QColor(0, 255, 0))


painter.drawLine(
self.xposition, 8, self.xposition, self._parent.height())
painter.drawEllipse(QtCore.QPoint(self.xposition, 8), 5, 5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, parent, track_id):
control_path = tools.getFileInSameDirectory(
__file__, "TimelinePopupWindow.ui")
self._ui = uic.loadUi(control_path)
self._ui.setWindowTitle("Track {:d} properties".format(track_id + 1))
self._ui.setWindowTitle("Row {:d} properties".format(track_id + 1))

# Dialog variables
self.behaviors = []
Expand Down
15 changes: 13 additions & 2 deletions pyforms_gui/controls/control_event_timeline/TimelineWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def paintEvent(self, e):
self._selected.draw(painter, showvalues=True)

# Draw the time pointer
self._pointer.draw(painter)
self._pointer.draw(painter, highlight=self._creating_event)

painter.end()

Expand Down Expand Up @@ -413,7 +413,7 @@ def keyReleaseEvent(self, event):

return

if event.key() == QtCore.Qt.Key_S and self._creating_event:
elif event.key() == QtCore.Qt.Key_S and self._creating_event:
# End, must be followed right after Start key and have no
# effect otherwise
self._creating_event_end = self._pointer.frame
Expand All @@ -429,6 +429,17 @@ def keyReleaseEvent(self, event):
else:
self._creating_event = False

# walk backwards 1 step
elif event.key() == QtCore.Qt.Key_A:
self.position = self.position - 1

# forward 1 step
elif event.key() == QtCore.Qt.Key_D:
self.position = self.position + 1




def mousePressEvent(self, event):
# Select the track
selected_track = Track.whichTrack(event.y())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, label="", default=0, max=100):
self.add_popup_menu_option("-")

# General righ click popup menus
self.add_popup_menu_option("Rows", self.__setLinePropertiesEvent,
self.add_popup_menu_option("Row properties", self.__setLinePropertiesEvent,
icon=conf.PYFORMS_ICON_EVENTTIMELINE_REMOVE)
self.add_popup_menu_option("-")

Expand Down Expand Up @@ -345,6 +345,13 @@ def rows(self):
@property
def graphs(self): return self._time.graphs

@property
def key_release_event(self):
return self._time.key_release_event
@key_release_event.setter
def key_release_event(self, value):
self._time.key_release_event = value

##########################################################################
#### PRIVATE FUNCTIONS ###################################################
##########################################################################
Expand Down
3 changes: 3 additions & 0 deletions pyforms_gui/controls/control_event_timeline/import_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from pyforms_gui.controls.control_text import ControlText
from pyforms_gui.controls.control_number import ControlNumber
from pyforms_gui.controls.control_label import ControlLabel
from pyforms_gui.controls.control_combo import ControlCombo
from pyforms_gui.controls.control_emptywidget import ControlEmptyWidget
from pyforms_gui.controls.control_file import ControlFile


import time
Expand Down
44 changes: 43 additions & 1 deletion pyforms_gui/controls/control_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,46 @@ def value(self, value):
if (type(oldvalue) is np.ndarray and type(value) is np.ndarray and oldvalue.any()!=value.any()) or \
(type(oldvalue) is np.ndarray and type(value) is not np.ndarray) or \
(type(oldvalue) is not np.ndarray and type(value) is np.ndarray):
self.changed_event()
self.changed_event()

##########################################################################
############ EVENTS ######################################################
##########################################################################

@property
def double_click_event(self):
return self._imageWidget.onDoubleClick

@double_click_event.setter
def double_click_event(self, value):
self._imageWidget.onDoubleClick = value

@property
def click_event(self):
return self._imageWidget.onClick

@click_event.setter
def click_event(self, value):
self._imageWidget.onClick = value

@property
def drag_event(self):
return self._imageWidget.onDrag

@drag_event.setter
def drag_event(self, value):
self._imageWidget.onDrag = value

@property
def end_drag_event(self):
return self._imageWidget.onEndDrag

@end_drag_event.setter
def end_drag_event(self, value):
self._imageWidget.onEndDrag = value

@property
def key_release_event(self): return self._imageWidget.on_key_release

@key_release_event.setter
def key_release_event(self, value): self._imageWidget.on_key_release = value
14 changes: 13 additions & 1 deletion pyforms_gui/controls/control_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pyforms_gui.utils.tools as tools
from confapp import conf

from AnyQt import uic
from AnyQt import uic, QtCore, QtGui

from pyforms_gui.controls.control_base import ControlBase

Expand All @@ -26,12 +26,24 @@ def init_form(self):
control_path = tools.getFileInSameDirectory(__file__, "label.ui")
self._form = uic.loadUi(control_path)
self._form.label.setText(self._label)
self._selectable = False
super(ControlLabel, self).init_form()

def load_form(self, data, path=None): pass

def save_form(self, data, path=None): pass

@property
def selectable(self): return self._selectable

@selectable.setter
def selectable(self, value):
if value:
self._form.label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
self._form.label.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
else:
self._form.label.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
self._form.label.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))

@property
def form(self): return self._form
Expand Down

0 comments on commit cb4e9ba

Please sign in to comment.