Giter Site home page Giter Site logo

pyglui's Introduction

Code style: black Build and deploy PyPI version pre-commit

pyglui

Cython powered OpenGL gui.

  • Similar to AntTweakBar but truly python compatible. No need for ctyped variables.

  • Uses render-to-texture for ulta low cpu use when static.

  • Designed to be used with glfw but should run with other window managers as well.

  • Includes pyfontstash for rendering text.

  • Includes cygl to access GL functions (which in turn uses GLEW)

  • cygl and pyfontstash can also be installed separately but are hosted in this project for convenience.

Installation

pip install pyglui

Source installation

Dependencies

  • install glew

Linux (via apt-get)

sudo apt-get install libglew-dev

Linux (via yum)

yum install glew-devel

MacOS

brew install glew
  • install pyglui
python -m pip install git+https://github.com/pupil-labs/pyglui

Source code

# Clone the repository to the local filesystem
git clone http://github.com/pupil-labs/pyglui --recursive
cd pyglui

# Build and install `pyglui` in "editable" mode
python -m pip install -e .

Run the demo

# Clone the repository to the local filesystem
git clone http://github.com/pupil-labs/pyglui --recursive
cd pyglui

# Build and install `pyglui` in "editable" mode, with examples dependencies
python -m pip install -e ".[examples]"

# Run the demo example
cd example
python3 example.py

Demo screenshot as of 2017-12-19

pyglui's People

Contributors

cpicanco avatar euryalus avatar fneitzel avatar laurentperrinet avatar michaelbarz avatar mkassner avatar nathakits avatar papr avatar patrickfuerst avatar pfaion avatar pre-commit-ci[bot] avatar romanroibu avatar snleu avatar willpatera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyglui's Issues

Global UI scale to resize elements

Create global UI scale option, so that all all menus and elements in the UI can scale/resize. This could be user driven to increase and decrease the GUI element size manually/from the UI or dependent on screen density so the elements resize automatically/responsively.

Pyglui Timeline_Menu crash

Error report from Pupil Player when trying to drag the timeline up after detection calibration markers for offline calibration.

player - [ERROR] launchables.player: Process Player crashed with trace:
Traceback (most recent call last):
  File "/home/pupil-labs/Documents/pupil_labs/pupil/pupil_src/launchables/player.py", line 457, in player
    unused_elements = g_pool.gui.update()
  File "pyglui/ui.pyx", line 203, in pyglui.ui.UI.update
  File "pyglui/ui.pyx", line 172, in pyglui.ui.UI.draw
  File "pyglui/menus.pxi", line 712, in pyglui.ui.Container.draw
  File "pyglui/menus.pxi", line 732, in pyglui.ui.Container.draw
  File "pyglui/menus.pxi", line 712, in pyglui.ui.Container.draw
  File "pyglui/menus.pxi", line 732, in pyglui.ui.Container.draw
  File "pyglui/menus.pxi", line 760, in pyglui.ui.Timeline_Menu.draw
  File "pyglui/menus.pxi", line 764, in pyglui.ui.Timeline_Menu.draw
  File "pyglui/menus.pxi", line 531, in pyglui.ui.Scrolling_Menu.draw
  File "pyglui/menus.pxi", line 541, in pyglui.ui.Scrolling_Menu.draw
  File "pyglui/menus.pxi", line 568, in pyglui.ui.Scrolling_Menu.draw_scroll_window_elements
  File "pyglui/timelines.pxi", line 20, in pyglui.ui.Timeline.draw
  File "pyglui/timelines.pxi", line 42, in pyglui.ui.Timeline.draw
TypeError: draw_sections() takes 3 positional arguments but 4 were given

Hide/show menu button uses area from top to bottom - Feature or Bug?

If you click the button/symbol for hiding/showing the menu, everything works fine.

(But) the functional element of the button has an area of the whole size of the window from top to bottom. So, if you want to resize the menu's width you can do that, even by not clicking on the button.

seekbar playbutton update

When hitting space to stop playback the seekbar does not refresh and thus playbutton state change is not shown.

Color Picker element

It would be nice to have a color picker element with which a user can easily select a color. Currently, this functionality is often implemented by using three sliders, one for each dimension in the RGB color space. The problem with this approach is that it does not give any colored feedback.

A color picker could look like this:
image

Implement Step Slider

Currently we have a continuous slider - but could also be nice to have a step slider (discrete steps) for the future. Not critical at this point.

Pyglui installation

