def show_example(self, link): try: response = requests.get(link) if response.status_code == 200: open("src/data/temp.gif", "wb").write(response.content) core.add_image("canvas", "src/data/temp.gif") except: simple.show_logger() core.log_debug("error")
def show_example(self, link): if core.does_item_exist("example_image"): core.delete_item("example_image") response = requests.get(link) if response.status_code == 200: open(EXAMPLE_IMAGE_FILE_PATH, "wb").write(response.content) core.add_image( "example_image", EXAMPLE_IMAGE_FILE_PATH, parent="workout_execution_group", )
WINDOW = 'L0lScape Configuration' with simple.window(WINDOW): core.set_main_window_title(WINDOW) core.set_main_window_size(430, 460) core.set_theme('Purple') core.set_style_item_spacing(5, 5) core.set_style_frame_padding(5, 5) core.add_additional_font('resources/monofur.ttf', 18) core.add_dummy(width=140) core.add_same_line() core.add_image('logo', 'resources/l0lscape.png') core.add_button('About', callback=modal, width=100) core.add_same_line() core.add_button('Github', callback=open_url, width=100) core.add_same_line() core.add_button('Discord', callback=open_url, width=100) core.add_same_line() core.add_button('Help', callback=open_url, width=100) core.add_separator() for value in load_config(): key = value.get('key') core.add_text(f'{key}', bullet=True)
def multiple_accounts(sender, data): core.delete_item('Account Email') core.delete_item('Account Password') core.add_input_text('Accounts File', default_value='accs_to_level.txt', before='Login', width=200) with simple.window('Moon Overwatch Leveling Bot'): core.set_style_item_spacing(15, 15) core.set_style_frame_padding(5, 5) core.add_additional_font('Roboto-Regular.ttf', 14) core.add_image('logo', 'moon.png') core.add_separator() core.add_input_text('Account Email', default_value='*****@*****.**', width=200) core.add_input_text('Account Password', default_value='weShouldBuffBrig!69', width=200) core.add_checkbox('Multiple Accounts', default_value=False, callback=multiple_accounts) core.add_same_line()
no_focus_on_appearing=True, no_bring_to_front_on_focus=False, no_close=True, no_background=True, show=True): with dpgs.child("center-group", autosize_x=True, autosize_y=True, no_scrollbar=True, menubar=False, border=False): dpg.add_dummy(name="left-spacer", width=0) dpg.add_same_line() with dpgs.group("item-to-center"): dpg.add_image(name='dearpygui logo', value='resources/dearpygui_horizontal.png') # window with tiles and scrollbars with dpgs.window( 'body window', x_pos=0, y_pos=header_height, width=1600, height=1200, autosize=True, no_resize=True, no_title_bar=True, no_move=True, no_scrollbar=False, no_collapse=True, horizontal_scrollbar=False,
def start_build_dpg(): with simple.window("FACEIT Elo Overlay", on_close=lambda: delete_item("FACEIT Elo Overlay"), no_title_bar=True, no_resize=True): """ Set window configurations """ simple.set_window_pos("FACEIT Elo Overlay", 0, 0) core.set_main_window_title("FACEIT Elo Overlay") core.set_main_window_size(492, 830) core.set_style_frame_rounding(6.00) core.add_additional_font("resources/OpenSans-Bold.ttf", size=14.5) """ Initial loads """ db_create.create_database(DBNAME) COLOR_List = config_functions.get_color() """ Set some Background and Font Colors also the frame rounding and the window size """ core.set_theme_item(mvGuiCol_Text, COLOR_List[1][0], COLOR_List[1][1], COLOR_List[1][2], COLOR_List[1][3]) core.set_theme_item(mvGuiCol_WindowBg, COLOR_List[3][0], COLOR_List[3][1], COLOR_List[3][2], COLOR_List[3][3]) core.set_theme_item(mvGuiCol_Border, COLOR_List[4][0], COLOR_List[4][1], COLOR_List[4][2], COLOR_List[4][3]) core.set_style_frame_border_size(1.00) core.set_theme_item(mvGuiCol_Button, COLOR_List[0][0], COLOR_List[0][1], COLOR_List[0][2], COLOR_List[0][3]) core.set_theme_item(mvGuiCol_ButtonHovered, COLOR_List[0][0], COLOR_List[0][1], COLOR_List[0][2], COLOR_List[0][3]) core.set_theme_item(mvGuiCol_ButtonActive, COLOR_List[2][0], COLOR_List[2][1], COLOR_List[2][2], COLOR_List[2][3]) core.set_theme_item(mvGuiCol_BorderShadow, COLOR_List[0][0], COLOR_List[0][1], COLOR_List[0][2] - 50, COLOR_List[0][3]) with simple.window('##Overlay', no_collapse=True, no_resize=True, no_move=True, no_close=True, x_pos=30, y_pos=0, width=445, height=790, no_title_bar=True): """ Set a Header """ bool_list_faceit, bool_list_match, name, acEloGoal = startup() core.add_button("FACEIT Overlay Menu") core.set_item_style_var("FACEIT Overlay Menu", mvGuiStyleVar_FramePadding, [5 * 27, 5 * 3]) core.add_spacing(count=5) """ Build up the FACEIT Stats configuration """ with simple.group("##GroupStats"): core.add_button("Default Configurations##STATS") core.set_item_style_var("Default Configurations##STATS", mvGuiStyleVar_FramePadding, [5 * 20, 5 * 3]) core.add_spacing(count=5) core.add_text("##TextFaceitName", default_value="FACEIT Name:", color=(255, 255, 0, -1)) core.add_input_text("##FaceitName", hint="FACEIT Name Case sensitive", default_value=name, callback=changes_detected) core.add_spacing(count=2) core.add_text("##TextEloGoal", default_value="FACEIT Elo goal:") core.add_input_text("##EloGoal", hint="Set your Elo goal, empty = disabled", default_value=str(acEloGoal), callback=changes_detected) core.add_spacing(count=5) """ Faceit Stats header """ core.add_button("FACEIT Stats") core.set_item_style_var("FACEIT Stats", mvGuiStyleVar_FramePadding, [5 * 26, 5 * 3]) core.add_spacing(count=2) """ Checkbox group """ core.add_checkbox( "Disable All##stats", default_value=False, callback=lambda sender, data: disable_all(sender)) core.add_same_line() core.add_checkbox("Enable All##stats", default_value=False, callback=lambda sender, data: enable_all(sender)) core.add_spacing(count=3) """ Checkbox group """ core.add_checkbox("Current Elo##stats", default_value=bool_list_faceit[0], callback=changes_detected) core.add_same_line(xoffset=250) core.add_checkbox("Faceit Rank##stats", default_value=bool_list_faceit[1], callback=changes_detected) """ Checkbox group """ core.add_checkbox("Elo Gained today##stats", default_value=bool_list_faceit[2], callback=changes_detected) core.add_same_line(xoffset=250) core.add_checkbox("Win Streak##stats", default_value=bool_list_faceit[3], callback=changes_detected) """ Checkbox group """ core.add_checkbox("Total Matches##stats", default_value=bool_list_faceit[4], callback=changes_detected) core.add_same_line(xoffset=250) core.add_checkbox("Matches Won##stats", default_value=bool_list_faceit[5], callback=changes_detected) core.add_spacing(count=2) win_loss = config_functions.get_win_loss() print(win_loss) if win_loss[0][0] is None: win_loss = [(0, 0)] core.add_text("##TextWinLoss", default_value="Win/Loss Stats:") core.add_checkbox("Day##WinLoss", default_value=int(win_loss[0][0]), callback=lambda sender, data: win_los(sender)) core.add_same_line() core.add_checkbox("Week##WinLoss", default_value=int(win_loss[0][1]), callback=lambda sender, data: win_los(sender)) core.add_spacing(count=5) """ Last Match header """ core.add_button("Last Match") core.set_item_style_var("Last Match", mvGuiStyleVar_FramePadding, [5 * 26.5, 5 * 3]) core.add_spacing(count=2) """ Checkbox group """ core.add_checkbox( "Disable All##match", default_value=False, callback=lambda sender, data: disable_all(sender)) core.add_same_line() core.add_checkbox("Enable All##match", default_value=False, callback=lambda sender, data: enable_all(sender)) core.add_spacing(count=3) """ Checkbox group """ core.add_checkbox("Score##match", default_value=bool_list_match[0], callback=changes_detected) core.add_same_line(xoffset=250) core.add_checkbox("Result (W/L)##match", default_value=bool_list_match[1], callback=changes_detected) """ Checkbox group """ core.add_checkbox("Map##match", default_value=bool_list_match[2], callback=changes_detected) core.add_same_line(xoffset=250) core.add_checkbox("K/D##match", default_value=bool_list_match[3], callback=changes_detected) """ Checkbox group """ core.add_checkbox("Elo Diff##match", default_value=bool_list_match[4], callback=changes_detected) core.add_same_line(xoffset=250) core.add_checkbox("Kills##match", default_value=bool_list_match[5], callback=changes_detected) """ Checkbox group """ core.add_checkbox("Death##match", default_value=bool_list_match[6], callback=changes_detected) core.add_spacing(count=5) """ Apply Configuration to the database Button """ core.add_button("Apply Configuration", callback=save_data) """ Start the Overlay with the current configuration """ core.add_spacing(count=3) core.add_button("Start", callback=open_overlay) core.set_item_style_var("Start", mvGuiStyleVar_FramePadding, [5 * 29.5, 5 * 3]) with simple.window('##Config', no_collapse=True, no_resize=True, no_move=True, no_close=True, x_pos=0, y_pos=1, width=20, height=790, no_title_bar=True): core.set_item_color("##Config", mvGuiCol_Text, color=(COLOR_List[1][0], COLOR_List[1][1], COLOR_List[1][2], COLOR_List[1][3])) core.set_item_color("##Config", mvGuiCol_WindowBg, color=(COLOR_List[3][0], COLOR_List[3][1], COLOR_List[3][2], COLOR_List[3][3] - 10)) core.set_item_style_var("##Config", mvGuiStyleVar_WindowRounding, value=[6]) core.set_item_color("##Config", mvGuiCol_Border, color=(COLOR_List[4][0], COLOR_List[4][1], COLOR_List[4][2], COLOR_List[4][3])) core.add_image_button("##ConfigPlus", value="resources/cfg_wheel.png", callback=animation_config_color, frame_padding=1, tip="Settings & Colors") core.add_same_line(xoffset=50) with simple.group("##Config_Colors", show=False): COLOR_List = config_functions.get_color() core.add_text( "You can type in the RBG Values or click on the right Color Button" ) core.add_color_edit4(name="Header#Color", default_value=[ COLOR_List[0][0], COLOR_List[0][1], COLOR_List[0][2], COLOR_List[0][3] ], label="Header") core.add_color_edit4(name="Text#Color", default_value=[ COLOR_List[1][0], COLOR_List[1][1], COLOR_List[1][2], COLOR_List[1][3] ], label="Text") core.add_color_edit4(name="ButtonActive#Color", default_value=[ COLOR_List[2][0], COLOR_List[2][1], COLOR_List[2][2], COLOR_List[2][3] ], label="Button Active") core.add_color_edit4(name="BG#Color", default_value=[ COLOR_List[3][0], COLOR_List[3][1], COLOR_List[3][2], COLOR_List[3][3] ], label="Background") core.add_color_edit4(name="Outline#Color", default_value=[ COLOR_List[4][0], COLOR_List[4][1], COLOR_List[4][2], COLOR_List[4][3] ], label="Outline") core.add_separator() core.add_button("Test Colors", callback=test_colors) core.add_same_line() core.add_button("Reset", callback=reset_colors) core.add_button("Save Colors", callback=save_colors) core.add_spacing(count=2) core.add_separator() core.add_separator() core.add_spacing(count=2) scale = config_functions.get_scale() core.set_global_font_scale(scale) core.add_text("Change The Global Font Size") core.add_drag_float( "Global Scale", default_value=scale, format="%0.2f", speed=0.01, callback=lambda sender, data: core.set_global_font_scale( core.get_value("Global Scale"))) core.add_button("Reset##1", callback=reset_scale) core.add_button("Save Size##1", callback=save_scale) core.add_spacing(count=2) core.add_separator() core.add_separator() core.add_spacing(count=2) refresh = config_functions.get_refresh() refreshSymbol = config_functions.get_refresh_sign() core.add_text( "Change The refresh time for the Overlay ( in seconds )") core.add_input_int("##RefreshTime", default_value=refresh, min_value=5, step=0) core.add_button("Save refresh time##1", callback=save_refresh_time) if refreshSymbol in "True": refreshSymbol = True else: refreshSymbol = False core.add_spacing(count=2) core.add_text("Enable, Disable the refresh sign in the overlay") core.add_checkbox("Refresh Symbol##RefreshTime", default_value=refreshSymbol, callback=refresh_symbol) core.add_separator() core.add_separator() core.add_button("Close##Color", callback=animation_config_color) core.add_spacing(count=3) core.add_image_button("##ConfigWeb", value="resources/web.png", callback=animation_config_web, frame_padding=1, tip="Web") core.add_spacing(count=2) core.add_image_button("##ConfigQuestion", value="resources/q.png", callback=animation_config_help, frame_padding=1, tip="Help") core.add_same_line(xoffset=50) with simple.group("##Web", show=False): web = webFunctions.get_web() web_parameters = webHandler.get_web_parameters() print(web_parameters) bgimage = "" core.add_text("Browser Settings") core.add_checkbox("Open in Browser Only##Browser", default_value=web[0], callback=lambda sender, data: save_web()) core.add_same_line() core.add_checkbox("Open in Browser and App##Browser", default_value=web[1], callback=lambda sender, data: save_web()) core.add_spacing(count=2) core.add_text("Text Size (pixel)") core.add_input_int("##BrowserTextSize", default_value=web_parameters[0][0], min_value=5, step=0, callback=save_font) core.add_text("Text Font:") core.add_combo("Font Family##Web", items=WEB_FONT, default_value=web_parameters[0][1], callback=save_font) core.add_spacing(count=2) core.add_text(name="Background Image##Web", default_value="Background Image") core.add_input_text("##BgImage", default_value=web_parameters[0][2], readonly=True) core.add_button("Search Background Image##Web", callback=openFileDialog.get_background_image, callback_data=bgimage) core.add_same_line() core.add_button( "Delete Background Image##Web", callback=lambda sender, data: core.set_value("##BgImage", "")) core.add_separator() core.add_separator() core.add_button("Close##Web", callback=animation_config_web) with simple.group("##Help", show=False): core.add_text("OUTDATED, WILL BE UPDATED IN THE NEXT RELEASE") core.add_input_text( "##HelpIntroText", multiline=True, readonly=True, height=110, width=340, default_value="Welcome to the help page of the Faceit Overlay\n" "here the options and different possibilities are\n" "explained to you.\n" "Here is a small overview;\n" "1: Start menu\n" "2: Color configuration\n" "3: Overlay") core.add_spacing(count=2) core.add_text("1: Start menu") core.add_image("##StartmenuImage", value="resources/start_menu.png") core.add_input_text( "##HelpStartMenuText", multiline=True, height=70, width=340, readonly=True, default_value="The start menu is the configuration menu\n" "Here you can change colors, global size\n" "Enable / disable stats you want to see\n" "and start the Overlay") core.add_spacing(count=2) core.add_text("2: Color configuration") core.add_image("##ColorconfImage", value="resources/color_config.png") core.add_input_text( "##HelpColorConfigText", multiline=True, height=220, width=340, readonly=True, default_value= "Here you can adjust the colors according to your own taste.\n" "The buttons have the following functions:\n\n" "Test Color: Sets the color for the menu so that you can check it.\n" "Reset Color: Sets the colors back to the default value.\n" "Save Color: Saves the colors so that they will be kept\n" "\t\t\t\t\t on the next startup.\n\n" "To adjust the global size of the texts and heads you can move \n" "the slider to the left or right and then use the buttons \n" "to perform the following functions:\n\n" "Reset: Set the size back to 1.0\n" "Save Size: Save the global size for the next start up") core.add_spacing(count=2) core.add_text("3: Overlay") core.add_image("##OverlayImage", value="resources/overlay.png") core.add_input_text( "##HelpOverlayText", multiline=True, height=100, width=340, readonly=True, default_value= "The overlay has basically no functionalities except \n" "that it updates itself regularly (every 60 seconds) \n" "and thus adjusts the values.\n" "But if you click on the headers \n" "FACEIT STATS | LAST GAME you get back to the start screen.\n" ) core.add_button("Close##Help", callback=animation_config_help) """ --------------------------------------------------------------------------------------------------------------- START DPG -------------------------------------------------------------------------------------------------------------""" core.enable_docking(dock_space=False) core.start_dearpygui(primary_window="FACEIT Elo Overlay")
def show_demo(): _create_static_textures() _create_dynamic_textures() with cxt.collapsing_header(label="Textures & Images"): with cxt.tree_node(label="Help"): dpg.add_separator() dpg.add_text("ABOUT TEXTURES:") dpg.add_text("Textures are buffers of RGBA data.", bullet=True, indent=20) dpg.add_text("Textures are used by 'image based' widgets:", bullet=True, indent=20) dpg.add_text("add_image", bullet=True, indent=50) dpg.add_text("add_image_button", bullet=True, indent=50) dpg.add_text("draw_image", bullet=True, indent=50) dpg.add_text("add_image_series", bullet=True, indent=50) dpg.add_text("Textures are themselves widgets.", bullet=True, indent=20) dpg.add_text( "Textures must be a child of a texture container widget.", bullet=True, indent=20) dpg.add_text( "Textures can be either static or dynamic (see following sections).", bullet=True, indent=20) dpg.add_separator() dpg.add_text("PROGRAMMER GUIDE:") dpg.add_text( "'image based' widgets hold a reference to a texture widget.", bullet=True, indent=20) dpg.add_text( "Deleting the texture widget will not affect widget's using it.", bullet=True, indent=50) dpg.add_text( "Textures are only free'd from the GPU when the reference count reaches 0.", bullet=True, indent=50) dpg.add_text( "The texture container widget is a root (has no parent).", bullet=True, indent=20) dpg.add_text("The texture container widget is hidden by default.", bullet=True, indent=20) dpg.add_text( "'Showing' it, opens a manager to inspect the textures within.", bullet=True, indent=50) dpg.add_same_line() dpg.add_button(label="Press Here", small=True, callback=lambda: dpg.configure_item( demo_texture_container, show=True)) dpg.add_separator() with cxt.tree_node(label="Static Textures"): dpg.add_separator() dpg.add_text("ABOUT STATIC TEXTURES:") dpg.add_text("Can NOT be modified after creation.", bullet=True, indent=20) dpg.add_text("Can be loaded from a file using the 'file' keyword.", bullet=True, indent=20) dpg.add_separator() with cxt.group(horizontal=True): with cxt.group(): dpg.add_text("Image Button") dpg.add_image_button(demo_static_texture_1) with cxt.group(): dpg.add_text("Image") dpg.add_image(demo_static_texture_2) with cxt.group(): dpg.add_text("Image (texture size)") dpg.add_image(demo_static_texture_3) with cxt.group(): dpg.add_text("Image (2x texture size)") dpg.add_image(demo_static_texture_3, width=200, height=200) dpg.add_image("INTERNAL_DPG_FONT_ATLAS") with cxt.tree_node(label="Dynamic Textures"): dpg.add_separator() dpg.add_text("ABOUT DYNAMIC TEXTURES:") dpg.add_text("Can be modified after creation with 'set_value'.", bullet=True, indent=20) dpg.add_text( "New data must be the same dimensions as the original", bullet=True, indent=20) dpg.add_separator() with cxt.group(): dpg.add_color_picker(label="Texture 1", default_value=(255, 0, 255, 255), no_side_preview=True, alpha_bar=True, width=200, callback=_update_dynamic_textures, callback_data=1) dpg.add_text("Image Button") dpg.add_image_button(demo_dynamic_texture_1, width=100, height=100) dpg.add_same_line() with cxt.group(): dpg.add_color_picker(label="Texture 2", default_value=(255, 255, 0, 255), no_side_preview=True, alpha_bar=True, width=200, callback=_update_dynamic_textures, callback_data=2) dpg.add_text("Image") dpg.add_image(demo_dynamic_texture_2) with cxt.tree_node(label="Image Series (plots)"): plot_id = dpg.add_plot(label="Image Plot", height=400) dpg.add_image_series("INTERNAL_DPG_FONT_ATLAS", [300, 300], [400, 400], label="font atlas", parent=plot_id) dpg.add_image_series(demo_static_texture_1, [0, 0], [100, 100], label="static 1", parent=plot_id) dpg.add_image_series(demo_static_texture_2, [150, 150], [200, 200], label="static 2", parent=plot_id) dpg.add_image_series(demo_static_texture_3, [200, -150], [300, -50], label="static 3", parent=plot_id) dpg.add_image_series(demo_dynamic_texture_1, [-200, 100], [-100, 200], label="dynamic 1", parent=plot_id) dpg.add_image_series(demo_dynamic_texture_2, [-200, -100], [-150, -50], label="dynamic 2", parent=plot_id) with cxt.tree_node(label="Drawlists"): with cxt.drawlist(width=400, height=300): dpg.draw_rectangle((0, 0), (400, 300), color=(100, 100, 100, 250), thickness=2) dpg.draw_image(demo_static_texture_3, [0, 0], [100, 100]) dpg.draw_image(demo_dynamic_texture_1, [200, 100], [300, 200])
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) set_render_callback(update_canvas) start_dearpygui(primary_window="Main Window")
def main(): empty_board = [['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E']] initial_board = [['Tn','Cn','An','Dn','Rn','An','Cn','Tn'], ['Pn','Pn','Pn','Pn','Pn','Pn','Pn','Pn'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['_E','_E','_E','_E','_E','_E','_E','_E'], ['Pb','Pb','Pb','Pb','Pb','Pb','Pb','Pb'], ['Tb','Cb','Ab','Db','Rb','Ab','Cb','Tb']] def mouse_click_callback(sender,data): nonlocal c_board if data == 0 and c_board.current_selection != -1: m_position = dpg.get_mouse_pos() position = c_board.get_board_position(m_position) if not position: return if c_board.current_selection == 0: c_board.change_box('P', position) # put peon elif c_board.current_selection == 1: c_board.change_box('T', position) # put toker elif c_board.current_selection == 2: c_board.change_box('C', position) # put horse elif c_board.current_selection == 3: c_board.change_box('A', position) # put bishop elif c_board.current_selection == 4: c_board.change_box('D', position) # put queen elif c_board.current_selection == 5: c_board.change_box('R', position) # put king elif c_board.current_selection == 6: c_board.change_box(None,position) # remove elif c_board.current_selection == 7: # draw arrow size = c_board.piece_size c = size//2 position = (position[0]*size+c,position[1]*size+c) if c_board.step == 0: c_board.lines.append([(),(),'']) c_board.lines[-1][0] = position elif c_board.step == 1: c_board.lines[-1][1] = position color = dpg.get_value('drawing_color') r = int(color[0]) g = int(color[1]) b = int(color[2]) color = 'rgb({},{},{})'.format(r,g,b) c_board.lines[-1][2] = color c_board.step = (c_board.step+1)%2 if c_board.step == 1: return elif c_board.current_selection == 8: # delete arrow size = c_board.piece_size c = size//2 position = (position[0]*size+c,position[1]*size+c) for i in range(len(c_board.lines)): line = c_board.lines[i] if position == line[0] or position == line[1]: c_board.lines.remove(line) break elif c_board.current_selection == 9: # color box color = dpg.get_value('drawing_color') r = int(color[0]) g = int(color[1]) b = int(color[2]) color = 'rgb({},{},{})'.format(r,g,b) col = position[0] row = position[1] c_board.colored_boxes[row][col] = color elif c_board.current_selection == 10: # discolor box col = position[0] row = position[1] c_board.colored_boxes[row][col] = None c_board.draw_board() if data == 1: if c_board.piece_color == 'b': c_board.piece_color = 'n' dpg.set_value('color_piece', "Negro") else: c_board.piece_color = 'b' dpg.set_value('color_piece', "Blanco") def key_press_callback(sender, data): nonlocal c_board if data == dpg.mvKey_Right: if c_board.reading_pgn: pars.current_match.next_position() c_board.draw_board() else: return if data == dpg.mvKey_Left: if c_board.reading_pgn: pars.current_match.previews_position() c_board.draw_board() else: return if data == dpg.mvKey_Escape : c_board.current_selection = -1 c_board.reading_pgn = False dpg.set_value("accion", "Sin seleccionar") dpg.set_value("pieza", "Sin seleccionar") return def load_callback(sender, data): def file_callback(sender, data): nonlocal c_board file = open(data[1],'rb') load_board = pickle.load(file) file.close() c_board = load_board c_board.draw_board() dpg.open_file_dialog(callback=file_callback, extensions=".sv") def save_callback(sender, data): nonlocal c_board c_board.save_board() def save_image_callback(sender,data): nonlocal c_board c_board.save_board_image() def clean_callback(sender, data): nonlocal c_board nonlocal empty_board c_board.reading_pgn = False c_board.board = copy.deepcopy(empty_board) c_board.lines = [] c_board.colored_boxes = [[None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None]] c_board.draw_board() def default_board_callback(sender, data): nonlocal c_board nonlocal initial_board c_board.reading_pgn = False c_board.board = copy.deepcopy(initial_board) c_board.lines = [] c_board.colored_boxes = [[None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None], [None,None,None,None,None,None,None,None]] c_board.draw_board() def close(sender,data): try: os.remove("tmp.png") except Exception as e: pass def pgn_reader(sender,data): def load_match(sender,data): nonlocal pars nonlocal c_board coords = dpg.get_table_selections(sender) dpg.delete_item('Partidas') dpg.delete_item('Lista de Partidas') i = coords[0][0] match = pars.matches[i] pars.current_match = match c_board.board = match.board c_board.reading_pgn = True dpg.set_value('accion','Leyendo partida PGN') dpg.set_value('pieza','Sin seleccionar') c_board.draw_board() def close_callback(sender,data): dpg.delete_item('Partidas') dpg.delete_item('Lista de Partidas') def file_callback(sender, data): nonlocal c_board nonlocal pars pars = Parser() pars.get_plays(data[0]+'/'+data[1]) # Lista de partidas cargadas--------------------------------TODO dpg.add_window('Lista de Partidas',on_close=close_callback) colums = set() for match in pars.matches: for att in match.attr: colums.add(att) colums = list(colums) # colums.sort() dpg.add_table("Partidas", colums, callback=load_match) rows = list() for match in pars.matches: row = list() for colum in colums: row.append(match.attr[colum]) rows.append(row) for row in rows: dpg.add_row("Partidas", row) dpg.end() dpg.open_file_dialog(callback=file_callback, extensions=".pgn") def control_button(sender,data): nonlocal c_board; c_board.reading_pgn = False add_arr = c_board.current_selection == 7 if add_arr and c_board.step == 1: c_board.lines.pop() c_board.step = 0 if sender == 'Peon': c_board.current_selection = 0 dpg.set_value("accion", "Añadiendo Pieza") dpg.set_value("pieza", "Peon") elif sender == 'Torre': c_board.current_selection = 1 dpg.set_value("accion", "Añadiendo Pieza") dpg.set_value("pieza", "Torre") elif sender == 'Caballo': c_board.current_selection = 2 dpg.set_value("accion", "Añadiendo Pieza") dpg.set_value("pieza", "Caballo") elif sender == 'Alfil': c_board.current_selection = 3 dpg.set_value("accion", "Añadiendo Pieza") dpg.set_value("pieza", "Alfil") elif sender == 'Reina': c_board.current_selection = 4 dpg.set_value("accion", "Añadiendo Pieza") dpg.set_value("pieza", "Reina") elif sender == 'Rey': c_board.current_selection = 5 dpg.set_value("accion", "Añadiendo Pieza") dpg.set_value("pieza", "Rey") elif sender == 'Eliminar Pieza': c_board.current_selection = 6 dpg.set_value("accion", "Eliminando Pieza") dpg.set_value("pieza", "Sin seleccionar") elif sender == 'Añadir flecha': c_board.current_selection = 7 dpg.set_value("accion", "Añadiendo flecha") dpg.set_value("pieza", "Sin seleccionar") elif sender == 'Eliminar flecha': c_board.current_selection = 8 dpg.set_value("accion", "Eliminando flecha") dpg.set_value("pieza", "Sin seleccionar") elif sender == 'Colorear casilla': c_board.current_selection = 9 dpg.set_value("accion", "Coloreando casilla") dpg.set_value("pieza", "Sin seleccionar") elif sender == 'Descolorear casilla': c_board.current_selection = 10 dpg.set_value("accion", "Descolorando casilla") dpg.set_value("pieza", "Sin seleccionar") c_board = Board(board = copy.deepcopy(empty_board)) pars = Parser() main_width = c_board.size+220 main_height= c_board.size+240 with dpgs.window('Diagramador'): dpg.set_main_window_size(main_width, main_height) dpg.set_main_window_resizable(False) dpg.set_exit_callback(close) with menu_bar('Menu bar'): with menu('Archivo'): dpg.add_menu_item("Guardar", callback=save_callback) dpg.add_menu_item("Guardar Imagen", callback=save_image_callback) dpg.add_menu_item("Cargar tablero", callback=load_callback) with menu('Herramientas'): dpg.add_menu_item("Leer archivo PGN", callback=pgn_reader) with menu('Color'): dpg.add_color_edit3('Seleccion de Color',source='drawing_color') dpg.add_drawing("canvas", width=c_board.size,height=c_board.size) dpg.add_image('board_img','',source=c_board.piece_p('Abb')) dpg.add_same_line() controles =( "\nControles\n" "Click Derecho : Cambiar color de pieza\n\n" "Flecha derecha: Mostrar siguiente jugada PGN\n\n" "Flecha izquierda: Mostrar la jugada PGN previa\n\n" ) dpg.add_child('controls',autosize_x=True,height=c_board.size) dpg.add_button('Peon',callback=control_button) dpg.add_button('Torre',callback=control_button) dpg.add_button('Caballo',callback=control_button) dpg.add_button('Alfil',callback=control_button) dpg.add_button('Reina',callback=control_button) dpg.add_button('Rey',callback=control_button) dpg.add_button('Eliminar Pieza',callback=control_button) dpg.add_button('Añadir flecha',callback=control_button) dpg.add_button('Eliminar flecha',callback=control_button) dpg.add_button('Colorear casilla',callback=control_button) dpg.add_button('Descolorear casilla',callback=control_button) dpg.add_text(controles) dpg.end() dpg.set_value('drawing_color',[0,0,0]) name = "Nombre de Archivo" dpg.add_input_text(name, width=250, source='save_name') name = "Nombre de Imagen" dpg.add_input_text(name, width=250, source='save_img_name') dpg.add_button("Limpiar tablero", callback=clean_callback) name = "Tablero por defecto" dpg.add_button(name, callback=default_board_callback) name = "Acción" dpg.add_label_text(name, default_value='Sin seleccionar', source="accion") dpg.add_label_text("Pieza", default_value='Sin seleccionar', source="pieza") dpg.add_label_text("Color de pieza", default_value='Blanco', source='color_piece') c_board.draw_board() dpg.set_key_press_callback(key_press_callback) dpg.set_mouse_click_callback(mouse_click_callback) dpg.start_dearpygui(primary_window = 'Diagramador')
def show_main(): logging.info("start show_main") global start_threading heigh, iCountMatch, iCountFaceit = config_functions.check_for_layout() name = config_functions.get_faceit_name_from_db() with simple.window(f"{name} Elo", height=heigh, width=190, no_title_bar=True, no_resize=True, on_close=lambda: delete_item("FACEIT Elo Overlay"), x_pos=200): logging.info("Build the window") simple.set_window_pos(f"{name} Elo", 0, 0) core.set_main_window_title(f"{name} Elo") core.set_main_window_size(width=250, height=heigh) # Now the magic happens ! core.set_style_frame_rounding(6.00) with simple.group("##Loading"): core.add_spacing(count=20) core.add_text("##LoadingText", default_value="Getting data from Faceit servers") """ Get Data from the API """ winLoss = config_functions.get_win_loss() if winLoss[0][0] == "1": mode = 0 else: mode = 1 logging.info("Get data from the API") iElo, acEloToday, iRank, \ acResult, acScore, acKd, \ acMap, iStreak, iMatches, \ iMatchesWon, acEloDiff, iKills, \ iDeath, iWin, iLoss = faceit_api.get_faceit_data_from_api(mode) """ Build the Faceit Header and Data """ if iCountFaceit > 0: logging.info("Build the window for Faceit stats") add_faceit(iElo, iRank, acEloToday, iStreak, iMatches, iMatchesWon, iWin, iLoss) """ Build the Last Game Header and Data """ if iCountMatch > 0: logging.info("Build the window for Match stats") add_last_game(acMap, acResult, acScore, acKd, acEloDiff, iKills, iDeath) """ ! Add some promotion ! """ core.add_spacing(count=1) core.add_text("powered by Dear PyGui") core.add_same_line() core.add_image("image##DPG", "resources/6727dpg.ico") simple.hide_item("##Loading") core.enable_docking(dock_space=False) hwnd = win32gui.GetForegroundWindow() win32gui.SetWindowText(hwnd, f"{name} Elo") start_threading = 1 long_process()
def add_faceit(iElo, iRank, acEloToday, iStreak, iMatches, iMatchesWon, iWin, iLoss): """ Check all Checkboxes and add the active to the Overlay """ nI = -1 skipacEloGoal = 0 list_faceit = sqlite3db.TExecSqlReadMany( DBNAME, """ SELECT * FROM CFG_STATS_FACEIT """) acEloGoal = config_functions.get_elo_goal_from_db() winLoss = config_functions.get_win_loss() logging.info("Building Faceit stats") core.add_button("\t\tFACEIT STATS\t\t", callback=switch_back_to_menu) core.add_same_line(name="##reload_same_line", show=False) core.add_image("##reload_image", value="resources/ref.png", width=16, height=16, show=False) for i in list_faceit[0]: nI = nI + 1 if i == str(1) and nI == 0: logging.info("Add Current Elo") core.add_text("\tCurrent Elo") core.add_same_line(xoffset=130) core.add_text("elo##", default_value=f"{iElo}") if acEloGoal and skipacEloGoal == 0: core.add_text("\tElo Goal") core.add_same_line(xoffset=130) core.add_text("eloGoal##", default_value=f"{acEloGoal}") skipacEloGoal = 1 if i == str(1) and nI == 1: logging.info("Add Rank") core.add_text("\tRank") core.add_same_line(xoffset=130) core.add_text("rank##", default_value=f"{iRank}") if i == str(1) and nI == 2: logging.info("Add Elo Today") core.add_text("\tElo Today") core.add_same_line(xoffset=130) core.add_text("elotoday##", default_value=f"{acEloToday}") if i == str(1) and nI == 3: logging.info("Add Win Streak") core.add_text("\tWin Streak") core.add_same_line(xoffset=130) core.add_text("streak##", default_value=f"{iStreak}") if i == str(1) and nI == 4: logging.info("Add Tot. Matches") core.add_text("\tTot. Matches") core.add_same_line(xoffset=130) core.add_text("matches##", default_value=f"{iMatches}") if i == str(1) and nI == 5: logging.info("Add Matches Won") core.add_text("\tMatches Won") core.add_same_line(xoffset=130) core.add_text("matcheswon##", default_value=f"{iMatchesWon}") if int(winLoss[0][0]) == 1: core.add_text("\tWin/Loss per Day") core.add_same_line(xoffset=130) core.add_text("Win/LossperDay##", default_value=f"{iWin} / {iLoss}") if int(winLoss[0][1]) == 1: core.add_text("\tWin/Loss per Week") core.add_same_line(xoffset=130) core.add_text("Win/LossperWeek##", default_value=f"{iWin} / {iLoss}")