Exemple #1
0
    def __init__(self):
        core.set_style_frame_padding(3, 3)
        core.set_style_window_padding(3, 3)
        core.set_main_window_size(650, 450)
        core.set_global_font_scale(1.5)
        with simple.window("main", autosize=True):
            with simple.group("panel", width=210):
                count = max(22, len(_fontnames))
                core.add_input_text("regex", label='', default_value=" ")
                core.add_listbox("font",
                                 label='',
                                 items=_fontnames,
                                 num_items=count,
                                 width=210,
                                 callback=self.__changed)
            core.add_same_line()
            with simple.group("text"):
                core.add_text(
                    "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\
				Phasellus in mollis mauris. Donec tempor felis eget libero accumsan sagittis.\
				Integer efficitur urna sed nibh auctor, non hendrerit libero pulvinar.\
				Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere\
				cubilia curae; In hac habitasse platea dictumst. Vestibulum consectetur,\
				sem vitae tristique rhoncus, sem ex maximus ligula, vitae egestas lorem libero\
				nec libero. Pellentesque habitant morbi tristique senectus et netus et malesuada\
				fames ac turpis egestas. Praesent gravida laoreet pharetra. Ut nec vulputate purus.\
				Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos\
				himenaeos. Maecenas malesuada neque vel ipsum imperdiet, et lobortis justo sollicitudin.",
                    wrap=560)
        simple.show_style_editor()
Exemple #2
0
	def __init__(self, theme=None, root=None):
		self.__current = theme
		if root is None:
			root = os.path.dirname(os.path.realpath(__file__))
			root = f'{root}/theme.json'
		self.__load(root)

		with simple.window("theme", autosize=True):
			themes = self.themes
			core.add_listbox("themes", label="",
				items=themes,
				num_items=len(themes),
				callback=self.__themeChange)

		self.apply(theme or self.__current)
Exemple #3
0
    def __init__(self):
        core.set_style_item_spacing(1, 1)
        core.set_style_window_padding(0, 0)

        with simple.window("main"):
            with simple.group("controls", width=520):
                with simple.group("buttons"):
                    for x in range(6):
                        core.add_button(f"id-{x}", label=f"button {x}")
                    core.add_color_button("bcolor", (196, 128, 155, 255))
                    core.add_radio_button("radio")
                    core.add_checkbox("checkbox")

                core.add_same_line()

                with simple.group("misc"):
                    core.add_date_picker("date")

                with simple.group("text"):
                    core.add_text("text")
                    core.add_input_text(
                        "input_text",
                        label="",
                        default_value=
                        "Call me Ish-meal. Tasty like an ashen log.")
                    core.add_label_text("label",
                                        label="",
                                        default_value="label")

                core.add_same_line()

                with simple.group("dropdown"):
                    core.add_listbox("listbox", label="", items=(1, 2, 3))
                    core.add_combo("combo", label="", items=(1, 2, 3))

                for x in ["float", "int"]:
                    with simple.group(x):
                        for what in ["add_drag_", "add_input_"]:
                            for y in ['', 2, 3, 4]:
                                n = f"{what}{x}{y}"
                                cmd = getattr(core, n)
                                cmd(n, label="", width=200)
                    core.add_same_line()

        manager.ThemeManager()
Exemple #4
0
    def __init__(self):
        core.set_style_item_spacing(0, 0)
        core.set_style_window_padding(0, 0)

        self.__rows = 0
        self.__cap = 0
        self.__board = []
        self.__width = 0
        self.__height = 0

        self.__puzzles = {}
        root = path.dirname(path.realpath(__file__))
        for f in listdir(root):
            full = f"{root}/{f}"
            if not path.isfile(full) or not f.endswith('.png'):
                continue
            who, _ = path.splitext(f)
            self.__puzzles[who] = full
        keys = list(self.__puzzles.keys())
        self.__puzzle = self.__puzzles[keys[0]]

        with simple.window("MainWindow", autosize=True):
            with simple.group("Controls"):
                for d in [3, 5, 7]:
                    core.add_same_line()
                    core.add_button(f"{d} x {d}",
                                    width=120,
                                    height=50,
                                    callback=self.__clearBoard)
                    core.add_same_line()
                    core.add_dummy()
                core.add_same_line()
                core.add_button("Solve!",
                                width=120,
                                height=50,
                                callback=self.__solve)
                core.add_same_line()
                items = [p for p in self.__puzzles.keys()]
                core.add_listbox("selection",
                                 items=items,
                                 callback=self.__imgChange)
        self.__clearBoard(self, 3)