You get some compatibility problem with the nvidia driver 375.66. Each ldconfig return an error from the others linux dependencies and the only library which won't install because of it is pyglui, i had to apply this command to correct it :
sudo mv /usr/lib/nvidia-375/libEGL.so.1 /usr/lib/nvidia-375/libEGL.so.1.org
sudo mv /usr/lib32/nvidia-375/libEGL.so.1 /usr/lib32/nvidia-375/libEGL.so.1.org
sudo ln -s /usr/lib/nvidia-375/libEGL.so.375.39 /usr/lib/nvidia-375/libEGL.so.1
sudo ln -s /usr/lib32/nvidia-375/libEGL.so.375.39 /usr/lib32/nvidia-375/libEGL.so.

Come from : https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-375/+bug/1662860

The new version of nvidia driver solve it but you have to install the x86 compatibility with.

I don't know if it will help or maybe I am in the wrong section not but i spend the whole day to find the problem and correct it.

Best regard,

Move close button to menu bar

Migrated from pull request: pupil-labs/pupil#233

For the next milestone consider making the close button as a simple X as part of the plugin title bar would be nice (see sketch with 2 ideas below).

pyglui_close_menu-01

Top - add close button and keep collapse button.
Option 2 - add close button and remove collapse button. Clicking/touching the title of plugin minimizes/collapses the plugin menu.

slider feature - text input to change value

Feature request - to directly enter the value in the sync_val.value display area via text input. This would mean that the value display area/label would become a text input area.

Currently Value is just a label, but it could also be a text_input ui element. Important if we want to be able to precisely set values (not necessary for step slider).

+--------------------------------+
| Label                    Value |
| ------------------O----------- |
+--------------------------------+
+--------------------------------+
| Label       [Value text_input] |
| ------------------O----------- |
+--------------------------------+

Update Slider Element

  • Slider handle should be implemented using FitBox so that it could be appropriately resized if global UI scale implemented in the future.
  • Rendering
    • label and value above slider element
    • Line for slider below label + value

Cythonizing pyglui fails on Win7 32bit

Hi guys!

Not quite sure what's the issue here in the moment.

missing cimport in module 'cygl': pyglui/ui.pyx
missing cimport in module 'cygl': pyglui/graph.pyx

Or did my cygl build already fail?

C:\Users\testing\git\pyglui>python setup.py install
'glew.pxd' is up-to-date.
missing cimport in module 'cygl': pyglui/ui.pyx
missing cimport in module 'cygl': pyglui/graph.pyx
Compiling pyglui/ui.pyx because it changed.
Compiling pyglui/graph.pyx because it changed.
Cythonizing pyglui/graph.pyx

Error compiling Cython file:
...
from cython cimport view
from cygl cimport glew as gl
^
:------------------------------------------------------------

pyglui\graph.pyx:2:0: 'glew.pxd' not found

Error compiling Cython file:
...
from cython cimport view
from cygl cimport glew as gl
             ^

:------------------------------------------------------------

pyglui\graph.pyx:2:18: Name 'glew' not declared in module 'cygl'

Error compiling Cython file:
...
from cython cimport view
from cygl cimport glew as gl
from cygl cimport utils
^
:------------------------------------------------------------

pyglui\graph.pyx:3:0: 'utils.pxd' not found

Error compiling Cython file:
...
from cython cimport view
from cygl cimport glew as gl
from cygl cimport utils
             ^

:------------------------------------------------------------

pyglui\graph.pyx:3:18: Name 'utils' not declared in module 'cygl'

Error compiling Cython file:
...
def push_view(int w=0,int h=0):
'''
Sets up pixel based gl coord system.
Use this to prepare rendering of graphs.
'''
gl.glMatrixMode(gl.GL_PROJECTION)
 ^

:------------------------------------------------------------

pyglui\graph.pyx:20:6: undeclared name not builtin: gl
Traceback (most recent call last):
File "setup.py", line 115, in
ext_modules=cythonize(extensions)
File "C:\Python34\lib\site-packages\Cython\Build\Dependencies.py", line 865, in cythonize
cythonize_one(*args[1:])
File "C:\Python34\lib\site-packages\Cython\Build\Dependencies.py", line 985, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pyglui/graph.pyx

Tooltips for thumb elements

Adapt the tooltip implementation such that the tooltip can point into the right and left direction. This way we can use tooltips for thumb elements as well.

Updated Version Format Crashes with Pupil Capture

File "...\pupil\pupil_src\launchables\world.py", line 99, in world
assert VersionFormat(pyglui_version) >= VersionFormat('1.15'), 'pyglui out of date, please upgrade to newest version'
AssertionError: pyglui out of date, please upgrade to newest version

Seems 1.7 is lower than 1.15 :)

Hide drag handle when menu collapsed

Menu drag handle should be hidden or disabled when menu is collapsed. Current dragging of a collapsed menu can lead to an unintended resize or simultaneous translation + scaling.

Suggestion - make drag handle invisible or disabled when menu is collapsed.

Handle Text Input Overflow

Issue migrated from #6

Handle overflowing text within the Text Input UI Element.

  • upon selecting the text field, the caret and text text should scroll to the end (if overflowing the field width)
  • navigating text with caret should scroll the text so the caret is never invisible.

Bug in the resize square

The resize square is the one at the bottom right of the test windows.

The problem

Resizing (width) of the window is started (sometimes) after (onDrag and) moving the mouse_pos far beyond (50+ pixels) of the resize square boundaries.

Moving the test window changes the mentioned resize behavior.

Solution

If the problem is not with the test windows themselves (Did I miss some configuration?), resize should occur promptly.

Solution 2

If the problem is, indeed, with the test windows, improve windows docs.

Make pyglui pickable

TL;DR: Please make your objects pickable so I can run separate processes without forking.

Context:
I am using your Pupil software. My task is to write a plugin which provides an API to Pupil software for PsychoPy scripts. To do this I created a plugin which starts the PsychoPy script in a separate process. Since you run into a bunch of problems if you do this without care on OS X you need to use the billiard module and disable forking for OS X. More information on this here.

If you disable forking a completely new process is created and everything is pickled and forwarded to it. The problem is that the whole ui is already instantiated at the time I start my PsychoPy script process. Therefore the UI has to be pickled too. But since it does not support pickling yet it crashes. I uploaded the Traceback to Gist.

If you know about another idea how to solve this problem, please let me know. :) Thanks for your great work! <3

make text input look good

  • add caret.
  • use textbox (this should be implemented in pyfontstash)
  • deal with overflow though sideways scrolling text

Text highlighting

Moved from #6

Selecting text with shift and arrow key works but when releasing shift key selection process with left arrow continues while using right arrow will stop it.

Over writing selected text is funny, I guess having the first key input replace the selection would be best.

Reduce area of the square to minimize FitBox onclick

Hi, I have a suggestion.

The problem

Because the entire title bar area is being used, the minimize onClick is conflicting with the BringToFront onClick functionality.

Solution 1

Instead of using the entire title bar area, the minimize area onClick could be reduced to the ICON square (square).

Solution 2

Minimize onDoubleClick in the entire title bar. (However, this conflicts with existing standards, double click on the title bar usually means "expand the window to client boundaries" or "reduce the window to the last reduced state".)

Update README

Update README with new screenshot of the system after adding new UI elements.

GUI layout guide

Draw a GUI layout guide with 'pixel perfect' spacing. Clearly label and explain:

  • menu space
  • element space
  • element outline
    • element field
  • nesting behavior/rules

Add this diagram to the wiki. See issue #7

Button text overflow

The Button text overflows under some conditions, e.g. if there is not enough horizontal space.

Graph classes (e.g. graph.Line_Graph()) should allow for more flexible data updates to data_points

Some major limitations with the pyglui graph.Line_graph() class:

  • the data source is a fixed size (in cinit: data_points = 25). It does not appear one can adjust this.

  • One can only update data_points using the add() function, or by assigning a source function. Furthermore, one can pass only a single value at a time, which is and prepended it onto the existing data source.

I would like some added functionality:

  • the ability to change the size of data_points
  • the ability to overwrite the data_points by passing in a numpy array of the same size.

setup.py install failed on Ubuntu 15.04 64 bit

I installed cygl, then tried install pyglui but it failed ..

$ python setup.py install
Traceback (most recent call last):
  File "setup.py", line 8, in <module>
    from pyglui.cygl.glew_pxd import generate_pxd
ImportError: No module named cygl.glew_pxd

win wheels.

@MichaelBarz after thinking about this again. Please remove the wheel and dist dir from the repo. Instead make a tag, and upload the wheel to in the release page. Then update the install instructions and point to the download link.

linux dependency

Trying this one now after:

sudo apt-get install libglew-dev
sudo pip install cython
rename 'cygl-master' folder to cygl
cd /....../cygl
sudo python setup.py install

