{"id":13738247,"url":"https://github.com/mwerezak/DearPyGui-Obj","last_synced_at":"2025-05-08T16:33:00.236Z","repository":{"id":53755461,"uuid":"341779775","full_name":"mwerezak/DearPyGui-Obj","owner":"mwerezak","description":"An object-oriented wrapper around DearPyGui","archived":true,"fork":false,"pushed_at":"2021-07-22T19:00:49.000Z","size":730,"stargazers_count":47,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-15T07:34:04.066Z","etag":null,"topics":["dearpygui","graphics","gui","imgui","python","python-gui","toolkit","tools","ui"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mwerezak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-24T04:34:25.000Z","updated_at":"2024-10-19T11:47:29.000Z","dependencies_parsed_at":"2022-09-02T15:01:53.087Z","dependency_job_id":null,"html_url":"https://github.com/mwerezak/DearPyGui-Obj","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwerezak%2FDearPyGui-Obj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwerezak%2FDearPyGui-Obj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwerezak%2FDearPyGui-Obj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwerezak%2FDearPyGui-Obj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mwerezak","download_url":"https://codeload.github.com/mwerezak/DearPyGui-Obj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253105411,"owners_count":21855019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dearpygui","graphics","gui","imgui","python","python-gui","toolkit","tools","ui"],"created_at":"2024-08-03T03:02:15.812Z","updated_at":"2025-05-08T16:32:59.872Z","avatar_url":"https://github.com/mwerezak.png","language":"Python","readme":"# DearPyGui-Obj\nAn object-oriented interface for [Dear PyGui](https://github.com/hoffstadt/DearPyGui).\n\n*Dear PyGui* is an excellent Python GUI framework built on top of the [Dear ImGui](https://github.com/ocornut/imgui) immediate-mode lightweight graphical interface library for C++. Dear PyGui itself is mostly a C++/CPython library with a thin scripting layer as it's primary interface.\n\nThis project aims to implement a pure-Python interface to Dear PyGui that takes full advantage of the Python language to provide a concise and ergonomic API.\n\n## Documentation\nDocumentation (on ReadTheDocs) can be found [here](https://dearpygui-obj.readthedocs.io/en/latest/index.html).\n\n## Features and Examples\nDearPyGui-Obj makes using DPG more concise and intuitive by allowing you to get and set widget properties using attributes. Setting the callback for a\nwidget is easy using the `callback` decorator.\n\n#### Basic Usage\nIf you've used Dear PyGui, using the object library should be familiar.\n\n``` python\nfrom dearpygui_obj import start_gui\nfrom dearpygui_obj import colors\nfrom dearpygui_obj.widgets import *\n\nwith Window('Example'):\n    text = Text('Edit me using the controls below!', color=colors.salmon)\n\n    Separator()\n\n    text_input = InputText('text content', text.value)\n    text_color = ColorEdit('text color', text.color)\n\n@text_input.callback\ndef callback():\n    text.value = text_input.value\n\n@text_color.callback\ndef callback():\n    text.color = text_color.value\n\nstart_gui()\n```\n\n#### Plots and Data Series\n\n``` python\nfrom dearpygui_obj import start_gui\nfrom dearpygui_obj.widgets import *\nfrom dearpygui_obj.plots.dataseries import *\n\nwith Window('Example') as win:\n    data = [ (-1, -9), (1, -4), (3, 11), (4, 5), (9, 7) ]\n    lineseries = LineSeries('example', data)\n\n    ## plot data series support indexing and all other MutableSequence methods\n    p1, p2 = lineseries[-2], lineseries[-1]\n    print('slope:', (p2.y - p1.y)/(p2.x - p1.x))  # elements are named tuples\n    lineseries.append((10, 2))  # but methods will accept any compatible sequence\n\n    ## you can also access and modify data as individual 1D sequences,\n    ## as long as the length does not change\n    print(*lineseries.y[0:3])  # prints -9 -4 11\n    lineseries.y[3] += 1\n    lineseries.y[0:3] = (-4, 7, -2)\n    lineseries.x[:] = [1, 2, 3, 4, 5, 6]\n    #lineseries.x = [1, 2, 3]  # TypeError: cannot change length of individual DataSeries field\n\n    plot = Plot()\n    plot.add_dataseries(lineseries)\n\nstart_gui()\n```\n\n#### Manipulate Tables using Slices\n``` python\nfrom dearpygui_obj import start_gui\nfrom dearpygui_obj.widgets import *\n\nwith Window('Example') as win:\n    table = Table(['col 1', 'col 2', 'col 3', 'col 4'])\n    table[:, :] = [\n        ['a', 'b', 'c', 'd'],\n        ['e', 'f', 'g', 'h'],\n        ['i', 'j', 'k', 'l'],\n        ['m', 'n', 'o', 'p'],\n    ]\n\n    btn = Button('Select Checkerboard')\n    @btn.callback\n    def callback():\n        table.selected[::2, ::2] = True\n        table.selected[1::2, 1::2] = True\n\nstart_gui()\n```\n\n#### Defining Custom Widgets\n``` python\nfrom dataclasses import dataclass\nfrom dearpygui_obj import start_gui\nfrom dearpygui_obj.widgets import *\n\n@dataclass\nclass Person:\n    firstname: str\n    lastname: str\n\nclass PersonInfo(UserWidget):\n    def __setup_content__(self, person: Person):\n        Separator()\n        with group_horizontal():\n            self.selected_chk = Checkbox()\n            Button(arrow=ButtonArrow.Up, callback=self.move_up)\n            Button(arrow=ButtonArrow.Down, callback=self.move_down)\n            Text(f'First name: {person.firstname}')\n            Text(f'Last name: {person.lastname}')\n\n    @property\n    def selected(self) -\u003e bool:\n        return self.selected_chk.value\n\nwith Window('Person List Example'):\n    with Group() as container:\n        pass\n\n    Separator()\n\n    remove_btn = Button('Remove Selected')\n    add_btn = Button('Add Person')\n    fname_inp = InputText('First name')\n    lname_inp = InputText('Last name')\n\n@remove_btn.callback\ndef callback():\n    for child in container.iter_children():\n        if child.selected:\n            child.delete()\n\n@add_btn.callback\ndef callback():\n    person = Person(fname_inp.value, lname_inp.value)\n    PersonInfo.add_to(container, person)\n    fname_inp.value = ''\n    lname_inp.value = ''\n\nstart_gui()\n```\n\n#### Drawing API\nThis is the same dynamic drawing example given in the DPG Wiki. You can compare \nit with the [original code](https://github.com/hoffstadt/DearPyGui/wiki/Drawing-API#modification).\n\n``` python\nfrom dearpygui_obj import start_gui\nfrom dearpygui_obj import colors\nfrom dearpygui_obj.widgets import *\n\ncounter = 0\nmodifier = 2\n\nwith Window(\"Tutorial\", size=(800, 800)):\n    canvas = Drawing(size=(700, 700))\n    circle = canvas.draw_circle((0, 0), 5, colors.from_rgba8(255, 255, 255))\n\n@dearpygui_obj.set_render_callback\ndef on_render():\n    global counter, modifier\n\n    counter += 1\n    if counter \u003c 300:\n        modifier += 1\n    elif counter \u003c 600:\n        modifier -= 1\n    else:\n        counter = 0\n        modifier = 2\n\n    circle.center = (15 + modifier*1.25, 15 + modifier*1.25)\n    circle.color = colors.from_rgba8(\n        255 - modifier*.8, 255 - modifier*.8, 255 - modifier*.3,\n    )\n    circle.radius = 15 + modifier/2\n    circle.segments = round(35-modifier/10)\n\nstart_gui()\n```\n\n#### Other Features\n``` python\nfrom dearpygui_obj import start_gui\nfrom dearpygui_obj import colors\nfrom dearpygui_obj.widgets import *\n\nwith Window('Example') as win:\n    ## See what config properties a widget has in the REPL\n    Button.get_config_properties() # Returns ['arrow', 'enabled', 'height', ...]\n\n    ## There are many small ergonomic improvements to the API of various widgets\n    ## For example, setting arrow buttons is just an Enum instead of two\n    ## separate properties\n    btn = Button(arrow=ButtonArrow.Right)\n\n    @btn.callback\n    def callback():\n        if btn.arrow:\n            btn.arrow = None\n            btn.label = 'Not an arrow button anymore!'\n\n    ## Colors\n    red = Text('This text is red.', color=colors.red) # preset HTML colors\n    green = Text('This text is green.', color=colors.from_hex('#00FF00'))\n\n    ## Radio buttons, combo boxes, and list widgets are mutable sequences\n    radio = RadioButtons(['Apple', 'Orange'])\n    radio[0] = 'Banana'\n    radio.remove('Orange')\n    radio.extend(['Pear', 'Grape'])\n    del radio[-1]\n\n## You can add widgets after creating the GUI using methods instead of keywords\nadd_text = Button.add_to(win, 'Add Label')  # add to the end of a container\n\n@add_text.callback\ndef callback():\n    Text.insert_before(add_text, 'Insert before.')  # insert before a widget\n\nstart_gui()\n```\n\n#### Using DearPyGui-Obj With Existing Dear PyGui Code\nDearPyGui-Obj aims to be fully *backwards compatible* with Dear PyGui. This means that you can freely mix code that uses both DearPyGui and DearPyGui-Obj without issues. Wherever possible, widget classes are designed to draw all of their state from DPG so that there is no possibility of invalidation. You can even create object instances for existing widgets that were created in vanilla DearPyGui.\n\n## Installation\nThis project is currently in the early implementation stage, and a lot of features still need to be implemented. Even the current name for the project is provisional and may change.\n\n**Requirements**\n- Python 3.8 64-bit\n- dearpygui 0.6.x\n\nYou can install from [TestPyPI](https://test.pypi.org/project/dearpygui-obj/):\n```\npip install -i https://test.pypi.org/simple/ dearpygui-obj\n```\n\nOr you can simply copy the `dearpygui_obj` package somewhere where Python can find it. \nDearPyGui-Obj will be available on PyPI proper once it has reached a fuller level of feature-completeness.\n\n## License\n\n*DearPyGui-Obj* is licensed under the [MIT License](https://github.com/mwerezak/DearPyGui-Obj/blob/master/LICENSE).\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwerezak%2FDearPyGui-Obj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmwerezak%2FDearPyGui-Obj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwerezak%2FDearPyGui-Obj/lists"}