On Wednesday, April 3, 2019 at 3:13:43 PM UTC-7, Yagamy Light wrote:
>
>
>
> On Wednesday, 3 April 2019 22:42:15 UTC+3, Samuel Lelievre wrote:
>>
>>
>>
>> Le mercredi 3 avril 2019 17:43:51 UTC+2, Yagamy Light a écrit :
>>>
>>> # Steps to reproduce (in terms of terminal comands:
>>>
>>>     $ cat sagemath_test.sage
>>>     plot(graphs.HeawoodGraph())
>>>     $ sage
>>>     
>>> ┌────────────────────────────────────────────────────────────────────┐
>>>     │ SageMath version 8.7, Release Date: 2019-03-23                    
>>>  │
>>>     │ Using Python 2.7.16. Type "help()" for help.                      
>>>  │
>>>     
>>> └────────────────────────────────────────────────────────────────────┘
>>>     sage: load("sagemath_test.sage")
>>>
>>> ## Expected
>>>
>>> A PNG viewer gets launched
>>>
>>> ## Actual
>>>
>>> Nothing happens.
>>>
>>> # Additional information
>>>
>>> I fond it as part of this problem 
>>> https://ask.sagemath.org/question/46004/evaluate-py-file/ It seems to 
>>> stuck in moderation, but basically: I spent some hours trying to figure out 
>>> how to get sage to draw a graph in a browser (similar to examples from 
>>> https://wiki.sagemath.org/interact/graph_theory), so far to no avail.
>>>
>>
>> Try changing your file to contain this instead:
>>
>> graphs.HeawoodGraph().plot().show()
>>
>
> Thanks for the workaround, I'll try tomorrow!
>
> While on it: as I understand this gonna show the plot in default PNG 
> viewer, right? However if I want to code an interactive app, such as any of 
> examples at [1], I need sage to open it in a browser, right? How do I 
> achieve that?
>
> 1:  https://wiki.sagemath.org/interact/graph_theory
>

Sage's "interacts" are available if you run Sage in its notebook interface: 
run "sage -n jupyter", and then you can for example paste the following 
code into a cell in the notebook:

@interact
def _(graph=['CycleGraph', 'CubeGraph', 'RandomGNP'],
      n=selector([1..10],nrows=1), p=selector([10,20,..,100],nrows=1)):
    print graph
    if graph == 'CycleGraph':
       print "n = %s (number of vertices)"%n
       G = graphs.CycleGraph(n)
    elif graph == 'CubeGraph':
       if n > 8:
           print "n reduced to 8"
           n = 8
       print "n = %s (dimension)"%n
       G = graphs.CubeGraph(n)
    elif graph == 'RandomGNP':
       print "n = %s (number of vertices)"%n
       print "p = %s%% (edge probability)"%p
       G = graphs.RandomGNP(n, p/100.0)
    print G.automorphism_group()
    show(plot(G))

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to