def __init__(self, heading, statistics):
Gtk.VBox.__init__(self)
self.m_heading = heading
self.m_data = []
self.m_statistics = statistics
python类VBox()的实例源码
def __init__(self, heading, st_data, st):
"""
st_data is the statistics data we want displayled
st is the statistics object the statistics are collected from.
"""
Gtk.VBox.__init__(self)
label = Gtk.Label(label=heading)
label.set_name("StatisticsH2")
label.set_alignment(0.0, 0.0)
self.pack_start(label, False, False, 0)
hbox = gu.bHBox(self, False)
frame = Gtk.Frame()
hbox.pack_start(frame, False, False, 0)
t = Gtk.Table()
frame.add(t)
keys = st.get_keys(True)
for x in range(len(keys)):
t.attach(Gtk.VSeparator(), x*2+1, x*2+2, 0, len(keys)*2)
for x in range(len(keys)-1):
t.attach(Gtk.HSeparator(), 0, len(keys)*2+1, x*2+1, x*2+2)
for y, key in enumerate(keys):
l = label_from_key(st, key)
t.attach(l, 0, 1, y*2, y*2+1, xpadding=gu.PAD)
for x, skey in enumerate(keys):
try:
s = st_data[key][skey]
except KeyError:
s = '-'
l = Gtk.Label(label=s)
if x == y:
l.set_name('BoldText')
t.attach(l, x*2+2, x*2+3, y*2, y*2+1, xpadding=gu.PAD)
self.show_all()
def clear(self):
#UGH why cant we just destroy the children of g_tables??!!
#for c in self.g_tables.children():
# c.destroy()
self.g_tables.destroy()
self.g_tables = Gtk.VBox(False, 0)
self.g_tables.set_spacing(gu.hig.SPACE_LARGE)
self.g_tables.show()
self.vbox.pack_start(self.g_tables, True, True, 0)
def bVBox(pack_into, expand=True, fill=True, padding=0):
b = Gtk.VBox(False, 0)
pack_into.pack_start(b, expand, fill, padding)
return b
def __init__(self):
Gtk.VBox.__init__(self)
self.set_spacing(hig.SPACE_MEDIUM)
self.set_border_width(hig.SPACE_LARGE)
def twoline(self, A, B):
vbox = Gtk.VBox(False, 0)
t1 = Gtk.Label(label=A)
t1.set_name("ProgressionLabelNumber")
t1.show();vbox.pack_start(t1, True, True, 0);
t1.set_alignment(0, 0);
t2 = Gtk.Label(label=B)
t2.set_name("ProgressionLabelNumber")
t2.show();vbox.pack_start(t2, True, True, 0);
t2.set_alignment(0, 0);
self.pack_start(vbox, False, False, 0)
def __init__(self):
Gtk.VBox.__init__(self)
self.m_todo_widgets = []
def __init__(self, parent):
Gtk.Window.__init__(self)
self.set_transient_for(parent)
self.set_destroy_with_parent(True)
self.set_modal(True)
vbox = Gtk.VBox(False, 0)
vbox.set_spacing(4)
self.add(vbox)
self.set_default_size(630, 400)
self.g_logwidget = LogWidget()
vbox.pack_start(self.g_logwidget, True, True, 0)
vbox.pack_start(Gtk.HSeparator(), False, False, 0)
bbox = Gtk.HButtonBox()
bbox.set_layout(Gtk.ButtonBoxStyle.END)
vbox.pack_start(bbox, False, False, padding=0)
self.g_close_button = Gtk.Button(stock="gtk-close")
self.g_close_button.set_sensitive(False)
self.g_close_button.connect('clicked', lambda w: self.destroy())
bbox.pack_start(self.g_close_button, True, True, 0)
self.show_all()
self.write = self.g_logwidget.write
self.popen = self.g_logwidget.popen
def add_heading(self, text):
def set_alignment(x, y):
for c in self.get_children()[0].get_children():
super(Gtk.Label, c).set_alignment(x, y)
vbox = Gtk.VBox(False, 0)
vbox.set_alignment = set_alignment
b = Gtk.Label()
b.set_markup(u"%s" % text)
b.set_alignment(0.0, 0.5)
vbox.pack_start(b, False, False, 0)
self.get_children()[0].reparent(vbox)
self.add(vbox)
def new_page_box(self, parent, heading):
page_vbox = Gtk.VBox()
page_vbox.set_spacing(gu.hig.SPACE_MEDIUM)
self.g_page_box.pack_start(page_vbox, True, True, 0)
it = self.g_pages.append(parent, [heading])
self.m_page_mapping[tuple(self.g_pages.get_path(it))] = page_vbox
return it, page_vbox
def create_mainwin_ui(self):
qbox = gu.hig_dlg_vbox()
self.g_notebook.append_page(qbox, Gtk.Label(label=_("Questions")))
gu.bLabel(qbox, _("Enter new chords using the mouse"), False, False)
hbox = gu.bHBox(qbox, False, False)
self.g_displayer = mpd.musicdisplayer.ChordEditor()
self.g_displayer.connect('clicked', self.on_displayer_clicked)
self.g_displayer.clear(2)
gu.bLabel(hbox, "")
hbox.pack_start(self.g_displayer, False)
gu.bLabel(hbox, "")
##
self.g_question_name = Gtk.Entry()
qbox.pack_start(gu.hig_label_widget(_("Question title:", True, True, 0), self.g_question_name, None), False)
self.g_navinfo = Gtk.Label(label="")
qbox.pack_start(self.g_navinfo, False)
##
self.m_P = EditorLessonfile()
cvbox = Gtk.VBox()
self.g_notebook.append_page(cvbox, Gtk.Label(label=_("Lessonfile header")))
## Header section
sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
self.g_title = Gtk.Entry()
cvbox.pack_start(gu.hig_label_widget(_("File title:", True, True, 0), self.g_title,
sizegroup))
self.g_content_chord = Gtk.RadioButton(None, "chord")
self.g_content_chord_voicing = Gtk.RadioButton(self.g_content_chord, "chord-voicing")
self.g_content_idbyname = Gtk.RadioButton(self.g_content_chord, "id-by-name")
box = Gtk.HBox()
box.pack_start(self.g_content_chord, True, True, 0)
box.pack_start(self.g_content_chord_voicing, True, True, 0)
box.pack_start(self.g_content_idbyname, True, True, 0)
cvbox.pack_start(gu.hig_label_widget(_("Content:", True, True, 0), box, sizegroup))
self.g_random_transpose = Gtk.Entry()
cvbox.pack_start(gu.hig_label_widget(_("Random transpose:", True, True, 0),
self.g_random_transpose, sizegroup))
#
#self.g_statusbar = Gtk.Statusbar()
#self.toplevel_vbox.pack_start(self.g_statusbar, False)
self.update_appwin()
def __init__(self, exname, num, labeltext):
Gtk.VBox.__init__(self)
#cfg.ConfigUtils.__init__(self, exname)
cfg.ConfigUtils.__dict__['__init__'](self, exname)
assert num in (2, 3)
self.m_num = num
self.g_override_default_instrument_checkbutton \
= gu.nCheckButton(exname, 'override_default_instrument',
labeltext,
callback=self.update_instrument_override)
self.pack_start(self.g_override_default_instrument_checkbutton,
False, False, 0)
hbox = gu.bVBox(self)
hbox.set_spacing(gu.PAD_SMALL)
sizegroup = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
self.g_instrsel_high = FramedInstrumentSelector(_("Highest:"), exname, 'highest_instrument',sizegroup)
hbox.pack_start(self.g_instrsel_high, False, False, 0)
if num == 3:
self.g_instrsel_middle = FramedInstrumentSelector(_("Middle:"),
exname, 'middle_instrument', sizegroup)
hbox.pack_start(self.g_instrsel_middle, False, False, 0)
else:
self.g_instrsel_middle = None
self.g_instrsel_low = FramedInstrumentSelector(_("Lowest:"),
exname, 'lowest_instrument', sizegroup)
hbox.pack_start(self.g_instrsel_low, False, False, 0)
self.update_instrument_override()
def __init__(self, model, parent):
Gtk.VBox.__init__(self)
self.m_model = model
self.m_parent = parent
sc = Gtk.ScrolledWindow()
sc.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.pack_start(sc, True, True, 0)
self.g_column_box = Gtk.HBox()
self.g_column_box.set_spacing(gu.hig.SPACE_LARGE)
self.g_column_box.set_border_width(gu.hig.SPACE_SMALL)
# We pack column into this box
sc.add_with_viewport(self.g_column_box)
self.show_all()
if model:
self.update_from_model()
def __init__(self, filename=None):
Gtk.Window.__init__(self)
logging.debug("fpeditor.Editor.__init__(%s)", filename)
gu.EditorDialogBase.__init__(self, filename)
self.set_default_size(800, 600)
self.g_main_box = Gtk.VBox()
self.add(self.g_main_box)
self.g_actiongroup.add_actions([
('GoBack', Gtk.STOCK_GO_BACK, None, None, None, self.go_back),
])
self.setup_toolbar()
self.g_title_hbox = Gtk.HBox()
self.g_title_hbox.set_spacing(gu.hig.SPACE_SMALL)
self.g_title_hbox.set_border_width(gu.hig.SPACE_SMALL)
label = Gtk.Label()
label.set_markup(u"<b>%s</b>" % _("Front page title:"))
self.g_title_hbox.pack_start(label, False, False, 0)
self.g_fptitle = Gtk.Entry()
self.g_title_hbox.pack_start(self.g_fptitle, True, True, 0)
self.g_main_box.pack_start(self.g_title_hbox, False, False, 0)
# This dict maps the windows created for all pages belonging to
# the file.
self.m_page_mapping = {}
self.m_model = None
if filename:
self.load_file(filename)
else:
self.m_model = pd.Page(_("Untitled%s") % self.m_instance_number,
pd.Column())
self.set_not_modified()
self.add_page(Page(self.m_model, self))
self.clipboard.update_buttons()
self.show_all()
self.add_to_instance_dict()
self.g_fptitle.set_text(self.m_model.m_name)
self.g_fptitle.connect('changed', self.on_frontpage_title_changed)
def show_bug_reports(self, *v):
m = Gtk.Dialog(_("Question"), self, 0)
m.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
m.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
vbox = Gtk.VBox()
m.vbox.pack_start(vbox, False, False, 0)
vbox.set_spacing(18)
vbox.set_border_width(12)
l = Gtk.Label(label=_("Please enter the email used when you submitted the bugs:"))
vbox.pack_start(l, False, False, 0)
self.g_email = Gtk.Entry()
m.action_area.get_children()[0].grab_default()
self.g_email.set_activates_default(True)
vbox.pack_start(self.g_email, False, False, 0)
m.show_all()
ret = m.run()
m.destroy()
if ret == Gtk.ResponseType.OK:
params = urllib.urlencode({
'pagename': 'SITS-Incoming/SearchBugs',
'q': 'SITS-Incoming/"Submitter: %s"' % utils.mangle_email(self.g_email.get_text().decode("utf-8")()),
})
try:
webbrowser.open_new("http://www.solfege.org?%s" % params)
except Exception, e:
self.display_error_message2(_("Error opening web browser"), str(e))
def exit_test_mode(self):
solfege.app.m_test_mode = False
self.m_action_groups['NotExit'].set_sensitive(True)
box = Gtk.VBox()
self.get_view().g_notebook.insert_page(box, Gtk.Label(label=_("Practise")), 0)
self.g.reparent(box)
self.get_view().g_notebook.show()
self.get_view().g_notebook.get_nth_page(0).show()
self.get_view().g_notebook.set_current_page(0)
self.get_view().exit_test_mode()
def __init__(self):
Gtk.Window.__init__(self)
self.connect('destroy', self.on_quit)
self.vbox = vbox = Gtk.VBox()
vbox.show()
self.add(vbox)
self.g_text = Gtk.TextView()
self.g_text.set_size_request(-1, 100)
self.g_text.show()
self.g_text.set_editable(True)
try:
s = open(musicfile, "r").read()
except IOError, e:
s = r"\staff{c' d' e'}"
self.m_buf = self.g_text.get_buffer()
self.m_buf.insert(self.m_buf.get_end_iter(), s)
vbox.pack_start(self.g_text, True, True, 0)
self.g_displayer = MusicDisplayer()
self.g_displayer.set_size_request(200, 200)
self.g_displayer.show()
self.vbox.pack_start(self.g_displayer, True, True, 0)
gu.bButton(vbox, "Parse", self.on_parse)
gu.bButton(vbox, "Display", self.on_display)
gu.bButton(vbox, "Display first notes", self.on_display_first_notes)
gu.bButton(vbox, "Play", self.on_play)
gu.bButton(vbox, "Play first", self.on_play_first)
def __init__(self, value):
#
Gtk.Dialog.__init__(self,
'Backlight Indicator | ' + _('Set backlight'),
None,
Gtk.DialogFlags.MODAL |
Gtk.DialogFlags.DESTROY_WITH_PARENT,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
self.connect('close', self.close_ok)
self.set_icon_from_file(comun.ICON)
#
vbox0 = Gtk.VBox(spacing=5)
vbox0.set_border_width(5)
self.get_content_area().add(vbox0)
frame0 = Gtk.Frame()
vbox0.pack_start(frame0, False, True, 1)
table0 = Gtk.Table(2, 2, False)
frame0.add(table0)
label23 = Gtk.Label(_('Backlight') + ':')
label23.set_alignment(0, 0.5)
table0.attach(label23, 0, 1, 0, 1,
xpadding=5, ypadding=5)
configuration = Configuration()
minimum_backlight = configuration.get('minimum-backlight')
maximum_backlight = configuration.get('maximum-backlight')
ba = BacklightManager()
backlight = ba.get_backlight()
adjustment3 = Gtk.Adjustment(backlight,
minimum_backlight,
maximum_backlight, 5, 10, 1)
self.backlight = Gtk.Scale()
self.backlight.set_digits(0)
self.backlight.set_size_request(200, 10)
self.backlight.set_adjustment(adjustment3)
table0.attach(self.backlight, 1, 2, 0, 1,
xpadding=5, ypadding=5)
self.backlight.set_value(value)
self.show_all()
def __init__(self, package_name):
self.install_choice = ()
Gtk.Window.__init__(self, title="Install")
self.set_default_size(300, 100)
self.set_resizable(False)
self.connect("delete-event", Gtk.main_quit)
main_box = Gtk.VBox()
button_box = Gtk.HBox()
install_message = "Would you like to install %s?" % package_name
intro_label = Gtk.Label(install_message)
install_button = Gtk.Button(label='Install')
cancel_button = Gtk.Button(label='Cancel')
install_button.connect('clicked', self.install_was_pressed)
cancel_button.connect('clicked', self.cancel_was_pressed)
self.add(main_box)
button_box.pack_start(install_button, True, True, 5)
button_box.pack_start(cancel_button, True, True, 5)
main_box.pack_start(intro_label, True, True, 0)
main_box.pack_start(button_box, True, True, 5)
def get_file(self, widget):
import re
import ui.gtk3.common
# Disable all the interface and Ok button.
self.hbox.set_sensitive(False)
self.options_hbox.set_sensitive(False)
self.butt_ok.set_sensitive(False)
# Progress bar
self.progress_box = Gtk.VBox(False, 0)
self.hseparator4 = Gtk.HSeparator()
self.progress_bar = Gtk.ProgressBar()
self.progress_box.pack_start(self.hseparator4, False, False, 0)
self.progress_box.pack_start(self.progress_bar, False, False, 0)
self.main_vbox.pack_start(self.progress_box, False, False, 2)
self.progress_box.show_all()
ui.gtk3.common.repaint()
self.file = self.input_entry.get_child().get_text()
if not re.match('^[a-z]+://', self.file):
# It's a local file.
self.manager.add_item('file://' + self.file)
self.get_options()
self.response(0)