@@ -105,16 +105,18 @@ def on_leave(self):
105
105
106
106
class CustomPopup (pup .Popup ):
107
107
108
- def __init__ (self , root , ** kwargs ):
108
+ def __init__ (self , root , catch_keyboard = True , ** kwargs ):
109
109
self .root = root
110
+ self .catch_keyboard = catch_keyboard
110
111
self .bind (on_open = self .open_callback )
111
112
self .bind (on_dismiss = self .dismiss_callback )
112
113
super (CustomPopup , self ).__init__ (** kwargs )
113
114
114
115
def open_callback (self , instance ):
115
116
print 'exec'
116
117
#self.root._keyboard.unbind(on_key_down=self.root._on_keyboard_down)
117
- self .root ._keyboard_release ()
118
+ if self .catch_keyboard :
119
+ self .root ._keyboard_release ()
118
120
#print('User focused', instance)
119
121
120
122
def dismiss_callback (self , instance ):
@@ -126,7 +128,8 @@ def dismiss_callback(self, instance):
126
128
# super(TextWidget, self).hide_keyboard()
127
129
128
130
#self.root._keyboard.bind(on_key_down=self.root._on_keyboard_down)
129
- self .root ._keyboard_catch ()
131
+ if self .catch_keyboard :
132
+ self .root ._keyboard_catch ()
130
133
#print('User defocused', instance)
131
134
132
135
class LoadDialog (fl .FloatLayout ):
@@ -599,8 +602,8 @@ def show_export(self):
599
602
600
603
def show_error (self , err_str ):
601
604
content = ErrorDialog (err_str , cancel = self .dismiss_popup )
602
- self ._popup = CustomPopup (self , title = "Error" , content = content ,
603
- size_hint = (0.4 , 0.3 ))
605
+ self ._popup = CustomPopup (self , catch_keyboard = False , title = "Error" ,
606
+ content = content , size_hint = (0.4 , 0.3 ))
604
607
self ._popup .open ()
605
608
606
609
def show_about (self ):
@@ -658,7 +661,7 @@ def load(self, path, filename):
658
661
self .dismiss_popup ()
659
662
self .close_graph ()
660
663
self .new_graph ()
661
- self .show_error ('ERROR: Corrupted file.' )
664
+ self .show_error ('Corrupted file.' )
662
665
663
666
def save (self , path , filename ):
664
667
self .working_dir = path
@@ -686,7 +689,10 @@ def export(self, path, filename):
686
689
s = norm .to_asp (i )
687
690
stream .write (s )
688
691
else :
689
- print 'File extension not supported.'
692
+ error_str = 'File extension not supported.'
693
+ print error_str
694
+ self .show_error (error_str )
695
+ return
690
696
self .dismiss_popup ()
691
697
692
698
def highlight_variables (self ):
@@ -697,11 +703,21 @@ def view_symbolic_formula(self):
697
703
698
704
def gringo_query (self ):
699
705
rpn = self .active_graph .get_formula_RPN ()
700
- print 'RPN formula: ' , rpn
701
- f = norm .Formula (rpn )
702
- n = f .root
706
+ print 80 * '-'
707
+ print 'RPN formula:\n ' , rpn
708
+ try :
709
+ f = norm .Formula (rpn )
710
+ n = f .root
711
+ n = norm .pnf (n )
712
+ print 80 * '-'
713
+ print 'Prenex RPN formula:\n ' , n
714
+ except Exception :
715
+ self .show_error ('Malformed formula.' )
716
+ return
717
+ print 80 * '-'
703
718
self .solver = gringo .Control ()
704
- for i in norm .normalization (n ):
719
+ m = norm .get_matrix (n )
720
+ for i in norm .normalization (m ):
705
721
#print i
706
722
s = norm .to_asp (i )
707
723
print 'ASP RULE: ' , s
@@ -719,6 +735,7 @@ def gringo_query(self):
719
735
print e
720
736
721
737
def on_model (self , m ):
738
+ print 80 * '-'
722
739
print 'Stable models:'
723
740
print m
724
741
0 commit comments