I am using wxPython to write an app. I have a menu that pops up. I would like to know how to keep it on the screen after the user clicks an item on the menu. I only want it to go away after the click off it or if I tell it to in the programming. Does anyone know how to do this?
I am using RHEL 6 and wxPython 3.01.1
I don't think the regular wx.PopupMenu will work that way. However if you look at the wxPython demo, you will see a neat widget called wx.PopupWindow that claims it can be used as a menu and it appears to work the way you want. The wx.PopupTransientWindow might also work.
Related
I'm going through this tutorial here http://zetcode.com/wxpython/menustoolbars/ under the section Submenus and Separators. I get the menu items and submenu to display, but my menu opens "to the left" like so:
instead of "to the right" like the reference image and all other menu examples I've seen which open like so:
Why is my menu opening the way it is? The window/frame size doesn't seem to matter as far as I can tell. I know the tutorial is Linux based while mine is Windows based, but other Windows based examples also show like the tutorial. Any ideas?
For reference, I'm using VS Code for editing (not that I think that matters), and a standard system install of Python 3.7 and wxPython 4.0.3.
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/
i am using python/tkinter to write a IM software on XP. now i've got all the main functions done except i don't know how to highlight or change colour my IM item on taskbar on windows xp when window is minimized to the taskbar when a new message is received. i've search for this but just got c# solution. i need help on python. thanks!
I needed to do this for a tkinter python slack client I am writing and found http://wiki.tcl.tk/1049 . After a bit of guessing, I found that
Tk().deiconify()
Tk().focus_force()
(i.e. on the root window) does the trick. Windows doesn't actually change the focus and show the window since applications are not allowed to do that (Windows after XP) but it flashes the taskbar instead. It will keep flashing until clicked on but that seems to be the behaviour of Skype/Slack etc. Certainly close enough for many uses.
Obviously this is an old question but I couldn't find a concise, python only, answer and still needed one!
I'm not sure if there is a good way of doing this with Tk. Maybe somebody more knowledgeable will be able to point you in a better direction. Since Python is so dependent on OO, you may have a difficult time writing bindings to the Windows window manager.
If you don't find anything else, I did stumble on http://wiki.tcl.tk/4089, which manages Windows icons on the taskbar. Perhaps you could utilize this to simulate the taskbar flash that you want?
I have a program here that has an entry box and a button.
I want python to enter a string into the entry box, then press the button. What is the best way of going about this?
This is for windows 7, BTW.
pyWinAuto will work nicely for this. With it you can "type" text into windows based on window title( or window class) as well as "click" buttons. Its fairly easy to use, and the website is pretty good about giving you examples on how to do what you want.
http://pywinauto.openqa.org/howto.html
I've heard of, but not yet tried myself:
WATSUP
Python Win32 GUI Automation, aka "pywinauto"
PyAutoGUI (installable through pip) can automate mouse/keyboard and works on Mac/Windows/Linux.
It also has some basic screenshot image recognition capabilities like Sikuli has.
https://pypi.python.org/pypi/PyAutoGUI
I am making a Python gui project that needs to duplicate the look of a Windows gui environment (ie Explorer). I have my own custom icons to draw but they should be selectable by the same methods as usual; click, ctrl-click, drag box etc. Are any of the gui toolkits going to help with this or will I have to implement it all myself. If there aren't any tools to help with this advice would be greatly appreciated.
edit I am not trying to recreate explorer, that would be madness. I simply want to be able to take icons and lay them out in a scrollable window. Any number of them may be selected at once. It would be great if there was something that could select/deselect them in the same (appearing at least) way that Windows does. Then all I would need is a list of all the selected icons.
Python has extensions for accessing the Win32 API, but good luck trying to re-write explorer in that by yourself. Your best bet is to use a toolkit like Qt, but you'll still have to write the vast majority of the application from scratch.
Is there any way you can re-use explorer itself in your project?
Updated for edited question:
GTK+ has an icon grid widget that you could use. See a reference for PyGTK+: gtk.IconView
In wxPython there's a plethora of ready-made list and tree controls (CustomTreeCtrl, TreeListCtrl, and others), a mixture of which you can use to create a simple explorer in minutes. The wxPython demo even has a few relevant examples (see the demo of MVCTree).
I'll assume you're serious and suggest that you check out the many wonderful GUI libraries available for Python.