def show_server_selection():
    #Server Selection
    core.add_text("server_selection_title", default_value="Select server", parent="status_window")
    core.add_listbox(
        "server_selection", 
        
        items         = console_client.client.host_list,
        default_value = 0,

        label  = "",
        parent = "status_window",

        width  = 230
    )


    core.add_text("server_selection_padding1", default_value="\n", parent="status_window")
    core.add_text("port_input_title", default_value="Change Port", parent="status_window")


    #Port Selection
    core.add_input_text(
        "port_input",

        parent        = "status_window",
        scientific    = True,
        default_value = str(console_client.client.port),
        label         = ""
    )

    #Padding
    core.add_text("server_selection_padding2", default_value="\n", parent="status_window")

    #Connect button
    core.add_button(
        "server_connect_button", 

        label    = "Connect",
        callback = connect_to_server,
        parent   = "status_window"
    )
Exemple #6
0
    def __init__(self):

        self.__last = -1

        self.__targetFPS = 30

        # playhead position
        self.__head = 0.

        # playback stopped
        self.__direction = 0.

        # looping on
        self.__loop = True

        # thread that is "streaming" the video
        self.__thread = None

        self.__frameCount = self.__width = self.__height = 0

        self.__root = path.dirname(path.realpath(__file__))

        core.set_style_item_spacing(1, 1)
        core.set_style_frame_padding(0, 0)
        core.get_style_window_padding(0, 0)
        width = 740
        height = 680
        core.set_main_window_size(width, height)

        with simple.window("MainWindow"):
            core.add_drawing("Canvas", width=width, height=height)

        w = 50
        h = 20
        with simple.window("Media Bar",
                           autosize=True,
                           no_collapse=True,
                           no_close=True,
                           no_scrollbar=True):
            with simple.group("Browser"):
                core.add_listbox("Listing",
                                 label='',
                                 items=[],
                                 callback=self.__itemChange)

            with simple.group("Shuttle"):
                core.add_button("Shuttle#Browse",
                                width=w,
                                height=h,
                                label="...",
                                callback=lambda: core.select_directory_dialog(
                                    callback=self.__browser))
                core.add_button("Shuttle#Front",
                                width=w,
                                height=h,
                                label='|<',
                                callback=lambda: self.__seek(0))
                core.add_same_line()
                core.add_button("Shuttle#Backwards",
                                width=w,
                                height=h,
                                label='<-',
                                callback=lambda: self.__play(-1))
                core.add_same_line()
                core.add_button("Shuttle#Forwards",
                                width=w,
                                height=h,
                                label='->',
                                callback=lambda: self.__play(1))
                core.add_same_line()
                core.add_button("Shuttle#End",
                                width=w,
                                height=h,
                                label='>|',
                                callback=lambda: self.__seek(-1))
                core.add_same_line()
                core.add_color_button("Shuttle#Loop", [50, 50, 227, 255],
                                      width=w,
                                      height=h,
                                      callback=self.__loopToggle)
                core.add_same_line()
                core.add_text("ShuttleFPS")
                core.add_drag_float("MediabarHead",
                                    label="",
                                    width=w * 5 + 5,
                                    callback=self.__cbSeek)

        core.set_render_callback(self.__render)
        core.set_mouse_wheel_callback(self.__mouseWheel)
        core.set_exit_callback(self.__close)
        self.__scanDir()
    def construct(self):
        with simple.group(self.name, parent=self.parent):
            # GUI elements for the algorithm selection ########################
            core.add_group("algorithm_input##labels",
                           horizontal=True,
                           horizontal_spacing=90)
            core.add_text("Available algorithms")
            core.add_text("Selected algorithms")
            core.end()  # algorithm_input##labels

            core.add_group("algorithm_input#lists",
                           horizontal=True,
                           horizontal_spacing=0)
            core.add_listbox(
                "algorithm_selector##available",
                label="",
                items=self.available_algorithms,
                width=220,
            )
            core.add_listbox(
                "algorithm_selector##selected",
                label="",
                items=self.selected_algorithms,
                width=220,
            )
            core.end()  # algorithm_input##lists

            def move(src, dest, gui_element):
                if len(src):
                    current = core.get_value(gui_element)
                    item = src.pop(current)
                    dest.append(item)
                    self.update_listbox()

            def move_all(src, dest):
                for i in src:
                    dest.append(i)
                src.clear()
                self.update_listbox()

            def add(sender):
                move(
                    self.available_algorithms,
                    self.selected_algorithms,
                    "algorithm_selector##available",
                )

            def add_all(sender):
                move_all(self.available_algorithms, self.selected_algorithms)

            def remove(sender):
                move(
                    self.selected_algorithms,
                    self.available_algorithms,
                    "algorithm_selector##selected",
                )

            def remove_all(sender):
                move_all(self.selected_algorithms, self.available_algorithms)

            core.add_group("algorithm_input##buttons", horizontal=True)
            core.add_button("Add", width=107, callback=add)
            core.add_button("Add all", width=107, callback=add_all)
            core.add_button("Remove", width=107, callback=remove)
            core.add_button("Remove all", width=107, callback=remove_all)
            core.end()  # algorithm_input##buttons
            core.add_button(
                "Execute",
                callback=self.execute_algorithms,
                callback_data=self.selected_algorithms,
            )

            # GUI elements for the metrics display ################################
            core.add_radio_button("metrics",
                                  items=["Elapsed times", "Expanded nodes"],
                                  callback=self.handle_metric,
                                  horizontal=True)
            core.add_plot("Metrics plot")
            core.add_bar_series("Metrics plot", "Metrics", [], [])
            core.set_plot_xlimits("Metrics plot", 0, 6)
