2

I have a such custom function:

MyCopy := DynamicModule[{from, to},
  Print@Grid[{{FileNameSetter[Dynamic[from], "Directory"], 
      Dynamic[from]}, {FileNameSetter[Dynamic[to], "Directory"], 
      Dynamic[to]}}, Alignment -> {Left}];
  Column[{Dynamic[from], Dynamic[to]}]]

Why my Column[{Dynamic[from], Dynamic[to]}]] doesn't work?

yode
  • 26,686
  • 4
  • 62
  • 167
  • What is the expected behaviour? – Feyre Dec 22 '16 at 14:49
  • @Feyre When I change my directory,the Column[{Dynamic[from], Dynamic[to]}]] will change too. – yode Dec 22 '16 at 14:51
  • 1
    DynamicModule is a "rectangle on a screen", by using Print you are throwing stuff away from that rectangle before the scoping procedure is finished. You can combine Grid and Column with another Column. Or you can Print from Initialization but you need to add DynamicModule[{}, Grid..., InheritScope -> True]. – Kuba Dec 22 '16 at 14:53
  • The real question is what is the flow you are trying to achieve? What do you want the user to see and when. – Kuba Dec 22 '16 at 14:56
  • 1
    p.s. must read: tutorial/AdvancedDynamicFunctionality – Kuba Dec 22 '16 at 14:56
  • Have to agree with @Kuba, I think that's one of the most useful tutorials available to a Mathematica user (as well as tutorial/AdvancedManipulateFunctionality) – ktm Dec 22 '16 at 15:10
  • @yode so, what would you like at achieve at the end? What exactly should happen? – Kuba Dec 22 '16 at 21:00
  • @Kuba this is what I want exactly,MyCopy1 := DynamicModule[{f}, DynamicModule[{from, to}, Print@{FileNameSetter[Dynamic[from], "Directory"], f = Dynamic[from]}; Dynamic[f]]],the last Dynamic[f] will take effect.But I don't know,why MyCopy2:=DynamicModule[{f},DynamicModule[{from,to},Print@{FileNameSetter[Dynamic[from],"Directory"],f=Dynamic[from]}; FileNames["*",Dynamic[f]]]] will don't work still,confusing very much. – yode Dec 22 '16 at 23:02
  • @yode I'm not asking what code you want. I'm asking what do you want the user to see, what should happen and when/after what user action. – Kuba Dec 23 '16 at 07:17

0 Answers0