예제 #1
0
파일: review.py 프로젝트: bartosh/pomni
 def __init__(self, component_manager):
     ReviewWidget.__init__(self, component_manager)
     self._main_widget = self.main_widget()
     self._review_controller = self.review_controller()
     self.renderer = self.component_manager.get_current('renderer')
     self.tts = None
     self.sndtext = None
     self.is_sound_card = False
     # create widgets
     self.page, self.question_container, self.answer_container, \
         self.question_text, self.answer_text, self.grades_table, \
         grades, buttons, self.tags_label = widgets.create_review_ui( \
         self._main_widget.switcher)
     self.tts_button, self.edit_button, self.del_button = \
         buttons[1], buttons[2], buttons[3]
     self.tts_available = tts.is_available()
     self.tts_button.set_sensitive(False)
     # connect signals
     self.question_text.connect('button-press-event', \
         self.preview_sound_in_review_cb)
     self.answer_text.connect('button-press-event', self.get_answer_cb)
     for grade_button in grades:
         grade_button.connect('clicked', self.grade_cb)
     buttons[0].connect('clicked', self.statistics_card_cb)
     buttons[1].connect('clicked', self.speak_cb)
     buttons[2].connect('clicked', self.edit_card_cb)
     buttons[3].connect('clicked', self.delete_card_cb)
     buttons[4].connect('clicked', self.review_to_main_menu_cb)
예제 #2
0
파일: review.py 프로젝트: axelson/pomni
    def __init__(self, component_manager):
        ReviewWidget.__init__(self, component_manager)
        self.w_tree = self.main_widget().w_tree
        self.get_widget = get_widget = self.w_tree.get_widget
        self.w_tree.signal_autoconnect(dict([(sig, getattr(self, sig + "_cb")) \
            for sig in ['review_to_main_menu', 'get_answer', 'grade', 'speak', \
            'delete_card', 'edit_card', 'preview_sound_in_review','add_card']]))
        self.next_is_image_card = False #Image card indicator
        self.sndtext = None
        self.tts = None
        self.renderer = self.component_manager.get_current('renderer')

        # Widgets as attributes
        self.edit_button = get_widget("review_toolbar_edit_card_button")
        self.del_button = get_widget("review_toolbar_delete_card_button")
        self.question_container = get_widget("question_container")
        self.answer_container = get_widget("answer_container")
        self.container_width = get_widget("question_text"). \
            window.get_geometry()[2]
        self.question_text = get_widget("question_text")
        self.answer_text = get_widget("answer_text")
        self.sound_container = get_widget("review_mode_snd_container")
        self.sound_button = get_widget("review_mode_snd_button")
        self.grades_table = get_widget("grades_table")
        self.tts_button = get_widget("review_toolbar_tts_button")
        self.tts_available = tts.is_available()
        self.tts_button.set_sensitive(self.tts_available)
예제 #3
0
    def __init__(self, component_manager):
        ReviewWidget.__init__(self, component_manager)
        parent = self.main_widget()
        gui.Frame.__init__(self, parent)
        parent.set_central_widget(self)

        # Note: ppygui makes heavy use of properties, so we can't use e.g.
        # self.question, as the presence of self.question would then
        # require a function self.set_question too.
        self._question_label = gui.Label(self, "Question:")
        self._question = gui.Html(self)

        self._answer_label = gui.Label(self, "Answer:")
        self._answer = gui.Html(self)

        self.show_button = gui.Button(self, "Show answer")
        self.show_button.bind(clicked=self.show_answer)
        self.is_show_button_enabled = True

        self.grade_sizer = gui.HBox(border=(2, 2, 2, 2), spacing=5)
        self.grade_buttons = []
        self.id_for_grade = {}
        for i in range(6):
            button = gui.Button(self,
                                title=3 * " " + str(i) + 3 * " ",
                                action=self.grade_answer)
            self.grade_buttons.append(button)
            self.id_for_grade[button._id] = i
            self.grade_sizer.add(button)
            if i == 0:
                self.grade_0_button = button
            elif i == 4:
                self.grade_4_button = button
        self.is_grade_buttons_enabled = False

        self.status_bar = gui.Label(self)

        sizer = gui.VBox(border=(2, 2, 2, 2))
        sizer.add(self._question_label)
        sizer.add(self._question)
        sizer.add(self._answer_label)
        sizer.add(self._answer)
        sizer.add(self.show_button)
        sizer.add(self.grade_sizer)
        sizer.add(self.status_bar)
        self.sizer = sizer
        self._question_text = ""
        self._answer_text = ""
