As my code is quite long and with a lot of nested layouts I won't put it in here but I essentially have a QHBoxLayout which I want to have a different background colour as the others. I First thought about changing the stylesheet but I quickly learned that the layout is not affected by that as it apparently is not a visual element. Hence my Question: How do I create simple (geometric) elements? Is it even possible to just have a colored box in the background and some lables and pictures in the foreground?
I tried just using a big QTextEdit block and colouring this with the StyleSheet but this didn't get me the results I hoped for as It'd be hard to align the text the way I want it to be and add pictures.
Related
I want to make a program that will perform different functions depending on which part of an image I click on. I'd be ok with cutting up the image into different parts and placing them together, but they are in the shape of a circle, so I'm not sure how well I'd even be able to cut it since i'm just using Paint, nor how accurately I could place those images back together.
I'll include the image I'm using below.
Is there a way to make a single image have multiple buttons associated with it using python? I've mostly been looking at tkinter and could not figure out a way to do it.
If not, is there a good method I can use to put the image back together after cutting it up and making each image a button?
I think I could do this using Reactjs, but I'd rather do it all in python in possible because of other parts of the program.
I can make one image a button, or a bunch of different images into a bunch of buttons, but I haven't yet figured out how to make one image a lot of buttons, or place all of those buttons properly togther without their blank spaces overlapping, so I'd rather it all be one whole image if possible.
I am writing a kicad plugin, and I need to create a GUI for this plugin. Because kicad uses wxpython, that is what I am using.
I have already figured out that placing my ui items using the layout sizers just isn't gonna give me the control I need to create the window I want. I know I can set the position of elements, and have been using that to create the ui I need.
The problem however, is that my window gets bigger than what would be reasonable (in some situations). Therefore I want to make it scrollable.
I have been playing around with wxformbuilder, and I found the wxScrolledWindow. That got me this far:
This is roughly what I want, except, when you want to place stuff within the scrolledWindow, you have to place one of the "sizers" in it (as far as I can tell at least), in which you place your buttons. The problem with that is, that, to my knowledge, setting the position of buttons in any of the sizers just has no effect at all.
So, my question is: how do I achieve this effect? and, is this even possible?
edit:
As an example of what I am trying to put within the scrolledwindow, this is a rough version of the ui I want to create (and want to be scrollable). (I want to eventually have, probably an icon button above each of the checkbox columns to indicate what they are for).
The final result would need to look something like this (the white squares being small images / buttons, also, in reality being not on the window bar,but in its own not scrolling section):
An example of something I wasn't able to achieve using sizers is, getting those checkboxes so close together, without making them appear off center. Different widgets seem to have different sizes, and checkboxes without border are especially small, so they end up appearing off center, example:
Also, those images above each column of checkboxes, which don't scroll, need to line up with the X coordinates of those scrolling checkboxes, which also seems very non trivial. Though also really hard to get right if I could give everything exact coords, so I might need to give up on that specific idea of making those not scrollable.
I am trying to create a GUI as pictured below. So far, I am using 3 frames (topbar, sidebar, and body) as the basics for splitting the GUI up. In the future, I plan to have navigation buttons on the sidebar, and body to give you a better idea of what I am trying to do.
However, I am struggling to figure out how to make the actual frames fill out the whole window when it resized. While I am new to Qt designer, I am aware of the layout feature and I have attempted to utilize it. For example the blue frame with the vertical layout, but this seems to only work on other widgets and not frames. Going back to my example, if I add the vertical layout to the blue part, it will stretch the line edit to fill the entire blue region (I want the line edit to be the size it is now) but it won't cause the blue region to fill the rest of the frame.
Is there a better widget to use for separating the GUI and adding background colors other than the frame container that I am using? Most of the examples I have seen, keep the layouts very basic, and I have not seen one where someone tries to break it up like this.
My work so far
Wire frame that shows what I am trying to do
I have a python program where I have several matplotlib canvases embedded into a wxpython application. One of the canvases has many crosses in it. When the user right-click in this canvas the closest cross should be removed together with everything belonging to this cross (they are linked through an unique id-tag, and there might be things in every canvas that should be removed). I want the removing (or actually the replotting) to be as fast as possible. The program is quite large so I use several threads etc.
The easiest thing to implement this is to use wx.CallAfter(canvas.draw) for each canvas. However, there is a delay between the rightclick and the refresh of every canvas so I believe that canvas.draw() is too slow.
I saw two other functions for fast redrawing: the matplotlib functions blit() and draw_artist(). As far as I understand, blit() refreshes changed pixels inside some area (I used the axes bbox). I managed to get it to work with blit() in the sense that the program ran without crashing...but not updating what you see on the screen.
Did not manage to get draw_artist() to work when removing a pixel (tried using first line.remove(), then draw_artist(line) but the line was ofcourse already dead so draw_artist did not work).
Note: I called blit() and draw_artist() with wx.CallAfter()!
The feeling I have is that blit() is the best solution, but I did not manage to get it to update to the "screen-level". So my question is: what is the fastest and most resource-saving way of removing artists from matplotlib.canvases (embedded into wxPython) without redrawing more than you need to, but still let the change propagate to the screen?
Which is the most efficient method to display a grid of about 1000 clickable images in wxPython ?
Currently i am using a GridSizer filled with StaticBitmap objects. But its quite slow for 500+ images.
One more thing is that, i have a listbox of categories on the left. That is to filter the images. Categories will be like "All", "Cat 1", "Cat 2" etc. When i click "All", all the image have to be displayed.
How i am doing this currently :
A VERTICAL BoxSizer will contain n
GridSizer objects, one for each
category. I add the StaticBitmap
objects to multiple GridSizers
depending on the categories it
belongs to.
Then i display only that GridSizer
depending on which category is
selected
This method is also terribly slow for anything over 300 images. So, how do i achieve the same effect efficiently ?
.
I'm assuming that not all 1000 images are onscreen at the same time, correct? If so, you should be able to just load up the number you need and when the user scrolls, load up the next set as needed. I think the people on the wxPython list usually used DCs to blit their images onscreen or they use the FloatCanvas widget. I would recommend asking over on their list where there are a number of experts on drawing images onscreen: https://groups.google.com/forum/#!forum/wxpython-users
I would think a ListCtrl in ICON style would be the best way to do this.
If you look at the wxPython Demos, the UltimateListCtrl sample in the wx.LC_ICON style is a good example of what you could create.