umsenhorqualquer / pyforms Goto Github PK
View Code? Open in Web Editor NEWPython layer of Windows forms, based on PyQt and OpenGL
License: MIT License
Python layer of Windows forms, based on PyQt and OpenGL
License: MIT License
Hi!
Interesting project! I have one question: can matplotlib plots also be displayed as widgets? Reading through the docs that was not immediately obvious.
For example how would one go about creating a slider and a matplotlib graph, for example such as this:
This "mockup" was done in an Ipython notebook:
from IPython.html.widgets import interact
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
def plot(n, f):
x = np.arange(0, 20, 0.1);
if f=='sin':
y = np.sin(x/n)
if f=='cos':
y = np.cos(x/n)
plt.plot(x, y)
interact(plot, n=(0.1,10, 0.1), f=('sin','cos'))
Calling dock.label("str") produces TypeError: 'str' object is not callable
the following code is not setting the icon on the BaseWidget
from pysettings import conf
import settings
conf+=settings
from pyforms import BaseWidget
import pyforms
from os import path
from PyQt4 import QtGui
class WinForm(BaseWidget):
def __init__(self):
ROOT_DIR = path.dirname(path.abspath(__file__))
iconPath = path.join(ROOT_DIR, 'logo2.ico')
print iconPath
BaseWidget.__init__(self,'WinForm')
#BaseWidget.setWindowIcon(self, QtGui.QIcon(iconPath))
self.setWindowIcon(QtGui.QIcon(iconPath))
if __name__ == "__main__":
pyforms.start_app( WinForm, geometry=(200, 200, 500, 400) )
Is this a bug or is there an issue with my code.
I added the new ControlLabel because I needed it urgently but it should be revised and validated.
Using 'use_save_dialog' flag cannot correctly return the saved file name in 'value' property. It only returns one single character.
In the source code, when the flag is set, it is already unpacking the tuple to take the first element. But for pyqt5, it choose the first element again, and make this error.
It's possible modify the content of the controls from other threads? I see that if you are in other thread you can change the values, but if in the same thread have blocking operations (OS change the process queue) then the app raise an exception like this:
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QTextDocument(0x7fc42d2a1380), parent's thread is QThread(0x7fc42bcf9b60), current thread is QThread(0x7fc42d0bf330)
Segmentation fault: 11
To solve this I try to find any callback loop that is called from main thread and execute a queue that modify the controls, but I can not find nothing.
Actually my code look like this:
> Create controls
> Wait until the user press a button
> Strart a thread
> Add to log some string
> Make a Blocking operation (Execute a shell command)
> Add to log the result <-- Here throw the exception
how do I get it to display the output of the ControlTextArea in real time?
It's default background is black, I've read the source but I still have not idea
Hey
PyForms can import pystatemachine module
from pyStateMachine.States.State import State,EndState
from pyStateMachine.StateMachineControllers.StatesController import StatesController
https://github.com/cmaugg/pystatemachine/blob/master/pystatemachine.py
I've check the pyStateMachine module and I couldn't found any StateMachineControllers class on it .
Anyway Can you share your pystatemachine module ?
Using Sublime text 3, copied exactly your code and get
NameError: name 'BaseWidget' is not defined
Hi,
The package doesn't seem to work after installation. Can someone help please ?
This is what I did:
$ virtualenv env --python=python3
$ source env/bin/activate
$ pip install pyforms
Launching the example from the documentation I get the following:
GL widgets or Opencv is not installed
No module named 'cv2'
Traceback (most recent call last):
File "pyforms/env/lib/python3.6/site-packages/pyforms/controls.py", line 47, in <module>
from pyforms.gui.controls.ControlOpenGL import ControlOpenGL
File "pyforms/env/lib/python3.6/site-packages/pyforms/gui/controls/ControlOpenGL.py", line 30, in <module>
from pyforms.gui.controls.control_player.VideoGLWidget import VideoGLWidget
File "pyforms/env/lib/python3.6/site-packages/pyforms/gui/controls/control_player/VideoGLWidget.py", line 8, in <module>
from pyforms.gui.controls.control_player.AbstractGLWidget import AbstractGLWidget
File "pyforms/env/lib/python3.6/site-packages/pyforms/gui/controls/control_player/AbstractGLWidget.py", line 7, in <module>
import logging, cv2
ModuleNotFoundError: No module named 'cv2'
Cannot mix incompatible Qt library (version 0x50905) with this library (version 0x50b01)
Aborted (core dumped)
So I did a:
$ pip install opencv-python
and after executing the example.py I still get:
Cannot mix incompatible Qt library (version 0x50905) with this library (version 0x50b01)
Aborted (core dumped)
Thanks in advance for your help.
Hi!
Love what you've done with pyforms, it has made it very quick and easy to throw together a functional GUI for a small application I'm working on.
I want to make a usability improvement to the user interface of my application, which would require the application to automatically set focus to a specific widget when a button is pressed. I tried looking around in both the pyforms and Qt documentation but couldn't find anything helpful. Is there a way to do this?
Even better would be the possibility to have the main application window listen to keypresses globally, and trigger a function when e.g. the TAB key is pressed (i.e. overriding/skipping the usual tab key functionality in a GUI).
The application is scanning barcodes using a USB barcode scanner, and the scanner sends a TAB key press after each successful scan, upon which I want to call a function to do a quick database search for the scanned barcode, and then reset the text field and set focus to it again so the scanner can be used again, without having to interact with the keyboard.
Cant import BaseWidget
import pyforms
from pyforms import BaseWidget
from pyforms.Controls import ControlText
from pyforms.Controls import ControlButton
class SimpleExample1(BaseWidget):
def __init__(self):
super(SimpleExample1,self).__init__('Simple example 1')
#Definition of the forms fields
self._firstname = ControlText('First name', 'Default value')
self._middlename = ControlText('Middle name')
self._lastname = ControlText('Lastname name')
self._fullname = ControlText('Full name')
self._button = ControlButton('Press this button')
#Define the button action
self._button.value = self.__buttonAction
def __buttonAction(self):
"""Button action event"""
self._fullname.value = self._firstname.value +" "+ self._middlename.value + \
" "+ self._lastname.value
#Execute the application
if name == "main": pyforms.start_app( SimpleExample1 )
Using pyforms 3.0.0 as installed in pipenv. Press any key defined in AbstractGLWidget's keyReleaseEvents, for example 'c':
Traceback (most recent call last):
File "../pyforms/gui/controls/control_player/AbstractGLWidget.py", line 435, in keyReleaseEvent
self._control.video_index += 20*self._control.fps
AttributeError: 'VideoQt5GLWidget' object has no attribute '_control'
Abort trap: 6
--
References to self._control (as well as other player-specific tasks, if it's going to be used for images?) should maybe be moved out of AbstractCLWidget, perhaps into ControlPlayer or VideoQt5GLWidget?
Hi, I having the following error when i am trying to import ControlImage. The traceback doesn't really make sense because i do have opencv 2.4.v5 and python bindings for QScintilla2. Any ideas ?
python pyform_aigyptiaka.py
No OpenGL library available
GL widgets or Opencv not installed
VisVis not installed
QScintilla2 not installed
Traceback (most recent call last):
File "pyform_aigyptiaka.py", line 8, in <module>
from pyforms.Controls import ControlImage
ImportError: cannot import name 'ControlImage'
I wrote a small script some time ago using Pyforms. I created a custom style.css
file for it. At the time it was working well. I just had to use this script again today and since my Python installation changed, I had to reinstall Pyforms. I did so using the repository as suggested in #37. I installed all the optional packages except qscintilla2. My script runs, the forms are created but the style are not applied. I tried the PersonWindow.py
script located in the tutorial folder of the repository, same issue.
Could I have missed something in my installation of Pyforms? I am using version 4.11.4 of pyqt.
Thank you in advance for your help!
I've copied and pasted the simple example into a python script just to test. Installed with pip install pyforms
Launching with Anaconda3 Python3.6 on windows 10 x64 through Pycharm doesn't open any window and the program finishes with the exit code listed above.
Launching the same but through the terminal causes python to crash with no error.
Tried uninstalling and reinstalling with --no-cache-dir to get a fresh download but no avail.
this seems to suggest a memory access error:
https://social.microsoft.com/Forums/en-US/431265d6-823e-4671-ae31-6e2b7e40170f/exit-code-0xc0000005?forum=windowshpcmpi
Not sure if something wrong on my side.
I know it's probably done with CSS, but I can't seem to find the right attribute to set. I've tried margin settings on QLineEdit, but that just changes the text boxes themselves. I'd like the controls themselves to be closer together. Thanks!
I find the project interesting, and it would be even more interesting / cool if it was supporting:
asciimatics
, urwid
or some other similar tools)HI, I'm trying to make an executable with PyInstaller, the test app works just fine when executed directly with python but instead, the compiled exe give me this error
C:\Users\Simone\Sviluppo\Tutorials\python\pyforms_test\dist>example.exe
Traceback (most recent call last):
File "example.py", line 1, in
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in load_unlocked
File "c:\users\simone.virtualenvs\pyforms_test-b9tyrkwk\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.dict)
File "site-packages\pyforms_init.py", line 6, in
File "site-packages\pyforms\utils\settings_manager.py", line 22, in add
File "site-packages\pyforms\utils\settings_manager.py", line 16, in __load_module
AttributeError: module 'pyforms' has no attribute 'settings'
[12552] Failed to execute script example
that's my very basic test app code
import pyforms
from pyforms import BaseWidget
from pyforms.controls import ControlText
from pyforms.controls import ControlButton
from pyforms.controls import ControlFile
class Example(BaseWidget):
def __init__(self):
BaseWidget.__init__(self, 'Example')
# fields
self._uno = ControlText('Uno', '1')
self._due = ControlText('Due', '2')
self._tre = ControlText('Tre', '3')
self._full = ControlText('Full')
self._button = ControlButton('Press me!')
self._file = ControlFile('File')
# layout
self.formset = [
{
'Tab1': ['_uno', '||', '_due', '||', '_tre'],
'Tab2': ['_full'],
'Tab3': ['_file']
},
'=',
(' ', '_button', ' ')
]
# menu
self.mainmenu = [
{
'File': [
{'Open': self.__openEvent},
'-',
{'Save': self.__saveEvent},
{'Save as': self.__saveAsEvent}
]
},
{
'Edit': [
{'Copy': self.__editEvent},
{'Past': self.__pastEvent}
]
}
]
# pops
path = self._full.add_popup_submenu('Path')
self._full.add_popup_menu_option('Dummy1', self.__dummyEvent1, submenu=path)
self._full.add_popup_menu_option('Dummy2', self.__dummyEvent2, submenu=path)
# actions
self._button.value = self.__buttonAction
# events
self._file.changed_event = self.__fileAction
def __buttonAction(self):
self._full.value = '{} {} {}'.format(self._uno.value, self._due.value, self._tre.value)
def __fileAction(self):
self._full.value = self._file.value
def __openEvent(self):
pass
def __saveEvent(self):
pass
def __saveAsEvent(self):
pass
def __editEvent(self):
pass
def __pastEvent(self):
pass
def __dummyEvent1(self):
self._full.value = 'UNO'
def __dummyEvent2(self):
self._full.value = 'DOS'
if __name__ == '__main__':
pyforms.start_app(Example, geometry=(500, 500, 300, 100))
Hi,
I made a project some time ago and used the 3.0 Version.
This snipped worked for me back then:
self._image = ControlImage('Image', visible=True)
self._image.value = image # image -> np.ndarray
When i use a later version the same snipped gives me a plain black image. I also tried giving a path to value, still just plain black.
Calling hide() doesn't hide the dock, same with show()
I've imported pyforms and pysettings from the hyperlinks as mentioned in another comment. When I try to import pyforms, i get the error message:
ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import pyforms
C:\Users\etqw5lb\AppData\Local\Continuum\anaconda3\lib\site-packages\pyforms_init_.py in ()
2 # -- coding: utf-8 --
3 import logging
----> 4 import loggingbootstrap
5 from pysettings import conf
6
ModuleNotFoundError: No module named 'loggingbootstrap'
Is there a series of support modules that need to me imported for pyforms? Something else I'm doing wrong?
There is moveCursor in PyQt. Is there such a thing inherited in ControlTextArea?
Hello,
I have an application where users need to enter numbers with decimal places into a ControlNumber.
I noticed that the number of decimal places is hardcoded to 0 in ControlNumber.py. Is there a reason for this?
Tomorrow I will try to submit a pull request
Thanks!
Just trying to use pyforms for the first time. When installing using virtualenv/python3.6 I came across a dependency on cv2:
No module named 'cv2'
Traceback (most recent call last):
File "/home/joerg/tmp/pf/lib/python3.6/site-packages/pyforms/controls.py", line 47, in <module>
from pyforms.gui.controls.ControlOpenGL import ControlOpenGL
File "/home/joerg/tmp/pf/lib/python3.6/site-packages/pyforms/gui/controls/ControlOpenGL.py", line 30, in <module>
from pyforms.gui.controls.control_player.VideoGLWidget import VideoGLWidget
File "/home/joerg/tmp/pf/lib/python3.6/site-packages/pyforms/gui/controls/control_player/VideoGLWidget.py", line 8, in <module>
from pyforms.gui.controls.control_player.AbstractGLWidget import AbstractGLWidget
File "/home/joerg/tmp/pf/lib/python3.6/site-packages/pyforms/gui/controls/control_player/AbstractGLWidget.py", line 7, in <module>
import logging, cv2
This can be fixed by
pip install opencv-python
My feeling is that it should be made a requirement though.
What will it take to make it so?
There is a syntax error in pyforms/pyforms/terminal/BaseWidget.py on line 16. Looks like a cut-and-paste error.
Line 16 should be:
self._parser = argparse.ArgumentParser()
not:
self._parser = argpaPYFORMS_MODE = 'TERMINAL'rse.ArgumentParser()
This doesn't run.
There are three causes:
ControlVisVis loading the default conf and then immediately checking it (default is set to PyQt4)
https://github.com/UmSenhorQualquer/pyforms/blob/master/pyforms/gui/Controls/ControlVisVis.py#L22
I don't know offhand how to elegantly solve this.
Base object QtGUI being referenced instead of the child
https://github.com/UmSenhorQualquer/pyforms/blob/master/pyforms/gui/Controls/ControlVisVis.py#L31
Solved by simply removing the QtGui.
in front of QtGui.QWidget()
and other instances
Passing VisVis hardcoded Qt4 string
https://github.com/UmSenhorQualquer/pyforms/blob/master/pyforms/gui/Controls/ControlVisVis.py#L40
Also easily solved by adding the if conf.PYFORMS_USE_QT5:
conditional to self._app = vv.use('pyqt4')
I get the following error when trying to run the pyforms
tutorial code:
Traceback (most recent call last):
File "src/view/example.py", line 1, in <module>
import pyforms
File "/usr/local/lib/python3.6/site-packages/pyforms/__init__.py", line 4, in <module>
from pysettings import conf;
ImportError: cannot import name 'conf'
Please install dependencies with your installer.
I'm having an issue after the installation of PyForms using the example code. I copied and pasted it into Visual Studio (I have VS use the local python install) and this error comes up:
Not sure where is going wrong though. I get the same problem when I run my code through IDLE. Also, this is the values of the locals:
builtins
{'ArithmeticError': <type 'exceptions.Ar...ticError'>, 'AssertionError': <type 'exceptions.As...ionError'>, 'AttributeError': <type 'exceptions.At...uteError'>, 'BaseException': <type 'exceptions.Ba...xception'>, 'BufferError': <type 'exceptions.Bu...ferError'>, 'BytesWarning': <type 'exceptions.By...sWarning'>, 'DeprecationWarning': <type 'exceptions.De...nWarning'>, 'EOFError': <type 'exceptions.EOFError'>, 'Ellipsis': Ellipsis, 'EnvironmentError': <type 'exceptions.En...entError'>, 'Exception': <type 'exceptions.Exception'>, 'False': False, 'FloatingPointError': <type 'exceptions.Fl...intError'>, 'FutureWarning': <type 'exceptions.Fu...eWarning'>, ...}
name
__main__
And here is the actual code:
""" Title: CIS 120's Final Project w/ GUI using PyForms
Date: November 30th, 2016
Author: Brenden Reeves
Class: CIS 120 - Mrs. Markly
"""
import pyforms
from pyforms import BaseWidget
from pyforms.Controls import ControlText
from pyforms.Controls import ControlButton
class WelcomeWindow(BaseWidget):
def __init__(self):
super(SimpleExample1,self).__init__('Simple example 1')
#Definition of the forms fields
self._firstname = ControlText('First name', 'Default value')
self._middlename = ControlText('Middle name')
self._lastname = ControlText('Lastname name')
self._fullname = ControlText('Full name')
self._button = ControlButton('Press this button')
if __name__ == "__main__":
pyforms.startApp(SimpleExample1)
I'm curious if there is a mechanism to control tab order. It seems to default to alphabetic which results in some behavior I don't want. I was hoping the order was controlled by the formset definition. Is there a way to change this?
I suspect that a small change to pyforms_gui/basewidget.py line 107:
for key, item in sorted(formsetdict.items()):
I think the issue is that sorting. If I'm reading it correctly it will sort it rather then leaving the structure as defined in the formset.
Thanks!
Hi there,
with a very simple app like your Example1 (one text control, one button), I get this message:
No handlers could be found for logger "/usr/local/lib/python2.7/dist-packages/pyforms/Controls.pyc"
Is there a way to avoid it?
Thanks
Is there a way to manually update the application? I am using this example code
from pyforms import BaseWidget
from pyforms.controls import ControlButton
import pyforms
import asyncio
class SimpleExample1(BaseWidget):
def __init__(self):
super(SimpleExample1, self).__init__('Simple example 1')
self._button = ControlButton('Press this button')
self._button.value = self.__buttonAction
def __buttonAction(self):
"""Button action event"""
print("bar")
async def main():
pyforms.start_app(SimpleExample1)
try:
while True:
print("foo")
SimpleExample1.update()
await asyncio.sleep(0.05)
finally:
pass
#Execute the application
if __name__ == "__main__":
aio_loop = asyncio.get_event_loop()
try:
aio_loop.run_until_complete(main())
finally:
if not aio_loop.is_closed():
aio_loop.close()
and I expect to read foo
each update, each 0.05 seconds. The thing is that I only see when I close th application (and it crashes since SimpleExample1.update()
misses some parameters I do not know).
My question is, is it possible to have another process in the background (my objective is to use Telegram's API) while updating the UI?
Using this example:
File "gui_test.py", line 4, in
from init import *
File "/Users/cmoore/Documents/GitHub/feature_extraction/init.py", line 18, in
from pyforms.Controls import ControlPlayer
ImportError: cannot import name ControlPlayer
OSX/Macbook Pro/MacPorts
Related: #42
Hi, first of all thanks for your work!
I would like to use pyforms in my small apps, but I encounter some problems:
pip install pyforms
it installs PyForms-0.1.7.3, but if I try to run your first example it complains about pysettings missing. from pysettings import conf
ImportError: cannot import name 'conf'
Looks like the pip version of pysettings is outdated, and pyforms setup.py doesn't check the requirements.
Just installed pyforms in Win10 with Py3.5.4. The installation was successful.
Now I get the following error when trying out the first example in the documentation:
Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyforms
>>> from pyforms import BaseWidget
>>> from pyforms.Controls import ControlText
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pyforms.Controls'
>>> from pyforms.Controls import ControlButton
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pyforms.Controls'
>>>
>>>
>>> pyforms
<module 'pyforms' from 'C:\\Users\\meh\\AppData\\Local\\Programs\\Python\\Python35\\lib\\site-packages\\pyforms\\__init__.py'>
>>> pyforms.__version__
'3.0.0'
Any ideas how to fix this?
Code taken from: https://pyforms.readthedocs.io/en/v3.0/getting-started/the-basic/
I'm currently having an issue where I can't get my basic imports to work, with the error described in the title. Whenever I search "loggingbootstrap" with any terms in tandem, I can't even find its existence except in this import statement. Currently I'm running MacOS Sierra v10.12.4 (16E195), with Anaconda as my primary environment, Python version 2.7.13. I have used the "pip install git+[REPO NAME HERE] --upgrade" command for pyforms and pysettings and I still can't get it to work.
In your readthedocs page you have the following example code:
if __name__ == "__main__": pyforms.start_app( SimpleExample1 )
But it raises the following exception:
AttributeError: 'module' object has no attribute 'start_app'
So looking around in StackOverflow I found that the correct method name is
startApp()
I installed pyforms using pip, and I got version 0.1.7.3. I can see that the readthedocspage is for the version 2.0. I couldn't find version specific documentation, which I think is a must if you have changes as big as this snake-case to cammel-case change.
While run first program of pyforms i was getting pysettings error. After that i had installed pysettings module but still this error is coming conf is ImportError: cannot import name conf
PLease provide better solution
Hey,
the update of BaseWidget.py caused a bug :
AttributeError: 'xxx' object has no attribute 'mainmenu'
I don't know if it's a consequence of the addition of the AnyQt imports but I had to come back to previous BaseWidget.py (after a certain amount of time to figure out what was wrong ๐ก )
from AnyQt.QtWidgets import QFrame
from AnyQt.QtWidgets import QVBoxLayout
...
The bug appears on OSX (10.13) and Linux (Mint).
Following the SimpleExample.py should be sufficient to reproduce the error.
Hi,
the documentation is ambiguous, does pyforms actually support python 3 or not?
On the top of the documentation there is the following paragraph:
Pyforms is a Python 2.7.x and 3.x cross-enviroment framework to develop GUI applications, which promotes modular software design and code reusability with minimal effort.
But later it lists only python3 in the dependencies.
When I try to run example application in WEB environment it saids: "ImportError: No module named pyforms_web.web"
Where can I find pyforms_web module?
Say, I am following the examples.
Tried to run the PersonWindow graphically and it runs just fine.
Tried to run from the terminal and it insists running with a GUI; then, again, it does print out a few messages:
$ python PersonWin.py --help
Matplot lib not installed or not working properly
GL widgets or Opencv not installed
QScintilla2 not installed
those were not listed as necessary requirements, are they?
Lastly, PyForms claims to offer the ability to run on the "Web", what exactly does that mean? and how to do it?
Thanks
gsal
I'm cross-developing for an old system that has issues with recent versions of Ubuntu, so I have it running 12.04. Which only has QT4 available. When I try to install pyforms with pip, it downloads pyforms 3.0.0, and complains that it can't find pyqt5.
How can I download a version that works with pyqt4?
Thanks,
Ran
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.