예제 #4
0
    def __init__(self, component_manager):
        ReviewWidget.__init__(self, component_manager)
        parent = self.main_widget()
        gui.Frame.__init__(self, parent)
        parent.set_central_widget(self)
       
        # Note: ppygui makes heavy use of properties, so we can't use e.g.
        # self.question, as the presence of self.question would then
        # require a function self.set_question too.
        self._question_label = gui.Label(self, "Question:")
        self._question = gui.Html(self)
        
        self._answer_label = gui.Label(self, "Answer:")
        self._answer = gui.Html(self)
        
        self.show_button = gui.Button(self, "Show answer")
        self.show_button.bind(clicked=self.show_answer)
        self.is_show_button_enabled = True

        self.grade_sizer = gui.HBox(border=(2, 2, 2, 2), spacing=5)
        self.grade_buttons = []
        self.id_for_grade = {}
        for i in range(6):
            button = gui.Button(self, title=3*" " + str(i) + 3*" ",
                                action=self.grade_answer)
            self.grade_buttons.append(button)
            self.id_for_grade[button._id] = i        
            self.grade_sizer.add(button)
            if i == 0:
                self.grade_0_button = button
            elif i == 4:
                self.grade_4_button = button                
        self.is_grade_buttons_enabled = False

        self.status_bar = gui.Label(self)

        sizer = gui.VBox(border=(2, 2, 2, 2))
        sizer.add(self._question_label)
        sizer.add(self._question)
        sizer.add(self._answer_label)
        sizer.add(self._answer)
        sizer.add(self.show_button)
        sizer.add(self.grade_sizer)
        sizer.add(self.status_bar)        
        self.sizer = sizer
        self._question_text = ""
        self._answer_text = ""
예제 #5
0
 def __init__(self, component_manager):
     ReviewWidget.__init__(self, component_manager)
     parent = self.main_widget()
     QtGui.QWidget.__init__(self, parent)
     parent.setCentralWidget(self)
     self.setupUi(self)
     self.grade_buttons = QtGui.QButtonGroup()
     self.grade_buttons.addButton(self.grade_0_button, 0)
     self.grade_buttons.addButton(self.grade_1_button, 1)
     self.grade_buttons.addButton(self.grade_2_button, 2)
     self.grade_buttons.addButton(self.grade_3_button, 3)
     self.grade_buttons.addButton(self.grade_4_button, 4)
     self.grade_buttons.addButton(self.grade_5_button, 5)
     self.connect(self.grade_buttons, QtCore.SIGNAL("buttonClicked(int)"),\
                  self.grade_answer)
     self.sched = QtGui.QLabel("", parent.status_bar)
     self.notmem = QtGui.QLabel("", parent.status_bar)
     self.act = QtGui.QLabel("", parent.status_bar)
     parent.clear_status_bar()
     parent.add_to_status_bar(self.sched)
     parent.add_to_status_bar(self.notmem)
     parent.add_to_status_bar(self.act)
     parent.status_bar.setSizeGripEnabled(0)
예제 #6
0
 def __init__(self, component_manager):
     ReviewWidget.__init__(self, component_manager)
     parent = self.main_widget()
     QtGui.QWidget.__init__(self, parent)
     parent.setCentralWidget(self)
     self.setupUi(self)
     # TODO: move this to designer with update of PyQt.
     self.grade_buttons = QtGui.QButtonGroup()
     self.grade_buttons.addButton(self.grade_0_button, 0)
     self.grade_buttons.addButton(self.grade_1_button, 1)
     self.grade_buttons.addButton(self.grade_2_button, 2)
     self.grade_buttons.addButton(self.grade_3_button, 3)
     self.grade_buttons.addButton(self.grade_4_button, 4)
     self.grade_buttons.addButton(self.grade_5_button, 5)
     self.grade_buttons.buttonClicked[int].connect(self.grade_answer)
     # TODO: remove this once Qt bug is fixed.
     self.setTabOrder(self.grade_1_button, self.grade_2_button)
     self.setTabOrder(self.grade_2_button, self.grade_3_button)
     self.setTabOrder(self.grade_3_button, self.grade_4_button)
     self.setTabOrder(self.grade_4_button, self.grade_5_button)
     self.setTabOrder(self.grade_5_button, self.grade_0_button)
     self.setTabOrder(self.grade_0_button, self.grade_1_button)
     self.focus_widget = None
     self.sched = QtGui.QLabel("", parent.status_bar)
     self.notmem = QtGui.QLabel("", parent.status_bar)
     self.act = QtGui.QLabel("", parent.status_bar)
     parent.clear_status_bar()
     parent.add_to_status_bar(self.sched)
     parent.add_to_status_bar(self.notmem)
     parent.add_to_status_bar(self.act)
     parent.status_bar.setSizeGripEnabled(0)
     self.widget_with_last_selection = self.question
     self.question.selectionChanged.connect(self.selection_changed_in_q)
     self.answer.selectionChanged.connect(self.selection_changed_in_a)
     QAOptimalSplit.__init__(self) 
     self.mplayer = QtCore.QProcess()
     self.media_queue = []