Exemple #8
0
def show_demo():

    with cxt.collapsing_header(label="Drawlists"):

        with cxt.group():

            dpg.add_radio_button(
                ("Layer 1", "Layer 2", "Layer 3"),
                default_value="Layer 1",
                callback=lambda sender: _set_layer(dpg.get_value(sender)))
            dpg.add_listbox(("Line", "Circle"),
                            label="Draw Item",
                            default_value="Line",
                            width=100,
                            callback=_switch_group)

            with cxt.group(width=200) as g:
                global line_group
                line_group = g
                p1_input = dpg.add_input_intx(label="p1",
                                              size=2,
                                              default_value=(10, 10))
                p2_input = dpg.add_input_intx(label="p2",
                                              size=2,
                                              default_value=(100, 100))
                thickness_input = dpg.add_input_int(label="thickness",
                                                    default_value=1)
                color_input = dpg.add_color_picker(label="color",
                                                   default_value=(255, 255,
                                                                  255, 255))
                dpg.add_button(label="Add",
                               callback=lambda: dpg.draw_line(
                                   dpg.get_value(p1_input),
                                   dpg.get_value(p2_input),
                                   thickness=dpg.get_value(thickness_input),
                                   color=dpg.get_value(color_input),
                                   parent=current_layer))

            with cxt.group(show=False, width=200) as g:
                global circle_group
                circle_group = g
                center_input = dpg.add_input_intx(label="center",
                                                  size=2,
                                                  default_value=(100, 100))
                radius_input = dpg.add_input_int(label="radius",
                                                 default_value=20)
                thickness_input = dpg.add_input_int(label="thickness",
                                                    default_value=1)
                seg_input = dpg.add_input_int(label="segments",
                                              default_value=0)
                color_input = dpg.add_color_picker(label="color",
                                                   default_value=(255, 255,
                                                                  255, 255))
                fill_input = dpg.add_color_picker(label="fill",
                                                  default_value=(0, 0, 0, 0),
                                                  alpha_bar=True)
                dpg.add_button(label="Add",
                               callback=lambda: dpg.draw_circle(
                                   dpg.get_value(center_input),
                                   dpg.get_value(radius_input),
                                   thickness=dpg.get_value(thickness_input),
                                   segments=dpg.get_value(seg_input),
                                   color=dpg.get_value(color_input),
                                   fill=dpg.get_value(fill_input),
                                   parent=current_layer))

        dpg.add_same_line()

        with cxt.drawlist(id="drawlist_demo", width=800, height=500):
            global current_layer, layer_1, layer_2, layer_3
            dpg.draw_rectangle((0, 0), (800, 500),
                               color=(100, 100, 100, 250),
                               thickness=2)
            layer_1 = dpg.add_draw_layer()
            layer_2 = dpg.add_draw_layer()
            layer_3 = dpg.add_draw_layer()
            current_layer = layer_1
Exemple #9
0
def show_demo():

    with cxt.collapsing_header(label="Widgets"):

        with cxt.tree_node(label="Basic"):

            with cxt.group(horizontal=True):
                dpg.add_button(label="Button", callback=_log)
                dpg.add_button(label="Button", callback=_log, small=True)
                dpg.add_button(label="Button", callback=_log,
                               arrow=True)  # default direction is mvDir_Up
                dpg.add_button(label="Button",
                               callback=_log,
                               arrow=True,
                               direction=dpg.mvDir_Left)
                dpg.add_button(label="Button",
                               callback=_log,
                               arrow=True,
                               direction=dpg.mvDir_Right)
                dpg.add_button(label="Button",
                               callback=_log,
                               arrow=True,
                               direction=dpg.mvDir_Down)

            dpg.add_checkbox(label="checkbox", callback=_log)
            dpg.add_radio_button(("radio a", "radio b", "radio c"),
                                 callback=_log,
                                 horizontal=True)
            dpg.add_selectable(label="selectable", callback=_log)

            with cxt.group(horizontal=True) as g:

                for i in range(0, 7):
                    button = dpg.add_button(label="Click", callback=_log)
                    dpg.set_theme_style(dpg.mvThemeStyle_Button_Rounding,
                                        i * 5,
                                        item=button)
                    dpg.set_theme_style(dpg.mvThemeStyle_Button_PaddingX,
                                        i * 3,
                                        item=button)
                    dpg.set_theme_style(dpg.mvThemeStyle_Button_PaddingY,
                                        i * 3,
                                        item=button)
                    dpg.set_theme_color(dpg.mvThemeCol_Button_Bg,
                                        _hsv_to_rgb(i / 7.0, 0.6, 0.6),
                                        item=button)
                    dpg.set_theme_color(dpg.mvThemeCol_Button_Active,
                                        _hsv_to_rgb(i / 7.0, 0.8, 0.8),
                                        item=button)
                    dpg.set_theme_color(dpg.mvThemeCol_Button_Hovered,
                                        _hsv_to_rgb(i / 7.0, 0.7, 0.7),
                                        item=button)

            with cxt.group(horizontal=True):

                dpg.add_text("Press a button: ")
                dpg.add_button(arrow=True,
                               direction=dpg.mvDir_Left,
                               callback=lambda: dpg.set_value(
                                   widget,
                                   int(dpg.get_value(widget)) - 1))
                dpg.add_button(arrow=True,
                               direction=dpg.mvDir_Right,
                               callback=lambda: dpg.set_value(
                                   widget,
                                   int(dpg.get_value(widget)) + 1))
                widget = dpg.add_text("0")

            widget2 = dpg.add_text("hover me")
            with cxt.tooltip(
                    parent=widget2
            ):  # note that "parent" is the item the tooltip show's for
                dpg.add_text("I'm a fancy tooltip")

            dpg.add_separator()

            dpg.add_text("Value", label="Label", show_label=True)
            dpg.add_combo(("AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF",
                           "GGGG", "HHHH", "IIII", "JJJJ", "KKKK"),
                          label="combo",
                          default_value="AAAA",
                          callback=_log)
            dpg.add_input_text(label="input text",
                               default_value="Hello, world!",
                               callback=_log)
            _help("USER:\n"
                  "Hold SHIFT or use mouse to select text.\n"
                  "CTRL+Left/Right to word jump.\n"
                  "CTRL+A or double-click to select all.\n"
                  "CTRL+X,CTRL+C,CTRL+V clipboard.\n"
                  "CTRL+Z,CTRL+Y undo/redo.\n"
                  "ESCAPE to revert.\n\n")
            dpg.add_input_text(label="input text (w/ hint)",
                               hint="enter text here",
                               callback=_log)
            dpg.add_input_int(label="input int", callback=_log)
            dpg.add_input_float(label="input float", callback=_log)
            dpg.add_input_float(label="input scientific",
                                format="%e",
                                callback=_log)
            dpg.add_input_floatx(label="input floatx",
                                 callback=_log,
                                 default_value=[1, 2, 3, 4])
            dpg.add_drag_int(label="drag int", callback=_log)
            _help("Click and drag to edit value.\n"
                  "Hold SHIFT/ALT for faster/slower edit.\n"
                  "Double-click or CTRL+click to input value.")
            dpg.add_drag_int(label="drag int 0..100",
                             format="%d%%",
                             callback=_log)
            dpg.add_drag_float(label="drag float", callback=_log)
            dpg.add_drag_float(label="drag small float",
                               default_value=0.0067,
                               format="%.06f ns",
                               callback=_log)
            dpg.add_slider_int(label="slider int", max_value=3, callback=_log)
            _help("CTRL+click to enter value.")
            dpg.add_slider_float(label="slider float",
                                 max_value=1.0,
                                 format="ratio = %.3f",
                                 callback=_log)
            dpg.add_slider_int(label="slider angle",
                               min_value=-360,
                               max_value=360,
                               format="%d deg",
                               callback=_log)
            _help("Click on the colored square to open a color picker.\n"
                  "Click and hold to use drag and drop.\n"
                  "Right-click on the colored square to show options.\n"
                  "CTRL+click on individual component to input value.\n")
            dpg.add_color_edit((102, 179, 0, 128),
                               label="color edit 4",
                               callback=_log,
                               uint8=True)
            dpg.add_color_edit(default_value=(.5, 1, .25, .1),
                               label="color edit 3",
                               callback=_log,
                               m_3component=True,
                               uint8=True,
                               floats=False)
            dpg.add_listbox(
                ("Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange",
                 "Pineapple", "Strawberry", "Watermelon"),
                label="listbox",
                num_items=4,
                callback=_log)
            dpg.add_color_button(label="color button")

        with cxt.tree_node(label="Bullets"):

            dpg.add_text("Bullet point 1", bullet=True)
            dpg.add_text(
                "Bullet point 2\nbullet text can be\nOn multiple lines",
                bullet=True)

            with cxt.tree_node(label="Tree node"):
                dpg.add_text("Another bullet point", bullet=True)

            dpg.add_text("1", bullet=True)
            dpg.add_same_line()
            dpg.add_button(label="Button", small=True)

        with cxt.tree_node(label="Text"):

            with cxt.tree_node(label="Colored Text"):

                dpg.add_text("Pink", color=(255, 0, 255))
                dpg.add_text("Yellow", color=(255, 255, 0))

            with cxt.tree_node(label="Word Wrapping"):

                dpg.add_text(
                    'This text should automatically wrap on the edge of the window.The current implementation for the text wrapping follows simple rules suited for English and possibly other languages',
                    wrap=0)
                dpg.add_slider_int(
                    label="wrap width",
                    default_value=500,
                    max_value=1000,
                    callback=lambda sender: dpg.configure_item(
                        "_demo_wrap", wrap=dpg.get_value(sender)))
                dpg.add_text(
                    'The lazy dong is a good dog. This paragraph should fit within the child. Testing a 1 character word. The quick brown fox jumps over the lazy dog.',
                    id="_demo_wrap",
                    wrap=100)

        with cxt.tree_node(label="Text Input"):

            dpg.add_checkbox(label="readonly",
                             callback=_config,
                             callback_data="Multi-line Text Input")
            dpg.add_checkbox(label="on_enter",
                             callback=_config,
                             callback_data="Multi-line Text Input")

            with cxt.tree_node(id="Multi-line Text Input"):

                dpg.add_input_text(
                    multiline=True,
                    default_value="/*\n"
                    " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n"
                    " the hexadecimal encoding of one offending instruction,\n"
                    " more formally, the invalid operand with locked CMPXCHG8B\n"
                    " instruction bug, is a design flaw in the majority of\n"
                    " Intel Pentium, Pentium MMX, and Pentium OverDrive\n"
                    " processors (all in the P5 microarchitecture).\n"
                    "*/\n\n"
                    "label:\n"
                    "\tlock cmpxchg8b eax\n",
                    height=300,
                    callback=_log,
                    tab_input=True)

            with cxt.tree_node(label="Filtered Text Input"):

                dpg.add_input_text(callback=_log, label="default")
                dpg.add_input_text(callback=_log,
                                   label="decimal",
                                   decimal=True)
                dpg.add_input_text(callback=_log,
                                   label="no blank",
                                   no_spaces=True)
                dpg.add_input_text(callback=_log,
                                   label="uppercase",
                                   uppercase=True)
                dpg.add_input_text(callback=_log,
                                   label="scientific",
                                   scientific=True)
                dpg.add_input_text(callback=_log,
                                   label="hexdecimal",
                                   hexadecimal=True)

            with cxt.tree_node(label="Password Input"):

                password = dpg.add_input_text(label="password",
                                              password=True,
                                              callback=_log)
                dpg.add_input_text(label="password (w/ hint)",
                                   password=True,
                                   hint="<password>",
                                   source=password,
                                   callback=_log)
                dpg.add_input_text(label="password (clear)",
                                   source=password,
                                   callback=_log)

        with cxt.tree_node(label="Simple Plots"):

            dpg.add_simple_plot(
                label="Frame Times",
                default_value=[0.6, 0.1, 1.0, 0.5, 0.92, 0.1, 0.2])
            dpg.add_simple_plot(label="Histogram",
                                default_value=(0.6, 0.1, 1.0, 0.5, 0.92, 0.1,
                                               0.2),
                                height=80,
                                histogram=True,
                                minscale=0.0)

            data1 = []
            for i in range(0, 70):
                data1.append(cos(3.14 * 6 * i / 180))

            dpg.add_simple_plot(label="Lines", default_value=data1, height=80)
            dpg.add_simple_plot(label="Histogram",
                                default_value=data1,
                                height=80,
                                histogram=True)
            dpg.add_progress_bar(label="Progress Bar",
                                 default_value=0.78,
                                 overlay="78%")
            dpg.add_same_line()
            dpg.add_text("Progress Bar")
            bar = dpg.add_progress_bar(default_value=0.78, overlay="1367/1753")
            dpg.set_theme_color(dpg.mvThemeCol_ProgressBar_Bar,
                                (255, 0, 0, 255),
                                item=bar)

        with cxt.tree_node(label="Multi-component Widgets"):

            for i in range(2, 5):

                with cxt.group():
                    float_source = dpg.add_input_floatx(
                        label=f"input float {i}",
                        min_value=0.0,
                        max_value=100.0,
                        size=i)
                    dpg.add_drag_floatx(label=f"drag float {i}",
                                        source=float_source,
                                        size=i)
                    dpg.add_slider_floatx(label=f"slider float {i}",
                                          source=float_source,
                                          size=i)

                with cxt.group():

                    int_source = dpg.add_input_intx(label=f"input int {i}",
                                                    min_value=0,
                                                    max_value=100,
                                                    size=i)
                    dpg.add_drag_intx(label=f"drag int {i}",
                                      source=int_source,
                                      size=i)
                    dpg.add_slider_intx(label=f"slider int {i}",
                                        source=int_source,
                                        size=i)

                dpg.add_dummy(height=10)

        with cxt.tree_node(label="Vertical Sliders"):

            dpg.add_slider_int(label=" ",
                               default_value=1,
                               vertical=True,
                               max_value=5,
                               height=160)
            dpg.add_same_line()

            with cxt.group(horizontal=True):

                values = [0.0, 0.60, 0.35, 0.9, 0.70, 0.20, 0.0]

                for i in range(0, 7):
                    widget3 = dpg.add_slider_float(label=" ",
                                                   default_value=values[i],
                                                   vertical=True,
                                                   max_value=1.0,
                                                   height=160)
                    dpg.set_theme_color(dpg.mvThemeCol_SliderFloat_Bg,
                                        _hsv_to_rgb(i / 7.0, 0.5, 0.5),
                                        item=widget3)
                    dpg.set_theme_color(dpg.mvThemeCol_SliderFloat_Grab,
                                        _hsv_to_rgb(i / 7.0, 0.9, 0.9),
                                        item=widget3)
                    dpg.set_theme_color(dpg.mvThemeCol_SliderFloat_BgActive,
                                        _hsv_to_rgb(i / 7.0, 0.7, 0.5),
                                        item=widget3)
                    dpg.set_theme_color(dpg.mvThemeCol_SliderFloat_BgHovered,
                                        _hsv_to_rgb(i / 7.0, 0.6, 0.5),
                                        item=widget3)

            dpg.add_same_line()
            with cxt.group():
                for i in range(0, 3):
                    with cxt.group(horizontal=True):
                        values = [0.20, 0.80, 0.40, 0.25]
                        for j in range(0, 4):
                            dpg.add_slider_float(label=" ",
                                                 default_value=values[j],
                                                 vertical=True,
                                                 max_value=1.0,
                                                 height=50)

            dpg.add_same_line()
            with cxt.group(horizontal=True):
                dpg.add_slider_float(label=" ",
                                     vertical=True,
                                     max_value=1.0,
                                     height=160,
                                     width=40)
                dpg.add_slider_float(label=" ",
                                     vertical=True,
                                     max_value=1.0,
                                     height=160,
                                     width=40)
                dpg.add_slider_float(label=" ",
                                     vertical=True,
                                     max_value=1.0,
                                     height=160,
                                     width=40)
                dpg.add_slider_float(label=" ",
                                     vertical=True,
                                     max_value=1.0,
                                     height=160,
                                     width=40)

        with cxt.tree_node(label="Time/Date Widgets"):

            dpg.add_time_picker(label="Time Picker",
                                default_value={
                                    'hour': 14,
                                    'min': 32,
                                    'sec': 23
                                })
            dpg.add_separator()

            with cxt.table(header_row=False):

                dpg.add_table_column()
                dpg.add_table_column()
                dpg.add_table_column()

                dpg.add_date_picker(label="Date Picker1",
                                    level=0,
                                    default_value={
                                        'month_day': 8,
                                        'year': 93,
                                        'month': 5
                                    })
                dpg.add_table_next_column()
                dpg.add_date_picker(label="Date Picker2",
                                    level=1,
                                    default_value={
                                        'month_day': 8,
                                        'year': 93,
                                        'month': 5
                                    })
                dpg.add_table_next_column()
                dpg.add_date_picker(label="Date Picker3",
                                    level=2,
                                    default_value={
                                        'month_day': 8,
                                        'year': 93,
                                        'month': 5
                                    })

        with cxt.tree_node(label="Loading Indicators"):

            dpg.add_loading_indicator()
            dpg.add_same_line()
            dpg.add_loading_indicator(style=1)

        with cxt.tree_node(label="Knobs"):

            with cxt.group(horizontal=True):

                dpg.add_knob_float(label="K1")
                dpg.add_knob_float(label="K2", default_value=25.0)
                dpg.add_knob_float(label="K3", default_value=50.0)

        with cxt.tree_node(label="2D/3D Sliders"):

            dpg.add_3d_slider(label="3D Slider", scale=0.5)
