mcodingllc / videossamplecode Goto Github PK
View Code? Open in Web Editor NEWCode from the mCoding sample videos
License: MIT License
Code from the mCoding sample videos
License: MIT License
Hi James,
pip install imgui[full]
After activating my virtualenv and runnIng demo.py
(which I downloaded from your git hub repo), I got the following error:
ImportError: ('Unable to load OpenGL library', 'dlopen(OpenGL, 10): image not found', 'OpenGL', None)
Which I was able to fix by following the directions here
basically, by modifying ctypesloader.py
file in my virtualenv's lib/python3.6/site-packages/OpenGl/platform
directory
and changing this:
fullName = util.find_library( name )
to this:
fullName = '/System/Library/Frameworks/OpenGL.framework/OpenGL'
Then at least I was able to get demo.py
to launch and the main window came up.
Though I did notice that the first window Hello, Imgui! opened right on top of the Active Examples window, and slightly too small... all the other windows also open right on top of the other windows that were already displayed. Not sure if that's an issue but, from the video it didn't look demo.py
behaved that way when you ran it. Though I did notice that a imgue.ini
file did appear that seems to manage the window sizes and locations...
That minor issue aside, when I try the menu bar example window, it shows fine, but when I click the close menu item on that window's file menu, the program crashes & I get the following error.
(imgui_37) Gregs-5k-iMac-Octo-Core-2:imgui gskluzacek$ python demo.py
exception caught, but too late!
Traceback (most recent call last):
File "demo.py", line 296, in <module>
main()
File "demo.py", line 289, in main
render_frame(impl, window, jb)
File "demo.py", line 249, in render_frame
imgui.render()
File "imgui/core.pyx", line 1891, in imgui.core.render
imgui.core.ImGuiError: ImGui assertion error (g.CurrentWindowStack.Size == 1) at imgui-cpp/imgui.cpp:3476
The one other issue I'm seeing is that when I try to open the last four example windows: tab bar, list box, popup context void and table, the program crashes with errors similar to the following:
(imgui_37) Gregs-5k-iMac-Octo-Core-2:imgui gskluzacek$ python demo.py
Traceback (most recent call last):
File "demo.py", line 296, in <module>
main()
File "demo.py", line 289, in main
render_frame(impl, window, jb)
File "demo.py", line 245, in render_frame
frame_commands()
File "demo.py", line 180, in frame_commands
if imgui.begin_tab_bar("MyTabBar"):
AttributeError: module 'imgui' has no attribute 'begin_tab_bar'
The attribute name mentioned in the error messages and the line number specified varies. For example: for the list box example, the attribute named in the error is begin_list_box
and the line number is 197
instead of 189
as shown above.
Additionally, the simple Basic GUI drawing loop code given on the pyimgui read the docs site does not bring up the window as shown there. The program just runs and exists without any thing being displayed and no error messages.
I'm rather suspect at this point, since the original error that occurred with openGL.
Do you think its my installation, OS, ??? Do you have any suggestions that you think I should try?
Here is the code from the pyimgui read the docs site:
import imgui
# initilize imgui context (see documentation)
imgui.create_context()
imgui.get_io().display_size = 100, 100
imgui.get_io().fonts.get_tex_data_as_rgba32()
# start new frame context
imgui.new_frame()
# open new window context
imgui.begin("Your first window!", True)
# draw text label inside of current window
imgui.text("Hello world!")
# close current window context
imgui.end()
# pass all drawing comands to the rendering pipeline
# and close frame context
imgui.render()
imgui.end_frame()
Here's a screen shot of the example windows that I am able to open
By the way, I really love the content that you put out on your Youtube channel. I think what you contribute to the community is just fantastic. Keep up the good work.
Regards,
Greg Skluzacek
When I try to call an overloaded class/static method, I get an error (TypeError: 'Overload' object is not callable
). I guess it's normal behavior, but why would class/static methods not work with overloading?
Script run: overload.py
Python version: 3.10.2
Based on the video, the fix should have been to empty the init.py files in both the sub packages.
Shouldn't the type hint for step_limit
there be Optional[int]
instead of just int
?
I tested the demo.py (renamed to imguitest.py) and it works, but if I try the tab bar the program crashes with the following Messages:
PS C:\Microsoft VS Code\Projekte> & "C:/Microsoft VS Code/Python/python.exe" "c:/Microsoft VS Code/Projekte/imguitest.py"
Traceback (most recent call last):
File "c:/Microsoft VS Code/Projekte/imguitest.py", line 296, in
main()
File "c:/Microsoft VS Code/Projekte/imguitest.py", line 289, in main
render_frame(impl, window, jb)
File "c:/Microsoft VS Code/Projekte/imguitest.py", line 245, in render_frame
frame_commands()
File "c:/Microsoft VS Code/Projekte/imguitest.py", line 180, in frame_commands
if imgui.begin_tab_bar("MyTabBar"):
AttributeError: module 'imgui' has no attribute 'begin_tab_bar'
Can anyone help?
The code you have provided has an error. The variable "shape" has been used even before declaring it. Replacing it from the current position to the line above "# Understand with for-loops" will rectify the error. Here's the corrected code.
# Answer
y = np.array([2, 3, 4]).reshape(1, 3, 1, 1)
# or
# y = np.array([2, 3, 4]).reshape(3, 1, 1)
shape = (1000, 3, 32, 32)
# Understand with for-loops
x = np.ones(shape, dtype=np.uint8) # for example
out = np.empty(shape, dtype=np.uint8)
N, C, W, H = shape
for n in range(N):
for channel in range(C):
for w in range(W):
for h in range(H):
out[n, channel, w, h] = x[n, channel, w, h] * y[0, channel, 0, 0]
Thank you.
The example of video 89 doesn't work anymore with flake8 versions 5.0.0-5.0.2. I confirmed I can get desired behavior with version 4.0.1
. The requirements.txt
in video 89 lists flake8>=4.0
, but to be correct that should be changed to flake8>=4.0<5
To reproduce the breaking change just install flake8 (which will install version 5+):
$ cd videos/089_custom_linting_with_ast
$ flake8 .
There was a critical error during execution of Flake8:
plugin code for `local[MCOD1]` does not match ^[A-Z]{1,3}[0-9]{0,3}$
Expected was no critical error.
Nowhere does local[MCOD1]
occur, so my bet's on a bug in flake8.
Some extra information on my actual setup on which I encountered the bug:
$ flake8 --version
5.0.0 (mccabe: 0.7.0, pycodestyle: 2.9.0, pyflakes: 2.5.0) CPython 3.10.4 on Windows
In video 080 - Python slots, slots, and object layout a function getsize was used.
It uses an answer from StackOverflow question How do I determine the size of an object in Python?, but as far as I can see, no credit is given. (Note: Questions at SO are licensed as CC BY-SA 4.0.)
i forked your "77 metaclasses in Python/overloading.py" to use in a project and found that even though it works normally on my local machine but it crashes in a googlecolab when used
This is not the correct way to configure the root logger. This configures the logger named "root", which is a child of the actual root logger. The effect is that logger = logging.getLogger("my_logger")
does not use the configuration from the JSON (since "my_logger"
is not a child of "root"
, but of the actual root logger, which has not been configured).
The root logger uses a separate root
key (source), so the correct JSON would be
"loggers": {},
"root": {
"level": "DEBUG",
"handlers": [
"stderr",
"file"
]
}
(the empty "loggers"
key can probably be skipped).
I am using the following function as a decorator:
def profile_func(func):
def decorator_func(*args, **kwargs):
with cProfile.Profile() as pr:
val = func(*args, **kwargs)
stats = pstats.Stats(pr)
stats.sort_stats(pstats.SortKey.TIME)
stats.dump_stats(filename=os.path.join(memex_utils.config.session, 'profiling.prof'))
return val
return decorator_func
But I get the following error:
with cProfile.Profile() as pr:
AttributeError: __enter__
I am using Python 3.7
63
line in README.md
table should have this name: Diagnose slow Python code. (Feat. async/await)
Not Find why your Python code is slow using this essential tool. (Feat. async/await)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.