예제 #7
0
 def __init__(self, component_manager):
     ReviewWidget.__init__(self, component_manager)
     parent = self.main_widget()
     QtGui.QWidget.__init__(self, parent)
     parent.setCentralWidget(self)
     self.setupUi(self)
     # TODO: move this to designer with update of PyQt.
     self.grade_buttons = QtGui.QButtonGroup()
     self.grade_buttons.addButton(self.grade_0_button, 0)
     self.grade_buttons.addButton(self.grade_1_button, 1)
     self.grade_buttons.addButton(self.grade_2_button, 2)
     self.grade_buttons.addButton(self.grade_3_button, 3)
     self.grade_buttons.addButton(self.grade_4_button, 4)
     self.grade_buttons.addButton(self.grade_5_button, 5)
     self.grade_buttons.buttonClicked[int].connect(self.grade_answer)
     # TODO: remove this once Qt bug is fixed.
     self.setTabOrder(self.grade_1_button, self.grade_2_button)
     self.setTabOrder(self.grade_2_button, self.grade_3_button)
     self.setTabOrder(self.grade_3_button, self.grade_4_button)
     self.setTabOrder(self.grade_4_button, self.grade_5_button)
     self.setTabOrder(self.grade_5_button, self.grade_0_button)
     self.setTabOrder(self.grade_0_button, self.grade_1_button)
     self.focus_widget = None
     self.sched = QtGui.QLabel("", parent.status_bar)
     self.notmem = QtGui.QLabel("", parent.status_bar)
     self.act = QtGui.QLabel("", parent.status_bar)
     parent.clear_status_bar()
     parent.add_to_status_bar(self.sched)
     parent.add_to_status_bar(self.notmem)
     parent.add_to_status_bar(self.act)
     parent.status_bar.setSizeGripEnabled(0)
     self.widget_with_last_selection = self.question
     self.question.selectionChanged.connect(self.selection_changed_in_q)
     self.answer.selectionChanged.connect(self.selection_changed_in_a)
     QAOptimalSplit.__init__(self)
     self.mplayer = QtCore.QProcess()
     self.media_queue = []
예제 #8
0
    def __init__(self, component_manager):
        ReviewWidget.__init__(self, component_manager)
        self.is_server_local = False
        self.question_label = ""
        self.question = ""
        self.is_question_box_visible = True
        self.answer = ""
        self.answer_label = _("Answer:")
        self.is_answer_box_visible = True
        self.show_button = ""
        self.is_show_button_enabled = True
        self.is_grade_buttons_enabled = False
        self.status_bar = ""
        self.template = Template("""
<!DOCTYPE html>
<html>
<head>
  <title>Mnemosyne</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
table {
  width: 100%;
  border: 1px solid black;
  padding: 1em;
}
table.buttonarea {
  border: 0;
  padding: 0;
  background-color: white;
}
input {
  width: 100%;
}

$card_css
</style>
</head>
<body>

<table class="buttonarea">
  <tr>
  $buttons
  </tr>
</table>

<p>$question_label</p>

<table id="mnem1" class="mnem">
  <tr>
    <td>$question</td>
  </tr>
</table>

<p>$answer_label</p>

<table id="mnem1" class="mnem">
  <tr>
    <td>$answer</td>
  </tr>
</table>

<p>$status_bar</p>

</body>
</html>
""")
예제 #9
0
 def __init__(self, component_manager):
     ReviewWidget.__init__(self, component_manager)
예제 #10
0
 def deactivate(self):
     self.stop_media()
     ReviewWidget.deactivate(self)