...

git clone --recursive (pyglui link)

Support element-dependend cursor shape on hover

It would be great if ui elements could tell the system to change the cursor shape on hovering it. E.g. GLFW_IBEAM_CURSOR for Text_Input or GLFW_HRESIZE_CURSOR for Trim Marks, etc

This would greatly improve the UX since users would notice areas of interaction that are currently hidden, e.g. draggable area of the Player seek handle.

We would need to extend handle_input to return a preferred cursor shape based on the input. The application managing the UI has to make the appropriate GLFW calls if the preferred cursor changes.

Further reading:

Add 'disabled' attribute for elements

Elements will need to be able to be disabled or inactive in the UI, but still visible. This could be added as a property of each element. The disabled state would need to be drawn differently (i.e. grey) and not accept any input (i.e. pass 'handle-input').

Any prebuilt windows whl

I have a visual studio 2017 and it keeps giving me this error
pyglui/cygl/utils.cpp(482): fatal error C1083: Cannot open include file: 'numpy/arrayobject.h': No such file or directory

Could someone plesae help out?

Issue with Recent OSX OpenGL Header relocation

Migrating the issue to the correct repo.

For OSX:
The setup.py for PyGlui expects to find the OpenGL headers in:

/System/Library/Frameworks/OpenGL.framework/Headers

They seem to have been moved in a (somewhat) recent OSX/Xcode updates to:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenGL.framework/Headers

After updating the include directory in setup.py the install instructions worked properly. I'm running El Capitan with Xcode 7.3 installed.
Something something... Apple -.-

Edit: Corrected Xcode version.

Allow on mouse wheel in drop down list.

Problem

Drop down element is static. If it is full of stuff (like in the pupil player/capture plugin list) the user will not be able to select anything beyond the visible items (of course).

Solution 1 (fake)

First I thought a tab ui element would be great. However, it is too complicated and does not solve the visibility problem for the tabs themselves:
screenshot from 2016-10-26 13 40 08

Solution 1 (For sure)

Allowing sliding (on mouse wheel) of the items in the drop down is enough and solves the visibility problem definitely. Prepending fixed names to the items with a code and sorting the list allow organizing things prettier.

"draw_concentric_circles" could be removed

Currently in screen_marker_calibration and single_marker_calibration, draw_points is used to draw a marker, instead of draw_concentric_circles. So I suggest draw_concentric_circles could be removed.

Allow other versions of glew on Darwin

When installing glew with homebrew I got the version 1.10.0. However in setup.py the glew version is hardcoded as 1.11.0 (glew_header = '/usr/local/Cellar/glew/1.11.0/include/GL/glew.h') so I had to manually change it to 1.10.0.

It would be nice if it could automatically locate the correct version.

Installation on MacOS (Migrated from pupil-labs/pupil/issues/279)

@csuh0115's original issue below migrated from: pupil-labs/pupil#279


Even after installing glew and cloning https://github.com/pupil-labs/pyglui --recursive, python setup.py install does not work for MacOS.
I am having two problems:

missing cimport in module 'pyglui.cygl': pyglui/ui.pyx
missing cimport in module 'pyglui.cygl': pyglui/graph.pyx`

It can't find the gl.h file?

pyglui/ui.c:264:10: fatal error: 'gl.h' file not found
#include "gl.h"
^
1 error generated.
error: command 'clang' failed with exit status 1`

Wheel release for v0.7 missing

Hey there! Thanks for your great work. Could you create a Wheel release for the current version v0.7? It would help some colleagues a lot. :)

Missing Designs for Sliders

If you adjust the 'Interface size' then the sliders design has sometimes no line or dots in the background.
This could be confusing, because in this way it looks like a on-off-button.

Usually this happens if the interface size is getting smaller, suddenly the graphics vanishing.

Update pupil icon font

Some of the icons are currently bit too small and thin which results in poor readabilty and clarity. The icons then needs an update to improve readability of the icons and clarity even at small sizes.

pyglui wiki

Make a simple 1 page wiki for pyglui as documentation of code with diagrams and screenshots.

Initial todo items:

  • General explanation of code structure
  • UI - Diagram FitBox size and position rules (positive/negative vectors)
  • UI - Explain design org and design size vs. computed org and computed size
  • Layout - Diagram and explanation of hierarchy

Submenu clipping

On pupil player v1.1 bundle, there is an overflow issue with the menu. At interface size 1, when sliding the menu all the way to the right, the menu overflows.

overflow

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.