I'm still in the process of learning more about WxPython and I ran into a simple problem.
I like the wx.AboutBox class that manages how credits, licensing and other info is displayed to the user...and I'm not looking forward to building my own from scratch...although I can.
The problem here is that let's say I click on a button which brings up an AboutBox...seems like if you keep on clicking that exact button then multiple instances of the same AboutBox is brought up...and you end up multiple windows that just looks awkward in my opinion. As far as I've looked into it...there's no way to call the ShowModal() function that would allow you to get the ID of the close button in the aboutbox template and do some processing to make sure that only one instance is running.
I want to know how to stop this issue from happening...I want a single instance of wx.AboutBox and if it's not possible with this class due to it's nature/limitations then I'll have to consider building my own as a last resort.
Thanks
Creating your own AboutBox dialog is pretty easy. Here's an article that shows one way to do it: http://www.blog.pythonlibrary.org/2008/06/11/wxpython-creating-an-about-box/ or you could just use a GenericMessageDialog too. See the wxPython demo or http://www.blog.pythonlibrary.org/2010/07/10/the-dialogs-of-wxpython-part-2-of-2/
It seems like you haven't solved this problem yet. In wxPython, there's a class called "SingleInstanceChecker". I think this is what you're looking for.
http://wxpython.org/Phoenix/docs/html/SingleInstanceChecker.html
Related
I am wondering if anybody knows how to get the # back to the toolbar in Spyder 5.1.5. I used to use that a lot when searching for functions in long codes of mine. Recently, I updated to the most recent version of Spyder and could not find # anywhere. Now, I need to scroll down a lot to see where the functions I am looking for are.
Using find is also OK, but for that, it is better to remember the name of the function correctly. So, this makes searching and finding last a lot longer than using one click to the # button.
Any ideas of how to get the # back?
Or does anybody use any other tool/shortcut to access the functions inside a very long code?
Thanks in advance.
Updated on May 7th, history information is under line "***********************"
#Jakub Sowa I cannot add any comment below yours, I tried top_window and children(), it didn't seem to work to me. fox example
tp = cg.appConnect().top_window()
tp.children(title="finance", control_type="Button").draw_outline()
error occurs like-- AttributeError: 'list' object has no attribute 'draw_outline'
So would you give me a specific example to demonstrate how does it work in your case?
I've been doing pywinauto automation for a couple of months, but it runs slowly for some code, for example:
I click the button for confirmation in following code:
self.dlg = cg.appConnect().window(title="Hygine_Platform", control_type="Window")
self.regdlg = self.dlg.child_window(title ="registry", auto_id ="FormRegBalance", control_type="Window")
self.okbtn = self.regdlg.child_window(title="confirm",auto_id="btnOk",control_type="Button")
def clickConfSettle(self):
self.okbtn.click_input()
If I use clickConfSettle(), it takes at least five seconds to complete. Does anybody have the same problem, is there any solution for this? I've checked the structure of the controls, it is quite simple, only has 3 levels.
I've been using the library for a week or two only, but I've figured that if you get the Window Specification of the top window and it's children as soon as possible like so self.app.top_window().children() where app is the pywinauto.Application(backend='uia', allow_magic_lookup=False).connect(handle=self.handle) then your application should work much faster.
It takes the dict lookup away from you, however, you can still access items by indexes or iterate over them (which in my case was way faster than using child_window method). I'm not sure about the clicking part though as it may require some more time, but for the most part - all of the lookups in my program have gone under 1s after that change.
I'd like to answer with what I've tried so far. If I use var.children(attributes), index is still required. so it works with var.children(attributes)[], that runs faster than before.
I'm currently at a crossroads. I'm somewhat versed in Python (2.7) and would really like to start getting into GUI to give my (although mini) projects some more depth and versibility.
For the most part, my scripts don't use anything graphical so this is the first time I'm dipping my toes in this water.
That said, I've tried using pygame and tkinter but seem to fail at every turn to get something up and running (although I had some slight success with pygame)
Am I correct to understand that for both I need X started in order to generate any type of interface, and with that, so I need X to get any type of input (touchscreen presses)?
Thanks in advance!
In order to use tkinter, you must have a graphics system running. For Windows and OSX that simply means you need to be logged in (ie: can't run as a service). For linux and other unix-like systems that means that you must have X running.
Neither tkinter nor any of the other common GUI toolkits will write directly to the screen.
I'm gonna give an alternative answer. If you know HTML, CSS and Javascript (or have time to give it a try) I would recommend using Flask, http://flask.pocoo.org/.
With flask you can create websites but you can also (as I am using it) let it be your GUI. It will work on any device and looks really good :).
I am new to python programming... Just wanted to know does IDLE has a concept of 'executing selected statements'??
F5 runs the whole program... Is there any way to do this?
No, not now. Since you are at least the second person to ask this, I added the idea to my personal list of possible enhancements. However, while running a selection would not be a problem, producing accurate tracebacks for exception would be. Doing so is an essential part of Python's operation.
Currently, one can disable code that you need to not run by commenting it out (Alt-F3) or by making it a string. One can stop execution after a particular statement by adding 1/0. Or you can copy code to a new editor window.
Do you have a specific use case in mind, or are you just wondering?
Install Spyder, with its dependecies, and you will have wonderful FREE IDE !
You will have another solution, is to use IPython Notebook, where you will be able to use your Internet Browser to run python codes!:
I've created a little screensaver-type program with Python, and I'd like to get it working properly under gnome-screensaver. The documentation is all written for C, and there don't appear to be libraries for Python. Is there any way to get this working?
gnome-screensaver doesn't integrate with the screensavers any more than with a small config file that sets the name, some other properties, and a command to execute to start the screensaver. This is documented in the gnome-screensaver FAQ.
The program that gets started needs to get the Window ID from the environment (XSCREENSAVER_WINDOW), and start displaying on that window. This is the tricky part, as it's not always obvious how to do that. Most toolkits should have methods to get a handle on an already existing window by giving the ID, so search your GUI-toolkit documentation for something like that.