Kivy Navigation Control - python

I was wondering whether it is possible to make a Navigation control just like the one in GIMP using the kivy framework in python
Navigation Control: This is a small cross-shaped button at the lower right corner of the image display. Click and hold (do not release the mouse button) on the navigation control to display the Navigation Preview. The Navigation Preview has a miniature view of the image with the displayed area outlined. Use the Navigation Preview to quickly pan to a different part of the image—move the mouse while keeping the button pressed. The Navigation Window is often the most convenient way to quickly navigate around a large image with only a small portion displayed. (See Navigation Dialog for other ways to access the Navigation Window). (If your mouse has a middle-button, click-drag with it to pan across the image).
Refer to point 11 on this link : https://docs.gimp.org/2.10/en/gimp-image-window.html
And : https://docs.gimp.org/2.10/en/gimp-navigation-dialog.html

Related

PyQt: How to find menu text color in that works with Ubuntu Unity?

I want to add colorless icons to menu items. To look reasonably, the icons should have the same color as the text used in the menu. It works everywhere except Ubuntu. The problem is that the default Ubuntu Unity theme uses different colors for the main menu and for other text (e.g. popup menus) in the application. I need the color specifically used by the main menu.
QApplication.palette().color(QPalette.Text) returns the dark gray color used by text in the application. It's almost invisible on the dark gray menu background.
I tried the palette() method on a QMenu descendant, but it returns the same value as QApplication.palette().
It turns out QMainWindow.menuBar().palette() has colors matching the Unity menu on top of the screen (I just learned it's called appmenu). That makes it possible to use the same color as the menu text.
But there is a problem. The version of the icon for the QtIcon.Active mode is not used for the active menu item. That can be seen in the high contrast mode. The text color changes, but the icon color doesn't. The icon "disappears" when the menu item is selected. That's not good enough for a polished program.
I tried many workarounds, such as adding extra pixmaps to the icon with QIcon.addPixmap(). Nothing works. The appmenu operates in a separate process and doesn't want to our "Active" icon. So I'm going to draw real icons that look good on any reasonable background and don't need to change color with the widget.
Too bad. I expected that the QIcon mode and state were made specifically for such tasks.

wxPython scrollbar doesn't stick

I've been playing with this cookbook example to make a scrollable matplotlib plot with wxPython. However, when I run this code on my Windows 7 machine at work, the scrollbar doesn't seem to work properly. In particular, if I click and drag it to a position, it does update the plot, but then the scrollbar moves back its starting position, instead of staying put. I'm curious if anyone has an idea what's going on here. FWIW, this code worked fine when I ran it on my Linux Mint 14 machine at home.
Right now, I'm trying to fix it by using a wx.ScrolledWindow or a wx.lib.scrolledpanel instead of adding the scrollbar directly to the canvas as in the example. I was also considering using a slider instead of a scrollbar
Thanks
From Programing Windows, Fifth Edition (emphasis mine)...
When you use scroll bars within your program, you share responsibility
with Windows for maintaining the scroll bars and updating the position
of the scroll bar thumb. These are Windows' responsibilities for
scroll bars:
Handle all processing of mouse messages to the scroll bar.
Provide a reverse-video "flash" when the user clicks the scroll bar.
Move the thumb as the user drags the thumb within the scroll bar.
Send scroll bar messages to the window procedure of the window containing the scroll bar.
These are the responsibilities of your program:
Initialize the range and position of the scroll bar.
Process the scroll bar messages to the window procedure.
Update the position of the scroll bar thumb.
Change the contents of the client area in response to a change in the scroll bar.
...so somewhere in OnScrollEvt() method, you'll need call SetScrollPos() with something like...
self.canvas.SetScrollPos(wx.HORIZONTAL, event.GetPosition(), True)

Button Transition

I am programming wxPython with GUI aid from pythonCard. The resource editor has made short work of my display so far.
The GUI has static boxes "cards" with information that the program outputs. I would like to transition to a different page on button click. So for example, clicking on ok should take me to page 2 (separate resource file).The complexity is I don't want to open up a new window for each click as I have 20 buttons.
I have 10 cards with same properties so on click i only want to change the particular and still be on main page however go to page two for particular card. Visually think of windows 8 tile and on click it flips to reveal more information.
Is this possible in wxPython? If so, how could i go about it?
It sounds to me like you want a Notebook or similar "book" control. The wxPython demo details the various book controls that wx supports. Or you might want to just swap panels, which is pretty easy to do as well. Here's a tutorial I wrote on the subject a while back:
http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/
And here are a couple links on notebooks and similar controls:
http://wxpython.org/docs/api/wx.Notebook-class.html
http://wiki.wxpython.org/Simple%20wx.Notebook%20Example
http://www.blog.pythonlibrary.org/2012/07/18/wxpython-how-to-programmatically-change-wx-notebook-pages/

Focus-follows-mouse in wxPython?

I'm developing an application that contains a number of panes. See the screenshot:
The left settings pane is a wx.ScrolledPanel that contains a number of wx.Panels.
The top events pane is a wx.grid.Grid.
The bottom data pane is a wx.Panel that contains a wx.grid.Grid.
The middle plot pane is a wx.Panel containing an enthought chaco plot.
The right detector pane is a wx.Panel.
I would like to implement focus follows mouse so that when I move my mouse over the plot I can immediately zoom in or out using my scroll wheel without first clicking on the plot to give it the focus.
Similarly when I move my mouse over the left settings , the top events or the bottom data panes I would like to be able to immediately scroll the window using the scroll wheel without first clicking on the window.
Currently I defined a function:
def focusFollowsMouse(window):
window.Bind(wx.EVT_ENTER_WINDOW, lambda event: window.SetFocus())
I would like to apply this function only on the four top-level panes: plot, settings, events and data.
However I need to call this function for each sub-panel or control in each of the top-level panes to get this to work. For example I need to apply this function individually to the Measurement Settings, Analysis Parameters, View Settings etc. panels.
Most likely the EVT_ENTER_WINDOW event is not propagated to parent windows.
Is there a way to get this to work without applying focusFollowsMouse to each and every sub-panel or control?
Thanks
This is Windows' behaviour - it works as you expect under GTK. Personally, I'd leave your app as it is, for consistency with other Windows applications, and install WizMouse

Drag button between panels in wxPython

Does anyone know of an example where it is shown how to drag a button from one panel to another in wxPython?
I have created a bitmap button in a panel, and I would like to be able to drag it to a different panel and drop I there.
I haven't found any examples using buttons, just text and files.
I am using the latest version of Python and wxPython.
If you want to graphically represent the drag, one good way to do this is to create a borderless Frame that follows the mouse during a drag. You remove the button from your source Frame, temporarily put it in this "drag Frame", and then, when the user drops, add it to your destination Frame.

Categories