-
Notifications
You must be signed in to change notification settings - Fork 0
/
GTK_gui.py
761 lines (605 loc) · 26.1 KB
/
GTK_gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pygtk
pygtk.require('2.0')
import gtk
import gobject
import pydot
(COLUMN_DEGREE, COLUMN_DIMENSION) = range(2)
(COLUMN_ROOT, COLUMN_QFF, COLUMN_ORDER) = range(3)
from mainapp import *
from sys import argv
DESCRIPTION = ('Arithmetic Root system')
AUTHORS = [ "MatÃas Graña <matiasg@dm.uba.ar>", \
"István Heckenberger <Istvan.Heckenberger@math.uni-leipzig.de>", \
"Leandro Vendramin <lvendramin@dm.uba.ar>"]
LICENSE = '''
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
class GTKApplication:
ui = '''<ui>
<menubar name="MenuBar">
<menu action="File">
<menuitem action="New"/>
<menuitem action="Open"/>
<separator/>
<menuitem action="Quit"/>
</menu>
<menu action="Gnuplot">
<menuitem action="Show simple roots"/>
<menuitem action="Show arrows"/>
<separator/>
<menuitem action="Redraw"/>
<menuitem action="Save Gnuplot file"/>
<menuitem action="Enter Gnuplot command"/>
</menu>
<menu action="Ars">
<menuitem action="View braid"/>
<separator/>
<menuitem action="Change current basis"/>
<menuitem action="Reflect on a simple root"/>
<menuitem action="Show roots"/>
<menuitem action="Show roots f and qff"/>
<menuitem action="Show Dynkin diagram"/>
<separator/>
</menu>
<menu action="Nichols algebra">
<menuitem action="Dimension"/>
<menuitem action="Dimension table"/>
<menuitem action="GK dimension"/>
<separator/>
<menuitem action="Hilbert series"/>
<separator/>
<menuitem action="Truncate degree"/>
</menu>
<menu action="Help">
<menuitem action="About"/>
</menu>
</menubar>
</ui>'''
def __init__(self):
""" Create the toplevel window """
window = gtk.Window()
window.set_title('Arithmetic Root Systems')
window.connect('destroy', lambda w: gtk.main_quit())
window.set_size_request(500, -1)
window.set_resizable(False)
vbox = gtk.VBox()
window.add(vbox)
# Globals
self.filename = None
self.about_dialog = None
self.command_dialog = None
self.truncate = 0
# Create a UIManager instance
uimanager = gtk.UIManager()
uimanager.set_add_tearoffs(True)
# Add the accelerator group to the toplevel window
accelgroup = uimanager.get_accel_group()
window.add_accel_group(accelgroup)
# Create an ActionGroup
actiongroup = gtk.ActionGroup('UIManageExample')
self.actiongroup = actiongroup
# Create a ToggleAction, etc.
actiongroup.add_toggle_actions([\
('Show simple roots', None, '_Show simple roots', '<Control>s', 'Show simple roots', self.toggle_gnuplot_showsimples, True),
('Show arrows', None, 'Show _arrows', '<Control>a', None, self.toggle_gnuplot_showarrows)])
# ('Open Gnuplot window', None, '_Open Gnuplot window', '<Control>o', None, self.toggle_gnuplotwindow, False)])
# Create actions
actiongroup.add_actions([('File', None, '_File'),
('New', gtk.STOCK_NEW, '_New'),
('Open', gtk.STOCK_OPEN, '_Open', '<Control>O', None, self.openfile),
('Quit', gtk.STOCK_QUIT, '_Quit me!', '<Control>Q', None, self.quit_cb),
('Gnuplot', None, '_Gnuplot'),
('Redraw', None, '_Redraw', None, None),
('Save Gnuplot file', None, '_Save Gnuplot file'),
('Enter Gnuplot command', None, 'Enter Gnuplot _command', None, None, self.enter_command),
('Ars', None, '_Ars'),
('View braid', None, '_View braid', None, None, self.view_braid),
('Change current basis', None, 'Change current _basis', None, None, self.change_basis),
('Reflect on a simple root', None, 'Reflect on a s_imple root', None, None, self.reflect_simple),
('Show roots', None, 'Show _roots', None, None, self.view_roots),
('Show roots f and qff', None, 'Show roots _f and qff', None, None, self.view_roots_f),
('Show Dynkin diagram', None, 'Show _Dynkin diagram', None, None, self.view_dynkin_diagram),
('Nichols algebra', None, '_Nichols algebra'),
('Dimension', None, '_Dimension', None, None, self.view_dimension),
('Dimension table', None, 'Dimension _table', None, None, self.view_dimension_table),
('GK dimension', None, '_GK dimension', None, None, self.view_GK_dimension),
('Hilbert series', None, '_Hibert series', None, None, self.view_hilbert_series),
('Truncate degree', None, '_Truncate degree', None, None, self.change_truncate_degree),
('Help', None, '_Help'),
('About', gtk.STOCK_ABOUT, '_About', None, None, self.about)
])
uimanager.insert_action_group(actiongroup, 0)
# Add a UI description
uimanager.add_ui_from_string(self.ui)
# Create a MenuBar
menubar = uimanager.get_widget('/MenuBar')
vbox.pack_start(menubar, False)
separator = gtk.HSeparator()
vbox.pack_start(separator, expand=False)
# Create the expander
expander = gtk.Expander("Details")
vbox.pack_start(expander, False, False, 0)
# Open file if called with a file name
if len(argv) > 1:
try:
ffdummy = open(argv[1], 'r');
ffdummy.close()
self.filename = argv[1]
label = gtk.Label(self.filename)
except:
print 'File error: can\'t open file',argv[1];
label = gtk.Label('No file loaded!')
else:
label = gtk.Label('No file loaded!')
expander.add(label)
#expander.connect('notify::expanded',self.__update_expander)
#vbox.pack_start(label)
self.filelabel = label
separator = gtk.HSeparator()
vbox.pack_start(separator, expand=False)
#buttonbox = gtk.HButtonBox()
gnuplotwindow = gtk.CheckButton('Gnuplot Window')
self.gpcheckb = gnuplotwindow
gnuplotwindow.set_active(False)
self.gpid = None
#buttonbox.pack_start(gnuplotwindow, False)
vbox.pack_start(gnuplotwindow)
# again, we set the filename
if self.filename <> None:
self.__aftersettingfilename(mustupdate=False)
# No braid file, no menu
self.actiongroup.get_action('Gnuplot').set_sensitive(self.filename<>None)
self.actiongroup.get_action('Ars').set_sensitive(self.filename<>None)
self.actiongroup.get_action('Nichols algebra').set_sensitive(self.filename<>None)
window.show_all()
return
def enter_command(self, action):
""" Enter a gnuplot command """
if self.command_dialog:
self.command_dialog.present()
return
dialog = gtk.Window(gtk.WINDOW_TOPLEVEL)
dialog.set_size_request(300, 50)
dialog.set_title("Gnuplot command")
dialog.connect("delete_event", self.__command_response)
vbox = gtk.VBox(False, 0)
dialog.add(vbox)
vbox.show()
entry = gtk.Entry()
entry.set_max_length(50)
entry.connect("activate", self.__command_entercallback, entry)
entry.set_text("enter your command here")
entry.select_region(0, len(entry.get_text()))
vbox.pack_start(entry, True, True, 0)
entry.show()
hbox = gtk.HBox(False, 0)
vbox.add(hbox)
hbox.show()
check = gtk.CheckButton("Redraw")
hbox.pack_start(check, False)
check.connect("toggled", self.__command_redraw, entry)
check.set_active(True)
check.show()
dialog.show()
self.command_dialog = dialog
def __command_response(self, dialog, response):
self.command_dialog.destroy()
self.command_dialog = None
def __command_redraw(self, checkbutton, entry):
""" for redraw """
if checkbutton.get_active():
print 'on!';
def __command_entercallback(self, widget, entry):
""" for enter gnuplot command """
not_valid = ['quit', 'reset']
if entry.get_text() not in not_valid:
self.__app.GnuplotWindow(entry.get_text())
self.__app.draw()
def openfile(self, action):
""" GTK open file dialog """
dialog = gtk.FileChooserDialog(title="Open ARS file")
dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
dialog.add_button(gtk.STOCK_OPEN, gtk.RESPONSE_OK)
filter = gtk.FileFilter()
filter.set_name("ARS files (*.ars)")
filter.add_pattern("*.ars")
dialog.add_filter(filter)
filter = gtk.FileFilter()
filter.set_name('All Files')
filter.add_pattern('*')
dialog.add_filter(filter)
result = dialog.run()
dialog.hide()
if result == gtk.RESPONSE_OK:
self.filename = dialog.get_filename()
print self.filename
self.__aftersettingfilename()
dialog.destroy()
def __aftersettingfilename(self, mustupdate=True):
self.__app = MainApp(self.filename, True)
if mustupdate:
self.__update_information()
if self.__app.Groupoid.Rank==2 or self.__app.Groupoid.Rank==3:
self.actiongroup.get_action('Gnuplot').set_sensitive(True)
self.gpcheckb.set_active(True)
self.gpid = self.gpcheckb.connect('toggled', self.toggle_gnuplotwindow)
self.__app.draw()
else:
self.actiongroup.get_action('Gnuplot').set_sensitive(False)
self.gpcheckb.set_active(False)
if not self.gpid == None:
self.gpcheckb.disconnect(self.gpid)
self.gpid = None
self.actiongroup.get_action('Ars').set_sensitive(True)
self.actiongroup.get_action('Nichols algebra').set_sensitive(True)
def view_GK_dimension(self, action):
""" GK dimension """
i = self.__app.Nichols.GKdim()
dialog = gtk.MessageDialog(None,\
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
gtk.MESSAGE_INFO, gtk.BUTTONS_OK,\
"The GK-dimension of the Nichols algebra is %s" % i)
dialog.run()
dialog.destroy()
def view_dimension(self, action):
""" The dimension of the Nichols algebra """
i = self.__app.Nichols.dimension()
if i == 0:
i = 'infinite'
else:
i = str(i)
dialog = gtk.MessageDialog(None,\
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,\
gtk.MESSAGE_INFO, gtk.BUTTONS_OK,\
"The dimension of the Nichols algebra is %s" % i)
dialog.run()
dialog.destroy()
def view_dynkin_diagram(self, action):
"""
Draw the generalized Dynkin diagram associated to the current basis
"""
# TODO:
# 1) dialog to save jpeg file
# 2) better managment of temporary file
nq = self.__app.Groupoid.braid_for_basis(self.__app.Groupoid.Bases[self.__app.Groupoid.CurrentBasis])
nq = triang(self.__app.Groupoid.NumberOfParameters,nq,self.__app.Groupoid.Order)
edges = []
for i in xrange(self.__app.Groupoid.Rank):
edges.append((i+1,i+1))
for j in xrange(i+1,self.__app.Groupoid.Rank):
if notone(self.__app.Groupoid.NumberOfParameters, nq[i][j], self.__app.Groupoid.Order):
edges.append((i+1,j+1))
jpeg=pydot.graph_from_edges(edges)
for i in xrange(self.__app.Groupoid.Rank):
ei = jpeg.get_edge(str(i+1),str(i+1))
ei.set('headlabel',nq[i][i])
ei.set('color','transparent')
for j in xrange(i+1,self.__app.Groupoid.Rank):
try:
eij = jpeg.get_edge(str(i+1),str(j+1))
eij.set_label(nq[i][j])
except:
pass
nl = jpeg.get_node_list()
for n in nl:
n.set('style','filled')
n.set('fillcolor','red')
n.set('shape','circle')
n.set('fixedsize','true')
n.set('width',.3)
jpeg.write_jpeg('dynkin.jpg', prog='neato')
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title('Dynkin diagram')
window.set_resizable(False)
window.set_border_width(10)
vbox = gtk.VBox(False, 0)
window.add(vbox)
vbox.show()
image = gtk.Image()
image.set_from_file("dynkin.jpg")
image.show()
vbox.pack_end(image, True, True, 2)
window.show()
def view_dimension_table(self, action):
""" Open a dialog with the dimension table """
print self.truncate
i = self.__app.Nichols.dimension()
if (i > 0) or (self.truncate > 0):
dt = self.__app.Nichols.hilberttable(self.truncate)
data = []
if (len(dt) > 0):
for j in xrange(len(dt)):
data.append([j,dt[j]])
else:
return
dialog = gtk.Window(gtk.WINDOW_TOPLEVEL)
dialog.set_resizable(True)
dialog.set_title('Dimension table')
dialog.set_default_size(300,200)
dialog.set_border_width(8)
vbox = gtk.VBox(False, 8)
dialog.add(vbox)
if i == 0:
i = 'infinite'
else:
i = str(i)
label = gtk.Label('The dimension of the Nichols algebra is %s'%i)
vbox.pack_start(label, False, False)
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
vbox.pack_start(sw)
# Create the model
model = gtk.ListStore(gobject.TYPE_UINT, gobject.TYPE_UINT)
for item in data:
iter = model.append()
model.set(iter, COLUMN_DEGREE, item[COLUMN_DEGREE], COLUMN_DIMENSION, item[COLUMN_DIMENSION])
treeview = gtk.TreeView(model)
treeview.set_rules_hint(True)
sw.add(treeview)
# For the rank
column = gtk.TreeViewColumn('Degree', gtk.CellRendererText(), text=COLUMN_DEGREE)
column.set_sort_column_id(COLUMN_DEGREE)
treeview.append_column(column)
# For the dimension
column = gtk.TreeViewColumn('Dimension', gtk.CellRendererText(), text=COLUMN_DIMENSION)
column.set_sort_column_id(COLUMN_DIMENSION)
treeview.append_column(column)
statusbar = gtk.Statusbar()
vbox.pack_start(statusbar, False, False, 0)
statusbar.push(0, 'Top degree: %d'%(len(dt)-1))
statusbar.show()
dialog.show_all()
def change_basis(self, action):
""" Dialog to change the current basis """
dialog = gtk.Window()
dialog.set_title('Change the current basis')
dialog.set_resizable(False)
dialog.set_border_width(8)
vbox = gtk.VBox(False, 8)
dialog.add(vbox)
label = gtk.Label('There are %d bases'%len(self.__app.Groupoid.Bases))
vbox.pack_start(label, False, False)
combobox = gtk.ComboBox()
liststore = gtk.ListStore(str)
cell = gtk.CellRendererText()
combobox.pack_start(cell)
combobox.add_attribute(cell, 'text', 0)
vbox.add(combobox)
combobox.set_wrap_width(4)
for n in xrange(len(self.__app.Groupoid.Bases)):
liststore.append(['%s'%self.__app.Groupoid.Bases[n]])
combobox.set_model(liststore)
combobox.connect('changed', self.__changed)
combobox.set_active(0)
dialog.show_all()
def __changed(self, combobox):
""" When a basis is selected we have to recalculate all the roots """
model = combobox.get_model()
index = combobox.get_active()
if index > -1:
self.__app.Groupoid.change_basis(index)
self.__update_information()
self.__app.draw()
def __changed_trun(self, combobox):
""" change degree truncation, poor man option """
index = combobox.get_active()
self.truncate = index
def __reflect(self, combobox,dialog):
""" After reflection on a root we have to recalculate all the roots """
model = combobox.get_model()
index = combobox.get_active()
if index > -1:
self.__app.Groupoid.apply_reflection(index)
self.__update_information()
self.__app.draw()
dialog.destroy()
def reflect_simple(self, action):
""" Dialog to reflect on a simple root """
dialog = gtk.Window(gtk.WINDOW_TOPLEVEL)
dialog.set_title('Choose!')
dialog.set_resizable(False)
dialog.set_border_width(8)
vbox = gtk.VBox(False, 8)
dialog.add(vbox)
label = gtk.Label('There are %d simple roots.'%self.__app.Groupoid.Rank)
vbox.pack_start(label, False, False, 0)
combobox = gtk.ComboBox()
liststore = gtk.ListStore(str)
cell = gtk.CellRendererText()
combobox.pack_start(cell)
combobox.add_attribute(cell, 'text', 0)
vbox.add(combobox)
# combobox.set_wrap_width(4)
for n in range(self.__app.Groupoid.Rank):
liststore.append(str(n+1))
combobox.set_model(liststore)
combobox.connect('changed', self.__reflect,dialog)
combobox.set_active(-1)
dialog.show_all()
def view_hilbert_series(self, action):
""" Open a dialog with the Hilbert series """
tmp = ""
hs = self.__app.Nichols.hilbertseries(True);
for i in xrange(len(hs)-1):
tmp = tmp + hs[i]
self.__view_text('Hilbert series', tmp)
def change_truncate_degree(self, action):
""" Open a window to set degree truncation """
dialog = gtk.Window()
dialog.set_title('Change degree truncation')
dialog.set_resizable(False)
dialog.set_border_width(8)
vbox = gtk.VBox(False, 8)
dialog.add(vbox)
label = gtk.Label('Change it!')
vbox.pack_start(label, False, False)
combobox = gtk.ComboBox()
liststore = gtk.ListStore(str)
cell = gtk.CellRendererText()
combobox.pack_start(cell)
combobox.add_attribute(cell, 'text', 0)
vbox.add(combobox)
combobox.set_wrap_width(4)
for n in xrange(18):
liststore.append(['%s'%n])
combobox.set_model(liststore)
combobox.connect('changed', self.__changed_trun)
combobox.set_active(0)
dialog.show_all()
def view_roots(self, action):
""" Open a dialog with positive and negative roots of the Weyl groupoid """
tmp = 'Current basis:\n'%self.__app.Groupoid.Bases[self.__app.Groupoid.CurrentBasis]
tmp = tmp + 'Positive Roots:\n'
for v in self.__app.Groupoid.PosRoots:
tmp = tmp + '%s\n'%v
tmp = tmp + '\nNegative Roots:\n'
for v in self.__app.Groupoid.NegRoots:
tmp = tmp + '%s\n'%v
self.__view_text('Roots', tmp, 'Current basis: %s'%self.__app.Groupoid.Bases[self.__app.Groupoid.CurrentBasis])
def view_roots_f(self, action):
""" Open a dialog with positive roots f and braiding q_ff of the Weyl groupoid """
data = self.__app.Nichols.roots_coefs()
#data = [['root','q_ff','order']] + rtsqs
#tmp = '%16s %10s %5s\n' % ('root','q_ff','order') + '='*33
#for i in rtsqs:
# tmp = tmp + '\n%16s %10s %5d' % (i[0],i[1],i[2])
#self.__view_text('Roots', tmp, 'Current basis: %s'%self.__app.Groupoid.Bases[self.__app.Groupoid.CurrentBasis])
dialog = gtk.Window(gtk.WINDOW_TOPLEVEL)
dialog.set_resizable(True)
dialog.set_title('Roots and orders')
dialog.set_default_size(300,200)
dialog.set_border_width(8)
vbox = gtk.VBox(False, 8)
dialog.add(vbox)
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
vbox.pack_start(sw)
# Create the model
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_UINT)
for item in data:
iter = model.append()
model.set(iter, COLUMN_ROOT, item[COLUMN_ROOT], COLUMN_QFF, item[COLUMN_QFF], COLUMN_ORDER, item[COLUMN_ORDER])
treeview = gtk.TreeView(model)
treeview.set_rules_hint(True)
sw.add(treeview)
# For the roots
column = gtk.TreeViewColumn('root', gtk.CellRendererText(), text=COLUMN_ROOT)
column.set_sort_column_id(COLUMN_ROOT)
treeview.append_column(column)
# For the braid
column = gtk.TreeViewColumn('q_ff', gtk.CellRendererText(), text=COLUMN_QFF)
column.set_sort_column_id(COLUMN_QFF)
treeview.append_column(column)
# For the order
column = gtk.TreeViewColumn('order', gtk.CellRendererText(), text=COLUMN_ORDER)
column.set_sort_column_id(COLUMN_ORDER)
treeview.append_column(column)
statusbar = gtk.Statusbar()
vbox.pack_start(statusbar, False, False, 0)
statusbar.push(0, 'Current basis:')
statusbar.push(1, '%s'%self.__app.Groupoid.Bases[self.__app.Groupoid.CurrentBasis])
statusbar.show()
dialog.show_all()
def view_braid(self, action):
""" Open a dialog with the braid data """
self.__view_text('Braid', self.__app.FileData, 'File: %s'%self.filename)
def about(self, action):
""" The about dialog """
if self.about_dialog:
self.about_dialog.present()
return
about = gtk.AboutDialog()
about.set_name("Arithmetic Root Systems")
#about.set_copyright("copyright")
about.set_authors(AUTHORS)
about.set_license(LICENSE)
about.set_comments('Weyl Groupoids and Nichols Algebras')
about.set_website("http://buggies.dm.uba.ar/ars/")
about.connect ("response", self.about_response)
about.show()
self.about_dialog = about
def about_response(self, dialog, response):
self.about_dialog.destroy()
self.about_dialog = None
def toggle_gnuplot_showarrows(self, action):
""" To toggle ShowArrows (show arrows) """
self.__app.change_option('ShowArrows')
self.__app.draw()
def toggle_gnuplot_showsimples(self, action):
""" To toggle ShowSimples (show simple roots) """
self.__app.change_option('ShowSimples')
self.__app.draw()
def toggle_gnuplotwindow(self, action):
""" To toggle OpenGnuplotWindow (open a gnuplot window?) """
self.__app.change_option('OpenGnuplotWindow')
if not self.__app.Options['OpenGnuplotWindow']:
self.actiongroup.get_action('Gnuplot').set_sensitive(False)
self.__app.GnuplotWindow('quit')
self.__app.GnuplotWindow = Gnuplot()
else:
self.actiongroup.get_action('Gnuplot').set_sensitive(True)
self.__app.draw()
def __view_text(self, title, buffer, sb=None):
""" To show text in a dialog box """
dialog = gtk.Window(gtk.WINDOW_TOPLEVEL)
dialog.set_resizable(True)
dialog.set_title(title)
dialog.set_default_size(200,200)
box1 = gtk.VBox(False, 10)
dialog.add(box1)
box1.show()
box2 = gtk.VBox(False, 10)
box2.set_border_width(0)
box1.pack_start(box2, True, True, 0)
box2.show()
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
textview = gtk.TextView()
textview.set_editable(False)
textview.set_cursor_visible(False)
textbuffer = textview.get_buffer()
sw.add(textview)
sw.show()
textview.show()
box2.pack_start(sw)
textbuffer.set_text(buffer)
if sb is not None:
statusbar = gtk.Statusbar()
box1.pack_start(statusbar, False, False, 0)
statusbar.push(0, sb)
statusbar.show()
dialog.show()
# def __update_expander(self,expander,params):
# self.__update_information()
# return
def __update_information(self):
""" The information of the expander box """
if self.filename == None:
label = gtk.Label('No braid file loaded')
else:
txt = 'Braid file: ' + self.filename + '\n'
txt += 'Rank: ' + str(self.__app.Groupoid.Rank) + '\n'
txt += 'Current Basis: ' + str(self.__app.Groupoid.Bases[self.__app.Groupoid.CurrentBasis])
self.filelabel.set_text(txt)
return
def quit_cb(self, b):
print 'Quitting program'
gtk.main_quit()
if __name__ == '__main__':
ba = GTKApplication()
gtk.main()
# vim:ts=4:sw=4:fenc=UTF-8: