rawpython / remi Goto Github PK
View Code? Open in Web Editor NEWPython REMote Interface library. Platform independent. In about 100 Kbytes, perfect for your diet.
License: Apache License 2.0
Python REMote Interface library. Platform independent. In about 100 Kbytes, perfect for your diet.
License: Apache License 2.0
Any plan to implement a checkbox widget?
I may hack one with two images of a checked and unchecked checkbox, but I believe you can do better by creating the html element for it.
When InputDialog is a single line the Return Key adds a second line of text and the first line disappears.
Its probably just a faulty network killing stuff and there is maybe nothing to do... but I do get:
Exception happened during processing of request from ('172.16.15.28', 32928)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/usr/local/lib/python2.7/dist-packages/remi/server.py", line 164, in handle
if not self.read_next_message():
File "/usr/local/lib/python2.7/dist-packages/remi/server.py", line 175, in read_next_message
length = self.rfile.read(2)
File "/usr/lib/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
error: [Errno 104] Connection reset by peer
Connecting a phone to my machine and accessing a non-trivial app.
Is there any try: except: thing we can do?
ListView does not grey the selected item like I think it it used to. Maybe it never did and I am imagining that it did!
I've tried set_value and set_key and they are not changing the value.
Any plan on implementing hover text on the widgets?
I would like to be able to show some text over a widget to help understand what it does.
'gui' is too broad of a name to be used for a framework. it is a general term that is already known and used.
can you select another one?
it would also better allow you to clean up the project structure as per #21
Please add an optional initial value parameter to the InputDialog.
Should we support old browsers (for example IE9) that mainly does not have websockets? As a solution we can build a layer that implements the same protocol of the websocket class in the server, but communicates with POST requests.
Is it a good idea?
The idle interval configuration parameter affects gui's response to button presses etc. In addition it affects how often the idle method is run. It would be good to separate these so the config is just for idle()
Can the uploader be made such that optionally only a single file can be selected, like in the file selection dialog.
Would it be possible to have an input supporting only numbers?
I can write letters in the actual SpinBox :S.
Maybe able to choose between Integer and some decimal point representation?
I noticed that the INPUT DIALOG generates a new web page and returned to the previous one when OK was pressed.
I just wondered if there could be a general purpose 'DIALOG'. It would have OK and Cancel buttons. It would be able to have any of the Widgets that the main gui page has (maybe with exceptions). The values of the widgets would be read by App when the OK button is pressed in the on_confirm event method using the read_value method for each of the widgets. The values would not be returned as a list as in the InputDialog.
InputDialog has Abort legend instead of Cancel
I would like to separate the code of my application from that of gui so that each can have its own licence etc. and gui is easily replaced when it changes.
The way I have done it is to have a two level directory structure
Not a very clear description but you can see it in action in https://github.com/KenT2/manager-for-pipresents.
If you like the idea it would be good to arrange your github repository in the same way; the top level directory would contain the two examples.
The change requires gui to have an empty init.py file and for some changes to imports etc in the example Apps.
However at the moment the res directory and styles.css have to be moved from gui upwards to be with the examples. I think it would be better for separation if they stayed in gui. Is this possible?
Hello, I was just trying your thing (looks pretty cool!) but I cannot run it correctly.
I just git cloned it then did:
sudo python setup.py install
and entered the examples folder and executed the widgets_overview_app.py
then I got:
127.0.0.1 - - [03/Nov/2015 21:25:15] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [03/Nov/2015 21:25:15] "GET /res/style.css HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 43276)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "widgets_overview_app.py", line 22, in __init__
super(MyApp, self).__init__(*args)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "/usr/local/lib/python2.7/dist-packages/remi-0.1-py2.7.egg/remi/server.py", line 540, in do_GET
self.process_all(function)
File "/usr/local/lib/python2.7/dist-packages/remi-0.1-py2.7.egg/remi/server.py", line 574, in process_all
with open(filename, 'r+b') as f:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/remi-0.1-py2.7.egg/remi/res/style.css'
----------------------------------------
127.0.0.1 - - [03/Nov/2015 21:25:15] "GET /res/logo.png HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 43277)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "widgets_overview_app.py", line 22, in __init__
super(MyApp, self).__init__(*args)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "/usr/local/lib/python2.7/dist-packages/remi-0.1-py2.7.egg/remi/server.py", line 540, in do_GET
self.process_all(function)
File "/usr/local/lib/python2.7/dist-packages/remi-0.1-py2.7.egg/remi/server.py", line 574, in process_all
with open(filename, 'r+b') as f:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/remi-0.1-py2.7.egg/remi/res/logo.png'
----------------------------------------
127.0.0.1 - - [03/Nov/2015 21:25:15] "GET /res/logo.png HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 43278)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "widgets_overview_app.py", line 22, in __init__
super(MyApp, self).__init__(*args)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "/usr/local/lib/python2.7/dist-packages/remi-0.1-py2.7.egg/remi/server.py", line 540, in do_GET
self.process_all(function)
File "/usr/local/lib/python2.7/dist-packages/remi-0.1-py2.7.egg/remi/server.py", line 574, in process_all
with open(filename, 'r+b') as f:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/remi-0.1-py2.7.egg/remi/res/logo.png'
Am I doing anything wrong?
Also Chrome (in ubuntu 14.04) says "Connection is closed" when I run the script. And the website looks wrong.
I tried to have a Slider and a SpinBox with floats and, altho they are represented, the callbacks are not being called.
A ListView.empty() method would be useful.
There are two simple dialogs which I have used a lot. They have no input field just the title and message fields, an OK button, and optionally a Cancel button. You can see my fudged versions in ok_cancel and display_error methods in pp_manager.py
When InputDialog is a single line, the text is longer than the box, and it contains a / it splits at / and the remainder goes second line.
I tried using the examples without running setup.py. This gave an import error. I moved the examples up a directory level and they worked,
Is there a way change the examples such that they will do the imports across sub-directories.
So other computers in the network can access the page. It may sound like a stupid question but i'm new to think kind of stuff.
I cannot work out how to reliably set the initial value of a DropDown. A set_value method would be useful as it would allow the displayed value to be changed by the App. Same will probably apply to the SpinBox, Slider and Colour Picker etc.
ListView items are removed using the object reference. It would be better if they were removed using the reference defined when they were created.
In the Generic Dialog I cannot get the ListView to format the columns correctly and checkbox seems to add a lot of space. See widgets_overview_app.py
I've seen this error happen from time to time, I cannot reproduce it:
Exception in server.py-read_next_message.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/remi/server.py", line 177, in read_next_message
length = self.bytetonum(length[1]) & 127
IndexError: string index out of range
When an Image widget points to a local resource, it fails to load.
Maybe just with having the single_line attribute to True we could have a callback when hitting enter.
Label has set_text that can be called from within the gui. I would like
Slider.set_value()
SpinBox.set_value()
so that I can update the GUI to reflect the state of my program
I have used the new uploader and downloader. I have also been doing a lot of development of my app and it is now on github at https://github.com/KenT2/manager-for-pipresents
All my development and testing has been on Pi for server and Internet Explorer and Firefox running on Windows. Most museums will be Windows/IE so that is my most important user.
The uploader and downloader upload and download fine with one exception (see next issue) I have one problem with each of them, it is not possible to dynamically change the destination directory for the uploader or the source file for the downloader because they are defined as widgets in the main page rather than dialogs.
Uploader would be much better if you could do
def on_a_click(self):
upload_dialog=gui.FileUploader(600,600,self.media_dir+os.sep)
upload_dialog.set_on_success_listener(self,'on_media_upload_success')
upload_dialog.set_on_failed_listener(self,'on_media_upload_failed')
upload_dialog.show(self)
which would be executed as a result of a button click or menu click etc. event . It would open the browser's file selection dialog directly. Downloader would be similar and open the browser's download box.
profile_download=gui.FileDownloader(600,600,'Click to download current profile',self.file_to_download)
profile_download.show(self)
The menu and listbox widgets could use some padding (particularly on the left)
Manually specifying widget coordinates is slow, error prone, and different to other gui frameworks.
Perhaps auto computation of widget location and size can be added. There are two pure python gui layout libraries available
http://cassowary.readthedocs.org/en/latest/
https://github.com/pybee/colosseum
Include set_value() in these widgets please:
TextInput
ListView select_by_key() and set_value()
Dropdown select_by_key() and set_value()
Slider
ColorPicker
Date
Is there a way to pass multiple variables from multiple text inputs to a single listener function?
My thought was to set up an on_change listener for each text input but use the same listener function name for each one, then when writing the actual listener function pass all the variables you want that function to use, for example:
self.input1 = gui.TextInput(200, 20)
self.input1.set_on_change_listener(self, 'listener_function')
self.input2 = gui.TextInput(200, 50)
self.input2.set_on_change_listener(self, 'listener_function')
def listener_function(self, var1, var2)
self.lbl.set_text(str(var1) + ' & ' + str(var2)
However, doing this breaks the function so it won't populate the 'lbl' or do anything else defined in that function but doesn't return any errors.
I'm not a PEP 8 code-snob, promise! I'm specifically talking about the getter- and setter-methods which are more at home in other languages, which nearly all of your widgets make use of. Especially at what I would consider the beginning of the project, you have a chance to make the Widget code very pythonic without any drawbacks (i.e. breaking backwards-compatibility).
Maybe I am being shortsighted, is there a reason why you are simply not using properties or attributes (when there's no logic involved in setting and/or getting the attribute)?
The download works fine in Firefox with the download dialog allowing it to be saved, but in IE the logo.png is displayed in the browser instead of causing the download dialog. I vaguely remember from the distant past that IE needs a header to be sent. Can advise you if necessary.
When I ran simple_app, I got this:
Traceback (most recent call last):
File "gui\simple_app.py", line 45, in
start( App )
File "C:\Python27\mypython\kpad\gui\server.py", line 198, in start
server = HTTPServer(('', PORT_NUMBER), mainGuiClass)
File "C:\Python27\lib\SocketServer.py", line 408, in init
self.server_bind()
File "C:\Python27\lib\BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "C:\Python27\lib\SocketServer.py", line 419, in server_bind
self.socket.bind(self.server_address)
File "C:\Python27\lib\socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions
Hello, I have an issue that is blocking me. I wanted to make a little internal interface to set up some sentences in multilang for another app and I deal with arabic.
The thing is, if I load from a file that contains arabic into a TextInput on the main
method of the app its shown fine. But if I do a set_text on it with the same text later on from a click of a button it's shown wrong.
I've made a proof of concept of this happening:
https://github.com/awesomebytes/remi_arabic_text
In: https://github.com/awesomebytes/remi_arabic_text/blob/master/test_arabic.py
First I load the contents of a text file with arabic doing a set_text just after creating the TextInput:
https://github.com/awesomebytes/remi_arabic_text/blob/master/test_arabic.py#L32-L33
But if do set_text on the TextInput later on it looks like:
https://github.com/awesomebytes/remi_arabic_text/blob/master/test_arabic.py#L47-L49
Help?
I tried to make a little app where I check for some parameters of a running system and show them in a DropDown. I wanted to update this dropdown with the current parameters of the system (to choose one, and from there on, show also a dynamically generated table of the data to hopefully be edited). I made refresh button for trying to update them. I expected reloading the webpage to actually run the function "main" again, but I found out that does not happen. I used simple_app.py as my starting point.
So in short, is it possible or will it be possible to edit/add elements to the layout? I see you can set_text in some fields, but what about update dropdown contents or directly add new widgets on the fly?
Maybe it is just possible right now but I don't see how :P
The readme, or hopefully the more complete documentation in the future (check out Sphinx), should indicate whether this project is usable with Python 2, 3 or both. If the latter is the case, the examples should be adjusted to work with both Python versions. Currently some of them make use of print-statements which are deprecated in Python 3.
This would allow more people to find the project and (more) easily install it with pip.
In the file selection dialog I think it would be more intuitive if clicking on the directory icon opened that directory and clicking on the filename does the selection of files and directories, rather than the other way round.
Clicking on a file icon would probably do nothing.
Full traceback:
Traceback (most recent call last):
File "/home/pybokeh/miniconda3/envs/remi/lib/python3.4/socketserver.py", line 617, in process_request_thread
self.finish_request(request, client_address)
File "/home/pybokeh/miniconda3/envs/remi/lib/python3.4/socketserver.py", line 344, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "test.py", line 10, in init
super(MyApp, self).init(*args)
File "/home/pybokeh/miniconda3/envs/remi/lib/python3.4/socketserver.py", line 673, in init
self.handle()
File "/home/pybokeh/miniconda3/envs/remi/lib/python3.4/http/server.py", line 398, in handle
self.handle_one_request()
File "/home/pybokeh/miniconda3/envs/remi/lib/python3.4/http/server.py", line 386, in handle_one_request
method()
File "/home/pybokeh/miniconda3/envs/remi/lib/python3.4/site-packages/remi/server.py", line 552, in do_GET
self.process_all(path)
File "/home/pybokeh/miniconda3/envs/remi/lib/python3.4/site-packages/remi/server.py", line 572, in process_all
self.wfile.write(encodeIfPyGT3(html))
File "/home/pybokeh/miniconda3/envs/remi/lib/python3.4/site-packages/remi/server.py", line 90, in encodeIfPyGT3
data = data.encode('latin-1')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2020' in position 20239: ordinal not in range(256)
import remi.gui as gui
from remi import start, App
import pandas as pd
from db import DB
# import ipdb; ipdb.set_trace()
class MyApp(App):
def __init__(self, *args):
super(MyApp, self).__init__(*args)
def main(self):
wid = gui.Widget(1200, 800, gui.Widget.LAYOUT_HORIZONTAL, 10)
db = DB(filename="/home/pybokeh/Dropbox/data_sets/nba", dbtype="sqlite")
column_names = [column.name for column in db.tables.player_game_stats._columns]
row_data = db.query("select * from player_game_stats where team_name like '%Cav%'").values
self.table = gui.Table(600, 400)
row = gui.TableRow()
for column in column_names:
item = gui.TableTitle()
item.append(str(id(item)), str(column))
row.append(str(id(item)), item)
self.table.append(str(id(row)), row)
for _row in row_data:
row = gui.TableRow()
for row_item in _row:
item = gui.TableTitle()
item.append(str(id(item)), str(row_item))
row.append(str(id(item)), item)
self.table.append(str(id(row)), row)
wid.append('1', self.table)
return wid
if __name__ == "__main__":
start(MyApp)
If I limit my query to return just 5 rows, I do not get an error. So it seems there is a character that it doesn't like somewhere in the other rows in my table.
Using virtual environment created with conda with python version 3.4.
import platform
print(platform.platform())
Linux-3.13.0-68-generic-x86_64-with-debian-jessie-sid
import pip
modules = pip.get_installed_distributions()
for m in modules:
print(m)
setuptools 18.4
prettytable 0.7.2
ptyprocess 0.5
ipython 4.0.0
ipython-genutils 0.1.0
PyMeta3 0.5.1
numpy 1.10.1
traitlets 4.0.0
wheel 0.26.0
python-dateutil 2.4.2
pandas 0.17.0
pexpect 4.0.1
simplegeneric 0.8.1
pybars3 0.9.1
decorator 4.0.4
ipdb 0.8.1
pytz 2015.7
six 1.10.0
pickleshare 0.5
remi 0.1
db.py 0.4.4
pip 7.1.2
path.py 8.1.2
Regards,
Daniel
It would be good to have the width and height of the FileSelectionDialog as parameters. As a fix I changed the height of the FileSelectionDialog locally in gui.py but the number of entries displayed does not change with the height
One of the Widget parameters is horizontal/vertical which is True or False. It would be much more readable to define constants HORIZONTAL and VERTICAL
How to add an attribute that does not equal anything.
Actually every changes / fixes / features, are pushed on master branch, but, the master branch should contain only stable / tested release.
Can I suggest this model?
I can only run one gui based app at a time because the port number is hardcoded.
This could be a duplicate, original seems to have got lost in Github when changing to remi :-(
Include get_value()/get_key() as appropriate in these widgets
SpinBox - value
ListView - key and value of selected item
DropDown - key and value of selected item
Input - value
Slider - value
ColorPicker - value
Date - value
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.