3
$\begingroup$

Using MMA 12.2

MMA offers a very nice table associated with each of the planets. Here is the code as an example:

Entity["Planet", "Neptune"]["Dataset"]

Here is the table it produces:

enter image description here

What I want to accomplish is:

  • Create checkboxes for each of the planets
  • All blank initially
  • Upon having one 'checked', it launches the code that produces the table (above)
  • Further, have secondary selections either overwrite the first or delete it and load the new one

This does not HAVE to be done using checkboxes. It seemed low-profile in appearance and the first thing that came to my mind.

Here is what I have thus far:

DynamicModule[{selectedPlanet = None}, 
Column[{CheckboxBar[
Dynamic[selectedPlanet], {"Saturn", "Mars", "Neptune"}], 
Button["Open Dataset", 
If[selectedPlanet === None, 
MessageDialog["Please select a planet."], 
Entity["Planet", selectedPlanet]["Dataset"] // Print], 
Method -> "Queued"]}]]

It works. It is not very appealing, but the table it brings up is void of any data other than the row 'headings'.

Here is the checkbox:

enter image description here

Here is the table:

enter image description here

I am stuck.

$\endgroup$
3
  • 1
    $\begingroup$ Entity["Planet", selectedPlanet[[1]]]["Dataset"] seems to work. $\endgroup$
    – Rabbit
    Feb 27 at 22:32
  • $\begingroup$ @Rabbit - Yes, that works, and thanks, but do you why? What is that extra bit of code doing? $\endgroup$
    – fiz
    Feb 27 at 22:56
  • $\begingroup$ @Rabbit - Put your answer up. Will chose this. $\endgroup$
    – fiz
    Feb 27 at 23:06

1 Answer 1

3
$\begingroup$

Entity["Planet", selectedPlanet[[1]]]["Dataset"] instead of Entity["Planet", selectedPlanet]["Dataset"] The value of "selectedPlanet" is, for example, {Mars}, that is, a list. By adding the Part specification, we get Mars - not a list.

$\endgroup$
3
  • $\begingroup$ Ok, I'll look at that specifically. Maybe I can advance my understanding some. Than you again. Sure appreciate it as I have spent a lot of time trying to get this to work. $\endgroup$
    – fiz
    Feb 27 at 23:47
  • 1
    $\begingroup$ @fiz Thank you for the accept. $\endgroup$
    – Rabbit
    Feb 27 at 23:53
  • $\begingroup$ No problem, you got it! $\endgroup$
    – fiz
    Feb 27 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.