In my Perl/Tk script I'm opening new windows, and i want the window opening will run an initial subroutine (when ever the window is opened)
How can I do it?
One way is to call the subroutine from the code that creates and/or raises the window. If you want the call to be bound to the action itself rather than the invocation of that action (maybe because the window could be opened from multiple places in the code) you would need to create an event binding. e.g.
$window->bind('<Map>', \&mysub);
Depending on what precisely you're trying to do, you might want to bind to the Create, Activate, or Visibility events instead. See the Tk event type documentation for more information.
Related
I use plain emacs in a terminal and like it that way (no spacemacs or gui emacs for me). In the gui versions, error messages pop up in a floating window, I think, and can be batted away. In my setup they open in a new split window and steal focus. To get rid of it I have to move the pointer back to my code window and then, if I want my code window full width, maximize the code window by deleting the other error window with a binding (which keeps the error window in the buffer list for reference). It's a lot of keystrokes for a simple error message. Ideally, I would like to not lose the focus from my code when they appear, and banish the error message window with a single binding (but keep it in the buffer list for reference... ideally being able to recall it in the way it initially appeared [in a split, without stealing focus] with another binding?
It is possible to dismiss an error window with C-x 0 (delete-window) if it has focus, but if previously you had two windows open in, say, a horizontal split, the error appears in the other window, and dismissing the error window removes your previous split. I create lots of unpredictable configurations so using a window arranger will not work for me to restore some preconfigured window arrangement.
How could I achieve this?
you can disable this behavior by setting two cider config vars to nil:
cider-show-error-buffer and cider-auto-select-error-buffer,
this would prevent the default behavior, still allowing you to manually select error buffer when needed with cider-selector.
Still i find it more convenient to use the popwin package for that, showing the error buffer as a popup, without breaking your windows layout.
(push "*cider-error*" popwin:special-display-config)
Not sure exactly if the errors you mention are compilation errors when developing Clojure/script but, in my experience (I also use Emacs in a terminal), you can dismiss the error message just by pressing q and it will close the frame and move the cursor back to the original frame.
Here's a short video of my experience: https://imgur.com/a/9jzr4yb
I also tried it having more than one frame, and it works as expected: it splits only the code editor frame to show the error; if you dismiss the error it removes the new frame and will keep your existing layout.
One option is to enable winner-mode and just bind winner-undo/winner-redo to keys you want to cycle between window configurations. After an error pops up a new frame, it is just one call to winner-undo to restore the prior configuration. This also gives you the desired behaviour for recalling the error configuration with winner-redo.
Event listener breakpoints in Google Chrome Devtools offers various number of options, but for me, they are not really of great use since they always throw me to some irrelevant part of code.
What I would like to know is if it is possible to limit it to just one class? For example onMouseClick send me to the 1st method that executes after mouse click, inside specific class. If none of the methods are fired inside this class, than simply do nothing.
You can set the breakpoints for each script and each line individually.
First open the debug-tools and chose a script in the sources-tab:
Then you can click on the line-number (here only no. 1) and it looks like this:
As you see now is the line marked, but also in the right col your individual breakpoint is listed.
After having marked the breakpoint you still have to reload the page that the scripts are executed again till to the breakpoint. Afterwards you can use the icons above the right col to step in or step over the commands following the breakpoint.
Having minified scripts, breakpoints are hard to use, so it's better to have a script where each line has only one command, it's much easier then to debug.
So for debugging you should change the corresponding script in your page to the non-minified version, perhaps also with a map-file if available.
I have a Main_window in MATLAB guide. I want open a New_window when I run Main_window, So I add this code in OpeningFcn of Main_window :
New_window();
When I run Main_window, New_window goes to back of Main_window. I want it in front of Main_window after running.
Any help?
This is happening because you are calling New_window before Main_window has finished executing.
Ideas:
You could simply call Main from new instead. I'm guessing that you already tried this and it doesn't work for your application
If you want the user to do something with new_window, then proceed to main_window, you could enable uiwait in the new_window opening fcn to keep it in focus until the user closes it.
Create a script that contains two lines
Main_window;
New_window;
Running that script will start both programs in sequence, and New_window will be on top.
Ultimately, if you want to maximize control, you should write your own gui instead of using GUIDE.
Say I want to look at an object and so I log it to the console:
console.log(theNoticeObj);
Then using Chrome Dev Tools, I inspect it in the console and change its property theNoticeObj.bounceHeight to 10px
Now if I want to trigger theNoticeObj.bounce() on that object immediately to locate it, is there an easy way to do that from the console?
Thanks
EDIT:
Breakpoints where suggested below, but this freezes execution.
In face what I want is the command line API to work with javascript objects, not just DOM elements. If that were possible I'm sure I would be able to find it. I might go and see if there are any feature requests to that end for chrome.
https://developers.google.com/chrome-developer-tools/docs/console#using_the_command_line_api
Try adding window.tno = theNoticeObject under the console.log statement. Reload the page and see if you can execute tno.bounce() from the console. If theNoticeObject is still in scope, this should work.
You can navigate to the Sources tab and open your javascript file containing the piece of code you want to play with, in this case let us assume it is
console.log(theNoticeObj);
Once you find this line, you can set a breakpoint at this point and when your program execution comes to this line it will halt.
You can then use the Console tab to do operations on all the javascript objects in current local scope, window scope. You can simply call:
theNoticeObj.bounce();
It executes in the current context reflecting changes on the screen.
Hope this helps.
Now you can right click any object in the console and use "Store as global variable".
A new console line appears with the name of a new global variable holding reference to the selected object.
So, I'm trying to implement a looping mode in the totem movie player. I would like to do this by adding a checkbox under "Edit" that turns looping on.
I'm trying to figure out what code gets called when "Edit" and the "Shuffle Mode" option under it is clicked. Is there any easy way to find where the appropriate event handler is?
My usual method of code reading (stepping through it with the debugger) didn't work because this is a GUI program, and as soon as you get to the main loop it doesn't stop until there's a breakpoint, and where to put the breakpoints is basically what I'm trying to find out.
I've been using Netbeans for this, and I should note that I can't use Eclipse.
Thank you.
The UI for Totem and the callback names for each element defined in the GtkBuilder file, data/totem.ui.
http://git.gnome.org/browse/totem/tree/data/totem.ui
This file says that the handler for the "Shuffle Mode" action is shuffle_mode_action_callback. Then you can use grep:
grep -r shuffle_mode_action_callback totem-git/src
The result of this command indicates that this function is defined in src/totem-menu.c.