dresscode


Namedresscode JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/pyrustic/dresscode
SummaryDress up your code with a beautiful graphical user interface !
upload_time2021-04-17 11:36:59
maintainerPyrustic Evangelist
docs_urlNone
authorPyrustic Evangelist
requires_python>=3.5
licenseMIT
keywords command-line gui interface desktop-application
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-animated-logo.gif" alt="Cover">
    <br>
    <p align="center">
    </p>
</div>



<!-- Intro Text -->
# Dresscode
<b> Dress up your code with a beautiful graphical user interface ! </b>

This project is part of the [Pyrustic Ecosystem](https://github.com/pyrustic/pyrustic#overview). Look powered by the [cyberpunk](https://github.com/pyrustic/tk-cyberpunk-theme#readme) theme.

<!-- Quick Links -->
[Showcase](#showcase) | [Installation](#installation) | [Usage](#usage) | [Tutorial](#tutorial) | [Reference](#reference)


# Showcase

Welcome ! Let me show you something:

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-1.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 1 - Demo </b>
    </p>
</div>

What if I told you that I did this with `1 Hex-digit lines of code` :tm: ?

The menu bar in `Figure 1` is not a gimmick. Clicking on the buttons in the menu bar opens another page. So in fact I showed only 1/3 of the pages !

Let's take a look at the other pages:

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-2.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 2 - 1 hex-digit lines of code generated an app with 3 pages ! </b>
    </p>
</div>


Now you are wondering how I did this with just `1 hex-digit lines of code` :tm:.

Well, I first defined the first page:

```python
from dresscode import page

home_page = page.Page(pid="home", name="Home")
home_page.add_entry(title="Username")
home_page.add_entry(title="Password", secretive=True)
home_page.add_button(new_row=True)
```

Then I defined the second page:

```python
from dresscode import page

edit_page = page.Page(pid="edit", name="Edit")
edit_page.add_entry(title="Username")
edit_page.add_button(on_click=lambda page, cid: page.show_toast("Hello"))
```

Then the third page:

```python
from dresscode import page

about_page = page.Page(pid="about", name="About")
about_page.add_button(text="Open Github")
about_page.add_button(text="Download the Wheel")
```


And then I created the app and linked the three pages to it.
```python
from dresscode import app, page
...
my_app = app.App(title="Dresscode Demo", width=450, height=150, home="home")
my_app.add_page(home_page)
my_app.add_page(edit_page)
my_app.add_page(about_page)
my_app.start()
```

The 1 hex-digit lines of code:

```python
from dresscode import app, page
my_app = app.App(title="Dresscode Demo", width=450, height=150, home="home")
home_page = page.Page(pid="home", name="Home")
home_page.add_entry(title="Username")
home_page.add_entry(title="Password", secretive=True)
home_page.add_button(new_row=True)
edit_page = page.Page(pid="edit", name="Edit")
edit_page.add_entry(title="Username")
edit_page.add_button(on_click=lambda page, cid: page.show_toast("Hello"))
about_page = page.Page(pid="about", name="About")
about_page.add_button(text="Open Github")
about_page.add_button(text="Download the Wheel")
my_app.add_page(home_page)
my_app.add_page(edit_page)
my_app.add_page(about_page)
my_app.start()
```



<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-3.gif" alt="Figure" width="650">
    <p align="center">
    <b> Figure 3 - Demo Animation </b>
    </p>
</div>

Voilà !

This is the full source code with comment and well structured:

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    # defining the home page here
    page = Page(pid="home", name="Home")  # pid = page id !
    page.add_entry(title="Username")
    page.add_entry(title="Password", secretive=True)  # secret secret !
    page.add_button(new_row=True)
    return page


def get_edit_page():
    page = Page(pid="edit", name="Edit")
    page.add_entry(title="Username")
    # Clicking this button will pop up a "Hello"
    page.add_button(on_click=lambda page, cid: page.show_toast("Hello"))
    return page


def get_about_page():
    page = Page(pid="about", name="About")
    page.add_button(text="Open Github")
    page.add_button(text="Download the Wheel")
    return page


# the home argument is the pid of the page to show at start up
app = App(title="Dresscode Demo", width=450, height=150, home="home")

# adding pages to the app !
app.add_page(get_home_page())
app.add_page(get_edit_page())
app.add_page(get_about_page())

# lift up !
app.start()  # the mainloop is hidden here ! ;)

```

Basically, you can just `pip install dresscode`, open a lightweight code editor, copy, paste, run the code and yeah it should work ! Try it !

Wondering what will happen when there are 10 pages ? Yes your menu bar will be full. The solution: buy large screens !

Joking aside, here's the solution:

```python
...
# Asking Dresscode to create a dropdown menu 'Menu'
# then stack inside it the references to the pages ! 
app.add_page(home_page, category="Menu")
app.add_page(edit_page, category="Menu")
app.add_page(about_page, category="Menu")
...

```
<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-4.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 4 - No need to buy large screens ! </b>
    </p>
</div>


## Installation

```bash

pip install dresscode --upgrade --upgrade-strategy eager

```


## Interaction with Dresscode
_Dress up your code with a beautiful graphical user interface !_ was the intro to this README. There is a clear distinction between the backend and the frontend. The question that arises is therefore how to communicate the frontend and the backend.

With `Dresscode`, you can specify when creating a component which handler to call when a particular event occurs.

With the button component, there are the `on_click` parameter to keep a reference to the event handler. So basically, you just need to have a handler with 2 parameters: `page` and `cid`.

```python
from dresscode.app import App
from dresscode.page import Page


def handler(page, cid):
    """
    page: the page object
    cid: the component id (here, the button cid)
    """
    # say 'Hello' !
    page.show_toast("Hello component {}".format(cid))
    # you can inspect the dict of components (keys are cid)
    components = page.components  # be curious, inspect the dict !
    # you can retrieve the data from a component
    username = page.get_data("username")
    # or you can display a large text
    page.show_text("Helloo\n{}".format(username), title="My large text")
    # or, ask for a confirmation
    ok = page.ask_confirmation()  # blocks the app, returns a boolean
    # you can even decide to scroll the content of the page
    page.scroll(value=1.0)
    # you can add a new page at runtime !!!
    app = page.app
    app.add_page(Page(pid="new_page", name="New"))
    # and guess what, you can open this new page !
    app.open_page("new_page")
    # and if you are in a hurry to open the home page
    app.open_home()


def get_home_page():
    # home page - a pid will be generated automatically if you don't set it
    page = Page(pid="home", name="Home")
    page.add_entry(cid="username", title="Username")
    # if you don't set a cid, it will be generated
    page.add_button(on_click=handler)  # a cid will be generated automatically

    # Note, if you click the button twice, you will get a:
    # dresscode.exception.DresscodeException
    # Duplicate page id isn't allowed (new_page) !
    # Guess why ! This isn't a bug but a feature ! hahaha !
    return page


app = App(title="Dresscode Demo", width=450, height=150, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```



## Components

Do you think Dresscode only offers two components, the input field and the button ?

Normally that would be enough. But I implemented a multitude of components to allow everyone to build applications quickly, from the simplest to the most complex.

### Checkbuttons

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-5.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 5 - Checkbuttons </b>
    </p>
</div>

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    items = ("Banana", "Apple", "Avocado")
    page.add_checkbutton(title="Choose your favorite fruits", items=items)
    # you could add a on_choice event handler ;)
    return page


app = App(title="Dresscode Demo", width=450, height=150, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```

### Dropdown list

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-6.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 6 - Drop-down list </b>
    </p>
</div>

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    items = ("Banana", "Apple", "Avocado")
    page.add_dropdown_list(title="Choose your favorite fruit", items=items)
    # you could add a on_choice event handler ;)
    return page


app = App(title="Dresscode Demo", width=450, height=150, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```



### Editor

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-7.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 7 - Editor </b>
    </p>
</div>

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    essay = "non est ad astra mollis e terris via\nSénèque"
    page.add_editor(title="My essay", text=essay, readonly=True)
    # you could change the width and or height...
    return page


app = App(title="Dresscode Demo", width=450, height=150, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```


### Label

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-8.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 8 - Label </b>
    </p>
</div>

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    page.add_label(text="Marvelous")
    page.add_label(text="Dresscode", color="white")
    page.add_label(text="Project", color="cyan")
    text = "Make Desktop Apps Great Again !"
    page.add_label(new_row=True, text=text, color="gray",
                   side="right",
                   font=("Corrier", 10))
    return page


app = App(title="Dresscode Demo", width=450, height=150, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```

### Radiobuttons

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-9.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 9 - Radiobuttons </b>
    </p>
</div>

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    items = ("Blue", "Red")
    page.add_radiobutton(title="Make a choice", items=items)

    return page


app = App(title="Dresscode Demo", width=450, height=150, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```

### Space

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-10.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 10 - SpaceX </b>
    </p>
</div>

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    items = ("Blue", "Red")
    page.add_button()
    page.add_button()
    page.add_space()  # you can alter the width, height and more...
    page.add_button()

    return page


app = App(title="Dresscode Demo", width=450, height=150, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```

### Spinbox

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-11.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 11 - Spinbox </b>
    </p>
</div>

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    items = ("Blue", "Red")
    page.add_spinbox(title="Make a choice", items=items)
    return page


app = App(title="Dresscode Demo", width=450, height=150, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```


### path entry
The path entry is part of `pyrustic.widget`. Discover the [Pyrustic framework](https://github.com/pyrustic/pyrustic/#readme) !

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-12.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 12 - Pathentry </b>
    </p>
</div>

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    page.add_path_entry(title="Directory", browse="dir")
    page.add_path_entry(new_row=True, title="File")
    return page


app = App(title="Dresscode Demo", width=450, height=150, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```

### Table
The table is part of `pyrustic.widget`. Discover the [Pyrustic framework](https://github.com/pyrustic/pyrustic/#readme) !

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-13.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 13 - Table </b>
    </p>
</div>

```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    columns = ("Name", "Age", "Gender")
    data = [("Jack", 45, "Male"), ("Jane", 37, "Female"), ("Alex", 100, "?")]
    page.add_table(title="My data", columns=columns, data=data)
    return page


app = App(title="Dresscode Demo", width=650, height=300, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```

### Image
Admit that you didn't expect this !

<!-- Image -->
<div align="center">
    <img src="https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-14.png" alt="Figure" width="650">
    <p align="center">
    <b> Figure 14 - Image </b>
    </p>
</div>


```python
from dresscode.app import App
from dresscode.page import Page


def get_home_page():
    page = Page(pid="home", name="Home")
    page.add_label(text="Welcome !", side=None, anchor="center", color="gray")
    with open("/home/alex/dresscode.png", "rb") as file:
        image = file.read()
    # to center any component, the trick: side=None, anchor="center" !
    page.add_image(new_row=True, image=image, side=None, anchor="center")
    page.add_label(text="https://github.com/pyrustic", side=None, anchor="center",
                   font=("Courrier", 10), new_row=True, color="gray")
    return page


app = App(title="Dresscode Demo", width=650, height=400, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```

### Cherry on the cake

Since we have this rebellious little side to wanting to customize everything, I implemented the possibility of adding custom components !

```python
from dresscode.app import App
from dresscode.page import Page


# I will cover this topic another time !


def data_getter(page, cid):
    data = None
    return data


def builder(page, cid):
    parts = {}
    return parts, data_getter


def get_home_page():
    page = Page(pid="home", name="Home")
    page.add_custom(builder=builder)
    return page


app = App(title="Dresscode Demo", width=650, height=400, home="home")

app.add_page(get_home_page())

# lift up !
app.start()

```

There you go, so I won't be asked to add new components ! :)

## Epilog

I created a Discord for announcements and discussions etc. Join the [Discord](https://discord.gg/fSZ6nxzVd6) !


Work in progress...



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pyrustic/dresscode",
    "name": "dresscode",
    "maintainer": "Pyrustic Evangelist",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "pyrustic@protonmail.com",
    "keywords": "command-line,gui,interface,desktop-application",
    "author": "Pyrustic Evangelist",
    "author_email": "pyrustic@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/35/4d/1bdc79489071eb523503965fae76881c0759464322ec0858bf8b05cf18e1/dresscode-0.0.2.tar.gz",
    "platform": "",
    "description": "\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-animated-logo.gif\" alt=\"Cover\">\n    <br>\n    <p align=\"center\">\n    </p>\n</div>\n\n\n\n<!-- Intro Text -->\n# Dresscode\n<b> Dress up your code with a beautiful graphical user interface ! </b>\n\nThis project is part of the [Pyrustic Ecosystem](https://github.com/pyrustic/pyrustic#overview). Look powered by the [cyberpunk](https://github.com/pyrustic/tk-cyberpunk-theme#readme) theme.\n\n<!-- Quick Links -->\n[Showcase](#showcase) | [Installation](#installation) | [Usage](#usage) | [Tutorial](#tutorial) | [Reference](#reference)\n\n\n# Showcase\n\nWelcome ! Let me show you something:\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-1.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 1 - Demo </b>\n    </p>\n</div>\n\nWhat if I told you that I did this with `1 Hex-digit lines of code` :tm: ?\n\nThe menu bar in `Figure 1` is not a gimmick. Clicking on the buttons in the menu bar opens another page. So in fact I showed only 1/3 of the pages !\n\nLet's take a look at the other pages:\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-2.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 2 - 1 hex-digit lines of code generated an app with 3 pages ! </b>\n    </p>\n</div>\n\n\nNow you are wondering how I did this with just `1 hex-digit lines of code` :tm:.\n\nWell, I first defined the first page:\n\n```python\nfrom dresscode import page\n\nhome_page = page.Page(pid=\"home\", name=\"Home\")\nhome_page.add_entry(title=\"Username\")\nhome_page.add_entry(title=\"Password\", secretive=True)\nhome_page.add_button(new_row=True)\n```\n\nThen I defined the second page:\n\n```python\nfrom dresscode import page\n\nedit_page = page.Page(pid=\"edit\", name=\"Edit\")\nedit_page.add_entry(title=\"Username\")\nedit_page.add_button(on_click=lambda page, cid: page.show_toast(\"Hello\"))\n```\n\nThen the third page:\n\n```python\nfrom dresscode import page\n\nabout_page = page.Page(pid=\"about\", name=\"About\")\nabout_page.add_button(text=\"Open Github\")\nabout_page.add_button(text=\"Download the Wheel\")\n```\n\n\nAnd then I created the app and linked the three pages to it.\n```python\nfrom dresscode import app, page\n...\nmy_app = app.App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\nmy_app.add_page(home_page)\nmy_app.add_page(edit_page)\nmy_app.add_page(about_page)\nmy_app.start()\n```\n\nThe 1 hex-digit lines of code:\n\n```python\nfrom dresscode import app, page\nmy_app = app.App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\nhome_page = page.Page(pid=\"home\", name=\"Home\")\nhome_page.add_entry(title=\"Username\")\nhome_page.add_entry(title=\"Password\", secretive=True)\nhome_page.add_button(new_row=True)\nedit_page = page.Page(pid=\"edit\", name=\"Edit\")\nedit_page.add_entry(title=\"Username\")\nedit_page.add_button(on_click=lambda page, cid: page.show_toast(\"Hello\"))\nabout_page = page.Page(pid=\"about\", name=\"About\")\nabout_page.add_button(text=\"Open Github\")\nabout_page.add_button(text=\"Download the Wheel\")\nmy_app.add_page(home_page)\nmy_app.add_page(edit_page)\nmy_app.add_page(about_page)\nmy_app.start()\n```\n\n\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-3.gif\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 3 - Demo Animation </b>\n    </p>\n</div>\n\nVoil\u00e0 !\n\nThis is the full source code with comment and well structured:\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    # defining the home page here\n    page = Page(pid=\"home\", name=\"Home\")  # pid = page id !\n    page.add_entry(title=\"Username\")\n    page.add_entry(title=\"Password\", secretive=True)  # secret secret !\n    page.add_button(new_row=True)\n    return page\n\n\ndef get_edit_page():\n    page = Page(pid=\"edit\", name=\"Edit\")\n    page.add_entry(title=\"Username\")\n    # Clicking this button will pop up a \"Hello\"\n    page.add_button(on_click=lambda page, cid: page.show_toast(\"Hello\"))\n    return page\n\n\ndef get_about_page():\n    page = Page(pid=\"about\", name=\"About\")\n    page.add_button(text=\"Open Github\")\n    page.add_button(text=\"Download the Wheel\")\n    return page\n\n\n# the home argument is the pid of the page to show at start up\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\n# adding pages to the app !\napp.add_page(get_home_page())\napp.add_page(get_edit_page())\napp.add_page(get_about_page())\n\n# lift up !\napp.start()  # the mainloop is hidden here ! ;)\n\n```\n\nBasically, you can just `pip install dresscode`, open a lightweight code editor, copy, paste, run the code and yeah it should work ! Try it !\n\nWondering what will happen when there are 10 pages ? Yes your menu bar will be full. The solution: buy large screens !\n\nJoking aside, here's the solution:\n\n```python\n...\n# Asking Dresscode to create a dropdown menu 'Menu'\n# then stack inside it the references to the pages ! \napp.add_page(home_page, category=\"Menu\")\napp.add_page(edit_page, category=\"Menu\")\napp.add_page(about_page, category=\"Menu\")\n...\n\n```\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-4.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 4 - No need to buy large screens ! </b>\n    </p>\n</div>\n\n\n## Installation\n\n```bash\n\npip install dresscode --upgrade --upgrade-strategy eager\n\n```\n\n\n## Interaction with Dresscode\n_Dress up your code with a beautiful graphical user interface !_ was the intro to this README. There is a clear distinction between the backend and the frontend. The question that arises is therefore how to communicate the frontend and the backend.\n\nWith `Dresscode`, you can specify when creating a component which handler to call when a particular event occurs.\n\nWith the button component, there are the `on_click` parameter to keep a reference to the event handler. So basically, you just need to have a handler with 2 parameters: `page` and `cid`.\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef handler(page, cid):\n    \"\"\"\n    page: the page object\n    cid: the component id (here, the button cid)\n    \"\"\"\n    # say 'Hello' !\n    page.show_toast(\"Hello component {}\".format(cid))\n    # you can inspect the dict of components (keys are cid)\n    components = page.components  # be curious, inspect the dict !\n    # you can retrieve the data from a component\n    username = page.get_data(\"username\")\n    # or you can display a large text\n    page.show_text(\"Helloo\\n{}\".format(username), title=\"My large text\")\n    # or, ask for a confirmation\n    ok = page.ask_confirmation()  # blocks the app, returns a boolean\n    # you can even decide to scroll the content of the page\n    page.scroll(value=1.0)\n    # you can add a new page at runtime !!!\n    app = page.app\n    app.add_page(Page(pid=\"new_page\", name=\"New\"))\n    # and guess what, you can open this new page !\n    app.open_page(\"new_page\")\n    # and if you are in a hurry to open the home page\n    app.open_home()\n\n\ndef get_home_page():\n    # home page - a pid will be generated automatically if you don't set it\n    page = Page(pid=\"home\", name=\"Home\")\n    page.add_entry(cid=\"username\", title=\"Username\")\n    # if you don't set a cid, it will be generated\n    page.add_button(on_click=handler)  # a cid will be generated automatically\n\n    # Note, if you click the button twice, you will get a:\n    # dresscode.exception.DresscodeException\n    # Duplicate page id isn't allowed (new_page) !\n    # Guess why ! This isn't a bug but a feature ! hahaha !\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n\n\n## Components\n\nDo you think Dresscode only offers two components, the input field and the button ?\n\nNormally that would be enough. But I implemented a multitude of components to allow everyone to build applications quickly, from the simplest to the most complex.\n\n### Checkbuttons\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-5.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 5 - Checkbuttons </b>\n    </p>\n</div>\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    items = (\"Banana\", \"Apple\", \"Avocado\")\n    page.add_checkbutton(title=\"Choose your favorite fruits\", items=items)\n    # you could add a on_choice event handler ;)\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n### Dropdown list\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-6.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 6 - Drop-down list </b>\n    </p>\n</div>\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    items = (\"Banana\", \"Apple\", \"Avocado\")\n    page.add_dropdown_list(title=\"Choose your favorite fruit\", items=items)\n    # you could add a on_choice event handler ;)\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n\n\n### Editor\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-7.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 7 - Editor </b>\n    </p>\n</div>\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    essay = \"non est ad astra mollis e terris via\\nS\u00e9n\u00e8que\"\n    page.add_editor(title=\"My essay\", text=essay, readonly=True)\n    # you could change the width and or height...\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n\n### Label\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-8.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 8 - Label </b>\n    </p>\n</div>\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    page.add_label(text=\"Marvelous\")\n    page.add_label(text=\"Dresscode\", color=\"white\")\n    page.add_label(text=\"Project\", color=\"cyan\")\n    text = \"Make Desktop Apps Great Again !\"\n    page.add_label(new_row=True, text=text, color=\"gray\",\n                   side=\"right\",\n                   font=(\"Corrier\", 10))\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n### Radiobuttons\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-9.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 9 - Radiobuttons </b>\n    </p>\n</div>\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    items = (\"Blue\", \"Red\")\n    page.add_radiobutton(title=\"Make a choice\", items=items)\n\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n### Space\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-10.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 10 - SpaceX </b>\n    </p>\n</div>\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    items = (\"Blue\", \"Red\")\n    page.add_button()\n    page.add_button()\n    page.add_space()  # you can alter the width, height and more...\n    page.add_button()\n\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n### Spinbox\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-11.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 11 - Spinbox </b>\n    </p>\n</div>\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    items = (\"Blue\", \"Red\")\n    page.add_spinbox(title=\"Make a choice\", items=items)\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n\n### path entry\nThe path entry is part of `pyrustic.widget`. Discover the [Pyrustic framework](https://github.com/pyrustic/pyrustic/#readme) !\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-12.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 12 - Pathentry </b>\n    </p>\n</div>\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    page.add_path_entry(title=\"Directory\", browse=\"dir\")\n    page.add_path_entry(new_row=True, title=\"File\")\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=450, height=150, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n### Table\nThe table is part of `pyrustic.widget`. Discover the [Pyrustic framework](https://github.com/pyrustic/pyrustic/#readme) !\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-13.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 13 - Table </b>\n    </p>\n</div>\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    columns = (\"Name\", \"Age\", \"Gender\")\n    data = [(\"Jack\", 45, \"Male\"), (\"Jane\", 37, \"Female\"), (\"Alex\", 100, \"?\")]\n    page.add_table(title=\"My data\", columns=columns, data=data)\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=650, height=300, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n### Image\nAdmit that you didn't expect this !\n\n<!-- Image -->\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/pyrustic/misc/master/media/dresscode-figure-14.png\" alt=\"Figure\" width=\"650\">\n    <p align=\"center\">\n    <b> Figure 14 - Image </b>\n    </p>\n</div>\n\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    page.add_label(text=\"Welcome !\", side=None, anchor=\"center\", color=\"gray\")\n    with open(\"/home/alex/dresscode.png\", \"rb\") as file:\n        image = file.read()\n    # to center any component, the trick: side=None, anchor=\"center\" !\n    page.add_image(new_row=True, image=image, side=None, anchor=\"center\")\n    page.add_label(text=\"https://github.com/pyrustic\", side=None, anchor=\"center\",\n                   font=(\"Courrier\", 10), new_row=True, color=\"gray\")\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=650, height=400, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\n### Cherry on the cake\n\nSince we have this rebellious little side to wanting to customize everything, I implemented the possibility of adding custom components !\n\n```python\nfrom dresscode.app import App\nfrom dresscode.page import Page\n\n\n# I will cover this topic another time !\n\n\ndef data_getter(page, cid):\n    data = None\n    return data\n\n\ndef builder(page, cid):\n    parts = {}\n    return parts, data_getter\n\n\ndef get_home_page():\n    page = Page(pid=\"home\", name=\"Home\")\n    page.add_custom(builder=builder)\n    return page\n\n\napp = App(title=\"Dresscode Demo\", width=650, height=400, home=\"home\")\n\napp.add_page(get_home_page())\n\n# lift up !\napp.start()\n\n```\n\nThere you go, so I won't be asked to add new components ! :)\n\n## Epilog\n\nI created a Discord for announcements and discussions etc. Join the [Discord](https://discord.gg/fSZ6nxzVd6) !\n\n\nWork in progress...\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Dress up your code with a beautiful graphical user interface !",
    "version": "0.0.2",
    "split_keywords": [
        "command-line",
        "gui",
        "interface",
        "desktop-application"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3bf005f1518b2debec5d50c5bd9f1f76",
                "sha256": "43b94cdf163aca87badd579412ef6d906442c58afb263965f1baae00eafc4460"
            },
            "downloads": -1,
            "filename": "dresscode-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3bf005f1518b2debec5d50c5bd9f1f76",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 19386,
            "upload_time": "2021-04-17T11:36:55",
            "upload_time_iso_8601": "2021-04-17T11:36:55.730756Z",
            "url": "https://files.pythonhosted.org/packages/51/f2/6ad478b25d1fda0f24253216193e06876bb2f2536b74a37494ec202e2f45/dresscode-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "15a3bb99c5ac1eea635f960861381483",
                "sha256": "4a0580471f5e8dcf6e89409ebe0fb881f5b7fbeb77534ef85a2f0ffc680d4519"
            },
            "downloads": -1,
            "filename": "dresscode-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "15a3bb99c5ac1eea635f960861381483",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 17193,
            "upload_time": "2021-04-17T11:36:59",
            "upload_time_iso_8601": "2021-04-17T11:36:59.038688Z",
            "url": "https://files.pythonhosted.org/packages/35/4d/1bdc79489071eb523503965fae76881c0759464322ec0858bf8b05cf18e1/dresscode-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-04-17 11:36:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "pyrustic",
    "error": "Could not fetch GitHub repository",
    "lcname": "dresscode"
}
        
Elapsed time: 0.24412s