예제 #11
0
    def __init__(self, component_manager):
        ReviewWidget.__init__(self, component_manager)
        self.review_controller().set_render_chain("web_server")
        self.client_on_same_machine_as_server = False
        self.question_label = ""
        self.question = ""
        self.is_question_box_visible = True
        self.answer = ""
        self.answer_label = _("Answer:")
        self.is_answer_box_visible = True
        self.show_button = ""
        self.is_show_button_enabled = True
        self.is_grade_buttons_enabled = False
        self.status_bar = ""
        self.template = Template("""
<!DOCTYPE html>
<html>
<head>
  <title>Mnemosyne</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
table {
  width: 100%;
  border: 1px solid black;
  padding: 1em;
}
table.buttonarea {
  border: 0;
  padding: 0;
  background-color: white;
}
input {
  width: 100%;
}

$card_css
</style>
</head>
<body>

<table class="buttonarea">
  <tr>
  $buttons
  </tr>
</table>

<p>$question_label</p>

<table id="mnem1" class="mnem">
  <tr>
    <td>$question</td>
  </tr>
</table>

<p>$answer_label</p>

<table id="mnem1" class="mnem">
  <tr>
    <td>$answer</td>
  </tr>
</table>

<p>$status_bar</p>

</body>
</html>
""")
예제 #12
0
    def __init__(self, component_manager):
        ReviewWidget.__init__(self, component_manager)
        parent = self.main_widget()
        gui.Frame.__init__(self, parent)
        parent.set_central_widget(self)

        # Note: ppygui makes heavy use of properties, so we can't use e.g.
        # self.question, as the presence of self.question would then
        # require a function self.set_question too.
        self._question_label = gui.Label(self, "Question:")
        self._question = gui.Html(self)

        self._answer_label = gui.Label(self, "Answer:")
        self._answer = gui.Html(self)

        self.show_button = gui.Button(self, "Show answer")
        self.show_button.bind(clicked=self.show_answer)
        self.is_show_button_enabled = True

        self.grade_sizer = gui.HBox(border=(2, 2, 2, 2), spacing=5)
        self.grade_buttons = []
        self.id_for_grade = {}
        for i in range(6):
            button = gui.Button(self,
                                title=3 * " " + str(i) + 3 * " ",
                                action=self.grade_answer)
            self.grade_buttons.append(button)
            self.id_for_grade[button._id] = i
            self.grade_sizer.add(button)
            if i == 0:
                self.grade_0_button = button
            elif i == 4:
                self.grade_4_button = button
        self.is_grade_buttons_enabled = False

        self.status_bar = gui.Label(self)

        sizer = gui.VBox(border=(2, 2, 2, 2))
        sizer.add(self._question_label)
        sizer.add(self._question)
        sizer.add(self._answer_label)
        sizer.add(self._answer)
        sizer.add(self.show_button)
        sizer.add(self.grade_sizer)
        sizer.add(self.status_bar)
        self.sizer = sizer
        self._question_text = ""
        self._answer_text = ""

        def show_answer(self, event):
            if not self.is_show_button_enabled:
                return
            self.review_controller().show_answer()

        def grade_answer(self, event):
            if not self.is_grade_buttons_enabled:
                return
            grade = self.id_for_grade[event.id]
            self.review_controller().grade_answer(grade)

        def set_question_box_visible(self, is_visible):
            if is_visible:
                self._question_label.show()
                self._question.show()
            else:
                self._question_label.hide()
                self._question.hide()

        def set_answer_box_visible(self, is_visible):
            if is_visible:
                self._answer_label.show()
                self._answer.show()
            else:
                self._answer_label.hide()
                self._answer.hide()

        def set_question_label(self, text):
            self._question_label.text = text

        def set_question(self, text):
            self._question_text = text

        def set_answer(self, text):
            self._answer_text = text

        def reveal_question(self, text):
            self._question.value = self._question_text

        def reveal_answer(self, text):
            self._answer.value = self._answer_text

        def clear_question(self):
            self._question.value = ""

        def clear_answer(self):
            self._answer.value = ""

        def update_show_button(self, text, is_default, is_enabled):
            if is_default:
                self.show_button.focus()
            self.show_button.text = text
            self.is_show_button_enabled = is_enabled

        def set_grades_enabled(self, is_enabled):
            self.is_grade_buttons_enabled = is_enabled

        def set_default_grade(self, grade):
            self.grade_buttons[grade].focus()

        def update_status_bar_counters(self):
            scheduled_count, non_memorised_count, active_count = \
                    self.review_controller().counters()
            self.status_bar.text = "Sch.:%d Not mem.:%d Act.:%d" % \
                    (scheduled_count, non_memorised_count, active_count)