I'm recently getting into Tkinter. Today I needed to create a scale, which has values snap to the left mouse button click. The standard seems to be, that it snaps to the right button.
Anyways, I found an answer:
Force TkInter Scale slider to snap to mouse
My question is: Where can I find documentation of the "Scale" class, or any other class, so I can make such adjustments myself in the future?
I tried my best to contact the user who provided the answer and ask him instead. But the terrible and deliberate design choices of this site do not allow that.
Related
I want to visualize one or more STL file(s) using a vtk render viewport inside my application. I was able to get it all running with this example here: https://kitware.github.io/vtk-examples/site/Python/IO/ReadSTL/
My question is as follows: I have a mouse to control it and it is just unbelievable how bad default the controls of the camera are. It is almost impossible to get the model rotated intentionally or focus on a certain part. I am confused as I could not find any topic here or elsewhere discussing this. Normally I would read through other threads to find an answer, but there doesn't seem to be any. So, maybe you can point me to an approach or even certain functions of how I can change these settings, that would be really great! Basically I want to mimic the camera behavior of say, Paraview or a common CAD tool. Like zooming with mouse wheel, rotating with RMB and holding down the wheel to pan.
Some background on my project: I have written a python program and created a quite ok UI using tkinter. However, recently I was thinking of rewriting some basic parts of it and also upgrading everything visually and in terms of handling. So, I want to move to Qt widgets and, there shall be a VTK rendering viewport inside my application to show some of the stuff that can be interacted with.
I was able to find a solution in the tutorials. By explicitly defining the vtkInteractorStyle with
style = vtk.vtkInteractorStyleTrackballCamera()
The handling is just as I wanted it to be.
So i'm programming python program that uses wxPython for UI, with wx.TreeCtrl widget for selecting pictures(.png) on selected directory. I would like to add hover on treectrl item that works like tooltip, but instead of text it shows bitmap picture.
Is there something that already allows this, or would i have to create something with wxWidgets?
I am not too familiar with wxWidgets, so if i have to create something like that how hard would it be, lot of code is already using the treectrl, so it needs to be able to work same way.
So how would i have to go about doing this? And if there might be something i might be missing id be happy to know.
Take a look at the wx.lib.agw.supertooltip module. It should help you to create a tooltip-like window that displays custom rich content.
As for triggering the display of the tooltip, you can catch mouse events for the tree widget (be sure to call Skip so the tree widget can see the events too) and reset a timer each time the mouse moves. If the timer expires because the mouse hasn't been moved in that long then you can use tree.HitTest to find the item that the cursor is on and then show the appropriate image for that item.
That is, without doing focus_set on some other widget?
The original post ended with the sentence above, but it did not meet quality standards. These standards demand that the problem is described completely, including what one has tried. They insist on proper grammar too.
Well, it is not really a problem, just a question. I tried to find a widget method, say, focus_unset, that would do the trick. I didn't. My grammar is proper. Maybe the robotic police is confused with terms like focus_set?
No. Some widget must have focus. You can set focus to the root window if you don't have any other widgets that naturally accept keyboard input.
I am creating a GUI that revolves around looking at a plot. The users are assumed to be very dense, as per instruction. That being said, I have been told that the default Zoom-to-rectangle button needs to have another button in the toolbar at the top of the program (which I would also program to a shortcut for ease of use).
The problem I am having is I don't know how to turn the mouse into the Zoom-to-rectangle. I don't want it to actually zoom, just change the mouse to where if it is then dragged across the plot while clicking, it will then zoom.
This is hard to explain, so if you need more information than what is provided please ask.
I've been trying to find a way to handle focusing on a pygtk combobox. The goal is to change the color of the combobox when it is focused and then change it back when focus leaves the combobox. I've tried using the "focus_out_event" but this doesn't seem to work with combobox. I've searched extensively for an answer to this problem and it seems this may be a gtk+ bug??
The solution I've come up with so far...
I have 4 separate combobox's cb0 - cb3. I have connected them to the same method...
self.cb0.connect("focus", self.focus)
In the method I change the state and color...
def focus(self, widget, direction):
if widget.get_state() == gtk.STATE_NORMAL:
widget.set_state(gtk.STATE_SELECTED)
widget.modify_base(gtk.STATE_SELECTED, gtk.gdk.Color("#99CCFF"))
else:
widget.set_state(gtk.STATE_NORMAL)
widget.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color("#FFFFFF"))
This provides the desired effect when tabbing with the keyboard. But if the combo boxes are clicked with the mouse I get undesirable results. Now I'm looking for a way to track mouse clicks.
I can't seem to find a signal or method to check when a specific combo box is clicked. Using the "grab_notify" signal will fire off a signal for all 4 combo boxes (thus changing all the boxes base color at once.)
This has been a frustrating problem taking waaay too much of my time. Seems like there should be a simple solution.