I have accumulated a few thousand lines of code with wxpthon.
But sometimes the frame crashes.
Is there a way to catch the exceptions that may have caused the crashes ?
I put in the following binding statements to try to catch the frame closing event.
But it does not work.
self.Bind(wx.EVT_CLOSE, self.onCloseWindows)
self.Bind(wx.EVT_QUERY_END_SESSION, self.onCloseWindows)
self.Bind(wx.EVT_END_SESSION, self.onCloseWindows)
Can someone help?
Related
I'd like to display an activity-indicator displayed when I do a long process.
I set a model busy flag to true.
I then call a method that returns a Promise - when the promise calls resolve, I then set the busy flag to false in my 'then' handler.
When I wait for the promise to resolve, I expect the Activity Indicator animation to be displayed but it's not.
I checked and made sure the UI set up is correct and it works.
The work that's being done is using nativescript-calendar plugin - I'm adding a few calendar entries.
I commented out the work that's being done and just went to sleep for a little bit and then called resolve() and the animation worked.
So the Activity Indicator and the Promise mechanism is setup correctly - it's something this plug-in is doing that's causing the AI not to display.
What could cause such a behavior?
I actually edited the Promise work code - put to sleep for about 1 second and then started the calendar work. I see the AI for 1 second and then it freezes.
So it looks like the calendar writes is causing the AI to freeze.
I was under the understanding that Promise work is done in the background and should not effect foreground animation.
I've had a similar issue when using SQLite.
As you haven't explicitly stated that your running the calendar in a worker I am assuming your keeping it in the UI thread (main thread).
Any large amount of work done in the UI thread will cause noticeable lag/delays. So for example you call the activity-indicator then call a process that maxes out the thread, the process finishes the activity indicator goes to be drawn on the screen but then is hidden straight away before it is displayed as the process is finished.
The ideal way to solve this is to move the calendar writes code into a worker (multithread your app) and on success message turn off the activity-indicator.
Take the simplest possible Windows program with a window and message loop, such as a Hello, World program.
Suppose that just before I enter the message loop, I draw into the window (naughtily done outside processing of wm_paint, but bear with me).
If I spend more than about 5 seconds doing this, or I draw something then spend 5 seconds doing something else, before I start the message loop, then the message system seems to 'time out'. The MSDN docs for PeekMessage says it becomes 'unresponsive' and turns it into a 'ghost' window.
My problem however is that it also clears the contents of the window!
Is there way of stopping it doing that? The same 'unresponsive' caption is shown if I spend too long drawing into the window even during offical wm_paint processing; it also starts to behave oddly by generating more wm_paint messages.
It seems very restrictive if everything (eg. complicated rendering, or image processing) must be done within 5 seconds, or if any algorithm needs to keep prodding the message queue to stop it timing out!
This is by design. You must keep checking for messages so that you can respond to user events such as resizing or closing the window. Even worse, if your application is not responding to events then that may cause other applications to freeze, as they may send your application a message and be stuck waiting for a reply.
If you have to do a lot of processing then either check for messages periodically, or do the work in a separate thread.
create a thread for extensive drawing on a cache bitmap. while bitmap is not ready just print on WM_PAIN event "processing please wait..." for example. when ready print that bitmap. and destroy the thread.
I have a paper-button with the on-tap function that opens a paper-dialog that contains a "Accept" paper-button that will close it when clicked.
The problem i'm getting is if depending on my screen resolution, and the dialog's "Accept" button is over the initial button to open the dialog, when clicked, the dialog opens and closes. I'm assuming the on-tap event is being fired to both.
I've tried these 2 methods but they do not seem to help.
event.cancelBubble = true;
event.stopPropagation();
The problem is that a capacitive screens or even mouses can generate multiple tap event on the same spot within a few milisec.
The mouses because a quick change in a high and low voltage (logical 1 and 0) generating an AC signal wich can jump trough on a capacitator (which can be the button two contactor between the air) if the conditions matching. But the onclick event is already catching this case and you does not require to do anything to solve it.
The capacitve screens are capacitators and just rolling your finger should trigger multiple tap events because your skin has different depth of insulation and hard to mark the tap begin and end in some cases.
This physical problem should be solved by the platform, but it is not in every situation currently (but most of the devices are filtering this). Im usally solving this isse with a transparent overlay element wich can catch the pointer events for a little duration so I could catch the "prelling" of a button or the capacitive screen for a few ms.
If a 10-20ms is enough for you then wait a frame in your on-tap function with requestAnimationFrame and then show the dialog. Cheap trick, but it does what it has to, but ultimately you can wait a fix timeout to show the dialog, because you have 100ms to respond a user interaction.
You cannot fix this by manipulating the browser events options though because as I know you dont have option to how much time need to pass until the next same event should happend. But if you wait a frame thats could behave like you add a delay between the events.
I'm making a game with a pause button. If you die in the game you go to a new frame with a Restart button. I remove the Event Listeners on Frame you land after you die, but it shows "1120: Access of undefined property pauseVenus". It was not a typo. Any Solutions.
This is my code for the frame with the game which is the 60th frame as it is a game within a virtual world:
pause_btn.addEventListener(MouseEvent.CLICK, pauseVenus);
function pauseVenus(event:MouseEvent):void{
gotoAndStop(61);
}
Then this is the code for Removing Event Listeners:
pause_btn.removeEventListener(MouseEvent.CLICK, pauseVenus);
(There are other Event Listeners too. I can remove them without a problem.)The error message is for 'pauseVenus' only. If I remove the line, "pause_btn.removeEventListener(MouseEvent.CLICK, pauseVenus);", it works.. But after you die it gets stuck on the new frame and Flash has to be closed!! Any solutions?
Thank You.
A simple 10.6 Cocoa app I wrote that basically draws a regular window with some buttons and text has been spewing hundreds of console log messages:
<Error>: CGContextSetCompositeOperation: invalid context 0x0
I do not directly call drawRect: and always use setNeedsDisplay:YES when I need to refresh.
Interestingly, this error does not happen on all machines, I'd say about 50% get the error. However, the program works fine in either case!
Anyone got any clue as to what this error means, where it's stemming from, and more importantly, how can I suppress/get rid of it?
Thanks
Try setting a breakpoint on CGPostError. If you can break on the logging, you can hopefully figure out what's going on.
You shouldn't be looking to just suppress it. It means context creation is failing (thus NULL gets passed for some context parameter), and that's not good.