我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用gi.repository.Gtk.HBox()。
def bottom_bar_handler(self, tim: time, text: str, action: str): """Add actions to the eventlist in the bottom bar. :param tim: Time of action. :param text: Recognized text. :param action: Action performed. """ row = Gtk.ListBoxRow() box = Gtk.HBox() box.set_homogeneous(True) text_label = Gtk.Label(text) text_label.set_line_wrap(True) box.pack_start(Gtk.Label(tim), False, False, 0) box.pack_start(text_label, True, True, 0) box.pack_start(Gtk.Label(action), False, False, 0) row.add(box) # Remove old entries if self.bottom_widget.get_object("event_list").get_row_at_index(40): self.bottom_widget.get_object("event_list").get_row_at_index(40).destroy() row.show_all() self.bottom_widget.get_object("event_list").prepend(row)
def buildTree(self, *args): for item in self.files: a = Gtk.Label(item) if os.path.isdir(self.projectPath + '/' + item): i = Gtk.Image.new_from_icon_name('folder', Gtk.IconSize.MENU) # change this for recursive function else: i = Gtk.Image.new_from_icon_name('text-x-script', Gtk.IconSize.MENU) hb = Gtk.HBox(spacing=6) hb.pack_start(i, False, False, 0) hb.pack_start(a, False, False, 0) row = Gtk.ListBoxRow() row.add(hb) self.sideView.add(row) self.sideView.show_all()
def add_module_is_deprecated_label(self): """ The deprecated module must set a message in self.g_deprecated_label in on_start_practise, preferable telling the file name of the lesson file. """ img = Gtk.Image() img.set_from_stock(Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.BUTTON) hbox = Gtk.HBox() hbox.set_border_width(12) self.practise_box.set_child_packing(self.g_lesson_heading, False, False, 0, 0) hbox.set_spacing(6) hbox.pack_start(img, True, True, 0) self.g_deprecated_label = Gtk.Label() hbox.pack_start(self.g_deprecated_label, True, True, 0) self.practise_box.pack_start(hbox, False, False, 0) self.practise_box.reorder_child(hbox, 0)
def add_select_num_beats_gui(self): ### hbox = Gtk.HBox() hbox.set_spacing(gu.hig.SPACE_SMALL) label = Gtk.Label(label=_("Number of beats in question:")) hbox.pack_start(label, False, False, 0) self.config_box_sizegroup.add_widget(label) label.set_alignment(1.0, 0.5) hbox.pack_start(gu.nSpinButton(self.m_exname, "num_beats", Gtk.Adjustment(4, 1, 100, 1, 10)), False, False, 0) self.config_box.pack_start(hbox, False, False, 0) hbox.show_all() # hbox = Gtk.HBox() hbox.set_spacing(gu.hig.SPACE_SMALL) label = Gtk.Label(label=_("Count in before question:")) hbox.pack_start(label, False, False, 0) self.config_box_sizegroup.add_widget(label) label.set_alignment(1.0, 0.5) hbox.pack_start(gu.nSpinButton(self.m_exname, "count_in", Gtk.Adjustment(2, 0, 10, 1, 10)), False, False, 0) hbox.show_all() self.config_box.pack_start(hbox, False, False, 0)
def add_lock_to_key_gui(self): # gui to lock to a key def toggle_lock_to_key_sensitivity(checkbutton): self.g_notename.set_sensitive(checkbutton.get_active()) self.g_scaletype.set_sensitive(checkbutton.get_active()) self.g_lock_to_key_hbox = Gtk.HBox(False, gu.hig.SPACE_SMALL) self.config_box.pack_start(self.g_lock_to_key_hbox, False, False, 0) check = gu.nCheckButton(self.m_exname, 'lock-to-key', _("Lock intervals to key:"), callback = toggle_lock_to_key_sensitivity) self.g_lock_to_key_hbox.pack_start(check, False, False, 0) self.g_notename = gu.nComboBox(self.m_exname, 'lock-to-key-note', mpd.MusicalPitch.new_from_int(60).get_user_notename(), [mpd.MusicalPitch.new_from_int(60 + x).get_user_notename() for x in range(12)]) self.g_notename.show() self.g_lock_to_key_hbox.pack_start(self.g_notename, False, False, 0) self.g_scaletype = gu.nComboBox(self.m_exname, 'lock-to-key-scaletype', _("Major"), [n['name'] for n in utils.key_data.values()]) self.g_scaletype.show() self.g_lock_to_key_hbox.pack_start(self.g_scaletype, False, False, 0) toggle_lock_to_key_sensitivity(check)
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 __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 create_tab(self, title, tab_child, icon=''): tab_box = Gtk.HBox(False, 3) close_button = Gtk.Button() image = Gtk.Image() image.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU) label = Gtk.Label(label=title) if icon: i = Gtk.Image() i.set_from_stock(eval('Gtk.STOCK_' + icon), Gtk.IconSize.MENU) tab_box.pack_start(i, False, False, 0) close_button.connect("clicked", self.close_tab, tab_child) close_button.set_image(image) close_button.set_relief(Gtk.ReliefStyle.NONE) tab_box.pack_start(label, True, True, 0) tab_box.pack_end(close_button, False, False, 0) tab_box.show_all() if title in ['Loading dasm...', 'Code', 'Callgraph', 'Flowgraph', 'Interactive', 'Strings', "Sections", 'Hexdump', 'Bindiff', 'File info']: close_button.hide() return tab_box
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 _append_recommended_for_you(self): # TODO: This space will initially contain an opt-in screen, and this # will update to the tile view of recommended apps when ready # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen self.bottom_hbox = Gtk.HBox(spacing=StockEms.SMALL) bottom_hbox_alignment = Gtk.Alignment() bottom_hbox_alignment.set_padding(0, 0, StockEms.MEDIUM - 2, StockEms.MEDIUM - 2) bottom_hbox_alignment.add(self.bottom_hbox) self.vbox.pack_start(bottom_hbox_alignment, False, False, 0) # TODO: During development, place the "Recommended For You" panel # at the bottom, but swap this with the Top Rated panel once # the recommended for you pieces are done and deployed # see https://wiki.ubuntu.com/SoftwareCenter#Home_screen self.recommended_for_you_panel = RecommendationsPanelLobby(self) self.bottom_hbox.pack_start(self.recommended_for_you_panel, True, True, 0)
def _add_progress_ui(self): # create toolbar box self.header = Gtk.HBox() # add spinner self.spinner = Gtk.Spinner() self.header.pack_start(self.spinner, False, False, 6) # add a url to the toolbar self.url = Gtk.Label() self.url.set_ellipsize(Pango.EllipsizeMode.END) self.url.set_alignment(0.0, 0.5) self.url.set_text("") self.header.pack_start(self.url, True, True, 0) # frame around the box self.frame = Gtk.Frame() self.frame.set_border_width(3) self.frame.add(self.header) self.pack_start(self.frame, False, False, 6) # connect the webkit stuff self.webkit.connect("notify::uri", self._on_uri_changed) self.webkit.connect("notify::load-status", self._on_load_status_changed)
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 get_test_symbolic_icons_window(): win = Gtk.Window() win.set_border_width(20) hb = Gtk.HBox(spacing=12) win.add(hb) ico = SymbolicIcon("available") hb.add(ico) ico = PendingSymbolicIcon("pending") ico.start() ico.set_transaction_count(33) hb.add(ico) ico = PendingSymbolicIcon("pending") ico.start() ico.set_transaction_count(1) hb.add(ico) win.show_all() win.connect("destroy", Gtk.main_quit) return win
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_text(text, image=None): hbox = Gtk.HBox() if image: image = load_image(os.path.join(comun.IMAGESDIR, image)) # image = Gtk.Image.new_from_file(image) image.set_alignment(1, 0.5) hbox.pack_start(image, True, True, 0) label = Gtk.Label.new(text) label.set_alignment(0, 0.5) hbox.pack_start(label, True, True, 0) return hbox
def applySettings(self, *args): self.sview.set_show_line_numbers(self.showLineNumbers) self.sbuff.set_highlight_matching_brackets(self.highlightMatchingBrackets) if self.wordWrap: self.sview.set_wrap_mode(Gtk.WrapMode.WORD_CHAR) else: self.sview.set_wrap_mode(Gtk.WrapMode.NONE) Gtk.Settings.get_default().set_property('gtk-application-prefer-dark-theme', self.darkMode) self.autoToggling = True self.toggleDarkCheck.set_active(self.darkMode) self.toggleHighlightCheck.set_active(self.highlightMatchingBrackets) self.toggleLineCheck.set_active(self.showLineNumbers) self.toggleWordWrap.set_active(self.wordWrap) self.autoToggling = False self.terminal.set_color_background(self.sview.get_style_context().get_background_color(Gtk.StateFlags.NORMAL)) if hasattr(self, 'gitButton'): text = Repository(self.projectPath).head.shorthand repo = Gtk.HBox(spacing=6) img = None if self.darkMode: img = Gtk.Image.new_from_file('resources/icons/git-branch-white.svg') else: img = Gtk.Image.new_from_file('resources/icons/git-branch.svg') repo.pack_start(img, False, False, 0) repo.pack_start(Gtk.Label(text), False, False, 0) repo.show_all() self.gitButton.remove(self.gitButton.get_child()) self.gitButton.set_tooltip_text("On branch " + text) self.gitButton.add(repo)
def __init__(self): Gtk.HBox.__init__(self) self.checkbox_dict = {} for x in range(1, mpd.interval.max_interval + 1): self.checkbox_dict[x] = c \ = Gtk.ToggleButton(mpd.interval.short_name[x]) c.connect('toggled', self.on_toggle) c.show() self.pack_start(c, True, True, 0)
def update_select_elements_buttons(self): """ (Re)create the checkbuttons used to select which rhythm elements to be used when creating questions. We only need to do this if we are in m_custom_mode. """ for but in self.soltogglebuttons: but.destroy() self.soltogglebuttons = [] gs = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) for i, v in enumerate(( [1, 4, -1, 8, 11, -1, 15, 18, 21, -1, 25, 28, -1, 32], [0, 3, 6, 7, 10, 13, 14, 17, 20, 23, 24, 27, 30, 31, 34], [2, 5, -1, 9, 12, -1, 16, 19, 22, -1, 26, 29, -1, 33])): hbox = Gtk.HBox(True, 0) for k in v: b = self.soltogglebutton(k) gs.add_widget(b) for n in self.m_t.m_P.header.solmisation_elements: if k == n: b.set_active(True) hbox.pack_start(b, True, True, 0) self.soltogglebuttons.append(b) spacing = Gtk.Alignment() if i in (0, 2): spacing.set_property('left-padding', 16) spacing.set_property('right-padding', 16) spacing.add(hbox) self.g_select_rhythms_box.pack_start(spacing, True, True, 0) spacing.show_all()
def __init__(self, teacher): abstract.LessonbasedGui.__init__(self, teacher) ################ # practise_box # ################ self.g_contents = Gtk.Table() hbox = gu.bHBox(self.practise_box, True, False) hbox.pack_start(Gtk.HBox(), True, True, 0) hbox.pack_start(self.g_contents, True, True, 0) hbox.pack_start(Gtk.HBox(), True, True, 0) self.g_contents.set_col_spacings(gu.PAD) self.g_contents.set_row_spacings(gu.PAD) self.g_music_displayer = mpd.MusicDisplayer() self.g_music_displayer.set_size_request(100, -1) self.g_contents.attach(self.g_music_displayer, 1, 2, 1, 2) self.g_flashbar = gu.FlashBar() self.practise_box.pack_start(self.g_flashbar, False, False, 0) self.std_buttons_add( ('new', self.new_question), ('repeat', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)), ('repeat_arpeggio', lambda w: self.run_exception_handled(self.m_t.m_P.play_question_arpeggio)), ('give_up', self.give_up)) self.practise_box.show_all() ############## # config_box # ############## self.config_box.set_spacing(gu.PAD_SMALL) self.add_random_transpose_gui() # ----------------------------------------- self.g_select_questions_category_box, category_box= gu.hig_category_vbox( _("Chord types to ask")) self.config_box.pack_start(self.g_select_questions_category_box, True, True, 0) self.g_select_questions = QuestionNameCheckButtonTable(self.m_t) self.g_select_questions.initialize(4, 0) category_box.pack_start(self.g_select_questions, False, False, 0) self.g_select_questions.show()
def __init__(self, parent): Gtk.Frame.__init__(self) self.set_shadow_type(Gtk.ShadowType.IN) self.g_parent = parent self.g_box = Gtk.HBox(False, 0) self.g_box.show() self.g_box.set_spacing(gu.PAD_SMALL) self.g_box.set_border_width(gu.PAD) self.add(self.g_box) self.m_data = [] # the number of rhythm elements the viewer is supposed to show self.m_num_beats = 0 self.g_face = None self.__timeout = None
def __init__(self, teacher): abstract.LessonbasedGui.__init__(self, teacher) self.m_key_bindings = {'backspace_ak': self.on_backspace} self.g_music_displayer = mpd.MusicDisplayer() self.practise_box.pack_start(self.g_music_displayer, False, False, 0) self.g_answer_button_box = gu.NewLineBox() self.practise_box.pack_start(self.g_answer_button_box, False, False, 0) # The user fill the answer in this box self.g_answer_frame = Gtk.Frame() self.g_answer_frame.set_shadow_type(Gtk.ShadowType.IN) self.practise_box.pack_start(self.g_answer_frame, False, False, 0) self.g_answer = Gtk.HBox() self.g_answer_frame.add(self.g_answer) self.g_answer_frame.show_all() # Flashbar self.g_flashbar = gu.FlashBar() self.g_flashbar.show() self.practise_box.pack_start(self.g_flashbar, False, False, 0) # action area self.std_buttons_add( ('new', self.new_question), ('play_music', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)), ('display_music', self.show_answer), ('repeat', self.repeat_question), ('guess_answer', self.guess_answer), ('play_tonic', lambda w: self.run_exception_handled(self.m_t.play_tonic)), ('give_up', self.give_up), ('backspace', self.on_backspace), ) ############## # statistics # ############## self.setup_statisticsviewer(statisticsviewer.StatisticsViewer, "")
def __init__(self, teacher): abstract.Gui.__init__(self, teacher) # self.g_music_displayer = mpd.MusicDisplayer() self.practise_box.pack_start(self.g_music_displayer, False, False, 0) # self.g_tap = gu.bButton(self.practise_box, _("Tap here"), self.on_tap) self.std_buttons_add( ('new', self.on_new_question), ('play_music', lambda w: self.run_exception_handled(self.m_t.m_P.play_question)), ('display_music', self.show_answer), ('repeat', self.on_repeat), ('give_up', self.on_give_up)) # Flashbar self.g_flashbar = gu.FlashBar() self.g_flashbar.show() self.practise_box.pack_start(self.g_flashbar, False, False, 0) # Config box label = Gtk.Label(label=_("Accuracy required:")) self.config_box_sizegroup.add_widget(label) label.set_alignment(1.0, 0.5) spin = gu.nSpinButton(self.m_exname, 'accuracy', Gtk.Adjustment(0, 0, 2, 0.01, 0.05)) spin.set_tooltip_text("See bug report #93 (http://bugs.solfege.org/93) and add suggested values to the bug report.") spin.set_digits(2) hbox = Gtk.HBox() hbox.set_spacing(gu.hig.SPACE_SMALL) hbox.pack_start(label, False, False, 0) hbox.pack_start(spin, False, False, 0) self.config_box.pack_start(hbox, False, False, 0) hbox.show_all()
def __init__(self, parent): Gtk.Frame.__init__(self) self.set_shadow_type(Gtk.ShadowType.IN) self.g_parent = parent self.g_box = Gtk.HBox() self.g_box.show() self.g_box.set_spacing(gu.PAD_SMALL) self.g_box.set_border_width(gu.PAD) self.add(self.g_box) self.m_data = [] # the number of rhythm elements the viewer is supposed to show self.m_num_notes = 0 self.g_face = None self.__timeout = None
def __init__(self, teacher): abstract.IntervalGui.__init__(self, teacher) self.g_test_stat_dlg = None self.std_buttons_add(('give_up', self.give_up)) ############## # config_box # ############## self.g_mici = MultipleIntervalConfigWidget(self.m_exname) self.config_box.pack_start(self.g_mici, False, False, 0) box = Gtk.HBox(False, 0) self.config_box.pack_start(box, False, False, padding=gu.PAD_SMALL) self._add_auto_new_question_gui(self.config_box) # ---------------------------------- self._create_select_inputwidget_gui() self.add_lock_to_key_gui() self.config_box.show_all() ############## # statistics # ############## self.setup_statisticsviewer(statisticsviewer.StatisticsViewer, _("Melodic interval")) self.select_inputwidget() def _f(watchvar): # The variables being watched by this function will change # when we switch lesson files or when we are in expert mode and # the user configures the exercise manually. We only have to run # end|start_exercise here in expert mode because it is called # automatically when we change lesson file. if self.m_t.m_custom_mode: self.on_end_practise() for i in range(self.get_int('maximum_number_of_intervals')): self.add_watch('ask_for_intervals_%i' % i, _f) self.add_watch('number_of_intervals', _f)
def bHBox(pack_into, expand=True, fill=True, padding=0): b = Gtk.HBox(False, 0) b.show() pack_into.pack_start(b, expand, fill, padding) return b
def __init__(self): Gtk.Frame.__init__(self) self.set_shadow_type(Gtk.ShadowType.IN) self.__stack = [] self.__label = HarmonicProgressionLabel('') self.__content = Gtk.HBox(False, 0) self.__content.show() self.add(self.__content) self.__timeout = None # The allocated size self.m_sx, self.m_sy = 0, 0
def create_stock_menu_item(stock, txt, callback, ag, accel_key, accel_mod): box = Gtk.HBox(False, 0) box.set_spacing(PAD_SMALL) im = Gtk.Image() im.set_from_stock(stock, Gtk.IconSize.MENU) item = Gtk.ImageMenuItem(txt) item.set_image(im) if accel_key != 0: item.add_accelerator('activate', ag, accel_key, accel_mod, Gtk.AccelFlags.VISIBLE) item.connect('activate', callback) return item
def setup_post(self): self.g_postbox = Gtk.HBox(False, 0) self.g_postbox.set_no_show_all(True) self.pack_start(self.g_postbox, True, True, 0)
def __init__(self): Gtk.Dialog.__init__(self, _(u"_Create profile\u2026").replace(u"\u2026", "").replace("_", "")) self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT) vbox = gu.hig_dlg_vbox() self.vbox.pack_start(vbox, True, True, 0) # label = Gtk.Label(label=_("Enter the name of the new folder:")) label.set_alignment(0.0, 0.5) vbox.pack_start(label, False, False, 0) # self.g_entry = Gtk.Entry() self.g_entry.connect('changed', self.on_entry_changed) self.g_entry.set_activates_default(True) vbox.pack_start(self.g_entry, False, False, 0) # label = Gtk.Label(label=_("Your profile data will be stored in:")) label.set_alignment(0.0, 0.5) vbox.pack_start(label, False, False, 0) # self.g_profile_location = Gtk.Label() vbox.pack_start(self.g_profile_location, False, False, 0) # self.g_statusbox = Gtk.HBox() self.g_statusbox.set_no_show_all(True) vbox.pack_start(self.g_statusbox, False, False, 0) im = Gtk.Image() im.set_from_stock(Gtk.STOCK_DIALOG_WARNING, Gtk.IconSize.MENU) self.g_statusbox.pack_start(im, False, False, 0) im.show() self.g_status = Gtk.Label() self.g_status.show() self.g_statusbox.pack_start(self.g_status, False, False, 0) self.g_entry.set_text(_("New Profile")) self.set_default_response(Gtk.ResponseType.ACCEPT)
def __init__(self, fields=('link',)): SelectWinBase.__init__(self) self.m_fields = fields app = solfege.app self.g_box = Gtk.VBox(False, 0) self.g_box.set_border_width(gu.hig.SPACE_MEDIUM) self.add_with_viewport(self.g_box) self.g_searchbox = Gtk.HBox(False, gu.hig.SPACE_SMALL) self.g_box.pack_start(self.g_searchbox, False, False, padding=gu.hig.SPACE_MEDIUM) self.g_searchentry = Gtk.Entry() self.g_searchbox.pack_start(self.g_searchentry, True, True, 0) self.g_searchentry.connect('activate', self.on_search) gu.bButton(self.g_searchbox, _("Search"), callback=self.on_search, expand=False) self.show_all()
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 FramedInstrumentSelector(title, exname, varname, sizegroup): box = Gtk.HBox() box.set_spacing(6) label = Gtk.Label(label=title) label.set_alignment(0.0, 0.5) box.pack_start(label, False, False, 0) n = nInstrumentSelector(exname, varname, None) sizegroup.add_widget(label) n.show() box.pack_start(n, True, True, 0) return box
def create_linkrow(self, link_this): hbox = Gtk.HBox() def ff(btn, page): if id(page) in editor_of(self).m_page_mapping: editor_of(self).show_page_id(id(page)) else: if not page[0]: page[0].append(pd.LinkList(link_this.m_name)) p = Page(page, parent_page(self)) p.show() editor_of(self).add_page(p) if isinstance(link_this, pd.Page): linkbutton = gu.ClickableLabel(link_this.m_name) linkbutton.connect('clicked', ff, link_this) else: try: linkbutton = gu.ClickableLabel(lessonfile.infocache.get(link_this, 'title')) linkbutton.set_tooltip_text(link_this) except lessonfile.InfoCache.FileNotFound: linkbutton = gu.ClickableLabel(_(u"«%s» was not found") % link_this) linkbutton.make_warning() hbox.pack_start(linkbutton, True, True, 0) linkbutton.connect('button-press-event', self.on_right_click_row, link_this) hbox.show_all() return hbox
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 __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 __init__(self, text, menu): GObject.GObject.__init__(self) self.menu = menu hbox1 = Gtk.HBox() hbox2 = Gtk.HBox() icon = Gtk.Image() icon.set_from_file(datafile_path('bokken-small.svg')) hbox1.pack_start(icon, True, True, 3) label = Gtk.Label() label.set_markup("<b>"+ text + "</b>") hbox1.pack_start(label, True, True, 3) arrow = Gtk.Arrow(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN) hbox1.pack_start(arrow, False, False, 3) hbox2.pack_start(hbox1, True, True, 0) # MEOW Text settings #attrs = Pango.AttrList() #attrs.change(Pango.AttrWeight(Pango.Weight.SEMIBOLD, 0, -1)) #label.set_attributes(attrs) self.add(hbox2) self.set_relief(Gtk.ReliefStyle.NORMAL) self.set_can_focus(True) self.set_can_default(False) self.connect("toggled", self.on_toggled) for sig in "selection-done", "deactivate", "cancel": menu.connect(sig, self.on_menu_dismiss)
def create_seek_buttons(self): self.hbox = Gtk.HBox(False, 1) self.back = Gtk.Button() self.back_img = Gtk.Image() self.back_img.set_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.MENU) self.back.set_image(self.back_img) self.back.set_relief(Gtk.ReliefStyle.NONE) self.back.connect('clicked', self.do_seek, 'b') self.forward = Gtk.Button() self.forward_img = Gtk.Image() self.forward_img.set_from_stock(Gtk.STOCK_GO_FORWARD, Gtk.IconSize.MENU) self.forward.set_image(self.forward_img) self.forward.set_relief(Gtk.ReliefStyle.NONE) self.forward.connect('clicked', self.do_seek, 'f') self.seek = Gtk.Entry() self.seek.set_max_length(30) self.seek.set_icon_from_stock(1, Gtk.STOCK_JUMP_TO) self.seek.set_activates_default(True) self.seek.connect("activate", self.goto) self.seek.connect("icon-press", self.goto) self.seek.set_icon_tooltip_text(1, 'Go') self.hbox.pack_start(self.back, False, False, 0) self.hbox.pack_start(self.forward, False, False, 0) self.hbox.pack_start(self.seek, True, True, 0) return self.hbox
def __init__(self): GObject.GObject.__init__(self) # XDotWidget xdotwidget = self.xdotwidget = xdot.DotWidget() # Toolbar uimanager = Gtk.UIManager() actiongroup = Gtk.ActionGroup('Actions') actiongroup.add_actions(( ('ZoomIn', Gtk.STOCK_ZOOM_IN, None, None, None, self.xdotwidget.on_zoom_in), ('ZoomOut', Gtk.STOCK_ZOOM_OUT, None, None, None, self.xdotwidget.on_zoom_out), ('ZoomFit', Gtk.STOCK_ZOOM_FIT, None, None, None, self.xdotwidget.on_zoom_fit), ('Zoom100', Gtk.STOCK_ZOOM_100, None, None, None, self.xdotwidget.on_zoom_100), )) uimanager.insert_action_group(actiongroup, 0) uimanager.add_ui_from_string(self.ui) toolbar = uimanager.get_widget('/ToolBar') toolbar.set_icon_size(Gtk.IconSize.SMALL_TOOLBAR) toolbar.set_style(Gtk.ToolbarStyle.ICONS) toolbar.set_show_arrow(False) label = self.label = Gtk.Label() hbox = Gtk.HBox(False, 5) hbox.pack_start(toolbar, False, True, 0) hbox.pack_start(label, False, True, 0) self.pack_start(hbox, False, True, 0) self.pack_start(xdotwidget, True, True, 0)
def add_text(self, data_dict, version): '''data_dict ontains text to be added. Key will be the title Value will be... well, the value :)''' self.box = Gtk.HBox(False, 1) self._statusbar.pack_start(self.box, False, False, 1) ellipsize = Pango.EllipsizeMode.NONE for element in data_dict.keys(): if element == 'Arch': _icon = Gtk.Image.new_from_file(self.icons[element]) else: _icon = Gtk.Image.new_from_stock(self.icons[element], Gtk.IconSize.MENU) self.box.pack_start(_icon, False, False, 0) # Element label label = Gtk.Label() label.set_markup('<b>%s:</b>' % element) label.set_padding(1, 0) label.set_max_width_chars(len(element) + 1) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) # Element content label = Gtk.Label(label=str(data_dict[element])) label.set_padding(1, 0) label.set_max_width_chars(len(str(data_dict[element]))) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) sep = Gtk.VSeparator() self.box.pack_start(sep, True, True, 1) if version: _icon = Gtk.Image.new_from_file(datafile_path('bokken-small.svg')) self.pack_start(_icon, False, False, 1) label = Gtk.Label() label.set_markup('<b>Bokken ' + version + '</b> (' + self.uicore.backend.capitalize() + ' ' + self.uicore.version + ')') label.set_padding(1, 0) self.pack_end(label, False, True, 0) self.show_all()
def __init__(self, core, main): self.uicore = core self.main = main self.last_fcn = '' #dotcode = self.uicore.get_callgraph() #GObject.GObject.__init__(self, False, 1) # MEOW GObject.GObject.__init__(self) self.side_vb = Gtk.VBox(False, 1) self.side_hb = Gtk.HBox(False, 1) #self.dot_widget = DotWidget() self.dot_widget = mydot_widget.MyDotWidget(self.uicore, self.main) self.create_tree() self.create_preview() self.pack_start(self.dot_widget, True, True, 0) self.bar = graph_bar.GraphBar(self.dot_widget, self, self.uicore) #self.pack_start(self.bar, False, False, 0) self.side_hb.pack_start(self.bar, False, False, 1) if self.uicore.backend == 'radare': self.pack_start(self.side_vb, False, False, 1) self.side_hb.pack_start(self.sw, True, True, 1) self.side_vb.pack_start(self.side_hb, True, True, 1) self.side_vb.pack_start(self.preview, False, False, 0)
def __init__(self, parent=None, title='', description='', long_description=''): Gtk.Window.__init__(self, title=title) self.set_parent(parent) self.set_transient_for(parent) self.set_destroy_with_parent(False) self.set_default_size(600, 500) self.vbox = Gtk.VBox(spacing=0) self.add(self.vbox) self.text_buffer = Gtk.TextBuffer() self.text_buffer.insert_at_cursor(description) self.text_buffer.insert_at_cursor( '\n\n' + '############################################################' + '\n') self.text_buffer.insert_at_cursor( 'Complete file implementing the input method follows here:\n') self.text_buffer.insert_at_cursor( '############################################################' + '\n') self.text_buffer.insert_at_cursor(long_description) self.text_view = Gtk.TextView() self.text_view.set_buffer(self.text_buffer) self.text_view.set_editable(False) self.text_view.set_cursor_visible(False) self.text_view.set_justification(Gtk.Justification.LEFT) self.text_view.set_wrap_mode(Gtk.WrapMode.WORD) self.scrolledwindow = Gtk.ScrolledWindow() self.scrolledwindow.set_hexpand(True) self.scrolledwindow.set_vexpand(True) self.scrolledwindow.add(self.text_view) self.vbox.pack_start(self.scrolledwindow, True, True, 0) self.close_button = Gtk.Button(stock=Gtk.STOCK_CLOSE) self.close_button.connect("clicked", self.on_close_button_clicked) self.hbox = Gtk.HBox(spacing=0) self.hbox.pack_end(self.close_button, False, False, 0) self.vbox.pack_start(self.hbox, False, False, 5)
def insert_image(self, widget): self.insert_window_image = Gtk.Window() self.insert_window_image.set_title("Insert Image") self.insert_window_image.set_resizable(True) self.insert_window_image.set_border_width(6) self.insert_window_image.set_default_size(300, 250) self.insert_window_image.set_position(Gtk.WindowPosition.CENTER) vbox = Gtk.VBox() label_alt_text = Gtk.Label("Alt Text:") self.entry_alt_text_i = Gtk.Entry() label_title = Gtk.Label("Title:") self.entry_title_i = Gtk.Entry() label_url = Gtk.Label("Path/Url:") self.entry_url_i = Gtk.Entry() vbox.pack_start(label_alt_text, self, False, False) vbox.pack_start(self.entry_alt_text_i, self, False, False) vbox.pack_start(label_title, self, False, False) vbox.pack_start(self.entry_title_i, self, False, False) vbox.pack_start(label_url, self, False, False) self.hbox_url = Gtk.HBox() self.hbox_url.pack_start(self.entry_url_i, self, True, False) self.path_file_button = Gtk.FileChooserButton(title= "Select an image") self.path_file_button.connect("file-set", self.file_chooser_button_clicked) self.hbox_url.pack_start(self.path_file_button, self, False, False) vbox.pack_start(self.hbox_url, self, False, False) button = Gtk.Button("Insert Image") vbox.pack_end(button, self, False, False) self.insert_window_image.add(vbox) self.insert_window_image.show_all() button.connect("clicked", self.insert_image_cmd, self.insert_window_image)
def __init__(self, window, format="dmy", separator='/', value = datetime.date.today()): Gtk.HBox.__init__(self) self.format = format self.separator = separator self._window = window self.entry = Gtk.Entry() self.entry.set_editable(False) self.button = Gtk.Button() self.button.add(Gtk.Arrow.new(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN)) self.button.connect('clicked', self.on_button) self.pack_start(self.entry, 0, 0, 0) self.pack_start(self.button, 0, 0, 0) self.month_changed = False self.set_date(value)
def __init__(self,url): self.code = None Gtk.Dialog.__init__(self) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_title(comun.APP) self.set_icon_from_file(comun.ICON) # 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(600,420) self.viewer.connect('navigation-policy-decision-requested', self.on_navigation_requested) self.viewer.open(url) # self.show_all() #################################################################### #########################BROWSER#################################### ####################################################################
def __init__(self, window, index=0, values = [], height = 150): Gtk.HBox.__init__(self) self._window = window self.entry = Gtk.Entry() self.entry.set_editable(False) self.button = Gtk.Button() self.button.add(Gtk.Arrow.new(Gtk.ArrowType.DOWN, Gtk.ShadowType.IN)) self.button.connect('clicked', self.on_button) self.pack_start(self.entry, 0, 0, 0) self.pack_start(self.button, 0, 0, 0) self.index = index self.values = values self.height = height
def __init__(self): Gtk.HBox.__init__(self) title = Gtk.Label('Size:') self.width = Gtk.Entry() self.height = Gtk.Entry() text = Gtk.Label('x') okay = Gtk.Button('Okay') okay.connect('clicked', self.clicked) self.pack_start(title, True, True, 10) self.pack_start(self.width, True, True, 0) self.pack_start(text, True, True, 0) self.pack_start(self.height, True, True, 0) self.pack_start(okay, True, True, 0) self.set_size(*self.default)