Prev: Writing a graphic to a notebook, cont
Next: Can't figure out how to include syntax coloring in Printout
From: Harrie Kraai on 6 Nov 2009 05:15 Hi there, I would like to write monitoring applications in Mathematica using Dynamic(Module) and Refresh, etc. An example is monitoring an RSS feed. I would like the interface to stay responsive, hence a simple Module with an infinite loop or something would not work. The "problem" with Dynamic constructs is that they are too "smart". They stop updating when they are not visible anymore. Of course in many/most cases that is a great feature. But not for monitoring. I would like the monitoring application to attract my attention while I am working on something else. The following graphic can be used for one hour to check whether the updating continues or not: panel = Table[Blue, {60}, {60}]; Dynamic[Refresh[dl = DateList[]; panel[[dl[[-2]] + 1, (dl[[-1]] // Floor) + 1]] = Red; ArrayPlot(a)panel, UpdateInterval -> 0.5, TrackedSymbols -> {}]] Scrolling the panel out of sight for a couple of seconds yields gaps in the Red trail. It would be very useful if I could force the Dynamic to keep on updating. Anyone an idea how to do this? (An option in Dynamic would be very helpful of course). HK
From: David Bailey on 7 Nov 2009 06:42 Harrie Kraai wrote: > Hi there, > > I would like to write monitoring applications in Mathematica using > Dynamic(Module) and Refresh, etc. An example is monitoring an RSS feed. > I would like the interface to stay responsive, hence a simple Module > with an infinite loop or something would not work. > > The "problem" with Dynamic constructs is that they are too "smart". They > stop updating when they are not visible anymore. Of course in > many/most cases that is a great feature. But not for monitoring. I would > like the monitoring application to attract my attention while I am > working on something else. > > The following graphic can be used for one hour to check whether the > updating continues or not: > > panel = Table[Blue, {60}, {60}]; > Dynamic[Refresh[dl = DateList[]; > panel[[dl[[-2]] + 1, (dl[[-1]] // Floor) + 1]] = Red; > ArrayPlot(a)panel, UpdateInterval -> 0.5, TrackedSymbols -> {}]] > > Scrolling the panel out of sight for a couple of seconds yields gaps in > the Red trail. > > It would be very useful if I could force the Dynamic to keep on updating. > Anyone an idea how to do this? (An option in Dynamic would be very > helpful of course). > > HK > I would create some controls, and then enter the infinite loop which you described and rejected. The loop can interrogate the RSS feed (maybe using Pause, to prevent the loop being a CPU hog). Your controls can set variables, e.g: Button["Stop",readyToFinish=True] The variables can be interrogated from within your loop and the appropriate action taken. Responding to interface requests from within the main loop also avoids tricky, hard to reproduce timing bugs that arise when a dynamic calculation happens to occur at an inconvenient point in the main task. David Bailey http://www.dbaileyconsultancy.co.uk
From: John Fultz on 7 Nov 2009 06:46
Dynamic simply does not work this way and probably never will. Dynamic is inherently about a computation updating part of the screen, not a computation which updates periodically. There is a function which might help, though. The documentation discusses a function in the JLink` context called AddPeriodical, and related functions for dealing with Periodical tasks. All of these functions also live in the Internal` context (with, I believe, the same syntax, but don't quote me on that), so you wouldn't necessarily have to load JLink`. You could still use a Dynamic to show the updated results of a periodical evaluation, of course. In this case, the Dynamic wouldn't do the real work, but just show results as they are updated. Sincerely, John Fultz jfultz(a)wolfram.com User Interface Group Wolfram Research, Inc. On Fri, 6 Nov 2009 05:17:29 -0500 (EST), Harrie Kraai wrote: > Hi there, > > I would like to write monitoring applications in Mathematica using > Dynamic(Module) and Refresh, etc. An example is monitoring an RSS feed. > I would like the interface to stay responsive, hence a simple Module > with an infinite loop or something would not work. > > The "problem" with Dynamic constructs is that they are too "smart". They > stop updating when they are not visible anymore. Of course in > many/most cases that is a great feature. But not for monitoring. I would > like the monitoring application to attract my attention while I am > working on something else. > > The following graphic can be used for one hour to check whether the > updating continues or not: > > panel = Table[Blue, {60}, {60}]; > Dynamic[Refresh[dl = DateList[]; > panel[[dl[[-2]] + 1, (dl[[-1]] // Floor) + 1]] = Red; > ArrayPlot(a)panel, UpdateInterval -> 0.5, TrackedSymbols -> {}]] > > Scrolling the panel out of sight for a couple of seconds yields gaps in > the Red trail. > > It would be very useful if I could force the Dynamic to keep on updating. > Anyone an idea how to do this? (An option in Dynamic would be very > helpful of course). > > HK |