Exemple #10
0
 def _setup_add_widget(self, dpg_args) -> None:
     dpgcore.add_listbox(self.id, **dpg_args)
Exemple #11
0
    def __init__(self):
        core.set_vsync(False)
        core.set_style_window_padding(0, 0)

        self.__iteration = 3
        # load the data blob

        root = path.dirname(path.realpath(__file__))
        with open(f'{root}/fractal.json', 'r') as data:
            self.__fractalData = OrderedDict(json.load(data))
        self.__fractalKeys = [k for k in self.__fractalData.keys()]
        d = self.__fractalKeys[0]
        self.__fractal = Fractal(**self.__fractalData[d])
        size = core.get_main_window_size()

        with simple.window("MainWindow"):
            with simple.group("Controls"):
                core.add_input_int("Iteration",
                                   width=120,
                                   min_value=2,
                                   max_value=40,
                                   min_clamped=True,
                                   max_clamped=True,
                                   default_value=self.__iteration,
                                   callback=self.__cbIterationValue)
                simple.tooltip(
                    "Iteration",
                    "How many times to re-run the pattern parser with the \
					previous runs output. Increasing this directly increases computation time."
                )

                with simple.group("Controls-Angle"):
                    core.add_input_float("Angle",
                                         width=120,
                                         default_value=self.__fractal.dAngle,
                                         callback=self.__cbAngleValue)
                    simple.tooltip(
                        "Angle",
                        "Degrees the turtle will turn either positive or negative, when issued such commands."
                    )
                    core.add_same_line()
                    core.add_checkbox("AngleAnimate",
                                      default_value=False,
                                      label="Animate")
                    core.add_input_float("AngleStep",
                                         width=120,
                                         default_value=.002,
                                         step=0.001,
                                         step_fast=0.01)
                    simple.tooltip(
                        "AngleStep",
                        "Amount the animator will step through the angle.")

                core.add_input_float("Length",
                                     width=120,
                                     default_value=self.__fractal.delta,
                                     callback=self.__cbDeltaValue)
                simple.tooltip(
                    "Length",
                    "Relative distance, forward or backward, the turtle will take when commanded."
                )
            core.add_same_line()
            core.add_listbox("power",
                             label='',
                             items=self.__fractalKeys,
                             callback=self.__cbFractalType)
            core.add_drawing("Canvas", width=size[0] * 2, height=size[1] * 2)
        core.set_resize_callback(self.__resize)
        core.set_render_callback(self.__render)
        self.__refresh()
