Comments (4)
Simple File Picker
Gif Preview (with Material Design Icons and rounding):
Windows support with drive selection:
Functionality
- Single click = highlight item
- Double click = open folder / choose file
- Also directory picker
- Editable location bar
- Auto refresh
- Manual refresh and parent folder button
- Linux and windows support with drive letter selection for windows
Usage
- You create an instance of the
FilePicker
class when you need to open the file picker - You keep reusing that same instance over multiple frames (this is for persistence of selected items and to preserve on system resources)
- Each frame you must call
FilePicker.tick()
to render the file picker and process events - You can check
FilePicker.active
to know if it is still open or not (bool) FilePicker.selected
tells you what file was chosen (absolute path string), if the user clicked cancel or the filepicker is still open it will beNone
You can find a code snippet in the gist I linked below.
Options
- You can instead launch a directory picker with the
DirPicker()
class or by passing thedir_picker=True
argument toFilePicker()
- Icons can be customized at the top of the file
- You can (and should) provide a custom
title
when creating each filepicker, this acts like any other imgui label / id - You can provide a custom starting dir to each filepicker with
start_dir
(can be both str and pathlib.Path, both relative and absolute); otherwise the default is the current working directory - You can provide a callback function to run when the filepicker is closed; it will run even when the user clicked cancel; it gets passed the value of
FilePicker.selected
, so an absolute path string or None if the filepicker was canceled - You can provide custom popup flags with
custom_popup_flags
if you want
Source
You can find the code for this widget along with a usage example in this gist.
Btw thanks for this widget showcase thread, hope gists are fine too :D
Changelog:
- 22-05-2022: implemented directory picker support
- 19-11-2022: added filtering / searching, icons can be changed at top of file, cleaner code
- 04-01-2023: fixed crash with permission errors on windows drive letters
from pyimgui.
Image Helper
Functionality
- Load images easily
- Lazy loading (initialize whenever, load when first shown)
- Animated images support (including GIFs)
- Rendering optimizations (doesn't render if not visible)
- Glob support (specify a path and a glob pattern to search in the path; the first result is used)
- Effortless rounded corners support
Attributes and methods:
.width
and.height
: size values in pixels, set to 1 until the image is loaded (and loading is lazy so don't cache these values!).missing
: whether the file doesn't exist, or the glob pattern didn't match anything.texture_id
: the opengl texture id to use withimgui.image()
. this is actually a property, it wraps._texture_id
handling all the loading, texture and animation stuff, so don't use._texture_id
directly!.reload()
: reset current texture to blank and load the image again from disk. useful if the file changed or if you're using a glob pattern.render(...)
: wrapper aroundimgui.image()
but with a good reason - it also handles rounded corners and off screen optimizations.crop_to_ratio(ratio)
:imgui.image()
and similars take auv0
anduv1
to crop the image and only show parts of it. this helper method crops to a certain ratio keeping the image centered and returnsuv0
anduv1
. look at the examples in the gist below for more info
Usage
- You create an instance of the
ImageHelper
class when and however you want, this does not consume many resources because the actual image loading is done lazily - You can show the image with
image.render(width, height)
- This takes more parameters, in particular
rounding=123
for rounded corners - All other arguments are passed to
imgui.image()
or the rounded equivalent - If you specify a rounding value but don't pass a
flags
value, flags defaults to rounding all corners
I highly suggest you check out some examples at the bottom of the gist below. Make sure to read the comments throughout the class, they are useful!
Source
You can find the code for this widget along with some usage examples in this gist.
Changelog:
- 19-11-2022: fixed huge memory leaks (pixel buffers duplicated in dram and vram) and big performance improvements
from pyimgui.
Simple Rating Widget
Functionality
- Familiar star rating design
- Custom star count
- Click on current value to reset to 0
Usage
- Very similar to any other standard imgui widget:
- Every frame call
ratingwidget(...)
- First argument is a label / id; it is not visible but it is used to identify the buttons, just like most other imgui widgets
- Second argument is the current value
- Third argument is the amount of stars that the widget has, it defaults to 5
- You can add additional arguments, they will be passed to the underlying
imgui.small_button()
call
Note: you will need material design icons or another icon font configured!
Source
You can find the code for this widget along with a few usage examples in this gist.
Changelog:
- 24-05-2022: fixed for frame border users
- 19-11-2022: moved icons to top of file for easy customization
from pyimgui.
Smooth scrolling and scroll multiplier
Example:
ezgif.com-gif-maker.mp4
Functionality
- Enabled globally
- Scroll multiplier
- Smooth scrolling
- Customizable smooth scrolling speed
- Framerate independent
Usage
- Scroll modifiers need to be applied before
new_frame()
- Just read the code below for the usage, it is quite straightforward!
Source
You can find the code for these modifiers in this gist.
from pyimgui.
Related Issues (20)
- -- deleted --
- Doesn't expose ImGuiStyle::ScaleAllSizes HOT 1
- Showing input text without a label HOT 1
- Documentation left side nav not scrollable
- Can't use it and i don't know why.
- "Game Insert"
- type stubs for pyimgui HOT 4
- None of the custom renderers change mouse cursor HOT 4
- default theme font HOT 4
- Loading SVGs as viewport/texture HOT 2
- [Bug}: When using pyimgui some users of my program have `GLError`s HOT 8
- Imgui port to pygame do not suport colaboration with programable opengl pipline
- Windows: Failed building wheel for imgui (from VsDevShell) HOT 5
- Example not working HOT 1
- pyimgui equivalent of ImGuiKey_NamedKey_END HOT 1
- Overflow error when using opengl, doublebuf and fullscreen HOT 1
- ImGui crashing when using OpenGL context 3.2+ even though GPU and driver support 4.6
- Upgrading dear imgui version beyond 1.82 HOT 6
- Anyone studied if F3D is able to render on pyimgui HOT 4
- I have a problem when i trying to use imgui[glfw] io.fonts.get_glyph_ranges_chinese_full() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyimgui.