This is an extension of the question asked here. I was not allowed to comment there.
#ImportanceOfBeingErnest provided an excellent answer to distinguish matplotlib button_press_events from zoom and pan clicks by connecting the motion_notify_event. In my experience, this works very well when using a trackpad. However, in practice, when I run my tkinter app with a sensitive mouse, it is difficult to click without also incorporating a subtle motion prior to releasing the button.
Any suggestions? I was considering setting a flag based on the time between the button_press_event and the button_release_event.
Related
I am currently building a simple app to encrypt files using AES encryption in python but the biggest downside of using Tkinter is the look of the UI. I did some research and found examples of what I want but do not know how to recreate it. (Example)
My problem is that when I replace buttons with images (like the OP of the Reddit post said he did in order to have a decent looking UI) I end up with an ugly bar of grey. (Image of the button)
I also want to remove the same type of bar with frames so if you have the answer for specifically that it would still be appreciated.
Support for for styles and themes has existed in tkinter for some time. A theme being a collection of styles for different widgets.
You can read more about style and themes here.
To the best of my knowledge, the standard widgets to not support rounded corners. All widgets have rectangular shapes.
You might be able to create something like that using a Canvas, but it would be a significant amount of work.
A more relevant point is that it might confuse your users if you don't reproduce the way the standard controls work.
UI elements are standardized for the same reason the controls in a car are; once you know one of them you can use all of them.
I'm building a 2D simple projectile motion simulation. I have the GUI layout on the PyQt5 side set (with buttons/dropdowns/checkboxes, but none work yet), and the VPython physics code set as well. I have a large area of the windowed application meant to show the screen (the same one that would pop up in a browser with only VPython code). I can't figure out how to connect the simulation visual to that portion of the window, so how would I do that? What widget should I use?
It's also worth mentioning that I am at an intermediate level with VPython and Python itself, but a complete beginner with PyQt5, so I've built the whole GUI in the Qt Designer.
I don't know if it's worth posting my code here as all of it is completely unmodified Qt Designer code with no references to VPython, but here's the code for the black box, which was placed in the UiMainWindow() class:
self.simulation_view = QtWidgets.QOpenGLWidget(self.centralwidget)
self.simulation_view.setGeometry(QtCore.QRect(70, 10, 961, 541))
self.simulation_view.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
self.simulation_view.setObjectName("simulation_view")
Here's a screenshot of the GUI, with the black box being an OpenGL widget (which is probably wrong for my case) where I want the simulation to appear:
My guess is that this won't work, because I might expect VPython's event loop and PyQt5's event loop would fight with each other. A different approach would be simply to use VPython's widgets, which includes buttons/dropdowns/checkboxes. I'll comment that for VPython questions it's better to post to the VPython forum, where there are many more VPython users who will see your question than if you post to stackoverflow:
https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users
I have the task to build up an interactive plot which i have already done more or less. But now I am supposed to give specific information about a point in a graph for example P(8|6) and by clicking on this point there should open a new window with specific information. Adding the information to the window wont be the problem but the window itself. How I can open a window by clicking on this specific point (keep in mind, it is no button since it changes from graph to graph)?
The answer is qwt! Study the documentation and examples for that project like your life depended on it, and you will find exactly what you need.
I wrote up a pretty complete example a year or so ago; but it is in C++; converting it to python should be pretty straight forward.
https://github.com/peteristhegreat/qwt_generic
Hope that helps.
I am trying to build a Kivy application with a sharp, crisp look and feel but the default Kivy UI is not exactly what I had in mind? Is there any way to create a custom theme to give your Kivy app style?
This app here is called Pithon and it was made from Kivy. I have searched everywhere but I can not find anything on how the developer managed such a clean look. Does anyone have any ideas?
A kivy developer called Andrés Rodríguez released a set of widgets based on google's material design principles. I am currently using them myself and they have surely saved me from alot of work. You can find KivyMD here (see bottom of this answer for more info). Their are some themes also based on the same principles but am yet to try them out one is FlatKivy and another is kivy material ui by Federico Curzel.
Some screenshots for kivyMD,flatkivy and kivy material ui respectively are here.
Click the highlighted links you will find a lot more info about the three projects.
The original KivyMD project by Andrés Rodríguez is no longer maintained but there is active fork of KivyMD by HeaTTheatR.
(Almost) all widgets have properties that can be used to set aspects of their style. For instance, with a Button you can change the background colour, the background image when pressed or released, and the size of the border region (it's scaled like in CSS border images). You can check the documentation for the specifics of a given widget.
An theme like in the screenshot you posted could be achieved by turning off background images for the buttons and just using solid colours, with the non-button text being normal Labels and the circle being drawn directly with a kivy canvas instruction or via an Image widget (along with an image of the circle).
I notice you mentioned padding in a comment but I'm not sure what you mean by it - do you mean the distance between the buttons? They may well be placed in a GridLayout which has a padding property controlling this, so you could set it to whatever you like.
I recognise that you're asking a more general question than 'how does this screenshot do it?', but the key point is that just about everything is customisable and it doesn't take many changes to go from the default theme to your image.
Edit: One useful feature that helps this kind of customisation is that you can use kv language to override styles for widget classes very easily, so you don't need to manually change every button etc.
I am looking to make a GUI in python but currently do not have much experience. The GUI must have a few key features, namely a slider bar to control audio, and a few basic menu buttons. I realize essentially all GUI development tools could handle these simple features, but I am also interested in some custom content as well. The basic look of the GUI I am looking to create is shown here:
In the image, the slider volume bar, "button1," "button2," the colored circles, and any slice of the circle (one highlighted section is shown) needs to be clickable and interactive. Moreover, the small colored circles must be able to dynamically revolve around the edge of the circle and remain clickable at all times. I have not used any GUI development tools yet, but have looked into pyGTK, pyQT, wxWidgets, and Kivy. Can anyone who has used these tools recommend which would be best suited? As far as shapes of buttons, am I restricted?
You can use pyopengl, pygame , pygtk .
I have one example how to show this images if you want take a look at :
http://free-tutorials.org software free section is decor.tgz example.
In my opinion you can use pyOpenGL is very portable to another language like C,C++ and also you can make it to Linux , Windows , Android.