def __init__(self,title,parent,max_value):
#
Gtk.Dialog.__init__(self,title,parent)
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
self.set_size_request(330, 40)
self.set_resizable(False)
self.connect('destroy', self.close)
#
vbox1 = Gtk.VBox(spacing = 5)
vbox1.set_border_width(5)
self.get_content_area().add(vbox1)
#
self.progressbar = Gtk.ProgressBar()
vbox1.pack_start(self.progressbar,True,True,0)
#
self.show_all()
#
self.max_value=max_value
self.value=0.0
self.map()
while Gtk.events_pending():
Gtk.main_iteration()
python类VBox()的实例源码
def __init__(self,title,parent,max_value):
#
Gtk.Dialog.__init__(self,title,parent)
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
self.set_size_request(330, 40)
self.set_resizable(False)
self.connect('destroy', self.close)
#
vbox1 = Gtk.VBox(spacing = 5)
vbox1.set_border_width(5)
self.get_content_area().add(vbox1)
#
self.progressbar = Gtk.ProgressBar()
vbox1.pack_start(self.progressbar,True,True,0)
#
self.show_all()
#
self.max_value=max_value
self.value=0.0
self.map()
while Gtk.events_pending():
Gtk.main_iteration()
def __init__(self, parent):
self.parent = parent
self.language = 'Plain'
self.curLinter = None
self.lintersObj = {
'c': LinterClang(self.parent, self)
}
self.linterPopover = Gtk.Popover()
self.errorsLbl = Gtk.Label('Errors: 0')
self.statusLbl = Gtk.Label('Status: OK')
self.linterPopoverBox = Gtk.VBox()
self.linterPopoverBox.set_border_width(10)
self.linterPopoverBox.pack_start(self.errorsLbl, False, False, 0)
self.linterPopoverBox.pack_start(self.statusLbl, False, False, 0)
self.linterPopover.add(self.linterPopoverBox)
##
def __init__(self, statistics, heading):
Gtk.ScrolledWindow.__init__(self)
self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.vbox = Gtk.VBox(False, 0)
self.vbox.set_spacing(gu.PAD)
self.vbox.set_border_width(gu.PAD)
self.add_with_viewport(self.vbox)
hbox = Gtk.HBox(False, 0)
hbox.set_spacing(gu.hig.SPACE_SMALL)
im = Gtk.Image.new_from_file("graphics/applications-system.svg")
self.g_settings_button = b = Gtk.Button()
b.connect('clicked', self.on_delete_statistics)
b.add(im)
hbox.pack_start(b, False, False, 0)
self.g_heading = Gtk.Label(label=heading)
self.g_heading.set_alignment(0.0, 0.5)
self.g_heading.set_name("StatisticsH1")
hbox.pack_start(self.g_heading, False, False, 0)
self.vbox.pack_start(hbox, False, False, 0)
self.m_statistics = statistics
self.g_tables = Gtk.VBox(False, 0)
self.g_tables.show()
self.vbox.pack_start(self.g_tables, True, True, 0)
self.show_all()
def hig_category_vbox(title, spacing=6):
"""
spacing the space to put between children. HIG say is should be 6, but
while packing Gtk.LinkButtons there is too much space between the links
when packing with 6 pixels. So I added the spacing parameter.
Return a tuple of two boxes:
box1 -- a box containing everything including the title. Useful
if you have to hide a category.
box2 The box you should pack your stuff in.
"""
vbox = Gtk.VBox(False, 0)
vbox.set_spacing(hig.SPACE_SMALL)
label = Gtk.Label(label='<span weight="bold">%s</span>' % title)
label.set_use_markup(True)
label.set_alignment(0.0, 0.0)
vbox.pack_start(label, False, False, 0)
hbox = Gtk.Box(False, 0)
vbox.pack_start(hbox, False, False, 0)
fill = Gtk.Label(label=" ")
hbox.pack_start(fill, False, False, 0)
category_content_vbox = Gtk.VBox(False, 0)
hbox.pack_start(category_content_vbox, True, True, 0)
category_content_vbox.set_spacing(spacing)
vbox.show_all()
return vbox, category_content_vbox
def __init__(self, parent):
Gtk.Window.__init__(self)
self.set_title(_("GNU Solfege lesson file editor") )
self.set_default_size(400, 400)
self.g_parent = parent
self.vbox = Gtk.VBox()
self.vbox.set_spacing(8)
self.add(self.vbox)
self.connect('delete_event', self.delete_cb)
self.g_htmlwidget = htmlwidget.HtmlWidget(None, None)
self.vbox.pack_start(self.g_htmlwidget, True, True, 0)
self.vbox.pack_start(Gtk.HSeparator(), False)
bbox = Gtk.HButtonBox()
bbox.set_border_width(8)
self.vbox.pack_start(bbox, False)
b = Gtk.Button(stock=Gtk.STOCK_CLOSE)
b.connect('clicked', self.close_cb)
bbox.pack_start(b, True, True, 0)
self.show_all()
self.set_focus(b)
def __init__(self, datadir):
Gtk.Window.__init__(self)
self.icons = stock.EditorIconFactory(self, datadir)
self.connect('destroy', lambda w: Gtk.main_quit())
self.g_help_window = None
# toplevel_vbox:
# -menubar
# -toolbar
# -notebook
# -statusbar
self.toplevel_vbox = Gtk.VBox()
self.add(self.toplevel_vbox)
self.create_menu_and_toolbar()
self.g_notebook = Gtk.Notebook()
self.toplevel_vbox.pack_start(self.g_notebook, True, True, 0)
self.vbox = Gtk.VBox()
self.toplevel_vbox.pack_start(self.vbox, True, True, 0)
self.create_mainwin_ui()
self.show_all()
def __init__(self, exname, name, sizegroup):
Gtk.VBox.__init__(self)
cfg.ConfigUtils.__dict__['__init__'](self, exname)
self.m_name = name
hbox = gu.bHBox(self)
hbox.set_spacing(gu.PAD_SMALL)
self.g_button = Gtk.Button(
soundcard.instrument_names[self.get_int(self.m_name)])
self.g_button.connect('clicked', self.on_btnclick)
hbox.pack_start(self.g_button, True, True, 0)
g = Gtk.VolumeButton()
g.props.value = self.get_int('%s_volume' % name) / MAX_VOLUME
def ff(volumebutton, value):
self.set_int('%s_volume' % name, int(value * MAX_VOLUME))
g.connect('value-changed', ff)
hbox.pack_start(g, False, False, 0)
self.g_menu = MidiInstrumentMenu(self.on_instrument_selected)
self.m_instrument = self.get_int('preferred_instrument')
hbox = Gtk.HBox()
hbox.set_spacing(6)
self.pack_start(hbox, True, True, 0)
def __init__(self, model, parent):
Gtk.VBox.__init__(self)
self.set_spacing(gu.hig.SPACE_MEDIUM)
self.m_model = model
self.m_parent = parent
assert isinstance(model, pd.Column)
self.g_section_box = Gtk.VBox()
self.g_section_box.set_spacing(gu.hig.SPACE_MEDIUM)
self.pack_start(self.g_section_box, False, False, 0)
for section in model:
assert isinstance(section, pd.LinkList)
gui_section = Section(section, self)
self.g_section_box.pack_start(gui_section, False, False, 0)
hbox = Gtk.HBox()
self.pack_start(hbox, False, False, 0)
b = Gtk.Button(_("Add section"))
hbox.pack_start(b, False, False, 0)
b.connect('clicked', self.on_add_section)
b = Gtk.Button(stock=Gtk.STOCK_PASTE)
b.connect('clicked', self.on_paste)
Editor.clipboard.register_paste_button(b, pd.LinkList)
hbox.pack_start(b, False, False, 0)
def __init__(self):
Gtk.Window.__init__(self)
vbox = Gtk.VBox()
self.add(vbox)
self.set_default_size(600, 400)
self.w = RhythmWidget()
s = elems.Score()
s.add_staff(staff_class=elems.RhythmStaff)
s.add_bar(elems.TimeSignature(3, 4))
s.add_bar(elems.TimeSignature(3, 4))
s.voice11.fill_with_skips()
self.w.set_score(s)
vbox.pack_start(self.w, True, True, 0)
#
c = RhythmWidgetController(self.w)
vbox.pack_start(c, False, False, 0)
c.show()
c.set_editable(True)
self.connect('delete_event', self.quit)
def __init__(self):
Gtk.Window.__init__(self, Gtk.WindowType.POPUP)
self.set_position(Gtk.WindowPosition.CENTER)
self.set_resizable(True)
frame = Gtk.Frame()
frame.set_shadow_type(Gtk.ShadowType.OUT)
self.add(frame)
vbox = Gtk.VBox()
vbox.set_border_width(20)
frame.add(vbox)
l = Gtk.Label(label=_("Starting GNU Solfege %s") % buildinfo.VERSION_STRING)
l.set_name("Heading1")
vbox.pack_start(l, True, True, 0)
l = Gtk.Label(label="http://www.solfege.org")
vbox.pack_start(l, True, True, 0)
self.g_infolabel = Gtk.Label(label='')
vbox.pack_start(self.g_infolabel, True, True, 0)
self.show_all()
def main():
win = Gtk.Window()
win.connect('destroy', Gtk.main_quit)
win.set_default_size(Width, Height)
global drawingarea
drawingarea = Gtk.DrawingArea()
drawingarea.connect('draw', draw)
drawing_event_box = Gtk.EventBox()
drawing_event_box.add(drawingarea)
drawing_event_box.connect('button-press-event', mouse_pressed)
drawing_event_box.connect('motion-notify-event', mouse_dragged)
check_useIk = Gtk.CheckButton("Lock Forearm & Hand")
check_useIk.set_active(True)
check_useIk.connect("toggled", check_toggled)
box = Gtk.VBox()
box.pack_start(check_useIk, False, True, 0)
box.pack_start(drawing_event_box, True, True, 0)
win.add(box)
win.show_all()
Gtk.main()
def __init__(self,
final_message: Dict,
progress_view: 'ProgressAndHistoryView',
core: ApartCore,
z_options: List[str]):
FinishedJob.__init__(self,
final_message,
progress_view,
core,
icon_name='dialog-error',
z_options=z_options)
self.fail_reason = key_and_val('Failed', self.msg['error'])
self.stats = Gtk.VBox()
self.stats.add(self.fail_reason)
self.stats.add(self.duration)
self.stats.get_style_context().add_class('finished-job-stats')
self.stats.show_all()
self.extra.add(self.stats)
def __init__(self, final_message:
Dict,
progress_view: 'ProgressAndHistoryView',
core: ApartCore,
z_options: List[str]):
FinishedJob.__init__(self, final_message, progress_view, core, icon_name='dialog-error',
z_options=z_options)
self.fail_reason = key_and_val('Failed', self.msg['error'])
self.image_source = key_and_val('Restoring from', self.msg['source'])
self.stats = Gtk.VBox()
for stat in [self.fail_reason, self.image_source, self.duration]:
self.stats.add(stat)
self.stats.get_style_context().add_class('finished-job-stats')
self.stats.show_all()
self.extra.add(self.stats)
# naive rerun is unsafe for restore jobs as /dev/abc1 may refer to different partition
# than when last run
self.rerun_btn.destroy()
def __init__(self,
final_message: Dict,
progress_view: 'ProgressAndHistoryView',
core: ApartCore,
z_options: List[str]):
FinishedJob.__init__(self, final_message,
progress_view,
core,
icon_name='object-select-symbolic',
forget_on_rerun=False,
z_options=z_options)
self.stats = Gtk.VBox()
self.image_source = key_and_val('Restored from', self.msg['source'])
for stat in [self.image_source, self.duration]:
self.stats.add(stat)
self.stats.get_style_context().add_class('finished-job-stats')
self.stats.show_all()
self.extra.add(self.stats)
# naive rerun is unsafe for restore jobs as /dev/abc1 may refer to different partition
# than when last run
self.rerun_btn.destroy()
def on_menuitem_custom_activate(self, widget):
self.custom_window = Gtk.Window()
self.custom_window.set_default_size(640, 480)
self.custom_window.set_position(Gtk.WindowPosition.CENTER)
self.custom_window.set_title("Custom CSS")
self.custom_vbox = Gtk.VBox()
self.custom_scroller = Gtk.ScrolledWindow()
self.custom_button = Gtk.Button("Apply")
self.custom_vbox.pack_end(self.custom_button, False, False, 0)
self.custom_text_view = Gtk.TextView()
self.custom_text_buffer = Gtk.TextBuffer()
self.custom_text_buffer.set_text(self.custom_css)
self.custom_text_view.set_buffer(self.custom_text_buffer)
self.custom_scroller.add(self.custom_text_view)
self.custom_vbox.pack_start(self.custom_scroller, True, True, 0)
self.custom_window.add(self.custom_vbox)
self.custom_window.show_all()
self.custom_button.connect("clicked", self.apply_custom_css, self.custom_window, self.custom_text_buffer)
def __init__(self):
window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
window.set_title("Audio-Player")
window.set_default_size(300, -1)
window.connect("destroy", Gtk.main_quit, "WM destroy")
vbox = Gtk.VBox()
window.add(vbox)
self.entry = Gtk.Entry()
vbox.pack_start(self.entry, False, True, 0)
self.button = Gtk.Button("Start")
self.button.connect("clicked", self.start_stop)
vbox.add(self.button)
window.show_all()
self.player = Gst.ElementFactory.make("playbin", "player")
fakesink = Gst.ElementFactory.make("fakesink", "fakesink")
self.player.set_property("video-sink", fakesink)
bus = self.player.get_bus()
bus.add_signal_watch()
bus.connect("message", self.on_message)
def __init__(self,MainGrid):
Gtk.VBox.__init__(self)
self.btn1=Gtk.Button()
self.btn1.set_image(Gtk.Image.new_from_icon_name("filenew",Gtk.IconSize.DIALOG))
self.btn1.set_name("button1")
self.add(self.btn1)
#
# self.win_width = MainGrid.window.win_width
# self.win_height = MainGrid.window.win_height
# wid = self.win_width * 0.1
# hei = self.win_height
# print "requested width: ",wid
# print "requested height: ",hei
# print "-----------------------------"
# self.set_size_request(wid, hei)
def __init__(self):
self.main_window = Gtk.Window()
self.main_window.set_border_width(5)
self.main_window.connect("destroy", self._destroy)
self.main_vbox = Gtk.VBox()
self.select_hbox = Gtk.HBox()
self.select_button = Gtk.Button("Select")
self.select_button.connect("clicked", self._select_clicked)
self.select_hbox.pack_start(self.select_button, False, True, 0)
self.file_combo = Gtk.ComboBoxText()
self.file_combo.connect("changed", self._file_combo_changed)
self.select_hbox.pack_start(self.file_combo, True, True, 0)
self.main_vbox.pack_start(self.select_hbox, False, True, 0)
self.metadata_table = Gtk.Table(1, 1)
self.metadata_table.attach(
Gtk.Label("Select a file to view metadata information..."), 0, 1, 0, 1)
self.main_vbox.pack_start(self.metadata_table, True, True, 0)
self.main_window.add(self.main_vbox)
self.main_window.show_all()
def __init__(self, addons_manager):
Gtk.VBox.__init__(self)
self.set_spacing(12)
self.addons_manager = addons_manager
self.cache = self.addons_manager.view.cache
self.db = self.addons_manager.view.db
self.icons = self.addons_manager.view.icons
self.recommended_addons = None
self.suggested_addons = None
self.label = Gtk.Label()
self.label.set_alignment(0, 0.5)
markup = '<big><b>%s</b></big>' % _('Add-ons')
self.label.set_markup(markup)
self.pack_start(self.label, False, False, 0)
def __init__(self, label_text=""):
Gtk.Viewport.__init__(self)
self.spinner = Gtk.Spinner()
self.spinner.set_size_request(48, 48)
# use a table for the spinner (otherwise the spinner is massive!)
spinner_table = Gtk.Table(3, 3, False)
self.spinner_label = Gtk.Label()
self.spinner_label.set_markup('<big>%s</big>' % label_text)
spinner_vbox = Gtk.VBox()
spinner_vbox.pack_start(self.spinner, True, True, 0)
spinner_vbox.pack_start(self.spinner_label, True, True, 10)
spinner_table.attach(spinner_vbox, 1, 2, 1, 2,
Gtk.AttachOptions.EXPAND, Gtk.AttachOptions.EXPAND)
#~ self.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(1.0, 1.0, 1.0))
self.add(spinner_table)
self.set_shadow_type(Gtk.ShadowType.NONE)
def get_test_buttons_window():
win = Gtk.Window()
win.set_size_request(200, 200)
vb = Gtk.VBox(spacing=12)
win.add(vb)
link = Link("<small>test link</small>", uri="www.google.co.nz")
vb.pack_start(link, False, False, 0)
button = Gtk.Button()
button.set_label("channels")
channels_button = ChannelSelector(button)
channels_button.parent_style_type = Gtk.Window
channels_button.set_build_func(_build_channels_list)
hb = Gtk.HBox()
hb.pack_start(button, False, False, 0)
hb.pack_start(channels_button, False, False, 0)
vb.pack_start(hb, False, False, 0)
win.show_all()
win.connect("destroy", Gtk.main_quit)
return win
def __init__(self, label_text=""):
Gtk.Viewport.__init__(self)
self.spinner = Gtk.Spinner()
self.spinner.set_size_request(48, 48)
# use a table for the spinner (otherwise the spinner is massive!)
spinner_table = Gtk.Table(3, 3, False)
self.spinner_label = Gtk.Label()
self.spinner_label.set_markup('<big>%s</big>' % label_text)
spinner_vbox = Gtk.VBox()
spinner_vbox.pack_start(self.spinner, True, True, 0)
spinner_vbox.pack_start(self.spinner_label, True, True, 10)
spinner_table.attach(spinner_vbox, 1, 2, 1, 2,
Gtk.AttachOptions.EXPAND, Gtk.AttachOptions.EXPAND)
#~ self.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(1.0, 1.0, 1.0))
self.add(spinner_table)
self.set_shadow_type(Gtk.ShadowType.NONE)
def __init__(self, lat=39.36873, lon=-2.417274645879, units='F'):
self.images = {}
self.echo = True
Gtk.Window.__init__(self)
self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
self.set_title(comun.APP)
self.set_default_size(900, 600)
self.set_icon_from_file(comun.ICON)
self.connect('destroy', self.close_application)
#
vbox = Gtk.VBox(spacing=5)
self.get_content_area().add(vbox)
hbox1 = Gtk.HBox()
vbox.pack_start(hbox1, True, True, 0)
self.scrolledwindow1 = Gtk.ScrolledWindow()
self.scrolledwindow1.set_policy(
Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.scrolledwindow1.set_shadow_type(Gtk.ShadowType.IN)
hbox1.pack_start(self.scrolledwindow1, True, True, 0)
self.viewer = WebKit.WebView()
self.scrolledwindow1.add(self.viewer)
self.scrolledwindow1.set_size_request(900, 600)
self.viewer.connect('title-changed', self.title_changed)
self.viewer.open('file://' + comun.HTML)
self.lat = lat
self.lon = lon
self.units = units
self.set_focus(self.viewer)
self.show_all()
self.message_queue = queue.Queue()
while Gtk.events_pending():
Gtk.main_iteration()
self.show_all()
self.inicialize()
self.run()
self.destroy()
# ###################################################################
# #########################ENGINE####################################
# ###################################################################
def get_image_with_text2(text, image=None):
vbox = Gtk.VBox()
if image:
# image = Gtk.Image.new_from_file(os.path.join(comun.IMAGESDIR,image))
image = load_image(os.path.join(comun.IMAGESDIR, image))
image.set_alignment(0.5, 0.5)
vbox.pack_start(image, True, True, 0)
label = Gtk.Label.new(text)
label.set_alignment(0.5, 0.5)
vbox.pack_start(label, True, True, 0)
return vbox
def __init__(self):
Gtk.Dialog.__init__(self, 'File Downloader',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.set_size_request(400, 100)
self.set_title('? ubi site file downloader')
self.connect('destroy', self.close_application)
#
vbox0 = Gtk.VBox(spacing = 10)
vbox0.set_border_width(5)
self.get_content_area().add(vbox0)
#
table1 = Gtk.Table(3,2,False)
vbox0.add(table1)
label10 = Gtk.Label('Extension:')
label10.set_alignment(0, 0.5)
table1.attach(label10,0,1,0,1)
#
self.entry10 = Gtk.Entry()
table1.attach(self.entry10,1,2,0,1)
#
label11 = Gtk.Label('Url:')
label11.set_alignment(0, 0.5)
table1.attach(label11,0,1,1,2)
#
self.entry11 = Gtk.Entry()
table1.attach(self.entry11,1,2,1,2)
#
#self.button = Gtk.Button('Select folder')
#self.button.connect('clicked',self.on_button_clicked)
#table1.attach(self.button,0,2,2,3)
#
self.show_all()
def __init__(self):
Gtk.Dialog.__init__(self, 'File Downloader',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.set_size_request(400, 100)
self.set_title('? ubi site file downloader')
self.connect('destroy', self.close_application)
#
vbox0 = Gtk.VBox(spacing = 10)
vbox0.set_border_width(5)
self.get_content_area().add(vbox0)
#
table1 = Gtk.Table(3,2,False)
vbox0.add(table1)
label10 = Gtk.Label('Extension:')
label10.set_alignment(0, 0.5)
table1.attach(label10,0,1,0,1)
#
self.entry10 = Gtk.Entry()
table1.attach(self.entry10,1,2,0,1)
#
label11 = Gtk.Label('Url:')
label11.set_alignment(0, 0.5)
table1.attach(label11,0,1,1,2)
#
self.entry11 = Gtk.Entry()
table1.attach(self.entry11,1,2,1,2)
#
#self.button = Gtk.Button('Select folder')
#self.button.connect('clicked',self.on_button_clicked)
#table1.attach(self.button,0,2,2,3)
#
self.show_all()
def add_select_elements_gui(self):
self.g_element_frame = frame = Gtk.Frame(label=_("Choose tones"))
self.config_box.pack_start(frame, False, False, 0)
self.g_select_rhythms_box = Gtk.VBox()
self.g_select_rhythms_box.set_border_width(gu.hig.SPACE_SMALL)
frame.add(self.g_select_rhythms_box)
self.soltogglebuttons = []
def add_rhythm_element(self, i):
assert len(self.m_data) <= self.m_num_beats
if len(self.g_box.get_children()) >= self.m_num_beats:
self.g_box.get_children()[self.m_num_beats-1].destroy()
vbox = Gtk.VBox(False, 0)
vbox.show()
im = gu.create_rhythm_image(const.RHYTHMS[i])
vbox.pack_start(im, True, True, 0)
vbox.pack_start(gu.create_png_image('rhythm-wrong'), False, False, 0)
vbox.get_children()[-1].hide()
self.g_box.pack_start(vbox, False, False, 0)
self.g_box.reorder_child(vbox, len(self.m_data))
self.m_data.append(i)
def mark_wrong(self):
if self.m_marked_wrong:
return
self.m_marked_wrong = True
vbox = Gtk.VBox()
assert len(self.get_children()) == 1
self.get_children()[0].reparent(vbox)
self.add(vbox)
label = Gtk.Label()
label.set_markup("<span size='small'>%s</span>" % gu.escape(_("Wrong")))
label.show()
vbox.pack_start(label, True, True, 0)
vbox.show()