wxpython treectrl show bitmap picture on hover - python

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.

Related

How to add a "remove button" at the right side of the hovering (or each) item of a wx.ComboBox popup

What I want is a mean to remove an item from the combobox without having to add a separate remove button somewhere else. So I want a remove button to appear at the right side on a combobox dropdown item when I hover over my mouse pointer on it. And, it is also OK if all the items have remove button at the right side and do not need hovering.
The images bellow will illustrate what I am saying [...please ignore my mspaint skils]
[combobox with remove button for hovering item]
https://i.imgur.com/kIMtF3G.jpg
[combobox with remove button for each item]
https://i.imgur.com/iyG23vG.jpg
[NOTE: Sorry, I cannot post images directly because it needs at least 10 reputation to post images.]
[I am new to python and wxpython. So please ignore my ignorance if any. And for the same reason any simple code sample will be greatly helpful.]
Regards.
The wx.ComboBox does not have this feature. The wxPython GUI toolkit uses the target platform's native widgets. If those widgets don't support doing it, then neither does wxPython.
However, wxPython does have custom widgets or you could create your own widget to do this sort of thing.
I also think you could use a context-menu for this task. You would need to right-click to make it work. Another method would be to bind to a mouse event and try to figure out where in the widget you are, but I think that method would be error prone.

Move mouse pointer to GTK widget

Does anybody know how to move a mouse pointer to a specific Gtk widget with Python code? Google does not seem to yield any results. I want to hover the pointer over the print button when popping up the GtkPrintOperation dialog. Theoretically, the code should work with any Gtk widget. What I found so far: you can get the position of the mouse. However, I need to set the position of the mouse. If I need to rewrite the whole Gtk stack it probably won't happen. One alternative would be to set the GtkButton as the default and then ENTER would print the document without moving the mouse to select the button.
Why I need this: the project is for my brother in law who is using OpenOffice Basic and he has this feature. I would definitely like to make an impression with Gtk (which is way more powerful). As he prints a lot of documents this is very needed. Any suggestions?
In X-Windows, you can use xdotool:
$ xdotool mousemove column row

wxpython: dynamically created buttons are disabled

I want to create buttons dynamically
self.ctset = wx.BitmapButton(panel, -1, self.pic1, pos=(10,10), size=(50,50))
self.ctset.Bind(wx.EVT_BUTTON, self.add_ct)
self.ctset.SetDefault()
and the add_ct binding function
def add_ct(self, event):
pos=(10,self.yct)
self.yct+=65
self.new = wx.BitmapButton(self, -1, self.pic1, pos=pos,size=(50,50))
self.new.SetDefault()
print "Cutset"
I don't know where I am going wrong but my dynamically created buttons always seem disabled!
I want to bind a function to the dynamically created buttons that allows me to drag them around. Any ideas would be of great help!
I am pretty new to python and wxpython.
I don't see any code that captures the mouse's coordinates or even any drag-and-drop code. You need to download the wxPython demo package from the wxPython website and look at the ShapedWindow example for catching mouse coordinates. See also this old thread: http://wxpython-users.1045709.n5.nabble.com/Drag-Button-around-a-Panel-td3358640.html
In it you will find someone who is doing something very similar to what you want. I also found the following links which you might find helpful:
Drag button between panels in wxPython
How to move items smoothly in wxPython?

pygtk window with box that ignores all X(mouse)events (passes them through)

I'd like to do the following: Create a fullscreen, always on top pygtk window with a webkit widget displaying some html, but with a box that is completely transparent, so that the windows below are visible. (This seems to be possible: Is it possible to render web content over a clear background using WebKit?)
What I'd like is to (sometimes) pass all mouse events that occur in the transparent box down to the windows below my application's window, so that I can interact with them normally. So not just visually transparent, but also transparent to mouse events.
Theoretically, I suppose I could catch all events I am interested in with a pygtk Eventbox, find the window directly below mine with wnck, and pass this event to it with python-xlib.
This doesn't exactly seem like the most elegant solution; is there a better way?
Forwarding the events won't work well as you guessed; it creates a lot of race conditions, and some apps will ignore stuff from XSendEvent anyway.
What you can do is set the input shape mask. See http://www.x.org/releases/current/doc/xextproto/shape.html and then look at XFixesSetWindowShapeRegion() in /usr/include/X11/extensions/Xfixes.h which lets you specify a shape "kind" (here you want ShapeInput).
Something like:
XRectangle rect;
XserverRegion region = XFixesCreateRegion(display, &rect, 1);
XFixesSetWindowShapeRegion(display, window, ShapeInput, 0, 0, region);
XFixesDestroyRegion(display, region);
The ability to set ShapeInput is "only" 5-6 years old so if you care about really crappy old versions of X11, you might be hosed.

Popup Dialog in Tkinter/Python

I need to add a popup dialog box on my GUI.
So, when ever I hover my mouse over a label, it should be able to show a popup( Like the type we get while hovering over a file in windows).
It should also disappear as soon i move away the mouse.
To start with, I am not even sure which module or class to use. I tried menu, but the results are not what i expected.
I also tried to learn tkCommonDialog, but couldn't understand it properly.
Please Advice!
The little popup window is called a tooltip.
This post may be relevant: http://bytes.com/topic/python/answers/505848-tkinter-button-overrelief
Take a look at the Balloon widget in the Tix package. I think it is just what you are looking for.

Categories

Resources