Skip to content

Commit

Permalink
feat: added get_platform(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffstadt committed Apr 26, 2022
1 parent 2a21114 commit 03a804e
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 1 deletion.
7 changes: 7 additions & 0 deletions DearPyGui/dearpygui/_dearpygui.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions DearPyGui/dearpygui/_dearpygui_RTD.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions DearPyGui/dearpygui/dearpygui.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions DearPyGui/dearpygui/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2804,3 +2804,10 @@ def _callback_manual_mutex(sender, app_data, user_data):
dpg.configure_item(b1, user_data=dpg.last_item(), callback=_callback_auto_mutex)
dpg.configure_item(b2, user_data=dpg.last_item(), callback=_callback_manual_mutex)
dpg.configure_item(b3, user_data=dpg.last_item())
if dpg.get_platform() == dpg.mvPlatform_Windows or dpg.get_platform() == dpg.mvPlatform_Linux:
with dpg.tree_node(label="Output Framebuffer"):
def _framebuffer_callback(sender, app_data):
dpg.show_item("__demo_texture_container")
dpg.add_dynamic_texture(app_data.get_width(), app_data.get_height(), app_data, parent="__demo_texture_container")
dpg.add_text("Outputs frame buffer an mvBuffer object, creates a dynamic texture, and shows the texture registry (check final item)")
dpg.add_button(label="Output Framebuffer", callback=lambda:dpg.output_frame_buffer(callback=_framebuffer_callback))
5 changes: 5 additions & 0 deletions DearPyGui/src/modules/dearpygui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ GetModuleConstants()
ModuleConstants.push_back({"mvComboHeight_Large", 2L });
ModuleConstants.push_back({"mvComboHeight_Largest", 3L });

ModuleConstants.push_back({"mvPlatform_Windows", 0L });
ModuleConstants.push_back({"mvPlatform_Apple", 1L });
ModuleConstants.push_back({"mvPlatform_Linux", 2L });

ModuleConstants.push_back({"mvColorEdit_AlphaPreviewNone", 0L });
ModuleConstants.push_back({"mvColorEdit_AlphaPreview", ImGuiColorEditFlags_AlphaPreview });
ModuleConstants.push_back({"mvColorEdit_AlphaPreviewHalf", ImGuiColorEditFlags_AlphaPreviewHalf });
Expand Down Expand Up @@ -685,6 +689,7 @@ PyInit__dearpygui(void)
MV_ADD_COMMAND(bind_item_font);
MV_ADD_COMMAND(bind_item_theme);
MV_ADD_COMMAND(capture_next_item);
MV_ADD_COMMAND(get_platform);

methods.push_back({ NULL, NULL, 0, NULL });

Expand Down
15 changes: 15 additions & 0 deletions DearPyGui/src/modules/dearpygui_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -4072,4 +4072,19 @@ get_clipboard_text(PyObject* self, PyObject* args, PyObject* kwargs)
const char* text = ImGui::GetClipboardText();

return ToPyString(text);
}

mv_internal mv_python_function
get_platform(PyObject* self, PyObject* args, PyObject* kwargs)
{

if (!GContext->manualMutexControl) std::lock_guard<std::mutex> lk(GContext->mutex);

#ifdef _WIN32
return ToPyInt(0L);
#elif __APPLE__
return ToPyInt(1L);
#else
return ToPyInt(2L);
#endif
}
12 changes: 12 additions & 0 deletions DearPyGui/src/modules/dearpygui_parsers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1897,4 +1897,16 @@ InsertParser_Block4(std::map<std::string, mvPythonParser>& parsers)
mvPythonParser parser = FinalizeParser(setup, args);
parsers.insert({ "get_clipboard_text", parser });
}

{
std::vector<mvPythonDataElement> args;

mvPythonParserSetup setup;
setup.about = "New in 1.6. Returns platform constant.";
setup.category = { "General" };
setup.returnType = mvPyDataType::Integer;

mvPythonParser parser = FinalizeParser(setup, args);
parsers.insert({ "get_platform", parser });
}
}
7 changes: 6 additions & 1 deletion docs/source/documentation/plots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,12 @@ Custom Series

**New in 1.6**. Custom series allow you to control the way a series is rendered.

Under construction. Minimal example below. Channels must be between 2 and 5.
A custom series can currently have between 2 and 5 channels. A channel is an array/list of
data. Each channel must be the same length. The first 2 channels and channel count are
required arguments. Additional channels can be provided with the y1, y2, and y3 keywords. You must
also set the "callback" keyword. The second argument will be provided by DPG as a list. The first item being
useful information. The following items are the original data sent in but transformed into pixel space. The
combination of all this information can be used to create a custom series. See simple example below:

.. code-block:: python
Expand Down

0 comments on commit 03a804e

Please sign in to comment.