-
Benoit Favre authoredBenoit Favre authored
section.py 1.30 KiB
from gi.repository import Gtk
class SectionManager(Gtk.HBox):
def __init__(self):
super(SectionManager, self).__init__()
self.set_name('SessionManager')
self.button_next = Gtk.Button('Next')
self.button_prev = Gtk.Button('Previous')
self.label = Gtk.Label()
self.label.get_style_context().add_class('current-section')
self.pack_start(self.button_prev, False, False, 5)
self.pack_start(self.label, True, True, 5)
self.pack_start(self.button_next, False, False, 5)
self.set_section(1)
self.confirmer = None
self.button_next.connect('clicked', lambda widget: self.confirmer.confirm('Go to next section?', 3, self.next_section))
self.button_prev.connect('clicked', lambda widget: self.confirmer.confirm('Go to previous section?', 3, self.previous_section))
def set_section(self, section):
self.section = section
self.label.set_text('Current section: %d' % self.section)
def get_view(self):
return self.hbox
def get_section(self):
return self.section
def next_section(self):
self.set_section(self.section + 1)
def previous_section(self):
self.set_section(self.section - 1)
def set_confirmer(self, confirmer):
self.confirmer = confirmer