Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Oct 24, 2022
1 parent 93ae357 commit a85c0be
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 56 deletions.
5 changes: 1 addition & 4 deletions bindings/imgui_bundle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from imgui_bundle._imgui_bundle import im_file_dialog as im_file_dialog
from imgui_bundle._imgui_bundle import imspinner as imspinner
from imgui_bundle._imgui_bundle import imgui_md as imgui_md
from imgui_bundle._imgui_bundle import (
run as run,
current_node_editor_context as current_node_editor_context
)
from imgui_bundle._imgui_bundle import run as run, current_node_editor_context as current_node_editor_context

from imgui_bundle import icons_fontawesome
from imgui_bundle.run_anon_block import run_anon_block as run_anon_block
Expand Down
6 changes: 5 additions & 1 deletion bindings/imgui_bundle/demos/demo_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def show_module_demo(demo_module: ModuleType, demo_function: Callable[[None], No
def demo_node_editor_separate_app():
if imgui.button("Run demo"):
import multiprocessing

p = multiprocessing.Process(target=demo_node_editor.main)
p.start()

Expand Down Expand Up @@ -93,7 +94,9 @@ def add_dockable_window(
add_dockable_window("Implot", demo_implot, demo_implot.demo_implot)
add_dockable_window("Node Editor", demo_node_editor, demo_node_editor_separate_app)
add_dockable_window("Markdown", demo_imgui_md, demo_imgui_md.demo_imgui_md)
add_dockable_window("Editor demo", demo_imgui_color_text_edit, demo_imgui_color_text_edit.demo_imgui_color_text_edit)
add_dockable_window(
"Editor demo", demo_imgui_color_text_edit, demo_imgui_color_text_edit.demo_imgui_color_text_edit
)
add_dockable_window("Additional Widgets", demo_widgets, demo_widgets.demo_widgets)

runner_params.docking_params.dockable_windows = dockable_windows
Expand All @@ -113,6 +116,7 @@ def show_gui():
# Part 3: Run the app
################################################################################################
import imgui_bundle

imgui_bundle.run(runner_params=runner_params, with_implot=True, with_node_editor=True, with_markdown=True)


Expand Down
7 changes: 3 additions & 4 deletions bindings/imgui_bundle/demos/demo_hello_imgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ def demo_implot_markdown_simple():
import numpy as np
from imgui_bundle import implot, imgui_md
import imgui_bundle

x = np.arange(0, np.pi * 4, 0.01)
y1 = np.cos(x)
y2 = np.sin(x)

def gui():
imgui_md.render("# This is the plot of _cosinus_ and *sinus*") # Markdown
imgui_md.render("# This is the plot of _cosinus_ and *sinus*") # Markdown
implot.begin_plot("Plot")
implot.plot_line("y1", x, y1)
implot.plot_line("y2", x, y2)
Expand Down Expand Up @@ -112,9 +113,7 @@ def show_one_feature(label, demo_function):
)
show_one_feature("Advanced docking demo", demo_hello_imgui_docking.main)

imgui.text(
"How to quickly run an app that uses implot and/or markdown"
)
imgui.text("How to quickly run an app that uses implot and/or markdown")
show_one_feature("Implot/Markdown simple", demo_implot_markdown_simple)

imgui.new_line()
Expand Down
2 changes: 2 additions & 0 deletions bindings/imgui_bundle/demos/demo_imgui_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AppState:

def show_code_advice(python_gui_function, cpp_code):
import inspect

imgui.push_id(cpp_code)

python_code = inspect.getsource(python_gui_function)
Expand Down Expand Up @@ -201,4 +202,5 @@ def immediate_gui_example():

if __name__ == "__main__":
import imgui_bundle

imgui_bundle.run(demo_imgui_bundle, with_markdown=True)
1 change: 1 addition & 0 deletions bindings/imgui_bundle/demos/demo_implot.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def demo_implot():

def main():
from imgui_bundle import run

run(demo_drag_rects, with_implot=True)


Expand Down
1 change: 1 addition & 0 deletions bindings/imgui_bundle/demos/demo_node_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def main():
config = ed.Config()
config.settings_file = "BasicInteraction.json"
import imgui_bundle

imgui_bundle.run(demo_node_editor, with_node_editor_config=config, with_markdown=True)


Expand Down
25 changes: 16 additions & 9 deletions bindings/imgui_bundle/demos/haikus/demo_node_triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class Lover:
name:str
name: str
node_id: ed.NodeId
pin_loves: ed.PinId
pin_hates: ed.PinId
Expand All @@ -11,15 +11,20 @@ class Lover:
def __init__(self, name: str) -> None:
self.name = name
self.node_id = ed.NodeId.create()
self.pin_loves = ed.PinId.create();
self.pin_hates = ed.PinId.create();
self.pin_loves = ed.PinId.create()
self.pin_hates = ed.PinId.create()
self.pin_in = ed.PinId.create()

def draw(self) -> None:
ed.begin_node(self.node_id)
ed.begin_pin(self.pin_in, ed.PinKind.input); imgui.text(self.name); ed.end_pin()
ed.begin_pin(self.pin_loves, ed.PinKind.output), imgui.text("Loves"); ed.end_pin();
ed.begin_pin(self.pin_hates, ed.PinKind.output); imgui.text("Hates"); ed.end_pin()
ed.begin_pin(self.pin_in, ed.PinKind.input)
imgui.text(self.name)
ed.end_pin()
ed.begin_pin(self.pin_loves, ed.PinKind.output), imgui.text("Loves")
ed.end_pin()
ed.begin_pin(self.pin_hates, ed.PinKind.output)
imgui.text("Hates")
ed.end_pin()
ed.end_node()


Expand All @@ -35,15 +40,17 @@ def __init__(self, lover: Lover, kind: str, loved: Lover) -> None:
self.id = ed.LinkId.create()

def draw(self) -> None:
red = ImVec4(0.3, 0.8, 0.2, 1.)
green = ImVec4(1., 0., 0., 1.)
red = ImVec4(0.3, 0.8, 0.2, 1.0)
green = ImVec4(1.0, 0.0, 0.0, 1.0)
if self.kind == "loves":
ed.link(self.id, self.lover.pin_loves, self.loved.pin_in, green)
else:
ed.link(self.id, self.lover.pin_hates, self.loved.pin_in, red)


paul = Lover("Paul"); claire = Lover("Claire"); cesar = Lover("Cesar")
paul = Lover("Paul")
claire = Lover("Claire")
cesar = Lover("Cesar")
lovers = [paul, claire, cesar]
links = [
Tie(paul, "loves", claire),
Expand Down
13 changes: 9 additions & 4 deletions bindings/imgui_bundle/demos/haikus/haiku_implot_heart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@
x = np.power(np.sin(interval), 3) * 16
y = 13 * np.cos(interval) - 5 * np.cos(2 * interval) - 2 * np.cos(3 * interval) - np.cos(4 * interval)

phase = 0; t0 = time.time() + 0.2; heart_pulse_rate = 80
phase = 0
t0 = time.time() + 0.2
heart_pulse_rate = 80


def gui():
global heart_pulse_rate, phase, t0
t = time.time();
phase += (t - t0) * heart_pulse_rate / (np.pi * 2); k = 0.8 + 0.1 * np.cos(phase)
t = time.time()
phase += (t - t0) * heart_pulse_rate / (np.pi * 2)
k = 0.8 + 0.1 * np.cos(phase)
t0 = t
imgui.text("Bloat free code")
implot.begin_plot("Heart"); implot.plot_line("", x * k, y * k); implot.end_plot()
implot.begin_plot("Heart")
implot.plot_line("", x * k, y * k)
implot.end_plot()
_, heart_pulse_rate = imgui_knobs.knob("Pulse", heart_pulse_rate, 30, 180)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
======= Glossary ====
"""
from imgui_bundle import run, imgui, imgui_node_editor as ed, ImVec4

conundrum = ed.PinId.create
soul = ed.NodeId.create
lament = ed.begin_node
sober = ed.end_node
Title = ed.begin
the_end = ed.end
tenderly = ImVec4(0.3, 0.5, 0.7, 1.)
ferociously = ImVec4(0.9, 0.9, 0.2, 1.)
tenderly = ImVec4(0.3, 0.5, 0.7, 1.0)
ferociously = ImVec4(0.9, 0.9, 0.2, 1.0)


def love_intrigue(intrigue):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,25 @@
class Character:
def __init__(my, name):
my.name = name
my.soul = soul(); my.loves = conundrum(); my.enemies = conundrum(); my.social_being = conundrum()
my.soul = soul()
my.loves = conundrum()
my.enemies = conundrum()
my.social_being = conundrum()

def fate_in_action(my):
lament(my.soul)
I(my.name, my.social_being)
I("love", my.loves); I("hate", my.enemies)
I("love", my.loves)
I("hate", my.enemies)
sober()


@dataclass
class Intrigue:
hero: _; deeply: _; feels: _; for_character: _
hero: _
deeply: _
feels: _
for_character: _

def fate_in_action(_):
start_intrigue(_)
Expand All @@ -36,7 +43,10 @@ def fate_in_action(_):
======= Romeo and Juliet ====
"""

Romeo = Character("Romeo"); Juliet = Character("Juliet"); Count_Paris = Character("Count Paris"); Mercutio = Character("Mercutio")
Romeo = Character("Romeo")
Juliet = Character("Juliet")
Count_Paris = Character("Count Paris")
Mercutio = Character("Mercutio")
Characters = [Romeo, Juliet, Count_Paris, Mercutio]
Love_Intrigues = [
Intrigue(Romeo, tenderly, "loves", Juliet),
Expand Down
1 change: 1 addition & 0 deletions pybind_native_debug/pybind_native_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def main() -> None:
sys.path.append(path_lg_imgui_bundle)

import demo_node_editor # type: ignore

demo_node_editor.main()


Expand Down
59 changes: 31 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,42 @@ def get_readme():
author_email="[email protected]",
description="ImGui Bundle: autogenerated python bindings for ImGui (docking), ImPlot, HelloImgui, etc.",
long_description=get_readme(),
long_description_content_type='text/markdown',
long_description_content_type="text/markdown",
url="https://github.com/pthom/imgui_bundle",
packages=([
"imgui_bundle",
"imgui_bundle.assets",
"imgui_bundle.assets.fonts",
"imgui_bundle.assets.fonts.Roboto",
"imgui_bundle.assets.images",
"imgui_bundle.demos",
"imgui_bundle.demos.assets",
"imgui_bundle.demos.assets",
"imgui_bundle.demos.assets.fonts",
]),
packages=(
[
"imgui_bundle",
"imgui_bundle.assets",
"imgui_bundle.assets.fonts",
"imgui_bundle.assets.fonts.Roboto",
"imgui_bundle.assets.images",
"imgui_bundle.demos",
"imgui_bundle.demos.assets",
"imgui_bundle.demos.assets",
"imgui_bundle.demos.assets.fonts",
]
),
package_dir={"": "bindings"},
cmake_install_dir="bindings/imgui_bundle",
# include_package_data=True,
extras_require={"test": ["pytest"]},
python_requires=">=3.6",
package_data={"imgui_bundle": [
"Readme.md",
"py.typed",
"*.pyi",
"assets/*.*",
"assets/fonts/*.ttf",
"assets/fonts/Roboto/*.*",
"assets/images/*.*",
"demos/assets/*.*",
"demos/assets/fonts/*.*",
"demos/assets/images/*.*",
]},
package_data={
"imgui_bundle": [
"Readme.md",
"py.typed",
"*.pyi",
"assets/*.*",
"assets/fonts/*.ttf",
"assets/fonts/Roboto/*.*",
"assets/images/*.*",
"demos/assets/*.*",
"demos/assets/fonts/*.*",
"demos/assets/images/*.*",
]
},
install_requires=["numpy >= 1.15", "munch >= 2.0.0"],

entry_points = {
'console_scripts': ['imgui_bundle_demo=imgui_bundle.demos.demo_all:main'],
}
entry_points={
"console_scripts": ["imgui_bundle_demo=imgui_bundle.demos.demo_all:main"],
},
)

0 comments on commit a85c0be

Please sign in to comment.