Exemple #12
0
                    "Double-click or CTRL+click to input value.")
            dpg.add_drag_int(label="drag int 0..100", format="%d%%", callback=_log)
            dpg.add_drag_float(label="drag float", callback=_log)
            dpg.add_drag_float(label="drag small float", default_value=0.0067, format="%.06f ns", callback=_log)
            dpg.add_slider_int(label="slider int", max_value=3, callback=_log)
            _help("CTRL+click to enter value.")
            dpg.add_slider_float(label="slider float", max_value=1.0, format="ratio = %.3f", callback=_log)
            dpg.add_slider_int(label="slider angle", min_value=-360, max_value=360, format="%d deg", callback=_log)
            _help(
                    "Click on the colored square to open a color picker.\n"
                    "Click and hold to use drag and drop.\n"
                    "Right-click on the colored square to show options.\n"
                    "CTRL+click on individual component to input value.\n")
            dpg.add_color_edit((102, 179, 0, 128), label="color edit 4", callback=_log, uint8=True)
            dpg.add_color_edit(default_value=(.5, 1, .25, .1), label="color edit 3", callback=_log, m_3component=True, uint8=True, floats=False)
            dpg.add_listbox(("Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon"), label="listbox", num_items=4, callback=_log)
            dpg.add_color_button(label="color button")

        with cxt.tree_node(label="Bullets"):

            dpg.add_text("Bullet point 1", bullet=True)
            dpg.add_text("Bullet point 2\nbullet text can be\nOn multiple lines", bullet=True)

            with cxt.tree_node(label="Tree node"):
                dpg.add_text("Another bullet point", bullet=True)

            dpg.add_text("1", bullet=True)
            dpg.add_same_line()
            dpg.add_button(label="Button", small=True)

        with cxt.tree_node(label="Text"):