def add_data_option(self, sender, data): """ Creates the data input window for the add data window """ with s.window( "Add Data Window", autosize=True, x_pos=0, y_pos=350, ): # Title text c.add_text("Add a new data row:") c.add_text( name=f"Idx: \t{len(self.table_data)}", tip="This is created automatically", ) # Text divider c.add_text("-" * 30) # input sliders c.add_slider_int(name=": x_val") c.add_slider_int(name=": y_val") # Action buttons c.add_button( "Cancel", callback=lambda *args: c.delete_item("Add Data Window"), ) c.add_same_line() c.add_button("Add Row", callback=self.save_new_row)
def run_gui(self): with window("Auto Pots"): set_start_callback(self.read_default_preferences) set_main_window_title('Auto Pots') set_window_pos("Auto Pots", 0, 0) add_spacing(count=12) add_button('Pick Maple Window', callback=self.pick_maple_window) add_text('Currently doing nothing. Pick MapleStory window.') add_spacing(count=12) add_text('Take HP Pot When Reaching', color=[232, 163, 33]) add_slider_int("% HP", default_value=45, max_value=99, width=int(SCREEN_WIDTH * 0.8), callback=self.change_hp_percentage) with menu('Select HP button on keyboard'): add_menu_item("Insert", callback=self.change_hp_keyboard_button) add_menu_item("Delete", callback=self.change_hp_keyboard_button) add_menu_item("Home", callback=self.change_hp_keyboard_button) add_menu_item("End", callback=self.change_hp_keyboard_button) add_menu_item("PgUp", callback=self.change_hp_keyboard_button) add_menu_item("PgDn", callback=self.change_hp_keyboard_button) add_spacing(count=12) add_text('Take MP Pot When Reaching', color=[232, 163, 33]) add_slider_int("% MP", default_value=30, max_value=99, width=int(SCREEN_WIDTH * 0.8), callback=self.change_mp_percentage) with menu('Select MP button on keyboard'): add_menu_item("Insert##1", callback=self.change_mp_keyboard_button) add_menu_item("Delete##1", callback=self.change_mp_keyboard_button) add_menu_item("Home##1", callback=self.change_mp_keyboard_button) add_menu_item("End##1", callback=self.change_mp_keyboard_button) add_menu_item("PgUp##1", callback=self.change_mp_keyboard_button) add_menu_item("PgDn##1", callback=self.change_mp_keyboard_button) add_spacing(count=12) add_button('Save Preferences As Default', callback=self.save_preferences) with popup("Save Preferences As Default", 'Save Popup', modal=True, mousebutton=mvMouseButton_Left): add_text('Your preferences has been saved') add_button("OK!", callback=lambda x, y: close_popup(item="Save Popup")) add_spacing(count=12) add_text('Currently doing nothing on HP. Pick button.') add_text('Currently doing nothing on MP. Pick button.') self.read_default_preferences() start_dearpygui(primary_window='Auto Pots')
def __init__(self): core.set_vsync(False) core.set_style_frame_padding(0, 0) self.__width = 60 self.__height = 40 self.__fire = [0] * (self.__height * self.__width) with simple.window("Controls", width=220, no_resize=True): core.add_slider_int("Width", width=150, default_value=self.__width, min_value=5, max_value=80, clamped=True) core.add_slider_int("Height", width=150, default_value=self.__height, min_value=5, max_value=50, clamped=True) with simple.window("MainWindow"): core.add_drawing("Canvas", width=1920, height=1080) color = (0, 0, 0, 255) for i in range(self.__width, self.__width * self.__height): core.draw_quad("Canvas", (0, 0), (0, 0), (0, 0), (0, 0), color, thickness=0, tag=f"quad-{i}") core.set_render_callback(self.__render)
def create_new_project(self, *_args): """ Defines a simple window that takes inputs for creating a new project :return: On save inserts project data into database """ with s.window("Create New Project", autosize=True): c.add_input_text("project_name##new_project", label="Project Name") c.add_input_text("client##new_project", label="Client") c.add_slider_int( "rate##new_project", label="Billing Rate per hour", max_value=100, tip="ctrl+click to directly type the number", ) c.add_slider_int( "monthly_frequency##new_project", label="Pay Frequency per Month", default_value=2, max_value=8, tip="How frequently pay is given, default twice a month", ) c.add_slider_int( "weekly_hour_allotment##new_project", label="Weekly Hours", max_value=80, default_value=20, tip="Hours per week for project.", ) c.add_button("Save##SaveProject", callback=self.save_new_project)
def change_depth(self): params.depth = core.get_value('SliderDepth') status.params_changed = True # Clear sliders for layer in range(self.MAX_DEPTH): text = f'Layer {layer+1}' slider_name = f'SliderOct{layer}' try: core.delete_item(text) core.delete_item(slider_name) except SystemError: pass # Add sliders for layer in range(params.depth): text = f'Layer {layer+1}' slider_name = f'SliderOct{layer}' core.add_text(text, parent='OctaveWindow') core.add_slider_int(slider_name, default_value=params.octave_spread[layer], min_value=-2, max_value=2, label='', width=100, parent='OctaveWindow', callback=self.change_octave)
def start(): """ Renders main window elements. """ with open('token.txt', 'r') as token_file: token = token_file.readline() try: # Connect to IBM core.run_async_function(get_backends_async, data=token) core.set_render_callback(show_button) # Progress bar with simple.window('Please wait', no_scrollbar=True, height=70, width=400, x_pos=500, y_pos=200): core.add_progress_bar('progress', value=0.0, overlay='Connecting to IBM...', width=400) core.run_async_function(progress_async, 0) # Menu bar with simple.menu_bar("Main Menu Bar"): with simple.menu("File"): core.add_menu_item("Save", callback=print_me) core.add_menu_item("Save As", callback=print_me) core.add_menu_item("Help", callback=open_help_window) core.add_menu_item("About", callback=open_about_window) # Parameters group with simple.group('left group', width=350): # Select file button core.add_child('##file_block', width=350, height=180, show=False) core.add_button('File Selector', callback=file_picker) core.add_spacing(name='##space2', count=3) core.add_text('File location:') core.add_label_text('##filedir', value='None Selected', source='directory') core.add_spacing(name='##space3', count=3) core.add_text('File name:') core.add_label_text('##file', value='None Selected', source='file_directory') core.end() core.add_spacing(name='##space4', count=3) # Architecture type radio button core.add_child('##settings_block', width=350, height=450, show=False) core.add_text('Architecture type:') core.add_radio_button('radio##1', items=[ 'IBM simulator', 'IBM quantum computer', 'Arbitrary computer coupling' ], callback=show_architecture_list, source='device_type') core.add_spacing(name='##space5', count=3) # "Create arbitrary coupling" button core.add_button('Create custom architecture', callback=create_architecture, show=False) core.add_spacing(name='##space11', count=3) # Layout radio button core.add_text('Quantum circuit layout method:') core.add_radio_button( 'radio##2', items=['Original IBM layout', 'Advanced SWAP placement'], source='layout_type') core.add_spacing(name='##space6', count=3) # Optimization level slider core.add_text('Optimization level:') core.add_slider_int( '##optimization_lvl', default_value=1, min_value=0, max_value=3, tip='drag the slider to select an optimization level', width=300, source='opt_level') core.add_spacing(name='##space7', count=3) # Number of iterations slider core.add_text('Number of iterations:') core.add_input_int('##num_of_iter', width=300, callback=check_iteration_num, default_value=100) core.add_spacing(name='##space8', count=3) # Default settings button core.add_button('Set Default', callback=set_default) core.end() core.add_spacing(name='##space9', count=3) # Process button core.add_button('Process', callback=process, show=False) # graph images core.add_same_line(name='line##3', xoffset=370) with simple.group('center group'): core.add_child('##images_block', width=640, show=False) # Input circuit preview core.add_text('Input circuit:') core.add_drawing('input_circuit', width=600, height=500) core.draw_rectangle('input_circuit', [0, 150], [600, 500], [255, 255, 255, 0], [255, 255, 255, 50]) # Output circuit view core.add_text('Output circuit:') core.add_drawing('output_circuit', width=600, height=500) core.draw_rectangle('output_circuit', [0, 150], [600, 500], [255, 255, 255, 0], [255, 255, 255, 50]) core.end() # program output core.add_same_line(name='line##3', xoffset=1020) with simple.group('right group'): core.add_child('##output_block1', width=460, height=300, show=False) core.add_button('Open qasm file', callback=open_qasm) core.add_text('Path to IBM circuit representation') core.add_label_text('##circuitImage') core.add_button('Mapping', callback=show_mapping) core.end() core.add_text('Program output:', show=False) core.add_child('##output_block2', width=460, height=180, show=False) core.add_text('Program output will be displayed here', wrap=440) core.end() except Exception as exc: print("[ERROR]: {}".format(exc))
def __init__(self): self.tensorFlowInterface = TensorFlowInterface() self.outputVisualisationWindow = OutputVisualisationWindow() self.historyGraphWindow = HistoryGraphWindow() with simple.window(self.windowName, width=self.xSize, height=self.ySize, x_pos=self.xPos, y_pos=self.yPos): core.add_text(self.simulationSetting) core.add_button(self.createNetwork, callback=self.create_network_callback) core.add_same_line() core.add_button(self.createVisualization, callback=self.create_visualisation_callback) core.add_same_line() core.add_button(self.createOutputPrediction, callback=self.create_output_prediction) core.add_same_line() core.add_button(self.historyGraph, callback=self.create_history_graph) core.add_button(self.trainData, callback=self.execute_training_data) core.add_same_line() #core.add_slider_int(self.timeToTrain, default_value = 100, min_value=1, max_value=1000, width = 200) core.add_input_int(self.timeToTrain, default_value=100, min_value=1, max_value=1000, width=200) core.add_same_line() core.add_checkbox(self.use2DInOut) core.add_slider_int(self.numberOfLayers, default_value=2, min_value=2, max_value=self.maxNumberOfLayers, callback=self.layer_slider_callback, width=200) for i in range(0, self.maxNumberOfLayers): core.add_slider_int(self.layer + str(i), default_value=1, width=200) core.add_same_line() core.add_combo(self.type + '##' + str(i), items=self.neuronTypeList, width=70, callback=self.change_list_callback, default_value='Dense') core.add_same_line() core.add_combo(self.activation + '##' + str(i), items=self.neuronActivationList, width=70, callback=self.change_list_callback, default_value='relu') core.add_separator() self.layer_slider_callback() #self.visualization_window = VisualizationWindow() self.betterVisualizer = BetterVisualizer() self.betterVisualizer.hide_window() self.importWindow = ImportWindow() self.neuronDataContainer = ModelDataContainer( self.neuronDataContainerDefaultData[0], self.neuronDataContainerDefaultData[1], self.neuronDataContainerDefaultData[2], self.neuronDataContainerDefaultData[3]) self.modify_neuron_list() self.tensorFlowInterface.create_model(self.neuronDataContainer) super().__init__()
def start(self): available_out_ports = mido.get_output_names() available_in_ports = mido.get_input_names() if len(available_in_ports) > 0: status.current_in_port = mido.open_input( available_in_ports[0], callback=self.get_midi_input) if len(available_out_ports) > 0: self.out_port = mido.open_output(available_out_ports[0]) core.set_main_window_size(350, 550) core.set_main_window_title('Fractal Melody Machine') core.set_theme('Gold') with simple.window('Fractal Melody Machine', width=500, height=300): core.add_text('MIDI Input Port') core.add_combo('ComboInPort', items=mido.get_input_names( ), default_value=status.current_in_port.name, label='', width=100, callback=self.change_midi_in_port) core.add_text('MIDI Output Port') core.add_combo('ComboOutPort', items=mido.get_output_names( ), default_value=self.out_port.name, label='', width=100, callback=self.change_midi_out_port) core.add_spacing(count=10) core.add_text('BPM') core.add_slider_int('SliderBPM', default_value=60, min_value=20, max_value=200, label='', width=100, callback=self.change_bpm) core.add_text('Depth') core.add_slider_int('SliderDepth', default_value=4, min_value=1, max_value=16, label='', width=100, callback=self.change_depth) core.add_same_line(spacing=45) core.add_text('DetectedKey', default_value='Detected Key: ') core.add_text('Branching Factor') core.add_slider_int('SliderBF', default_value=2, min_value=2, max_value=4, label='', width=100, callback=self.change_bf) core.add_text('Octave Spread') core.add_child('OctaveWindow', width=300, height=150) core.end() core.add_text('Figures') core.add_child('FigureWindow', width=300, height=150) core.add_table('FigureTable', [], hide_headers=True, height=10) core.add_columns('FigureTableCols', 2, border=False) core.add_checkbox(str(theory.FIGURE_WHOLE_NOTE), label='Whole note', callback=self.change_figures) core.add_checkbox(str(theory.FIGURE_QUARTER_NOTE), label='Quarter note', callback=self.change_figures, default_value=True) core.add_checkbox(str(theory.FIGURE_16TH_NOTE), label='16th note', callback=self.change_figures) core.add_checkbox(str(theory.FIGURE_64TH_NOTE), label='64th note', callback=self.change_figures) core.add_next_column() core.add_checkbox(str(theory.FIGURE_HALF_NOTE), label='Half note', callback=self.change_figures) core.add_checkbox(str(theory.FIGURE_8TH_NOTE), label='8th note', callback=self.change_figures, default_value=True) core.add_checkbox(str(theory.FIGURE_32ND_NOTE), label='32nd note', callback=self.change_figures) core.end() # Initialize octave spread sliders self.change_depth() core.start_dearpygui(primary_window='Fractal Melody Machine')
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)
def _setup_add_widget(self, dpg_args) -> None: dpgcore.add_slider_int(self.id, **dpg_args)
with window("Main Window"): with group("Left Panel", width=200): add_button("Start Video", callback=video_callback) add_same_line() add_button("End Video", callback=video_callback) add_checkbox("Recording", default_value=False, source="is_recording") add_same_line(spacing=20) add_checkbox("Goggle View", default_value=False, source="display_goggle_view") for name, (low, high, step, default) in parameters.items(): add_slider_int(name, default_value=default, min_value=low, max_value=high, source=name) add_same_line() image = np.zeros((640, 480, 3), dtype=np.uint8) image = cv2.cvtColor(image, cv2.COLOR_RGB2RGBA) add_texture("texture", image, 640, 480) add_image("canvas", "texture") add_slider_float("FPS", max_value=60, enabled=False, no_input=True, source="realtime_fps") add_data("video_on", False)
parent="main") run_async_function(async_sleep, backupinfo[1], return_handler=backupcallback) else: add_text(f'Backup failed. Is the world being accessed?', parent="main") run_async_function(async_sleep, backupinfo[2], return_handler=backupcallback) else: add_text(f'World ({backupinfo[0]}) not found', parent="main") if __name__ == '__main__': set_main_window_size(480, 400) with window("main"): add_text("MCAutoBack") add_input_text("World Name", default_value="Cube World") add_button("Backup", callback=backupcallback) add_slider_int("Wait Time", default_value=300, min_value=30, max_value=1200) add_slider_int("Fail Wait Time", default_value=30, min_value=5, max_value=300) start_dearpygui(primary_window="main")
"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"):