Git Product home page Git Product logo

guibedos's Introduction

GUI Bedos

PySide widgets and helpers

This project is used alongside Qt.py.

If you don't plan on using Qt.py, you must use PyQt5/PySide2 (from Qt import QtWidgets)

CSS

It is common to apply a custom CSS stylesheet to a QApplication.

This module allows to load 6 different themes, borrowed from the FreeCAD project

Stylesheets and icons are provided

Available themes are

  • dark-blue
  • dark-green
  • dark-orange
  • light-blue
  • light-green
  • light-orange
from Qt.QtWidgets import QApplication, QPushButton
from guibedos import css

app = QApplication([])
css.set_theme(app, 'dark-blue')

button = QPushButton('Hello you')
button.show()

app.exec_()

CSS Themes

Custom stylesheets

You can add your custom stylesheets to the chosen theme by passing a list of stylesheets to the set_theme() method.

custom_stylesheet_file_path = os.path.join(
    os.path.abspath((os.path.dirname(__file__))),
    'resources',
    'stylesheet.css'
).replace('\\', '/')

custom_stylesheet = open(custom_stylesheet_file_path).read()

css.set_theme(app, 'dark-blue', [custom_stylesheet])

Widgets

FlowLayout

The "flow" layout is not available in native Qt.

Allows to layout in 2D a 1D array of widgets

This widget was borrowed then adapted from PySide Examples

from Qt.QtWidgets import QPushButton
from guibedos.widgets import FlowLayout

layout = FlowLayout()
layout.addWidget(QPushButton('one'))
layout.addWidget(QPushButton('two'))
layout.addWidget(QPushButton('three'))
layout.addWidget(QPushButton('four'))

Flow Layout

TagBar

An augmented QLineEdit with buttons, allowing to edit a list of "tags"

  • Text + Button selection with SHIFT + ARROW
  • Copy/Paste
  • Clic on button removes it

TagBar

See examples/tag-bar.py in this repository

DeclarativeForm

The DeclarativeForm allows to generate widgets from a data structure of properties

Useful for asking the user a series of info without the hassle of manually creating the widgets

DelarativeForm

See examples/declarative-form.py in this repository

from guibedos import declarative_form as df

property_ = df.Group('personal_info', caption="Personnal Information", properties=(
    df.Text('name', caption='Name', default='Jean'),
    df.Text('surname', caption='Surname', default='Bauchefort'),
    df.Text('password', caption='Password')
))

Calling data() on the widget returns a data structure reflecting property's structure, filled with user-entered values

{
 "personal_info": {
  "name": "Jean",
  "surname": "Bauchefort",
  "password": ""
 }
}

helpers

Hourglass

Context manager that freezes the widget and display a hourglass cursor

import guibedos.helpers

class MyWidget(QtWidgets.QWidget):

    def __init__(self, parent=None):
        QWidgets.QWidget.__init_(self, parent)
       
    def lengthy_stuff():
        with guibedos.helpers.Hourglass(self):
            # do a lot of stuff

Update Combo

Updates a QComboBox items and tries to select previously selected item

If previously selected item was present, no QSignal is emitted

import guibedos.helpers

guibedos.helpers.update_combo(some_qcombobox, ['some', 'items'])

Blender

The module blender exposes a way to show QWidgets alongside Blender.

You will need a custom-compiled PySide build (compiled with the same compiler as Blender)

This modules groups and docks all widgets into a QMainWindow, and ensures that the QApplication is updated within blender's main loop.

Do not use QApplication.exec_(), as it is a synchronous call, and will freeze blender

import guibedos.blender
from some import SomeWidget

class SomeOperator(bpy.types.Operator):
    """
    Does something useful, with PySide
    """
    bl_idname = "cube.some"
    bl_label = "Some"

    def execute(self, context):
        self.report({'OPERATOR'}, 'bpy.ops.cube.some()')

        window = guibedos.blender.new_widget(SomeWidget)
        guibedos.blender.dock_to_main_window(window)

        return {'FINISHED'}

    def invoke(self, context, event):
        return self.execute(context)

Notes

  • CSS stylesheets and icons are borrowed from FreeCAD, more info here

  • Some parts of this project are borrowed from GPLv2 licensed projects. If so, it is stated in the file

guibedos's People

Contributors

amondelin avatar firegreen avatar mrfrangipane avatar

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.