|
View:
New views
13 Messages
—
Rating Filter:
Alert me
|
|
|
Child windowHi all. I was wondering if there's a way to have a child window, as so far I can't seem to be able to create one. MDIChild is not what I need, and a dialogue box isn't capable of what I need to do. I supposes there's a simple answer to this question, but I am seriously stumped. Any suggestions/advice/comments welcome.
-Nate ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
|
|
|
Re: Child windowThank you, and I had suspected FXTopWindow might be what I was looking for, but the class reference at fox-toolkit.org does not show necessary arguments to initialize one.
-Nate On Sun, May 24, 2009 at 11:59 PM, Mathew Robertson <mathew@...> wrote:
------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Child windowFXTopWindow is an abstract class, it cant't be created. You brobably need to create another FXMainWindow. In what sence should it be a child window? On May 26, 2009, at 2:44 PM, n d wrote: Thank you, and I had suspected FXTopWindow might be what I was looking for, but the class reference at fox-toolkit.org does not show necessary arguments to initialize one. ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Child windowOn Tuesday 26 May 2009, n d wrote:
> Thank you, and I had suspected FXTopWindow might be what I was looking for, > but the class reference at fox-toolkit.org does not show necessary arguments > to initialize one. > > -Nate FXTopWindow is actually intended to be subclassed. However, you're not likely to need it since its probably more convenient to use FXMainWindow or FXDialogBox anyway... - Jeroen ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://www.creativitycat.com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Running interpreter from FOXHi all,
I need to run Python from a FOX app, and would like to implement a simple debug facility (like single stepping through the Python code and putting breakpoints). Python has a "pdb" class for just this sort of thing. pdb, however, is console-based but I don't want to bother my users with a command-line. Python has the ability to invoke a callback function (in C or C++) for each line executed, and several other useful events. Unfortunately, it does not have an easy way of executing line-by-line directly under the caller's control. In other words, one must either return normally from the callback in order to process the next line, or throw an exception in the callback to halt the whole thing. There's no API that can simply be called to execute one (and only one) line. The FOX question is this: could I invoke FXApp::runWhileEvents() within the Python trace callback? Considering that the main app loop is already running, is this recursive invocation OK? Reading the documentation, I don't see any reason why not, but it doesn't hurt to ask. Here is a more detailed scenario: suppose there is a text widget that has the Python code, and buttons which say "run", "stop" and "pause". "run" starts interpreting the code, and "stop" should always cancel it, and "pause" is a temporary halt so local variables can be examined etc. In all cases, the rest of the application should be active (no wait cursors or modal dialogs!). . The "run" button handler sets a run flag if pressed, and registers the following chore. . The "stop" button handler clears the run and pause flags. . The "pause" button handler sets a pause flag. In the chore: . if run flag is set, call PyRun...() which invokes the following callback for each line. . clear the run flag (because script terminated) In the Python trace callback: . do { . call FXApp::runWhileEvents() . (In this recursive invocation of the event loop, the run and pause flags may be manipulated.) . } while (pause flag) . If the run flag is not set then we throw an exception, otherwise we just return. I'm hoping this will work. Anyone see any problems? Is it best to invoke the event loop from within a chore, or would a normal FOX "onCmd..." handler be OK? Regards, SJH ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Running interpreter from FOXOn Tuesday 26 May 2009, Hardy, Stephen wrote:
> Hi all, > > I need to run Python from a FOX app, and would like to implement a simple debug facility (like single stepping through the Python code and putting breakpoints). Python has a "pdb" class for just this sort of thing. pdb, however, is console-based but I don't want to bother my users with a command-line. > > Python has the ability to invoke a callback function (in C or C++) for each line executed, and several other useful events. Unfortunately, it does not have an easy way of executing line-by-line directly under the caller's control. In other words, one must either return normally from the callback in order to process the next line, or throw an exception in the callback to halt the whole thing. There's no API that can simply be called to execute one (and only one) line. > > The FOX question is this: could I invoke FXApp::runWhileEvents() within the Python trace callback? Considering that the main app loop is already running, is this recursive invocation OK? Reading the documentation, I don't see any reason why not, but it doesn't hurt to ask. > > Here is a more detailed scenario: suppose there is a text widget that has the Python code, and buttons which say "run", "stop" and "pause". "run" starts interpreting the code, and "stop" should always cancel it, and "pause" is a temporary halt so local variables can be examined etc. In all cases, the rest of the application should be active (no wait cursors or modal dialogs!). > > . The "run" button handler sets a run flag if pressed, and registers the following chore. > . The "stop" button handler clears the run and pause flags. > . The "pause" button handler sets a pause flag. > > In the chore: > . if run flag is set, call PyRun...() which invokes the following callback for each line. > . clear the run flag (because script terminated) > > In the Python trace callback: > . do { > . call FXApp::runWhileEvents() > . (In this recursive invocation of the event loop, the run and pause flags may be manipulated.) > . } while (pause flag) > . If the run flag is not set then we throw an exception, otherwise we just return. > > I'm hoping this will work. Anyone see any problems? > > Is it best to invoke the event loop from within a chore, or would a normal FOX "onCmd..." handler be OK? Interleaving Python's exec loop and FOX's event loop seems best. You can use chores, which will basically run some python code whenever there are no immediately pressing events from the GUI. I do suggest to look at other solutions: 1) Make your program multi-threaded. In that case, the python interpreter would run in a separate thread. Interfacing between Python and FOX must be done via FXMessageChannel, of course. 2) Another solution is cooperative task switching AKA coroutines. I believe there are ways to do this, last time I looked. This is like threads, in that each coroutine has its own stack space etc. but unlike threads the coroutines switch instruction steams synchronously, by calling an explicit function to transfer control. Significant advantage of this approach is that no complex synchronization methods are needed for the coroutines to communicate. Look for "portable coroutines" library. If I were to seriously consider something like this I'd look really hard at coroutines or threads... Regards, - Jeroen ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Running interpreter from FOXJeroen,
thanks for the tips. I was looking at coroutines -- that was my first choice since I had experience implementing them in a small embedded system. Unfortunately, the portable implementation (libpcl) requires one to guess the stack size required. Not a good thing for an interpreter, where arbitrary user scripts can be run. Also, libpcl is Unix-only, I think. Threads are also a pain, because one has to design a communication protocol, which makes debugging much more difficult. This application has to be rock-solid (as opposed to high performance), and I'm afraid I don't have time to completely iron out any bugs in a multithreaded application. So, I'll go with the scheme I initially presented which, if it works, has the advantage of not requiring any OS-dependent libraries. Regards, SJH > -----Original Message----- > From: Jeroen van der Zijp [mailto:jeroen@...] > Sent: Tuesday, May 26, 2009 2:45 PM > To: foxgui-users@... > Cc: Hardy, Stephen > Subject: Re: [Foxgui-users] Running interpreter from FOX > > On Tuesday 26 May 2009, Hardy, Stephen wrote: > > Hi all, > > > > I need to run Python from a FOX app, and would like to implement a > simple debug facility (like single stepping through the Python code and > putting breakpoints). Python has a "pdb" class for just this sort of > thing. pdb, however, is console-based but I don't want to bother my > users with a command-line. > > > > Python has the ability to invoke a callback function (in C or C++) > for each line executed, and several other useful events. > Unfortunately, it does not have an easy way of executing line-by-line > directly under the caller's control. In other words, one must either > return normally from the callback in order to process the next line, or > throw an exception in the callback to halt the whole thing. There's no > API that can simply be called to execute one (and only one) line. > > > > The FOX question is this: could I invoke FXApp::runWhileEvents() > within the Python trace callback? Considering that the main app loop > is already running, is this recursive invocation OK? Reading the > documentation, I don't see any reason why not, but it doesn't hurt to > ask. > > > > Here is a more detailed scenario: suppose there is a text widget that > has the Python code, and buttons which say "run", "stop" and "pause". > "run" starts interpreting the code, and "stop" should always cancel it, > and "pause" is a temporary halt so local variables can be examined etc. > In all cases, the rest of the application should be active (no wait > cursors or modal dialogs!). > > > > . The "run" button handler sets a run flag if pressed, and registers > the following chore. > > . The "stop" button handler clears the run and pause flags. > > . The "pause" button handler sets a pause flag. > > > > In the chore: > > . if run flag is set, call PyRun...() which invokes the following > callback for each line. > > . clear the run flag (because script terminated) > > > > In the Python trace callback: > > . do { > > . call FXApp::runWhileEvents() > > . (In this recursive invocation of the event loop, the run and > pause flags may be manipulated.) > > . } while (pause flag) > > . If the run flag is not set then we throw an exception, otherwise we > just return. > > > > I'm hoping this will work. Anyone see any problems? > > > > Is it best to invoke the event loop from within a chore, or would a > normal FOX "onCmd..." handler be OK? > > Interleaving Python's exec loop and FOX's event loop seems best. You > can use chores, which will basically > run some python code whenever there are no immediately pressing events > from the GUI. > > I do suggest to look at other solutions: > > 1) Make your program multi-threaded. In that case, the python > interpreter would run in a separate > thread. > Interfacing between Python and FOX must be done via > FXMessageChannel, of course. > > 2) Another solution is cooperative task switching AKA coroutines. > I believe there are ways to do > this, last time I looked. > This is like threads, in that each coroutine has its own stack > space etc. but unlike threads > the coroutines switch instruction steams synchronously, by > calling an explicit function to > transfer control. > > Significant advantage of this approach is that no complex > synchronization methods are needed > for the coroutines to communicate. > > Look for "portable coroutines" library. > > > If I were to seriously consider something like this I'd look really > hard at coroutines or threads... > > > Regards, > > - Jeroen ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Child windowIt needs to be a child window int the sense that this window's parent/owner is the main window of the app I'm writing.
On Tue, May 26, 2009 at 8:35 AM, Sergey Smirnov <sasmir@...> wrote:
------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Running interpreter from FOXOn Tuesday 26 May 2009, Hardy, Stephen wrote:
> Jeroen, > > thanks for the tips. I was looking at coroutines -- that was my first choice since I had experience implementing them in a small embedded system. Unfortunately, the portable implementation (libpcl) requires one to guess the stack size required. Not a good thing for an interpreter, where arbitrary user scripts can be run. Also, libpcl is Unix-only, I think. > > Threads are also a pain, because one has to design a communication protocol, which makes debugging much more difficult. This application has to be rock-solid (as opposed to high performance), and I'm afraid I don't have time to completely iron out any bugs in a multithreaded application. So, I'll go with the scheme I initially presented which, if it works, has the advantage of not requiring any OS-dependent libraries. Some time ago, I had a similar problem. Note, this was before we had thread support in FOX. My solution then was to put the interpreter read-eval-print loop in charge, and invoke the GUI event loop in the gettoken() routine. This means the user could do anything he wants, but when an input is completed into the interpreter script window then the interpreter resumes control until whatever function the user typed is completed and the interpreter gets back to gettoken(). It all felt very natural. The one tweak you want to add is of course some periodic callback to runWhileEvents() (modal for all windows) so as to keep the GUI fresh, in case the interpreter executes some long-winded function. Regards, - Jeroen ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Child windowOn Tuesday 26 May 2009, n d wrote:
> It needs to be a child window int the sense that this window's parent/owner > is the main window of the app I'm writing. You're not referring to a multiple document interface, by any chance? - Jeroen ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Running interpreter from FOXI tried it last night and it worked very nicely. The only fly in the ointment was not related to FOX, but rather that the Python trace callback does not seem to support throwing a (Python) exception using the usual PyErr...() function. The exception is basically ignored. Thus, I couldn't get my "cancel" function working. Looks like I'll have to pore over the Python source...
One point worthy of note: if the interpreter callback has code as originally proposed i.e. do { runWhileEvents(); } while (paused); then it hogs the CPU in paused mode, since it never gets to block. Change to do { runWhileEvents(); if (paused) runOneEvent(); } while (paused); then it works properly, since runOneEvent() blocks if there are no events. Maybe there's a better way of doing this, but I couldn't see it. I have no problem with runaway Python code, since the callback is invoked for every statement. There would only be a problem if one of the built-in functions blocked for a long time. Fortunately, Python allows built-ins to be overridden, so I could replace all potentially blocking functions with something which allows the GUI to proceed. Since the callback is invoked very frequently, I'm wondering if runWhileEvents() can test for pending events quickly. It would be ideal if it returns very quickly in the common case that there are no events. Otherwise, if it is fairly slow compared with the Python VM executing a piece of code, then I might add some logic to test only once in a hundred callbacks or so. Regards, SJH > > Jeroen, > > > > thanks for the tips. I was looking at coroutines -- that was my > first choice since I had experience implementing them in a small > embedded system. Unfortunately, the portable implementation (libpcl) > requires one to guess the stack size required. Not a good thing for an > interpreter, where arbitrary user scripts can be run. Also, libpcl is > Unix-only, I think. > > > > Threads are also a pain, because one has to design a communication > protocol, which makes debugging much more difficult. This application > has to be rock-solid (as opposed to high performance), and I'm afraid I > don't have time to completely iron out any bugs in a multithreaded > application. So, I'll go with the scheme I initially presented which, > if it works, has the advantage of not requiring any OS-dependent > libraries. > > Some time ago, I had a similar problem. Note, this was before we had > thread support in FOX. > > My solution then was to put the interpreter read-eval-print loop in > charge, and invoke the > GUI event loop in the gettoken() routine. > > This means the user could do anything he wants, but when an input is > completed into the interpreter > script window then the interpreter resumes control until whatever > function the user typed is completed > and the interpreter gets back to gettoken(). > > It all felt very natural. > > The one tweak you want to add is of course some periodic callback to > runWhileEvents() (modal for all > windows) so as to keep the GUI fresh, in case the interpreter executes > some long-winded function. > > > Regards, > > > > - Jeroen > ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Child windowUnfortunately no. I suppose a good analogy would be like how a chat window for an IM client (like pidgin) is a child to the buddy list.
On Wed, May 27, 2009 at 10:17 AM, Jeroen van der Zijp <jeroen@...> wrote:
------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
| Free embeddable forum powered by Nabble | Forum Help |