예제 #1
0
def create_node_selector_window():
    with dpg.window(label='Node Selector', pos=[10, 60], width=300, height=890) as node_selector:
        # Create the window of the Node selector

        node_tree = generate_node_tree()
        base_id = node_tree[0][0]
        base_name = node_tree[0][1]
        with dpg.tree_node(label=base_name, parent=node_selector, default_open=True, id=base_id, open_on_arrow=True):

            # Read what *_com files exist in the Heron/Operations dir and sub dirs and create the correct
            # tree_node widget
            for parent_id, parent, node_id, node in node_tree:
                with dpg.tree_node(label=node, parent=parent_id, default_open=True, id=node_id):
                    for op in operations_list:
                        if node == op.parent_dir:
                            colour = gu.choose_color_according_to_operations_type(node)
                            button = dpg.add_button(label=op.name, width=200, height=30, callback=on_add_node)
                            with dpg.theme() as theme_id:
                                with dpg.theme_component(0):
                                    dpg.add_theme_color(dpg.mvThemeCol_Button, colour, category=dpg.mvThemeCat_Core)
                                    dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 5, category=dpg.mvThemeCat_Core)

                            dpg.bind_item_theme(button, theme_id)
        return node_selector
예제 #2
0
파일: main.py 프로젝트: filipecn/maldives
    if i == 0: return (255 * v, 255 * t, 255 * p)
    if i == 1: return (255 * q, 255 * v, 255 * p)
    if i == 2: return (255 * p, 255 * v, 255 * t)
    if i == 3: return (255 * p, 255 * q, 255 * v)
    if i == 4: return (255 * t, 255 * p, 255 * v)
    if i == 5: return (255 * v, 255 * p, 255 * q)


button_themes = 7 * [0]

for i_t in range(0, 7):
    with dpg.theme() as button_themes[i_t]:
        dpg.add_theme_color(dpg.mvThemeCol_Button, _hsv_to_rgb(i_t / 7.0, 0.6, 0.6))
        dpg.add_theme_color(dpg.mvThemeCol_ButtonActive, _hsv_to_rgb(i_t / 7.0, 0.8, 0.8))
        dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered, _hsv_to_rgb(i_t / 7.0, 0.7, 0.7))
        dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, i_t * 5)
        dpg.add_theme_style(dpg.mvStyleVar_FramePadding, i_t * 3, i_t * 3)

logger = mvLogger()
logger.log_level = 0

exchange: BinanceExchange = None

tickers = ['BTC', 'ETH']
prices = {}


class WindowData:
    # plots
    candle_plot: int = 0
    volume_plot: int = 0
예제 #3
0
color_1 = tuple(int(color_1_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))
color_2 = tuple(int(color_2_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))
color_3 = tuple(int(color_3_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))
color_4 = tuple(int(color_4_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))
color_5 = tuple(int(color_5_hex.replace("#", "")[i:i+2], 16) for i in (0, 2, 4))




def save_callback():
    print("Save Clicked")

# dpg.set_main_window_size(500,500)
with dpg.window(label="Main Controls", width=426, height=900) as window_id:
    with dpg.theme() as theme:
        dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 25)
        dpg.add_theme_color(dpg.mvThemeCol_Button, color_2)
        dpg.add_theme_color(dpg.mvThemeCol_ButtonActive, color_4)
        dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered, color_2)
        dpg.add_theme_color(dpg.mvThemeCol_Border, color_2)
        dpg.add_theme_color(dpg.mvThemeCol_FrameBg, color_2)
        dpg.add_theme_color(dpg.mvThemeCol_WindowBg, color_1)


        # dpg.add_theme_style(dpg.mvStyleVar_FramePadding, i*3, i*3)

    master_toggle = dpg.add_checkbox(label="Master")
    autoclicker_toggle = dpg.add_checkbox(label="Autoclicker")
    timer_toggle = dpg.add_checkbox(label="Timer")
    volume_up_button = dpg.add_button(label="Volume Up", callback=lambda: android.send_keycode(keycodes.AKEYCODE_VOLUME_UP))
    volume_down_button = dpg.add_button(label="Volume Down", callback=lambda: android.send_keycode(keycodes.AKEYCODE_VOLUME_DOWN))
예제 #4
0
import dearpygui.dearpygui as dpg

# Themes can consist of a colors and styles

# You can use the style editor to test themes at runtime and find the right constants for colors and styles
dpg.show_style_editor()

# Create a theme container and color and styles
with dpg.theme() as our_theme:

    dpg.add_theme_color(dpg.mvThemeCol_Button, (0, 255, 0, 255))
    dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered, (0, 255, 255, 255))
    dpg.add_theme_color(dpg.mvThemeCol_Text, (255, 0, 0, 255))

    # Some styles use only one variable "x" and some use 2 "x,"y" looking at the style editor can help
    dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 20)
    dpg.add_theme_style(dpg.mvStyleVar_FramePadding, 10, 10)

with dpg.window(label="Tutorial", width=500, height=500):
    dpg.add_button(label="Default Theme")

    # Setting theme at start up
    our_button = dpg.add_button(label="Set At Start-up")
    dpg.set_item_theme(our_button, our_theme)

    # Themes can be set at runtime using a lambda
    dpg.add_button(
        label="Set Theme at Runtime",
        callback=lambda sender: dpg.set_item_theme(sender, our_theme))

    # Themes can be set to all items of a specific type at runtime using a callback
