我们从Python开源项目中,提取了以下29个代码示例,用于说明如何使用gi.repository.Gtk.Frame()。
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 __init__(self, configuration, channels): Gtk.Frame.__init__(self) self.configuration = configuration self.channels = channels vbox = Gtk.Box(self, orientation=Gtk.Orientation.VERTICAL, spacing=2) vbox.set_homogeneous(False) self.add(vbox) self.label = Gtk.Label() vbox.pack_start(self.label, False, True, 0) if "group" in configuration: self.label.set_text(configuration["group"]) hbox = Gtk.Box(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=6) hbox.set_homogeneous(False) vbox.pack_start(hbox, False, True, 0) self.button_settings = Gtk.Button.new() self.button_settings.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.BUTTON)) self.button_settings.connect("clicked", self.on_settings_clicked) hbox.pack_start(self.button_settings, False, True, 0) self.hbox = Gtk.Box(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=6) hbox.pack_start(self.hbox, True, True, 0) if "functions" in configuration: for func in configuration["functions"]: button = Gtk.Button(func["label"]) button.connect("clicked", self.on_button_clicked) button.brick_function = func self.hbox.pack_start(button, True, True, 0) self.sbrick = None self.hbox.set_sensitive(False)
def __init__(self): Gtk.Frame.__init__(self) self.sbrick = None self.set_label("SBrick Information") self.store = Gtk.ListStore(str, str) self.iterSBrickID = self.store.append(["SBrick BlueGiga ID", "--"]) self.iterHardwareVersion = self.store.append(["Hardware Version", "--"]) self.iterSoftwareVersion = self.store.append(["Software Version", "--"]) self.iterNeedAuthentication = self.store.append(["Need Authentication", "--"]) self.iterIsAuthenticated = self.store.append(["Is Authenticated", "--"]) self.iterAuthenticationTimeout = self.store.append(["Authentication Timeout", "--"]) self.iterInputVoltage = self.store.append(["Input Voltage", "--"]) self.iterTemperature = self.store.append(["Temperature", "--"]) self.iterPowerCycles = self.store.append(["Power Cycles", "--"]) self.iterWatchdogTimeout = self.store.append(["Watchdog Timeout", "--"]) self.iterUpTime = self.store.append(["Up Time", "--"]) self.iterThermalLimit = self.store.append(["Thermal Limit", "--"]) self.listView = Gtk.TreeView(self.store) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Item", renderer, text=0) self.listView.append_column(column) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn("Value", renderer, text=1) self.listView.append_column(column) self.scrollTree = Gtk.ScrolledWindow() self.scrollTree.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.scrollTree.add_with_viewport(self.listView) self.scrollTree.set_min_content_height(100) self.add(self.scrollTree) self.set_sensitive(False)
def add_select_elements_gui(self): self.g_element_frame = frame = Gtk.Frame(label=_("Rhythms to use in question")) self.config_box.pack_start(frame, False, False, 0) self.g_select_rhythms_box = gu.NewLineBox() self.g_select_rhythms_box.set_border_width(gu.PAD_SMALL) frame.add(self.g_select_rhythms_box)
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 __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, 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, 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 __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 __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 remove_all(self): for child in self.box.get_children(): self.box.remove(child) for child in self.get_children(): if type(child) is not Gtk.Frame: self.remove(child)
def createSubTab(Tab, notebook, label): Tab.set_border_width(10) notebook.append_page(Tab, Gtk.Label(label)) Frame = Gtk.Frame() Tab.add(Frame) Grid = Gtk.Grid() Frame.add(Grid) return Grid # Setting Columns in TreeView
def createSubFrame(Tab): Frame = Gtk.Frame() Tab.add(Frame) grid = Gtk.Grid() Frame.add(grid) return grid
def make_plugin_grid(icon, plg, mdesc, mexts, mtype): grid = Gtk.Grid() grid.set_column_homogeneous(False) grid.set_property("margin", 20) plg_grid = Gtk.Grid() plg_grid.set_column_spacing(10) plg_grid.attach(icon, 0, 0, 1, 1) plg_grid.attach(plg, 1, 0, 1, 1) mime_grid = Gtk.Grid() mime_grid.set_hexpand(True) mime_grid.set_column_spacing(10) mime_grid.set_row_spacing(5) mime_grid.set_column_homogeneous(True) mime_grid.set_row_homogeneous(False) mime_grid.attach(make_mime_label("<b>{}</b>".format(_("MIME Type")), 1,), 0, 0, 1, 1) mime_grid.attach(make_mime_label("<b>{}</b>".format(_("Description")), 1), 1, 0, 1, 1) mime_grid.attach(make_mime_label("<b>{}</b>".format(_("Extension")), 1), 2, 0, 1, 1) for c, i in enumerate(mtype): mime_grid.attach(make_mime_label(i, 0), 0, c+1, 1, 1) for c, i in enumerate(mdesc): mime_grid.attach(make_mime_label(i, 0), 1, c+1, 1, 1) for c, i in enumerate(mexts): if not i: i = "" else: i = ", ".join(i) mime_grid.attach(make_mime_label(i, 0), 2, c+1, 1, 1) frame_mime = Gtk.Frame(name="frame_mime") frame_mime.add(mime_grid) grid.attach(plg_grid, 0, 0, 1, 1) grid.attach(frame_mime, 0, 1, 1, 1) return grid
def cert_declarations(data, arg): action = certificate(data, arg) box = Gtk.Frame(name="frame_x509") if arg == 14: view = View() view.set_auto_indent(True) view.set_show_line_numbers(True) view.set_wrap_mode(Gtk.WrapMode.WORD) view.set_monospace(True) view.get_buffer().set_text(action) view.set_can_focus(False) box.add(view) return box label = Gtk.Label(name="label_x509") label.set_selectable(True) label.set_can_focus(False) label.set_alignment(0.0, 0.0) label.set_markup(action) box.add(label) return box
def __setup_ui(self, win): btn_setting = Gtk.Button("Settings") btn_setting.set_margin_right(self.HORIZONTAL_MARGIN) btn_reload = Gtk.Button("Reload") btn_box = Gtk.HBox() btn_box.add(btn_setting) btn_box.add(btn_reload) self._listbox = Gtk.TreeView(self._list_store) self._listbox.set_headers_visible(False) self._listbox.connect("row-activated", self.__row_activated) self._scrollable = Gtk.ScrolledWindow() self._scrollable.add(self._listbox) self.__fill_listbox() self._frame = Gtk.Frame() self._frame.add(self._scrollable) self._frame.set_border_width(1) self._frame.set_margin_bottom(self.VERTICAL_MARGIN) vbox = Gtk.VBox() vbox.pack_start(self._frame, 1, 1, 1) vbox.pack_end(btn_box, 0, 0, 0) vbox.set_margin_top(self.VERTICAL_MARGIN) vbox.set_margin_bottom(self.VERTICAL_MARGIN) vbox.set_margin_left(self.VERTICAL_MARGIN) vbox.set_margin_right(self.VERTICAL_MARGIN) win.add(vbox) return btn_reload, btn_setting
def __init__(self, table_type, source, reference, save_callback_function, save_function, stats_callback_function, tab_grid, output_directory): self.save_callback_function = save_callback_function self.stats_callback_function = stats_callback_function self.save_function = save_function self.table_type = table_type self.source = source self.reference = reference self.tab_grid = tab_grid self.output_directory = output_directory self.saved_reference_filepath = "" self.last_segment_changed = -1 self._table_initializing() self.make_table_interface() self.update_table() self.modified_references = [] self.last_cell_focused = None self.last_cell_focused_index = -1 # Post Editing: Table search_frame = Gtk.Frame() self.table_scroll_window = Gtk.ScrolledWindow() self.table_scroll_window.set_hexpand(True) self.table_scroll_window.set_vexpand(True) self.table_scroll_window.add(self.table) search_frame.add(self.table_scroll_window) self.tab_grid.attach(search_frame, 0, 1, 2, 1) # Post Editing: Term Search table_frame = Gtk.Frame() self.search_results_scroll_window = Gtk.ScrolledWindow() self.search_results_scroll_window.show() term_search_frame = Gtk.Frame(label="Term Search") term_search_entry = Gtk.Entry() term_search_frame.add(term_search_entry) self.tab_grid.add(term_search_frame) term_search_entry.connect("changed", self.search_and_mark_wrapper) self.search_results_scroll_window.add(self.search_buttons_table) table_frame.add(self.search_results_scroll_window) self.tab_grid.attach_next_to(table_frame, term_search_frame, Gtk.PositionType.BOTTOM, 2, 1)
def _set_training(self): """@brief Prepares GUI to run MT and LM training.""" self.training = Gtk.Box() grid = Gtk.Grid() # Start training button. self.start_training_button = Gtk.Button("Start training") self.start_training_button.connect("clicked", self._train) grid.add(self.start_training_button) # Output frame. training_results_frame = Gtk.Frame(label="Results") scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_hexpand(True) scrolledwindow.set_vexpand(True) resultsText = Gtk.TextView() resultsText.set_editable(False) resultsText.set_cursor_visible(False) resultsText.set_wrap_mode(True) self.trainingResultsTextBuffer = resultsText.get_buffer() scrolledwindow.add(resultsText) training_results_frame.add(scrolledwindow) grid.attach_next_to(training_results_frame, self.start_training_button, Gtk.PositionType.BOTTOM, 1, 1) self.training.add(grid) self.notebook.insert_page(self.training, Gtk.Label('Training'), 1)
def __init__(self, title): Gtk.Frame.__init__(self) self.set_shadow_type(Gtk.ShadowType.IN) frame_style = self.get_style_context() frame_style.add_class("view") self.size_group = Gtk.SizeGroup() self.size_group.set_mode(Gtk.SizeGroupMode.VERTICAL) self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(self.box) toolbar = Gtk.Toolbar.new() toolbar_context = toolbar.get_style_context() Gtk.StyleContext.add_class(Gtk.Widget.get_style_context(toolbar), "cs-header") label = Gtk.Label.new() label.set_markup("<b>%s</b>" % title) title_holder = Gtk.ToolItem() title_holder.add(label) toolbar.add(title_holder) self.box.add(toolbar) toolbar_separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL) self.box.add(toolbar_separator) separator_context = toolbar_separator.get_style_context() frame_color = frame_style.get_border_color(Gtk.StateFlags.NORMAL).to_string() # css_provider = Gtk.CssProvider() # css_provider.load_from_data(".separator { -GtkWidget-wide-separators: 0; \ # color: %s; \ # }" % frame_color) # separator_context.add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) self.list_box = Gtk.ListBox() self.list_box.set_selection_mode(Gtk.SelectionMode.NONE) self.list_box.set_header_func(list_header_func, None) self.box.add(self.list_box)
def __init__(self, location, ws, weather): Gtk.Dialog.__init__(self, 'my-weather-indicator | ' + _('Forecast'), None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_size_request(200, 200) self.connect('destroy', self.close_application) self.set_icon_from_file(comun.ICON) vbox0 = Gtk.VBox(spacing=5) vbox0.set_border_width(5) self.get_content_area().add(vbox0) label11 = Gtk.Label(label='<b>' + location + '</b>') label11.set_markup('<b>' + location + '</b>') vbox0.pack_start(label11, True, True, 0) frame = Gtk.Frame() vbox0.add(frame) hbox1 = Gtk.HBox(spacing=5) hbox1.set_border_width(5) frame.add(hbox1) self.ws = ws forecast = weather['forecasts'] self.table = Gtk.Table(rows=9, columns=5, homogeneous=False) self.table.set_col_spacings(10) self.create_labels() if self.ws == 'yahoo': total = 2 if self.ws == 'wunderground': total = 4 else: total = 5 for i in range(0, total): self.create_forecast_dor_day(forecast, i) hbox1.add(self.table) # if self.ws == 'yahoo': filename = comun.YAHOOLOGO web = comun.YAHOOWEB elif self.ws == 'worldweatheronline': filename = comun.WOLRDWEATHERONLINE web = comun.WOLRDWEATHERONLINEWEB elif self.ws == 'openweathermap': filename = comun.OPENWEATHERMAPLOGO web = comun.OPENWEATHERMAPWEB elif self.ws == 'wunderground': filename = comun.UNDERGROUNDLOGO web = comun.UNDERGROUNDWEB image = load_image(filename, size=64) image.set_alignment(0.5, 0.5) button = Gtk.Button() button.set_image(image) button.connect('clicked', (lambda x: webbrowser.open(web))) hbox1.pack_start(button, True, True, 0) # self.show_all() while Gtk.events_pending(): Gtk.main_iteration() self.run() self.destroy()
def __init__(self, channel, sbrick_channel): Gtk.Frame.__init__(self) self.sbrickChannel = sbrick_channel self.channel = channel self.sbrick = None self.set_label("Channel: %d - %s" % ((channel + 1), self.sbrickChannel["name"])) self.vbox = Gtk.FlowBox() # , orientation=Gtk.Orientation.HORIZONTAL, spacing=3) self.vbox.set_border_width(2) self.vbox.set_max_children_per_line(7) self.vbox.set_min_children_per_line(7) self.vbox.set_selection_mode(Gtk.SelectionMode.NONE) self.add(self.vbox) # self.vbox.pack_start(Gtk.Label("PWM: "), True, False, 0) self.vbox.add(Gtk.Label("PWM: ")) self.pwmAdjustment = Gtk.Adjustment(255, 0, 255, 5, 10, 0.0) self.spinPWM = Gtk.SpinButton.new(self.pwmAdjustment, 5, 0) # self.vbox.pack_start(self.spinPWM, True, False, 0) self.vbox.add(self.spinPWM) self.pwmAdjustment.connect("value-changed", self.on_pwm_changed) self.checkReverse = Gtk.CheckButton("Reverse") self.checkReverse.connect("toggled", self.on_reverse_changed) self.vbox.add(self.checkReverse) # self.vbox.pack_start(self.checkReverse, True, False, 0) self.checkTime = Gtk.CheckButton("Time MS:") # self.vbox.pack_start(self.checkTime, True, False, 0) self.vbox.add(self.checkTime) self.checkTime.connect("toggled", self.on_time_toggled) self.timeAdjustment = Gtk.Adjustment(1000, -1, 30000, 100, 1000, 0.0) self.spinTime = Gtk.SpinButton.new(self.timeAdjustment, 10, 0) # self.vbox.pack_start(self.spinTime, True, False, 0) self.vbox.add(self.spinTime) self.spinTime.set_sensitive(False) self.checkBrake = Gtk.CheckButton("Break Stop") # self.vbox.pack_start(self.checkBrake, True, False, 0) self.vbox.add(self.checkBrake) self.buttonGo = Gtk.Button("Start") self.buttonGo.connect("clicked", self.on_switch_go_clicked) # self.vbox.pack_start(self.buttonGo, True, False, 0) self.vbox.add(self.buttonGo) self.set_sensitive(False) self.on = False self.pwm = 0 self.reverse = False # noinspection PyUnusedLocal
def __init__(self, teacher): abstract.IntervalGui.__init__(self, teacher) self.g_test_stat_dlg = None ################ # practice_box # ################ self.std_buttons_add( ('repeat_melodic', self.repeat_melodic), ('give_up', self.give_up), ) ############## # config_box # ############## self.g_ask_for_frame = frame = Gtk.Frame(label=_("Ask for these intervals")) self.config_box.pack_start(frame, False, False, 0) self.g_interval_selector = nIntervalCheckBox(self.m_exname, 'intervals') def _ff(var): if self.m_t.m_custom_mode: # If we are running in custom mode, then the user can # select himself what intervals to practise. And then # we have to reset the exercise. self.on_end_practise() self.on_start_practise() self.add_watch('intervals', _ff) self.g_interval_selector.set_border_width(gu.PAD) frame.add(self.g_interval_selector) self.add_lock_to_key_gui() #------we need some space self.config_box.pack_start(Gtk.HBox(), False, False, padding=gu.PAD_SMALL) # ------------------------------------------ self._add_auto_new_question_gui(self.config_box) # ---------------------------------------------- self._create_select_inputwidget_gui() # ------------ frame ------------------- self.config_box.set_spacing(0) self.config_box.show_all() ############## # statistics # ############## self.setup_statisticsviewer(statisticsviewer.StatisticsViewer, _("Harmonic interval")) self.select_inputwidget()
def __init__(self, teacher): abstract.LessonbasedGui.__init__(self, teacher) self.m_stacking_frame_min_height = 0 ############### # practise_box ############### self.practise_box.set_spacing(gu.PAD) hbox = gu.bHBox(self.practise_box, True, True) hbox.set_spacing(gu.PAD) ################## # chordtype frame ################## frame = Gtk.Frame(label=_("Identify chord type")) hbox.pack_start(frame, True, True, 0) self.g_chordtype_box = Gtk.VBox() self.g_chordtype_box.set_border_width(gu.PAD_SMALL) frame.add(self.g_chordtype_box) ################# # stacking frame ################# self.g_stacking_frame = Gtk.Frame(label=_("Chord voicing")) self.g_stacking_frame.set_sensitive(False) hbox.pack_start(self.g_stacking_frame, True, True, 0) vbox = Gtk.VBox() vbox.set_border_width(gu.PAD_SMALL) self.g_stacking_frame.add(vbox) t = Gtk.Table(1, 1, 1) vbox.pack_start(t, True, True, 0) self.g_source = Gtk.VBox() t.attach(self.g_source, 0, 1, 0, 1, Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL) self.g_answer = Gtk.VBox() t.attach(self.g_answer, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL) self.g_redo = Gtk.Button("<<<") self.g_redo.connect('clicked', lambda o, self=self: self.fill_stacking_frame()) vbox.pack_end(self.g_redo, False, False, 0) self.g_flashbar = gu.FlashBar() self.practise_box.pack_start(self.g_flashbar, False, False, 0) self.std_buttons_add(('new-chord', self.new_question), ('repeat', lambda _o: self.m_t.m_P.play_question()), ('repeat_arpeggio', lambda _o: self.m_t.m_P.play_question_arpeggio()), ('give_up', lambda _o, self=self: self.give_up())) self.practise_box.show_all() ############## # config_box # ############## self.config_box.set_spacing(gu.PAD_SMALL) self.add_random_transpose_gui()
def __init__(self, statistics): Gtk.Frame.__init__(self) table = Gtk.Table() self.add(table) self.boxdict = {} self.m_totals = {} # 0 1 2 3 4 5 6 7 8 # 0 ------------------------------------------- # 1 | | Session | Today | # 2 | | Percent Count | Percent Count | # 3 +------ ---------------------------------- # 4 | Total | 85% | 13 | # 5 +------------------------- # 6 | label1 | 100% | 4 | # | label2 | 50% | 5 | # 7 +----------------------------------------- for k, l, x in (('session', _("Session"), 2), ('today', _("Today"), 5), ('last7', _("Last 7 days"), 8), ('total', _("Total"), 11)): table.attach(Gtk.Label(label=l), x, x+2, 0, 1, xpadding=gu.PAD_SMALL, ypadding=gu.PAD_SMALL) b = Gtk.VBox(False, 0) table.attach(b, x, x+1, 6, 7) self.boxdict[k+'percent'] = b b = Gtk.VBox(False, 0) table.attach(b, x+1, x+2, 6, 7) self.boxdict[k+'count'] = b l = Gtk.Label() table.attach(l, x, x+1, 4, 5) self.m_totals[k+'percent'] = l l = Gtk.Label() table.attach(l, x+1, x+2, 4, 5) self.m_totals[k+'count'] = l for x in (2, 5, 8, 11): table.attach(Gtk.Label(label=_("Percent")), x, x+1, 1, 2, xpadding=gu.PAD_SMALL, ypadding=gu.PAD_SMALL) table.attach(Gtk.Label(label=_("Count")), x+1, x+2, 1, 2, xpadding=gu.PAD_SMALL, ypadding=gu.PAD_SMALL) l = Gtk.Label(label=_("Total")) l.set_alignment(0.0, 0.5) table.attach(l, 0, 1, 4, 5, xpadding=gu.PAD_SMALL, ypadding=gu.PAD_SMALL) table.attach(Gtk.HSeparator(), 0, 13, 3, 4) table.attach(Gtk.HSeparator(), 0, 13, 5, 6) table.attach(Gtk.VSeparator(), 1, 2, 0, 7) table.attach(Gtk.VSeparator(), 4, 5, 0, 7) table.attach(Gtk.VSeparator(), 7, 8, 0, 7) table.attach(Gtk.VSeparator(), 10, 11, 0, 7) self.boxdict['keys'] = key_box = Gtk.VBox(False, 0) table.attach(key_box, 0, 1, 6, 7) for key, box in self.boxdict.items(): box.set_border_width(gu.PAD_SMALL) self.update(statistics) self.show_all()
def __init__(self): Gtk.Dialog.__init__(self, _("GNU Solfege Preferences"), solfege.win, 0, (Gtk.STOCK_HELP, Gtk.ResponseType.HELP, Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)) cfg.ConfigUtils.__init__(self, 'configwindow') self.connect('response', self.apply_and_close) # We do this so that the window is only hidden when the # user click on the close button provided by the window manager. self.connect('delete-event', self.on_destroy)#lambda w, e: True) hbox = Gtk.HBox() hbox.set_spacing(gu.hig.SPACE_LARGE) hbox.set_border_width(gu.hig.SPACE_SMALL) self.vbox.pack_start(hbox, True, True, 0) frame = Gtk.Frame() self.g_pages = Gtk.TreeStore(str) self.g_pview = Gtk.TreeView(self.g_pages) self.g_pview.set_headers_visible(False) hbox.pack_start(frame, False, False, 0) frame.add(self.g_pview) self.g_page_box = Gtk.HBox() hbox.pack_start(self.g_page_box, True, True, 0) self.m_page_mapping = {} def cursor_changed(treeview): path, col = treeview.get_cursor() if not path: return path = tuple(path) for key, page in self.m_page_mapping.items(): if key == path: page.show() else: page.hide() self.m_page_mapping[path].show_all() tvcol = Gtk.TreeViewColumn("Col 0") self.g_pview.append_column(tvcol) cell = Gtk.CellRendererText() tvcol.pack_start(cell, True) tvcol.add_attribute(cell, 'text', 0) hbox.show_all() self.create_midi_config() self.create_user_config() self.create_external_programs_config() self.create_gui_config() self.create_practise_config() self.create_sound_config() self.create_statistics_config() self.g_pview.connect('cursor-changed', cursor_changed)
def __init__(self, title, catalog, units, prereqs, time, course_type, ge_type, course_id, notes): Gtk.EventBox.__init__(self) Course.__init__( self, title, catalog, units, prereqs, time, course_type, ge_type, course_id, notes) self.course_class = self.course_type.lower().replace(" ", "-") self.get_style_context().add_class(self.course_class) self.set_size_request(200, -1) self.frame = Gtk.Frame() self.add(self.frame) self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) self.box.set_margin_top(10) self.box.set_margin_bottom(10) self.box.set_margin_start(5) self.box.set_margin_end(5) self.frame.add(self.box) if self.notes is not None: self.title_text = Gtk.Label(self.title + "*") else: self.title_text = Gtk.Label(self.title) self.catalog_text = Gtk.Label(self.catalog) self.credits_text = Gtk.Label("(" + str(self.credits) + ")") if self.prereqs and self.prereqs != ['']: self.prereqs_text = Gtk.Label("(" + ', '.join(self.prereqs) + ")") self.prereqs_text.get_style_context().add_class('prereq-text') self.prereqs_text.set_justify(Gtk.Justification.CENTER) self.prereqs_text.set_line_wrap(True) self.box.pack_end(self.prereqs_text, True, True, 0) if self.ge_type != [None] and self.ge_type != []: self.ge_text = Gtk.Label("[" + '/'.join(self.ge_type) + "]") self.ge_text.get_style_context().add_class('ge-text') self.box.pack_end(self.ge_text, True, True, 0) self.title_text.set_line_wrap(True) self.title_text.set_justify(Gtk.Justification.CENTER) self.catalog_text.set_justify(Gtk.Justification.CENTER) self.credits_text.set_justify(Gtk.Justification.CENTER) self.box.pack_start(self.title_text, True, True, 0) self.box.pack_start(self.catalog_text, True, True, 0) self.box.pack_start(self.credits_text, True, True, 0) self.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, [], DRAG_ACTION) self.set_tooltip_text(self.notes) self.show_all()
def create_main_window(self): self.main_window = Gtk.Window( title = _("Pathologic Classic HD"), type = Gtk.WindowType.TOPLEVEL, window_position = Gtk.WindowPosition.CENTER_ALWAYS, resizable = False, default_width = 360 ) self.main_window.connect('delete-event', self.quit_app) frame_crop = Gtk.Frame( label = _("Crop videos (FFmpeg)"), label_xalign = 0.5, margin_left = 10, margin_right = 10, margin_top = 10, margin_bottom = 10 ) box_frame_crop = Gtk.Box( orientation = Gtk.Orientation.VERTICAL, margin_left = 10, margin_right = 10, margin_top = 10, margin_bottom = 10, spacing = 10 ) self.combobox_crop = Gtk.ComboBoxText() self.combobox_crop.append_text(_("4:3 (no cropping)")) self.combobox_crop.append_text('16:9') self.combobox_crop.append_text('16:10') self.combobox_crop.set_active(self.crop) self.button_crop = Gtk.Button(label=_("Crop and quit")) self.button_crop.connect('clicked', self.cb_button_crop) self.progressbar = Gtk.ProgressBar( hexpand = True, show_text = True, text = _("Processing..."), pulse_step = 0.1, no_show_all = True ) box_frame_crop.pack_start(self.combobox_crop, True, True, 0) box_frame_crop.pack_start(self.button_crop, True, True, 0) box_frame_crop.pack_start(self.progressbar, True, True, 0) frame_crop.add(box_frame_crop) self.main_window.add(frame_crop) self.main_window.show_all()
def on_button_pressed(self, widget): dialog = Gtk.FileChooserDialog(title=_("Choose an Image File"), action=Gtk.FileChooserAction.OPEN, transient_for=self.get_toplevel(), buttons=(_("_Cancel"), Gtk.ResponseType.CANCEL, _("_Open"), Gtk.ResponseType.OK)) filter_text = Gtk.FileFilter() filter_text.set_name(_("Image files")) filter_text.add_mime_type("image/*") dialog.add_filter(filter_text) backgrounds = "/usr/share/backgrounds" if os.path.exists(self.value): dialog.set_filename(self.value) if os.path.exists(backgrounds): dialog.add_shortcut_folder(backgrounds) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.frame = Gtk.Frame(visible=False, no_show_all=True) preview = Gtk.Image(visible=True) box.pack_start(self.frame, False, False, 0) self.frame.add(preview) dialog.set_preview_widget(box) dialog.set_preview_widget_active(True) dialog.set_use_preview_label(False) box.set_margin_end(12) box.set_margin_top(12) box.set_size_request(320, -1) dialog.connect("update-preview", self.update_icon_preview_cb, preview) response = dialog.run() if response == Gtk.ResponseType.OK: filename = dialog.get_filename() self.bind_object.set_text(filename) dialog.destroy()