예제 #5
0
    if i == 3: return (255 * p, 255 * q, 255 * v)
    if i == 4: return (255 * t, 255 * p, 255 * v)
    if i == 5: return (255 * v, 255 * p, 255 * q)


button_themes = 7 * [0]

for i_t in range(0, 7):
    with dpg.theme() as button_themes[i_t]:
        dpg.add_theme_color(dpg.mvThemeCol_Button,
                            _hsv_to_rgb(i_t / 7.0, 0.6, 0.6))
        dpg.add_theme_color(dpg.mvThemeCol_ButtonActive,
                            _hsv_to_rgb(i_t / 7.0, 0.8, 0.8))
        dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered,
                            _hsv_to_rgb(i_t / 7.0, 0.7, 0.7))
        dpg.add_theme_style(dpg.mvStyleVar_FrameRounding, 1 * 5)
        dpg.add_theme_style(dpg.mvStyleVar_FramePadding, 2 * 3, 2 * 3)


def rlines():
    with dpg.child(width=200, height=90):
        item = dpg.add_button(label='RLINES')
        dpg.set_item_theme(dpg.last_item(), button_themes[5])
        with dpg.tooltip(dpg.last_item()):
            dpg.add_text('Linhas de Resistencia')
        s = dpg.add_slider_float(label='%',
                                 default_value=2,
                                 min_value=0.1,
                                 max_value=5)
        i = dpg.add_input_int(default_value=0, label='')
    with dpg.drag_payload(parent=item,
예제 #6
0
    def spawn_node_on_editor(self):
        self.context = zmq.Context()
        self.initialise_parameters_socket()

        with dpg.node(label=self.name,
                      parent=self.parent,
                      pos=[self.coordinates[0],
                           self.coordinates[1]]) as self.id:
            colour = choose_color_according_to_operations_type(
                self.operation.parent_dir)
            with dpg.theme() as self.theme_id:
                with dpg.theme_component(0):
                    dpg.add_theme_color(dpg.mvNodeCol_TitleBar,
                                        colour,
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_TitleBarSelected,
                                        colour,
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_TitleBarHovered,
                                        colour,
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundSelected,
                                        [120, 120, 120, 255],
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_NodeBackground,
                                        [70, 70, 70, 255],
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundHovered,
                                        [80, 80, 80, 255],
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_color(dpg.mvNodeCol_NodeOutline,
                                        [50, 50, 50, 255],
                                        category=dpg.mvThemeCat_Nodes)
                    dpg.add_theme_style(dpg.mvNodeStyleVar_NodeBorderThickness,
                                        x=4,
                                        category=dpg.mvThemeCat_Nodes)
            dpg.bind_item_theme(self.id, self.theme_id)

            # Loop through all the attributes defined in the operation (as seen in the *_com.py file) and put them on
            # the node
            same_line_widget_ids = []
            for i, attr in enumerate(self.operation.attributes):

                if self.operation.attribute_types[i] == 'Input':
                    attribute_type = dpg.mvNode_Attr_Input
                elif self.operation.attribute_types[i] == 'Output':
                    attribute_type = dpg.mvNode_Attr_Output
                elif self.operation.attribute_types[i] == 'Static':
                    attribute_type = dpg.mvNode_Attr_Static

                attribute_name = attr + '##{}##{}'.format(
                    self.operation.name, self.node_index)

                with dpg.node_attribute(label=attribute_name,
                                        parent=self.id,
                                        attribute_type=attribute_type):
                    if attribute_type == 1:
                        dpg.add_spacer()
                    dpg.add_text(label='##' + attr + ' Name{}##{}'.format(
                        self.operation.name, self.node_index),
                                 default_value=attr)

                    if 'Parameters' in attr:
                        for k, parameter in enumerate(
                                self.operation.parameters):
                            if self.operation.parameter_types[k] == 'int':
                                id = dpg.add_input_int(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    default_value=self.node_parameters[k],
                                    callback=self.update_parameters,
                                    width=100,
                                    min_clamped=False,
                                    max_clamped=False,
                                    min_value=int(-1e8),
                                    max_value=int(1e8),
                                    on_enter=True)
                            elif self.operation.parameter_types[k] == 'str':
                                id = dpg.add_input_text(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    default_value=self.node_parameters[k],
                                    callback=self.update_parameters,
                                    width=100,
                                    on_enter=True)
                            elif self.operation.parameter_types[k] == 'float':
                                id = dpg.add_input_float(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    default_value=self.node_parameters[k],
                                    callback=self.update_parameters,
                                    width=100,
                                    min_clamped=False,
                                    max_clamped=False,
                                    min_value=-1e10,
                                    max_value=1e10,
                                    on_enter=True)
                            elif self.operation.parameter_types[k] == 'bool':
                                id = dpg.add_checkbox(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    default_value=self.node_parameters[k],
                                    callback=self.update_parameters)
                            elif self.operation.parameter_types[k] == 'list':
                                default_value = self.node_parameters[k][0]
                                if type(self.node_parameters[k]) == str:
                                    default_value = self.node_parameters[k]
                                id = dpg.add_combo(
                                    label='{}##{}'.format(
                                        parameter, attribute_name),
                                    items=self.node_parameters_combos_items[k],
                                    default_value=default_value,
                                    callback=self.update_parameters,
                                    width=100)

                            self.parameter_inputs_ids[parameter] = id

                    dpg.add_spacer(label='##Spacing##' + attribute_name,
                                   indent=3)

            # Add the extra input button with its popup window for extra inputs like ssh and verbosity
            self.extra_input_window()