def file_selected(button): print("Selected file: %s" % filechooserwidget.get_filename()) Gtk.main_quit() window = Gtk.Window() window.set_title("FileChooserWidget") window.set_default_size(600, 400) window.connect("destroy", Gtk.main_quit) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5) window.add(box) filechooserwidget = Gtk.FileChooserWidget(action=Gtk.FileChooserAction.OPEN) box.pack_start(filechooserwidget, True, True, 0) buttonbox = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL) buttonbox.set_layout(Gtk.ButtonBoxStyle.END) buttonbox.set_spacing(2) box.pack_start(buttonbox, False, False, 0) button = Gtk.Button(label="_Open", use_underline=True) button.connect("clicked", file_selected) buttonbox.add(button) window.show_all() Gtk.main()
def add_button(label, cb): btn = Gtk.Button(label=label) vbox.add(btn) btn.connect('button-press-event', cb)
def __init__(self, client, window): super().__init__() add_close_accel(self, self.destroy) self._client = client self._window = window self.is_closed = False self.set_title("Window Information for %s" % window.get_title()) self.set_destroy_with_parent(True) self.set_resizable(True) self.set_decorated(True) self.set_transient_for(window) self.set_icon(get_icon_pixbuf("information.png")) self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) def window_deleted(*_args): self.is_closed = True self.connect('delete_event', window_deleted) tb = TableBuilder(1, 2) self.wid_label = slabel() tb.new_row("Window ID", self.wid_label) self.title_label = slabel() self.title_label.set_line_wrap(True) self.title_label.set_size_request(320, -1) #self.title_label.set_justify(Gtk.Justification.LEFT) self.title_label.set_alignment(0, 0.5) tb.new_row("Title", self.title_label) self.or_image = Gtk.Image() tb.new_row("Override-Redirect", self.or_image) self.state_label = slabel() tb.new_row("State", self.state_label) self.attributes_label = slabel() tb.new_row("Attributes", self.attributes_label) self.focus_image = Gtk.Image() tb.new_row("Focus", self.focus_image) self.button_state_label = slabel() tb.new_row("Button State", self.button_state_label) #self.group_leader_label = slabel() #tb.new_row("Group Leader", self.group_leader_label) tb.new_row("") self.gravity_label = slabel() tb.new_row("Gravity", self.gravity_label) self.content_type_label = slabel() tb.new_row("Content Type", self.content_type_label) tb.new_row("", slabel()) self.pixel_depth_label = slabel() tb.new_row("Pixel Depth", self.pixel_depth_label) self.alpha_image = Gtk.Image() tb.new_row("Alpha Channel", self.alpha_image) self.opengl_image = Gtk.Image() tb.new_row("OpenGL", self.opengl_image) tb.new_row("") self.geometry_label = slabel() tb.new_row("Geometry", self.geometry_label) self.outer_geometry_label = slabel() tb.new_row("Outer Geometry", self.outer_geometry_label) self.inner_geometry_label = slabel() tb.new_row("Inner Geometry", self.inner_geometry_label) self.offsets_label = slabel() tb.new_row("Offsets", self.offsets_label) self.frame_extents_label = slabel() tb.new_row("Frame Extents", self.frame_extents_label) self.max_size_label = slabel() tb.new_row("Maximum Size", self.max_size_label) self.size_constraints_label = slabel() tb.new_row("Size Constraints", self.size_constraints_label) tb.new_row("") #backing: self.backing_properties = slabel() tb.new_row("Backing Properties", self.backing_properties) tb.new_row("") btn = Gtk.Button(label="Copy to clipboard") btn.connect("clicked", self.copy_to_clipboard) tb.new_row("", btn) vbox = Gtk.VBox() vbox.pack_start(tb.get_table(), True, True, 20) self.add(vbox)
def edit_appli(self, widget, event, section, app): d = Gtk.Dialog(title=_("Edit the launcher")) # Edition du nom de l'appli entry = Gtk.Entry() entry.connect("activate", self.mod_app_name, entry, d, section, app) # entrée valide entry.show() namebtn = Gtk.Button(label = _("Change")) namebtn.connect_object("clicked", self.mod_app_name, entry, None, d, section, app ) namebtn.show() # on met ça dans une boîte box = Gtk.HBox(False,2) box.pack_start(entry, True, True, 3) box.pack_start(namebtn, False, False, 0) box.show() # et le tout dans un étiquette nameframe = Gtk.Frame(label = _("Change the label")) nameframe.add(box) nameframe.show() # Changement de l'icône iconbtn = Gtk.Button(label = _("Change icon")) iconbtn.connect_object("clicked", self.mod_app_icon_dialog, entry, None, d, section, app ) iconbtn.show() # on met ça dans une boîte # et le tout dans un étiquette iconframe = Gtk.Frame(label = _("Change the application icon")) iconframe.add(iconbtn) iconframe.show() # déplacement de l'application upbtn = Gtk.Button(label=_("Move up")) downbtn = Gtk.Button(label=_("Move down")) upi = Gtk.Image() upi.set_from_stock(Gtk.STOCK_GO_UP, Gtk.IconSize.MENU) upbtn.set_image(upi) downi = Gtk.Image() downi.set_from_stock(Gtk.STOCK_GO_DOWN, Gtk.IconSize.MENU) downbtn.set_image(downi) upbtn.connect_object("clicked", self.move_app_up, None, d, section, app) downbtn.connect_object("clicked", self.move_app_down, None, d, section, app) upbtn.show() downbtn.show() # on met ça dans une boîte box = Gtk.HBox(False,2) box.pack_start(upbtn, True, True, 3) box.pack_start(downbtn, False, False, 0) box.show() # et le tout dans un étiquette moveframe = Gtk.Frame(label = _("Move this app")) moveframe.add(box) moveframe.show() # Nécessaire pour la suppression delbtn = Gtk.Button(label = _("Delete"), stock=Gtk.STOCK_DELETE) delbtn.connect("clicked", self.del_appli, d, section, app) delbtn.show() delframe = Gtk.Frame(label = _("Delete this launcher")) delframe.add(delbtn) delframe.show() # ajout des objets au dialogue d.vbox.pack_start(nameframe, True, True, 0) d.vbox.pack_start(iconframe, True, True, 0) d.vbox.pack_start(moveframe, True, True, 0) d.vbox.pack_start(delframe, True, True, 0) d.run()
def make_menu(self): """build the menu""" self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL) self.window.connect("delete_event", self.close_application) self.window.set_title("Handymenu configuration") self.window.set_border_width(0) # Conteneur principal self.mainbox = Gtk.VBox(False, 10) self.mainbox.set_border_width(10) # configuration principale self.make_entrylist() # coches pour modules modulesbox = Gtk.HBox(False, 5) modulesframe = Gtk.Frame(label = _("Modules")) modulesframe.add(modulesbox) self.mainbox.pack_start(modulesframe, False, False, 0) # module recent_files recents_files_check = Gtk.CheckButton(_("Show recent files")) recents_files_check.set_tooltip_text(_("Show recent files")) if "_recent_files_" in load_modules()[1]: recents_files_check.set_active(True) recents_files_check.connect("toggled", self.module_toggle, "_recent_files_") modulesbox.pack_start(recents_files_check, False, False,0) # module firefox most viewed most_ffox_check = Gtk.CheckButton(_("Most visited")) most_ffox_check.set_tooltip_text(_("Show most visited uri")) if "_most_ffox_view_" in load_modules()[1]: most_ffox_check.set_active(True) most_ffox_check.connect("toggled", self.module_toggle, "_most_ffox_view_") modulesbox.pack_start(most_ffox_check, False, False,0) # position des modules self.modules_position = Gtk.SpinButton() #adjustment = Gtk.Adjustment(0, start, max, step, 10, 0) adjustment = Gtk.Adjustment(0, 1, len(self.config)+1, 1, 10, 0) self.modules_position.set_adjustment(adjustment) self.modules_position.set_numeric(True) self.modules_position.set_value(load_modules()[0]) self.modules_position.set_tooltip_text(_("Position of modules in menu")) self.modules_position.connect("value-changed", \ lambda x: set_modules_position(self.modules_position.get_value_as_int())) modulesbox.pack_start(self.modules_position, False, False,1) # conteneur pour les boutons btnbox = Gtk.HBox(True, 2) self.mainbox.pack_start(btnbox, False, False, 0) defaultbtn = Gtk.Button(label = _("Reset")) resetimg = Gtk.Image() resetimg.set_from_stock(Gtk.STOCK_REDO, Gtk.IconSize.BUTTON) defaultbtn.set_image(resetimg) defaultbtn.connect_object("clicked", self.back_to_default, self.window ) btnbox.pack_start(defaultbtn, False, False,0) viewbtn = Gtk.Button(label = _("View config")) viewbtn.connect("clicked", lambda x: self.view_config()) btnbox.pack_start(viewbtn, False, False, 0) savebtn = Gtk.Button(label = _("Quit"), stock=Gtk.STOCK_CLOSE) savebtn.connect_object("clicked", self.close_application, self.window, None ) btnbox.pack_start(savebtn, False, False, 0) self.window.add(self.mainbox) self.window.set_default_size(620, 560) self.window.show_all()
def get_sized_button(lable, w, h, clicked_listener=None): b = Gtk.Button(lable) if clicked_listener != None: b.connect("clicked", lambda w,e: clicked_listener()) b.set_size_request(w, h) return b
def __init__(self, parent, imagen): Gtk.Dialog.__init__(self, ) self.set_title(_('Information')) self.set_modal(True) self.add_button(Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_resizable(False) self.connect('destroy', self.close) vbox = Gtk.VBox(spacing=5) vbox.set_border_width(5) self.get_content_area().add(vbox) frame = Gtk.Frame() vbox.pack_start(frame, True, True, 0) table = Gtk.Table(n_rows=3, n_columns=3, homogeneous=False) table.set_border_width(5) table.set_col_spacings(5) table.set_row_spacings(5) frame.add(table) label1 = Gtk.Label(label=_('Id') + ':') label1.set_alignment(0, 0.5) table.attach(label1, 0, 1, 0, 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) self.entry1 = Gtk.Entry() self.entry1.set_width_chars(50) self.entry1.set_alignment(0) table.attach(self.entry1, 1, 2, 0, 1, xoptions=Gtk.AttachOptions.EXPAND, yoptions=Gtk.AttachOptions.SHRINK) label2 = Gtk.Label(label=_('Title') + ':') label2.set_alignment(0, 0.5) table.attach(label2, 0, 1, 1, 2, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) self.entry2 = Gtk.Entry() self.entry2.set_width_chars(50) self.entry2.set_alignment(0) table.attach(self.entry2, 1, 2, 1, 2, xoptions=Gtk.AttachOptions.EXPAND, yoptions=Gtk.AttachOptions.SHRINK) label3 = Gtk.Label(label=_('Dimensions') + ':') label3.set_alignment(0, 0.5) table.attach(label3, 0, 1, 2, 3, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) self.entry3 = Gtk.Entry() self.entry3.set_width_chars(50) self.entry3.set_alignment(0) table.attach(self.entry3, 1, 2, 2, 3, xoptions=Gtk.AttachOptions.EXPAND, yoptions=Gtk.AttachOptions.SHRINK) label4 = Gtk.Label(label=_('Url') + ':') label4.set_alignment(0, 0.5) table.attach(label4, 0, 1, 3, 4, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) self.entry4 = Gtk.Entry() self.entry4.set_width_chars(50) self.entry4.set_alignment(0) table.attach(self.entry4, 1, 2, 3, 4, xoptions=Gtk.AttachOptions.EXPAND, yoptions=Gtk.AttachOptions.SHRINK) self.button4 = Gtk.Button() self.button4.connect('clicked', self.on_button4_clicked) self.button4.set_image( Gtk.Image.new_from_stock(Gtk.STOCK_COPY, Gtk.IconSize.BUTTON)) table.attach(self.button4, 2, 3, 3, 4, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) label5 = Gtk.Label(label=_('Thumbnail') + ' 72x72:') label5.set_alignment(0, 0.5) table.attach(label5, 0, 1, 4, 5, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) self.entry5 = Gtk.Entry() self.entry5.set_width_chars(50) self.entry5.set_alignment(0) table.attach(self.entry5, 1, 2, 4, 5, xoptions=Gtk.AttachOptions.EXPAND, yoptions=Gtk.AttachOptions.SHRINK) self.button5 = Gtk.Button() self.button5.connect('clicked', self.on_button5_clicked) self.button5.set_image( Gtk.Image.new_from_stock(Gtk.STOCK_COPY, Gtk.IconSize.BUTTON)) table.attach(self.button5, 2, 3, 4, 5, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) label6 = Gtk.Label(label=_('Thumbnail') + ' 144x144:') label6.set_alignment(0, 0.5) table.attach(label6, 0, 1, 5, 6, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) self.entry6 = Gtk.Entry() self.entry6.set_width_chars(50) self.entry6.set_alignment(0) table.attach(self.entry6, 1, 2, 5, 6, xoptions=Gtk.AttachOptions.EXPAND, yoptions=Gtk.AttachOptions.SHRINK) self.button6 = Gtk.Button() self.button6.connect('clicked', self.on_button6_clicked) self.button6.set_image( Gtk.Image.new_from_stock(Gtk.STOCK_COPY, Gtk.IconSize.BUTTON)) table.attach(self.button6, 2, 3, 5, 6, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) label7 = Gtk.Label(label=_('Thumbnail') + ' 288x288:') label7.set_alignment(0, 0.5) table.attach(label7, 0, 1, 6, 7, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) self.entry7 = Gtk.Entry() self.entry7.set_width_chars(50) self.entry7.set_alignment(0) table.attach(self.entry7, 1, 2, 6, 7, xoptions=Gtk.AttachOptions.EXPAND, yoptions=Gtk.AttachOptions.SHRINK) self.button7 = Gtk.Button() self.button7.connect('clicked', self.on_button7_clicked) self.button7.set_image( Gtk.Image.new_from_stock(Gtk.STOCK_COPY, Gtk.IconSize.BUTTON)) table.attach(self.button7, 2, 3, 6, 7, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK) if imagen is not None: self.entry1.set_text(imagen.params['id']) self.entry2.set_text(imagen.params['title']) self.entry3.set_text( '%sx%s' % (imagen.params['width'], imagen.params['height'])) self.entry4.set_text(imagen.params['url']) self.entry5.set_text(imagen.thumbnails[0]['url']) label5.set_label('%s %sx%s:' % (_('Thumbnail'), imagen.thumbnails[0]['width'], imagen.thumbnails[0]['height'])) self.entry6.set_text(imagen.thumbnails[1]['url']) label6.set_label('%s %sx%s:' % (_('Thumbnail'), imagen.thumbnails[1]['width'], imagen.thumbnails[1]['height'])) self.entry7.set_text(imagen.thumbnails[2]['url']) label7.set_label('%s %sx%s:' % (_('Thumbnail'), imagen.thumbnails[2]['width'], imagen.thumbnails[2]['height'])) self.show_all()
def __init__(self, name, path, themed_icon, fill_level=None): Gtk.ListBoxRow.__init__(self) self.set_size_request(-1, 80) self.set_can_focus(False) self.themed_icon = themed_icon # CSS Name self.set_name('ShredderLocationEntry') self.path, self.name = path, name name_label = Gtk.Label( '<b>{}</b>'.format(GLib.markup_escape_text(name)) ) name_label.set_use_markup(True) name_label.set_hexpand(True) name_label.set_halign(Gtk.Align.START) path_label = Gtk.Label( '<small>{}</small>'.format(GLib.markup_escape_text(path)) ) path_label.set_use_markup(True) path_label.set_hexpand(True) path_label.set_halign(Gtk.Align.START) icon_img = Gtk.Image.new_from_gicon( themed_icon, Gtk.IconSize.DIALOG ) icon_img.props.pixel_size = 64 icon_img.set_halign(Gtk.Align.START) icon_img.set_margin_start(3) icon_img.set_margin_end(10) icon_img.set_vexpand(True) icon_img.set_valign(Gtk.Align.FILL) self.check_box = Gtk.Switch() self.check_box.connect('notify::active', self.on_check_box_toggled) self.check_box.set_tooltip_text('Prefer this directory?') self.check_box.set_margin_end(5) self.check_box.set_margin_top(13) self.check_box.set_can_focus(False) self.separator = Gtk.Separator() self.separator.set_hexpand(True) self.separator.set_halign(Gtk.Align.FILL) ####################### # Put it all together # ####################### grid = Gtk.Grid() self.add(grid) # Quick-select button with arrow inside: shortcut_btn = Gtk.Button() shortcut_btn.add(Gtk.Arrow(Gtk.ArrowType.RIGHT, Gtk.ShadowType.NONE)) shortcut_btn.set_relief(Gtk.ReliefStyle.NONE) shortcut_btn.set_vexpand(False) shortcut_btn.set_valign(Gtk.Align.START) shortcut_btn.set_margin_top(17) shortcut_btn.set_margin_end(15) shortcut_btn.set_opacity(0.7) shortcut_btn.set_can_focus(False) shortcut_btn.set_size_request(-1, 28) shortcut_btn.connect('clicked', lambda *_: self.emit('shortcut')) grid.attach(icon_img, 0, 0, 5, 5) grid.attach(name_label, 5, 2, 1, 1) grid.attach(path_label, 5, 3, 1, 1) grid.attach(self.check_box, 7, 2, 1, 1) grid.attach(shortcut_btn, 8, 2, 1, 1) grid.attach(self.separator, 0, 8, 9, 1) if fill_level is not None: level_bar = Gtk.LevelBar() level_bar.set_valign(Gtk.Align.START) level_bar.set_halign(Gtk.Align.END) level_bar.set_vexpand(False) level_bar.set_size_request(150, 10) level_bar.set_margin_end(20) level_bar.set_margin_top(20) # Define new values for 'high' and 'low' level_bar.remove_offset_value(Gtk.LEVEL_BAR_OFFSET_HIGH) level_bar.remove_offset_value(Gtk.LEVEL_BAR_OFFSET_LOW) level_bar.add_offset_value(Gtk.LEVEL_BAR_OFFSET_LOW, 0.75) level_bar.add_offset_value(Gtk.LEVEL_BAR_OFFSET_HIGH, 0.25) level_label = Gtk.Label() level_label.set_valign(Gtk.Align.START) level_label.set_halign(Gtk.Align.END) level_label.set_margin_end(20) level_label.set_vexpand(False) used, total = fill_level # Watch for zero division: if total > 0: percent = int(used / total * 100) else: percent = 100 level_label.set_markup( '<small>{f} / {t} - {p}%</small>'.format( f=size_to_human_readable(used), t=size_to_human_readable(total), p=percent ) ) level_bar.set_value(percent / 100) grid.attach(level_label, 6, 3, 1, 1) grid.attach(level_bar, 6, 2, 1, 1) else: size_widget = DeferSizeLabel(path) size_widget.set_margin_top(15) size_widget.set_margin_end(20) grid.attach(size_widget, 6, 2, 1, 1)
def __init__(self): Gtk.Window.__init__(self, title="Inmobiliaria") # Nos conectamos a la base self.bbdd = dbapi2.connect("BasesDeDatos/Casas.db") #self.bbdd.execute("create table Casas(codc number, dir text,habitaciones number, superficie number)") """ cursor=self.bbdd.cursor() self.bbdd.cursor().execute("insert into Casas Values(1, 'dir 1', 1, 70)") cursor = self.bbdd.cursor() self.bbdd.cursor().execute("insert into Casas Values(2, 'dir 2', 2, 80)") cursor = self.bbdd.cursor() self.bbdd.cursor().execute("insert into Casas Values(3, 'dir 3', 3, 90)") self.bbdd.commit() """ self.informeCasas() casas = self.bbdd.cursor().execute("select codc,dir,habitaciones,superficie from Casas") self.mainBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6) self.comprar = Gtk.Button("Comprar") self.comprar.connect("clicked", self.compra) self.modelo = Gtk.ListStore(int, str, int, int) # Rellenamos el modelo for x in casas: self.modelo.append([x[0], x[1], x[2], x[3]]) # Creamos la tabla self.tabla = Gtk.TreeView() celdaText = Gtk.CellRendererText() columnaCodigo = Gtk.TreeViewColumn('Codigo', celdaText, text=0) self.tabla.append_column(columnaCodigo) celdaText2 = Gtk.CellRendererText(xalign=1) columnaNombre = Gtk.TreeViewColumn('direccion', celdaText2, text=1) self.tabla.append_column(columnaNombre) celdaText3 = Gtk.CellRendererText(xalign=1) columnaPrecio = Gtk.TreeViewColumn('habitaciones', celdaText3, text=2) self.tabla.append_column(columnaPrecio) celdaText3 = Gtk.CellRendererText(xalign=1) columnaPrecio = Gtk.TreeViewColumn('superficie', celdaText3, text=2) self.tabla.append_column(columnaPrecio) self.tabla.set_model(self.modelo) seleccion = self.tabla.get_selection() seleccion.connect("changed", self.seleccion) self.mainBox.pack_start(self.tabla, True, True, 0) self.mainBox.pack_start(self.comprar, False, False, 0) self.add(self.mainBox) self.show_all()
def __init__(self, basePath): Gtk.Window.__init__(self, title=(_("Search")), icon_name="edit-find", default_height=400, default_width=650) self.connect("destroy", self.quit) self.search = None self.results = Gtk.ListStore(str, str, str) mainBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, border_width=10) self.add(mainBox) contentBox = Gtk.Box(border_width=0) mainBox.pack_start(contentBox, True, True, 0) ##left pane leftPane = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, border_width=10) contentBox.pack_start(leftPane, False, False, 0) #search box self.searchBox = SearchBox(self.startSearch) leftPane.pack_start(self.searchBox, False, False, 5) #location selector leftPane.pack_start(Gtk.Label(_("Start in"), halign=Gtk.Align.START), False, False, 5) self.location = Gtk.FileChooserButton.new( "Select a folder", Gtk.FileChooserAction.SELECT_FOLDER) leftPane.add(self.location) if not basePath is None: self.location.set_filename(basePath) #follow symlinks self.symlinks = Gtk.CheckButton.new_with_label(_("Follow symlinks")) leftPane.add(self.symlinks) #display hidden files/folders self.hidden = Gtk.CheckButton.new_with_label(_("Search hidden")) leftPane.add(self.hidden) #stop button self.stopButton = Gtk.Button(label=(_("Stop")), sensitive=False) leftPane.pack_end(self.stopButton, False, False, 5) self.stopButton.connect("clicked", self.stopSearch) ##right pane rightPane = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, border_width=10) contentBox.pack_start(rightPane, True, True, 0) #results display tree scrollBox = Gtk.ScrolledWindow( ) #width_request = 500, height_request = 250) rightPane.pack_start(scrollBox, True, True, 5) tree = Gtk.TreeView(self.results) scrollBox.add(tree) fileNameColumn = Gtk.TreeViewColumn() fileNameColumn.set_title(_("File")) fileNameColumn.set_resizable(True) fileNameColumn.set_sizing(Gtk.TreeViewColumnSizing.FIXED) fileNameColumn.set_fixed_width(200) fileNameColumn.set_min_width(200) tree.append_column(fileNameColumn) iconRenderer = Gtk.CellRendererPixbuf() fileNameColumn.pack_start(iconRenderer, expand=False) fileNameColumn.add_attribute(iconRenderer, "icon-name", 0) fileNameRenderer = Gtk.CellRendererText( ellipsize=Pango.EllipsizeMode.END) fileNameColumn.pack_start(fileNameRenderer, expand=False) fileNameColumn.add_attribute(fileNameRenderer, "text", 1) pathRenderer = Gtk.CellRendererText() pathColumn = Gtk.TreeViewColumn(_("Path"), pathRenderer, text=2) pathColumn.set_resizable(True) tree.append_column(pathColumn) #context menu Context(tree) tree.connect("row-activated", self.launchItem) #status text hbox = Gtk.Box() mainBox.pack_start(hbox, False, False, 0) self.currentLabel = Gtk.Label() self.currentLabel.set_ellipsize(Pango.EllipsizeMode.END) hbox.pack_start(self.currentLabel, False, False, 5) self.show_all()
def registered_plugins_panel(self, _configdialog): """ This implements the gui portion of the Plugins panel """ vbox_reg = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) scrolled_window_reg = Gtk.ScrolledWindow() self._list_reg = Gtk.TreeView() self._list_reg.set_grid_lines(Gtk.TreeViewGridLines.HORIZONTAL) # model: plugintype, hidden, pluginname, plugindescr, pluginid self._model_reg = Gtk.ListStore( GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, int) self._selection_reg = self._list_reg.get_selection() # add filter capabilities self._tree_filter = self._model_reg.filter_new() self._tree_filter.set_visible_func(self._apply_filter) # set model with sorting enabled self._list_reg.set_model(Gtk.TreeModelSort(model=self._tree_filter)) self._list_reg.connect('button-press-event', self.button_press_reg) self._cursor_hndlr = self._selection_reg.connect('changed', self._cursor_changed) col0_reg = Gtk.TreeViewColumn( title=_('Type'), cell_renderer=Gtk.CellRendererText(), text=R_TYPE) col0_reg.set_sort_column_id(R_TYPE) col0_reg.set_resizable(True) self._list_reg.append_column(col0_reg) col1 = Gtk.TreeViewColumn( cell_renderer=Gtk.CellRendererText(wrap_mode=2, wrap_width=65), markup=R_STAT_S) label = Gtk.Label(label=_('Status')) label.show() label.set_tooltip_markup( _("'*' items are supplied by 3rd party authors,\n" "<s>strikeout</s> items are hidden")) col1.set_widget(label) col1.set_resizable(True) col1.set_sort_column_id(R_STAT_S) self._list_reg.append_column(col1) col2_reg = Gtk.TreeViewColumn( title=_('Name'), cell_renderer=Gtk.CellRendererText(wrap_mode=2, wrap_width=150), markup=R_NAME) col2_reg.set_sort_column_id(R_NAME) col2_reg.set_resizable(True) self._list_reg.append_column(col2_reg) col = Gtk.TreeViewColumn( title=_('Description'), cell_renderer=Gtk.CellRendererText(wrap_mode=2, wrap_width=400), markup=R_DESC) col.set_sort_column_id(R_DESC) col.set_resizable(True) self._list_reg.append_column(col) self._list_reg.set_search_column(2) scrolled_window_reg.add(self._list_reg) vbox_reg.pack_start(scrolled_window_reg, True, True, 0) # panel button box hbutbox = Gtk.ButtonBox() hbutbox.set_layout(Gtk.ButtonBoxStyle.SPREAD) __info_btn = Gtk.Button(label=_("Info")) hbutbox.add(__info_btn) __info_btn.connect('clicked', self.__info, self._list_reg) self._hide_btn = Gtk.Button(label=_("Hide")) hbutbox.add(self._hide_btn) self._hide_btn.connect('clicked', self.__hide, self._list_reg) self._install_btn = Gtk.Button(label=_("Install")) hbutbox.add(self._install_btn) self._install_btn.connect('clicked', self.__install, self._list_reg) self._edit_btn = Gtk.Button(label=_("Edit")) self._edit_btn.connect('clicked', self.__edit, self._list_reg) self._load_btn = Gtk.Button(label=_("Load")) self._load_btn.connect('clicked', self.__load, self._list_reg) if __debug__: hbutbox.add(self._edit_btn) hbutbox.add(self._load_btn) vbox_reg.pack_start(hbutbox, False, False, 2) # checkbox row hbutbox = Gtk.ButtonBox() hbutbox.set_layout(Gtk.ButtonBoxStyle.SPREAD) _show_hidden_chk = Gtk.CheckButton.new_with_label( _("Show hidden items")) hbutbox.add(_show_hidden_chk) self._show_hidden = self.options_dict['show_hidden'] #self._show_hidden = config.get('behavior.do-not-show-hidden-addons') _show_hidden_chk.set_active(self._show_hidden) _show_hidden_chk.connect('clicked', self.__show_hidden_chk) _show_builtin_chk = Gtk.CheckButton.new_with_label( _("Show Built-in items")) hbutbox.add(_show_builtin_chk) self._show_builtins = self.options_dict['show_builtins'] # self._show_builtins = config.get('behavior.do-not-show-builtins') _show_builtin_chk.set_active(self._show_builtins) _show_builtin_chk.connect('clicked', self.__show_builtins_chk) label = Gtk.Label(label=_("* indicates 3rd party addon")) hbutbox.add(label) vbox_reg.pack_start(hbutbox, False, False, 0) return _('Plugins'), vbox_reg
def _new_remove_btn(self): but_remove = Gtk.Button() but_remove.add( IconFactory.get_image('tryton-remove', Gtk.IconSize.SMALL_TOOLBAR)) but_remove.set_relief(Gtk.ReliefStyle.NONE) return but_remove
def startup(self): print('create button') self._impl = Gtk.Button(label=self.label) self._impl.connect("clicked", wrapped_handler(self, self.on_press))
def __init__(self, indicator=None, widgetnumber=1, weather=None): Gtk.Window.__init__(self) self.set_default_size(5, 5) self.set_icon_from_file(comun.ICON) self.set_decorated(False) self.set_border_width(0) self.screen = self.get_screen() self.visual = self.screen.get_rgba_visual() if self.visual != None and self.screen.is_composited(): self.set_visual(self.visual) self.set_app_paintable(True) self.add_events(Gdk.EventMask.ALL_EVENTS_MASK) self.connect('draw', self.on_expose, None) #self.connect('destroy', self.save_preferences, None) self.connect("button-press-event", self.click) self.connect("button-release-event", self.release) self.connect("motion-notify-event", self.mousemove) vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) self.add(vbox) hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) vbox.pack_start(hbox, False, False, 10) button = Gtk.Button() button.connect('clicked', self.on_button_clicked) hbox.pack_start(button, False, False, 10) self.pin = Gtk.Image() button.add(self.pin) button.set_name('pin') # self.drag = False self.drag_x = 0 self.drag_y = 0 self.filename = None self.temperature = None self.location = None self.parse_time = False self.widgetnumber = widgetnumber self.indicator = indicator self.weather_data = weather self.load_preferences() self.read_widgetfile() ans = self.read_main_data() if ans is not None: self.set_size_request(ans[0], ans[1]) self.parse_data() # style_provider = Gtk.CssProvider() css = """ #pin{ opacity:0.05; border-image: none; background-image: none; background-color: rgba(0, 0, 0, 0); border-radius: 0px; } #pin:hover { transition: 1000ms linear; opacity:1.0; border-image: none; background-image: none; background-color: rgba(0, 0, 0, 0); border-radius: 0px; } """ style_provider.load_from_data(css.encode('UTF-8')) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) # self.show_all()
def __init__(self): Gtk.Window.__init__(self, title="Hello World") #calling constructur of super class and ad title self.button = Gtk.Button(label="Click Here") #Creating buttons self.button.connect("clicked", self.on_button_clicked)# connect clicked signal and add it ass child to top-level window self.add(self.button) #
window = Gtk.Window() window.connect('destroy', Gtk.main_quit) specs_label = Gtk.Label() specs_label.set_markup('<b>Filter specifications</b>') design_method = LabeledComboBoxText(label='Design method', options=factory.filters.keys()) filter_widget = FilterWidget(design_method.value) @design_method.changed.register def set_filter(name): filter_widget.state = name design_button = Gtk.Button(label='Design') export_button = Gtk.Button(label='Export') export_button.show() def on_clicked_design(*args): designer = filter_widget.designer try: params = designer.params print(params) dt = 1 / params['fs'] system = designer.design(params) system = signal.dlti(*system, dt=dt)
def __init__(self): Gtk.Window.__init__(self, title="Calculator") self.grid = Gtk.Grid() self.button0 = Gtk.Button(label="0") self.button0.connect("clicked", self.Button0_Click) self.button1 = Gtk.Button(label="1") self.button1.connect("clicked", self.Button1_Click) self.button2 = Gtk.Button(label="2") self.button2.connect("clicked", self.Button2_Click) self.button3 = Gtk.Button(label="3") self.button3.connect("clicked", self.Button3_Click) self.button4 = Gtk.Button(label="4") self.button4.connect("clicked", self.Button4_Click) self.button5 = Gtk.Button(label="5") self.button5.connect("clicked", self.Button5_Click) self.button6 = Gtk.Button(label="6") self.button6.connect("clicked", self.Button6_Click) self.button7 = Gtk.Button(label="7") self.button7.connect("clicked", self.Button7_Click) self.button8 = Gtk.Button(label="8") self.button8.connect("clicked", self.Button8_Click) self.button9 = Gtk.Button(label="9") self.button9.connect("clicked", self.Button9_Click) self.buttonPlus = Gtk.Button(label="+") self.buttonPlus.connect("clicked", self.ButtonPlus_Click) self.buttonMinus = Gtk.Button(label="-") self.buttonMinus.connect("clicked", self.ButtonMinus_Click) self.buttonDivide = Gtk.Button(label="/") self.buttonDivide.connect("clicked", self.ButtonDivide_Click) self.buttonMulti = Gtk.Button(label="X") self.buttonMulti.connect("clicked", self.ButtonMulti_Click) self.buttonEqual = Gtk.Button(label="=") self.buttonEqual.connect("clicked", self.ButtonEqual_Click) self.buttonClear = Gtk.Button(label="C") self.buttonClear.connect("clicked", self.ButtonClear_Click) self.textBox = Gtk.Entry() self.grid.add(self.button7) self.grid.attach_next_to(self.button8, self.button7, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.button9, self.button8, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.buttonPlus, self.button9, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.button4, self.button7, Gtk.PositionType.BOTTOM, 1, 1) self.grid.attach_next_to(self.button5, self.button4, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.button6, self.button5, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.buttonMinus, self.button6, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.button1, self.button4, Gtk.PositionType.BOTTOM, 1, 1) self.grid.attach_next_to(self.button2, self.button1, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.button3, self.button2, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.buttonDivide, self.button3, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.button0, self.button2, Gtk.PositionType.BOTTOM, 1, 1) self.grid.attach_next_to(self.buttonEqual, self.button0, Gtk.PositionType.RIGHT, 1, 1) self.grid.attach_next_to(self.buttonMulti, self.buttonDivide, Gtk.PositionType.BOTTOM, 1, 1) self.grid.attach_next_to(self.buttonClear, self.button1, Gtk.PositionType.BOTTOM, 1, 1) self.grid.attach_next_to(self.textBox, self.button7, Gtk.PositionType.TOP, 4, 1) self.add(self.grid)
def __init__(self): self.builder = Gtk.Builder() self.builder.add_from_file("/usr/share/linuxmint/mintdrivers/main.ui") self.builder.connect_signals(self) for o in self.builder.get_objects(): if issubclass(type(o), Gtk.Buildable): name = Gtk.Buildable.get_name(o) setattr(self, name, o) else: print("can not get name for object '%s'" % o) self.window_main.show() self.window_main.set_title(_("Driver Manager")) self.window_main.connect("delete_event", self.quit_application) self.button_driver_revert = Gtk.Button(label=_("Re_vert"), use_underline=True) self.button_driver_revert.connect("clicked", self.on_driver_changes_revert) self.button_driver_apply = Gtk.Button(label=_("_Apply Changes"), use_underline=True) self.button_driver_apply.connect("clicked", self.on_driver_changes_apply) self.button_driver_cancel = Gtk.Button(label=_("_Cancel"), use_underline=True) self.button_driver_cancel.connect("clicked", self.on_driver_changes_cancel) self.button_driver_restart = Gtk.Button(label=_("_Restart..."), use_underline=True) self.button_driver_restart.connect("clicked", self.on_driver_restart_clicked) self.button_driver_revert.set_sensitive(False) self.button_driver_revert.set_visible(True) self.button_driver_apply.set_sensitive(False) self.button_driver_apply.set_visible(True) self.button_driver_cancel.set_visible(False) self.button_driver_restart.set_visible(False) self.box_driver_action.pack_end(self.button_driver_apply, False, False, 0) self.box_driver_action.pack_end(self.button_driver_revert, False, False, 0) self.box_driver_action.pack_end(self.button_driver_restart, False, False, 0) self.box_driver_action.pack_end(self.button_driver_cancel, False, False, 0) self.info_bar.set_no_show_all(True) self.progress_bar = Gtk.ProgressBar() self.box_driver_action.pack_end(self.progress_bar, False, False, 0) self.progress_bar.set_visible(False) self.needs_restart = False self.live_mode = False self.apt_client = client.AptClient() with open('/proc/cmdline') as f: cmdline = f.read() if ((not "boot=casper" in cmdline) and (not "boot=live" in cmdline)): print("Post-install mode detected") self.info_bar_label.set_text( _("Drivers cannot be installed.\nPlease connect to the Internet or insert the Linux Mint installation DVD (or USB stick)." )) self.check_internet_or_live_dvd() self.button_info_bar.connect("clicked", self.check_internet_or_live_dvd) else: print("Live mode detected") self.live_mode = True self.info_bar.hide() self.update_cache()
def __init__(self, title, header='', can_cancel=False, cancel_callback=None, message_area=False, parent=None): """ Specify the title and the current pass header. """ from gi.repository import Gtk self.__mode = ProgressMeter.MODE_FRACTION self.__pbar_max = 100.0 self.__pbar_index = 0.0 self.__old_val = -1 self.__can_cancel = can_cancel self.__cancelled = False if cancel_callback: self.__cancel_callback = cancel_callback else: self.__cancel_callback = self.handle_cancel if has_display(): self.__dialog = Gtk.Dialog() else: self.__dialog = CLIDialog() if self.__can_cancel: self.__dialog.connect('delete_event', self.__cancel_callback) else: self.__dialog.connect('delete_event', self.__warn) self.__dialog.set_title(title) self.__dialog.set_border_width(12) self.__dialog.vbox.set_spacing(10) self.__dialog.vbox.set_border_width(24) self.__dialog.set_size_request(400, 125) if parent: self.__dialog.set_transient_for(parent) self.__dialog.set_modal(True) tlbl = Gtk.Label(label='<span size="larger" weight="bold">%s</span>' % title) tlbl.set_use_markup(True) self.__dialog.vbox.add(tlbl) self.__lbl = Gtk.Label(label=header) self.__lbl.set_use_markup(True) self.__dialog.vbox.add(self.__lbl) self.__pbar = Gtk.ProgressBar() self.__dialog.vbox.add(self.__pbar) if self.__can_cancel: self.__dialog.set_size_request(350, 170) self.__cancel_button = Gtk.Button(stock=Gtk.STOCK_CANCEL) self.__cancel_button.connect('clicked', self.__cancel_callback) self.__dialog.vbox.add(self.__cancel_button) self.message_area = None if message_area: area = Gtk.ScrolledWindow() text = Gtk.TextView() text.set_border_width(6) text.set_editable(False) self.message_area = text area.add_with_viewport(text) area.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.__dialog.vbox.add(area) self.message_area_ok = Gtk.Button(stock=Gtk.STOCK_OK) self.message_area_ok.connect("clicked", self.close) self.message_area_ok.set_sensitive(False) self.__dialog.vbox.pack_start(self.message_area_ok, expand=False, fill=False) self.__dialog.set_size_request(500, 350) self.__dialog.show_all() if header == '': self.__lbl.hide()
def init_plugins_tab(self): logging.debug(">>") #Remove components in vbox - in case of re-detection for child in self.vboxPlugins.get_children(): if isinstance(child, Gtk.Table): self.vboxPlugins.remove(child) pluginList = self.plugins.getPluginsList() logging.debug(pluginList) for plugin in pluginList: #Store plugin details pluginClass = plugin[0] pluginName = plugin[1] pluginDescription = plugin[2] #Build frame with name and description pluginFrame = Gtk.Frame(label="<b>" + pluginName + "</b>") pluginFrameLabel = pluginFrame.get_label_widget() pluginFrameLabel.set_use_markup(True) description = Gtk.Label(label="<small>" + pluginDescription + "</small>") description.set_alignment(0, 0) description.set_use_markup(True) description.set_line_wrap(True) pluginFrame.add(description) #Get plugin information name, description, status = self.plugins.getPluginInfo(pluginClass) #Create labels and buttons configButton = Gtk.Button(label=_("Configure")) #Connect button handlers configButton.connect('clicked', self.on_pluginsButton_Configure_clicked, pluginClass) if status == 0 or status == "0": #Plugin disabled pluginFrame.set_sensitive(0) statusLabel = Gtk.Label(label=_("Disabled")) else: statusLabel = Gtk.Label(label=_("Enabled")) #Create a table for the frame and button pluginTable = Gtk.Table() pluginTable.attach(pluginFrame, 0, 1, 0, 1, xoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, xpadding=5) pluginTable.attach(statusLabel, 1, 2, 0, 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK, xpadding=5, ypadding=5) pluginTable.attach(configButton, 2, 3, 0, 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.SHRINK, xpadding=5, ypadding=5) #Add frame to tab self.vboxPlugins.pack_start(pluginTable, expand=False, fill=False, padding=5) self.win_importdata.show_all() logging.debug("<<") return
def __init__(self, settings): super().__init__() self.set_relative_to(None) self.settings = settings self.export_plain = Gtk.Button( label=_("Text"), action_name="document.export", tooltip_text=_("Export document to plain text file"), relief=Gtk.ReliefStyle.NONE, always_show_image=True, image_position=Gtk.PositionType.TOP) self.export_plain.set_image( Gtk.Image.new_from_resource("/com/github/tenderowl/norka/icons/text.svg")) self.export_markdown = Gtk.Button( label=_("Markdown"), action_name="document.export-markdown", tooltip_markup=Granite.markup_accel_tooltip( ("<Control><Shift>s",), _("Export document to markdown")), relief=Gtk.ReliefStyle.NONE, always_show_image=True, image_position=Gtk.PositionType.TOP) self.export_markdown.set_image( Gtk.Image.new_from_resource("/com/github/tenderowl/norka/icons/text-markdown.svg")) self.export_html = Gtk.Button( _("Html"), action_name="document.export-html", tooltip_text=_("Export document to HTML"), relief=Gtk.ReliefStyle.NONE, always_show_image=True, image_position=Gtk.PositionType.TOP) self.export_html.set_tooltip_text(_("Export document to HTML")) self.export_html.set_image( Gtk.Image.new_from_resource("/com/github/tenderowl/norka/icons/text-html.svg")) self.export_file = Gtk.ModelButton() self.export_file.get_child().destroy() self.export_file.add(Granite.AccelLabel(label=_("Export to file"), accel_string='<Control><Shift>s')) self.export_file.set_action_name("document.export") self.export_medium = Gtk.ModelButton() self.export_medium.get_child().destroy() self.export_medium.add(Granite.AccelLabel(label=_("To Medium"))) self.export_medium.set_action_name("document.export-medium") self.export_writeas = Gtk.ModelButton() self.export_writeas.get_child().destroy() self.export_writeas.add(Granite.AccelLabel(label=_("To Write.as"))) self.export_writeas.set_action_name("document.export-writeas") menu_grid = Gtk.Grid(margin_bottom=3, margin_top=3, orientation=Gtk.Orientation.VERTICAL, width_request=200) menu_grid.attach(Granite.HeaderLabel(_("Files"), margin_left=12, margin_right=12), 0, 0, 3, 1) menu_grid.attach(self.export_plain, 0, 1, 1, 1) menu_grid.attach(self.export_markdown, 1, 1, 1, 1) menu_grid.attach(self.export_html, 2, 1, 1, 1) menu_grid.attach(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL, margin_top=12), 0, 2, 3, 1) menu_grid.attach(Granite.HeaderLabel(_("Internet"), margin_left=12, margin_right=12), 0, 3, 3, 1) menu_grid.attach(self.export_medium, 0, 4, 3, 1) menu_grid.attach(self.export_writeas, 0, 5, 3, 1) self.add(menu_grid) menu_grid.show_all()
def __init__(self): Gtk.Window.__init__(self, title="Hello World") self.button = Gtk.Button(label="Click Here") self.button.connect("clicked", self.on_button_clicked) self.add(self.button)
def make_entrylist(self): self.section_list = Gtk.Notebook() self.section_list.set_tab_pos(Gtk.PositionType.LEFT) self.section_list.set_scrollable(True) for s in self.config: label = Gtk.Label(s['name']) applist = Gtk.VBox() scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled_window.set_size_request(620,-1) self.section_list.append_page(scrolled_window, label) # pour ajouter des applications scrolled_window.drag_dest_set(0, [], 0) scrolled_window.drag_dest_add_text_targets() scrolled_window.drag_dest_add_uri_targets() scrolled_window.connect("drag-data-received", self.on_drag_data_received, s) scrolled_window.connect("drag-drop", self.on_drag_drop) scrolled_window.connect('drag-motion', self.on_drag_motion) # boutons de config hb = Gtk.HBox(False, 10) delbtn = Gtk.Button(label = _("Delete this section")) delbtn.connect_object("clicked", self.del_section, s) addbtn = Gtk.Button(label=_("Search for applications")) addbtn.connect("button_press_event", self.appfinder) hb.pack_start(addbtn, True, True, 0) hb.pack_start(delbtn, True, True, 0) if self.config.index(s) > 0: upbtn = Gtk.Button(label = _("Move section up")) upbtn.connect_object("clicked", self.move_sec, s, -1) hb.pack_start(upbtn, True, True, 0) if self.config.index(s) < len(self.config)-1: downbtn = Gtk.Button(label = _("Move section down")) downbtn.connect_object("clicked", self.move_sec, s, +1) hb.pack_start(downbtn, True, True, 0) applist.pack_start(hb, False,False, 10) dragdrophelp = Gtk.Label(_("To add an application, Drag and drop it below")) applist.pack_start(dragdrophelp, False,False, 2) for a in s['apps']: appname, icon, cmd= a['name'], a['icon'], a['cmd'] image = Gtk.Image() if icon.endswith('.png') or icon.endswith('.jpg'): image.set_from_file(icon) else: image.set_from_icon_name(icon, iconsize) image.set_from_icon_name(icon, Gtk.IconSize.DIALOG) image.set_pixel_size(iconsize) # nom de l'appli bapp = Gtk.Button(label=appname) bapp.set_image(image) #l'image est au dessus du texte bapp.set_image_position(Gtk.PositionType.TOP) # apparence du bouton bapp.set_relief(Gtk.ReliefStyle.NONE) bapp.connect("button_release_event", self.edit_appli, s, a) applist.pack_start(bapp, True, True, 0) scrolled_window.add_with_viewport(applist) # ajout de la possibilité d'ajouter des sections addbox = Gtk.VBox() instruction = Gtk.Label(_("Name of the new section: ")) entry = Gtk.Entry() entry.connect("activate", self.add_new_section) # entrée valide addbox.pack_start(instruction, False, True, 3) addbox.pack_start(entry, False, False, 20) addbtn = Gtk.Button(label = _("More"), stock=Gtk.STOCK_ADD) addbtn.connect_object("clicked", self.add_new_section, entry ) addbox.pack_start(addbtn, False, False, 10) addlabel = Gtk.Image() pixbuf = GdkPixbuf.Pixbuf.new_from_file(os.path.join(handy_icons,"add_section.png")) scaled_buf = pixbuf.scale_simple(24,24,GdkPixbuf.InterpType.BILINEAR) addlabel.set_from_pixbuf(scaled_buf) addlabel.set_tooltip_text(_("Add a section")) self.section_list.append_page(addbox, addlabel) self.mainbox.pack_start(self.section_list, True, True, 0)
def __init__(self,vbox, ccw=None): self.ccw=ccw Gtk.HBox.__init__(self,False,0) self.b = b = Gtk.Button(_("Reset all")) b.connect("clicked", self.reset_cb,vbox) self.pack_end(b,False,False,0)
def __init__(self): Gtk.Window.__init__(self, title='BOMSI GUI (' + BOMSI_GUI_OPSYS + '/' + BOMSI_GUI_RELEASE + ')') self.set_border_width(10) #This is the vertical container vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=30, halign=Gtk.Align.START, valign=Gtk.Align.START) self.add(vbox) #First row with logo, system info and basic checks topbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10) logo_img = Gtk.Image.new_from_file(PWD + '/gui_img/BOMSI_logo_gui.png') topbox.pack_start(logo_img, False, False, 0) #(child,expand=True,fill=True,padding=0) #Box with two rows: sysinfo button/files check and hide/show vars editor vbox_top = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) #Little box for the sysinfo button and the files checker hbox_sys_files = Gtk.Box() button_showinfo = Gtk.Button(label="System Info", halign=Gtk.Align.END) button_showinfo.connect("clicked", self.on_button_clicked_info) hbox_sys_files.pack_start(button_showinfo, False, False, 0) #Check if all the needed BOMSI files are in the PATH_TO_BOMSI directory BOMSI_FILES = [ 'bomsi_lib_conf', 'bomsi_lib_vm', 'bomsi_vars', 'bomsi-iso.sh' ] for bfile in BOMSI_FILES: if not os.path.isfile(PATH_TO_BOMSI + '/' + bfile): text_label_conffile = "<span foreground='red'><big>" + u'\u24e7'.encode( 'utf8' ) + "</big> " + bfile + " file not found at:</span> \n " + PATH_TO_BOMSI try: not text_label_conffile except: text_label_conffile = "<span foreground='green'><big>" + u'\u2713'.encode( 'utf8') + "</big> all BOMSI files detected</span>" BFILES_EXIST = " " label_checkconff = Gtk.Label(halign=Gtk.Align.END) label_checkconff.set_markup(text_label_conffile) hbox_sys_files.pack_start(label_checkconff, False, True, 0) vbox_top.pack_start(hbox_sys_files, False, True, 0) #Notebook with the install variables notebook_vars = Gtk.Notebook() switch_box = Gtk.Box() switch_label = Gtk.Label('Hide BOMSI variables editor: ', halign=Gtk.Align.END) switch_box.pack_start(switch_label, False, False, 0) switch_sysinfo = Gtk.Switch() switch_sysinfo.connect("notify::active", self.notebook_vars_show, notebook_vars) switch_sysinfo.props.valign = Gtk.Align.END switch_box.pack_start(switch_sysinfo, False, False, 0) ## These three lines come from the previus section vbox_top.pack_start(switch_box, True, True, 0) topbox.pack_start(vbox_top, True, True, 0) vbox.pack_start(topbox, True, True, 0) #Function for creating elements on the variables dialog def vars_entry_unit(LABEL, VARIABLE, TTTEXT): grid_li = Gtk.Grid(valign=Gtk.Align.START) vars_li = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10, valign=Gtk.Align.START) vars_li.set_tooltip_text(TTTEXT) label = Gtk.Label(LABEL, halign=Gtk.Align.START) label.set_width_chars(14) label.set_line_wrap(True) vars_li.pack_start(label, False, False, 0) vars_entry = Gtk.Entry() vars_entry.set_width_chars(14) try: VALUE = bomsi_gui_lib.read_bomsi_vars(PATH_TO_BOMSI)[VARIABLE] except: VALUE = '' # If variable not defined in bomsi_vars vars_entry.set_text(VALUE) vars_entry.set_halign(Gtk.Align.END) vars_li.pack_start(vars_entry, False, False, 0) button_save = Gtk.Button(label="<Save", halign=Gtk.Align.END) button_save.connect("clicked", bomsi_gui_lib.edit_bomsi_var, PATH_TO_BOMSI, VARIABLE, vars_entry) vars_li.pack_start(button_save, False, False, 0) #grid_li.attach(label,0,2,0,1) #grid_li.attach(vars_entry,2,4,0,1 ) #grid_li.attach(button_save,4,5,0,1) return vars_li # Main variables table_mainvars = Gtk.Table( 5, 2, True, valign=Gtk.Align.START) #(rows,columns,homogenous, ...) table_mainvars.set_row_spacings(10) table_mainvars.set_col_spacings(10) tooltip = 'Name of the ISO file which will be created\n(in the home directory)\ni.e.:controller.iso' item = vars_entry_unit('ISO name', 'OUT_ISO_NAME_GUI', tooltip) table_mainvars.attach(item, 0, 2, 0, 1) tooltip = 'Disk device in which the\nCentOS is going to\nget installed.\n i.e.: sda (for physical HDs)\nor vda (for virtual HDs' item = vars_entry_unit('Disk name', 'HD', tooltip) table_mainvars.attach(item, 0, 2, 1, 2) tooltip = 'Number of Virtual CPUs\n(for virtual environments).\n i.e.: 2' item = vars_entry_unit('# of VCPUs', 'VCPUS', tooltip) table_mainvars.attach(item, 0, 2, 2, 3) tooltip = 'Amount of RAM memory (in Mb)\n(for virtual environments).\n i.e.: 4092' item = vars_entry_unit('Virt. RAM', 'VRAM', tooltip) table_mainvars.attach(item, 0, 2, 3, 4) tooltip = 'The name of the management\nnetwork (or bridge) for VMs\n (i.e. "network=management" or "bridge=br0")' item = vars_entry_unit('Virt mgm net', 'VIRT_NIC_MAN', tooltip) table_mainvars.attach(item, 0, 2, 4, 5) tooltip = 'Network interface associated to the admin network.\ni.e.: eth0' item = vars_entry_unit('iface admin', 'IFACE0', tooltip) table_mainvars.attach(item, 2, 4, 0, 1) tooltip = 'Network interface associated to the tunnel network\ni.e.:eth1 or eth0.1' item = vars_entry_unit('iface tunnel', 'IFACE1', tooltip) table_mainvars.attach(item, 2, 4, 1, 2) tooltip = 'Network interface associated to the storage network\ni.e.:eth2 or eth0.2' item = vars_entry_unit('iface storage', 'IFACE2', tooltip) table_mainvars.attach(item, 2, 4, 2, 3) tooltip = 'Network interface associated to the external network' item = vars_entry_unit('iface extern', 'IFACE_EXT', tooltip) table_mainvars.attach(item, 2, 4, 3, 5) # tooltip= # item= # table_mainvars.attach(item,0,2,1,2) item = vars_entry_unit( 'ISO name', 'OUT_ISO_NAME_GUI', 'Name of the ISO file which will be created\n(in the home directory)\ni.e.:controller.iso' ) vars_main_hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10) #First column of main variables tab vars_main_hbox_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10, valign=Gtk.Align.START) vars_main_hbox_vbox.pack_start( vars_entry_unit( 'ISO name', 'OUT_ISO_NAME_GUI', 'Name of the ISO file which will be created\n(in the home directory)\ni.e.:controller.iso' ), True, False, 0) vars_main_hbox_vbox.pack_start( vars_entry_unit( 'Disk name', 'HD', 'Disk device in which the\nCentOS is going to\nget installed.\n i.e.: sda' ), True, False, 0) vars_main_hbox_vbox.pack_start( vars_entry_unit( '# of VCPUs', 'VCPUS', 'Number of Virtual CPUs\n(for virtual environments).\n i.e.: 2' ), False, False, 0) vars_main_hbox_vbox.pack_start( vars_entry_unit( 'RAM', 'VRAM', 'Amount of RAM memory (in Mb)\n(for virtual environments).\n i.e.: 4092' ), False, False, 0) vars_main_hbox_vbox.pack_start( vars_entry_unit( 'Virt mgm net', 'VIRT_NIC_MAN', 'The name of the management\nnetwork (or bridge) for VMs\n (i.e. "management" or "br0")' ), False, False, 0) #vars_main_hbox_vbox.pack_start(vars_entry_unit('', '', ''), True, True, 0) vars_main_hbox.pack_start(vars_main_hbox_vbox, False, False, 0) #Second column of passwords variables tab vars_main_hbox_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10, valign=Gtk.Align.START) #vars_main_hbox_vbox.pack_start(vars_entry_unit('Glance', 'GLANCE_PASSWORD','Password for Glance'), True, True, 0) vars_main_hbox.pack_start(vars_main_hbox_vbox, False, False, 0) notebook_vars_main = Gtk.Label(label="Main variables") # Main Passwords vars_pwt_hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10) #First column of password variables tab vars_pwt_hbox_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10, valign=Gtk.Align.START) vars_pwt_hbox_vbox.pack_start( vars_entry_unit('CentOS root', 'ROOT_PASSWORD', 'Root password for login to the machine'), True, True, 0) vars_pwt_hbox_vbox.pack_start( vars_entry_unit('MariaDB admin', 'MYSQL_ROOT', 'Root password for the MySQL/Mariadb database'), True, True, 0) vars_pwt_hbox_vbox.pack_start( vars_entry_unit('Rabbit admin', 'RABBIT_PASS', 'RabbitMQ admin password'), True, True, 0) vars_pwt_hbox_vbox.pack_start( vars_entry_unit('admin user', 'KEYSTONE_ADMIN_PASSWORD', '"OpenStack admin user'), True, True, 0) vars_pwt_hbox_vbox.pack_start( vars_entry_unit('demo user', 'KEYSTONE_DEMO_PASSWORD', '"OpenStack demo user'), True, True, 0) vars_pwt_hbox.pack_start(vars_pwt_hbox_vbox, True, True, 0) #Second column of passwords variables tab vars_pwt_hbox_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10, valign=Gtk.Align.START) vars_pwt_hbox_vbox.pack_start( vars_entry_unit('Glance', 'GLANCE_PASSWORD', 'Password for Glance'), True, True, 0) vars_pwt_hbox_vbox.pack_start( vars_entry_unit('Nova', 'NOVA_PASSWORD', 'Password for Neutron'), True, True, 0) vars_pwt_hbox_vbox.pack_start( vars_entry_unit('Neutron', 'NEUTRON_PASSWORD', 'Password for Nova'), True, True, 0) vars_pwt_hbox.pack_start(vars_pwt_hbox_vbox, True, True, 0) notebook_vars_pwl = Gtk.Label(label="Passwords") vars_ips_hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10) #First column of the Server IPs tab vars_ips_hbox_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10, valign=Gtk.Align.START) #vars_ips_hbox_vbox.pack_start(vars_entry_unit('iface admin', 'IFACE0','Network interface associated to the admin network'), True, True, 0) #vars_ips_hbox_vbox.pack_start(vars_entry_unit('iface tunnel', 'IFACE1','Network interface associated to the tunnel network'), True, True, 0) #vars_ips_hbox_vbox.pack_start(vars_entry_unit('iface storage', 'IFACE2','Network interface associated to the storage network'), True, True, 0) #vars_ips_hbox_vbox.pack_start(vars_entry_unit('iface external', 'IFACE_EXT','Network interface associated to the external network'), True, True, 0) vars_ips_hbox_vbox.pack_start( vars_entry_unit('Controller', 'CONTROLLER_IP', 'IP of the controller server'), True, True, 0) vars_ips_hbox_vbox.pack_start( vars_entry_unit('Network', 'NEUTRON_NODE_IP', 'IP of the network node'), True, True, 0) vars_ips_hbox_vbox.pack_start( vars_entry_unit('Compute', 'COMPUTE_IPS', 'IP of the compute node (1st one)'), True, True, 0) vars_ips_hbox.pack_start(vars_ips_hbox_vbox, True, True, 0) #Second column of the Server IPs tab vars_ips_hbox_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10, valign=Gtk.Align.START) vars_ips_hbox_vbox.pack_start( vars_entry_unit('Prefix admin net', 'IPPR_A', 'Admin network without the last number'), True, True, 0) vars_ips_hbox_vbox.pack_start( vars_entry_unit('Prefix tunnel net', 'IPPR_T', 'Tunnel network without the last number'), True, True, 0) vars_ips_hbox_vbox.pack_start( vars_entry_unit('Prefix stor. net', 'IPPR_S', 'Storage network without the last number'), True, True, 0) vars_ips_hbox_vbox.pack_start( vars_entry_unit('Gateway', 'GATEWAY', 'Default gateway for the management network'), True, True, 0) vars_ips_hbox_vbox.pack_start( vars_entry_unit('DNS server', 'NAMESERVER', 'IP of the DNS server'), True, True, 0) vars_ips_hbox.pack_start(vars_ips_hbox_vbox, True, True, 0) notebook_vars_ipl = Gtk.Label(label="Server IPs") #Pack both tabs in the variables notebook notebook_vars.append_page(table_mainvars, notebook_vars_main) #notebook_vars.append_page(vars_main_hbox, notebook_vars_main) notebook_vars.append_page(vars_pwt_hbox, notebook_vars_pwl) notebook_vars.append_page(vars_ips_hbox, notebook_vars_ipl) #Show the variables notebook in main window vbox.pack_start(notebook_vars, False, True, 0) #Box containing possible options #Download packages vbox_packages = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) label_packages = Gtk.Label() label_packages.set_markup( "Download OS files\n <small>using a VM</small>") logo_packages = Gtk.Image.new_from_file( PWD + '/gui_img/download_packages.png') button_packages = Gtk.Button() button_packages.set_image(logo_packages) button_packages.connect("clicked", bomsi_gui_lib.opt_packages, PATH_TO_BOMSI) vbox_packages.pack_start(label_packages, False, True, 0) vbox_packages.pack_start(button_packages, False, True, 0) #Just create the ISO vbox_iso = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) label_only_iso = Gtk.Label() label_only_iso.set_markup( "Dry run \n <small>Only generate ISO</small>") logo_opt_iso = Gtk.Image.new_from_file(PWD + '/gui_img/cd.png') #label_only_iso_name = Gtk.Label() #label_only_iso_name.set_markup('File name:') #entry_only_iso = Gtk.Entry() try: ISO_LABEL_GUI = bomsi_gui_lib.read_bomsi_vars( PATH_TO_BOMSI)['OUT_ISO_NAME_GUI'] except: ISO_LABEL_GUI = 'BOMSI-multiboot.iso' #entry_only_iso.set_text(ISO_LABEL) button_only_iso = Gtk.Button() button_only_iso.set_image(logo_opt_iso) button_only_iso.connect("clicked", bomsi_gui_lib.opt_only_iso, PATH_TO_BOMSI, ISO_LABEL_GUI) vbox_iso.pack_start(label_only_iso, False, True, 0) vbox_iso.pack_start(button_only_iso, False, True, 0) #vbox_iso.pack_start(label_only_iso_name, False, True, 0) #vbox_iso.pack_start(entry_only_iso, False, True, 0) #Install the ISO on a pendrive vbox_pen = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) label_iso2pen = Gtk.Label() label_iso2pen.set_markup( "Create Pendrive \n<small>with auto-installer</small>") logo_opt_pen = Gtk.Image.new_from_file(PWD + '/gui_img/pen.png') button_iso2pen = Gtk.Button() button_iso2pen.set_image(logo_opt_pen) ERROR_WIN = self.on_error_clicked button_iso2pen.connect("clicked", bomsi_gui_lib.create_pendrive, PATH_TO_BOMSI) #button_iso2pen.connect("clicked",self.on_error_clicked) #If pendrives connected, list them, otherwise raise error diskbox = Gtk.Box(spacing=0) label_usb = Gtk.Label() DISKS = bomsi_gui_lib.get_pendrives() if len(DISKS) == 0: print "Info: no pendrives detected" label_usb.set_markup('No pendrives\ndetected!') label_usb.set_tooltip_text( 'Close the window, connect pendrive \n and run this GUI again.' ) else: label_usb.set_markup('Use disk:') diskbox.pack_start(label_usb, False, False, 0) #List of connected pendrives disklist = Gtk.ComboBoxText() disklist.set_entry_text_column(0) for disk in DISKS: disklist.append_text(disk) disklist.set_entry_text_column(0) disklist.connect("changed", bomsi_gui_lib.set_selected_disk, disklist, PATH_TO_BOMSI) diskbox.pack_start(disklist, False, False, 0) #currency_combo = Gtk.ComboBoxText() #currency_combo.set_entry_text_column(0) #for currency in currencies: # currency_combo.append_text(currency) #print type(disklist), type(label_usb), DISKS vbox_pen.pack_start(label_iso2pen, False, True, 0) vbox_pen.pack_start(button_iso2pen, False, True, 0) vbox_pen.pack_start(label_usb, False, True, 0) vbox_pen.pack_start(diskbox, False, True, 0) #Create KVM machines with the ISO(s) vbox_kvm = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) label_kvm = Gtk.Label() label_kvm.set_markup( "Local KVM \n<small>use local KVM (virsh)</small>") logo_opt_kvm = Gtk.Image.new_from_file(PWD + '/gui_img/kvm.png') label_kvm_name = Gtk.Label() label_kvm_name.set_markup('Install type:') combo_kvm = Gtk.ComboBoxText() combo_kvm.set_entry_text_column(0) combo_kvm.append_text('2_nodes') combo_kvm.append_text('controller') combo_kvm.append_text('network') combo_kvm.append_text('compute1') combo_kvm.append_text('compute2') combo_kvm.append_text('compute3') combo_kvm.connect("changed", bomsi_gui_lib.edit_bomsi_var, PATH_TO_BOMSI, 'INSTALL_TYPE', combo_kvm) button_kvm = Gtk.Button() button_kvm.set_image(logo_opt_kvm) button_kvm.connect("clicked", bomsi_gui_lib.create_local_virt_env, PATH_TO_BOMSI, combo_kvm) vbox_kvm.pack_start(label_kvm, False, False, 0) vbox_kvm.pack_start(button_kvm, False, False, 0) vbox_kvm.pack_start(label_kvm_name, False, False, 0) vbox_kvm.pack_start(combo_kvm, False, False, 0) vbox_rkvm = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) label_rkvm = Gtk.Label() label_rkvm.set_markup("Remote KVM \n<small>remote KVM server</small>") logo_opt_rkvm = Gtk.Image.new_from_file(PWD + '/gui_img/kvm.png') button_rkvm = Gtk.Button() button_rkvm.set_image(logo_opt_rkvm) vbox_rkvm.pack_start(label_rkvm, False, True, 0) vbox_rkvm.pack_start(button_rkvm, False, True, 0) #This is the box with the install options (only iso, pendrive, KVM) row_options = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50, halign=Gtk.Align.CENTER) row_options.pack_start(vbox_packages, False, True, 0) row_options.pack_start(vbox_iso, False, True, 0) row_options.pack_start(vbox_pen, False, True, 0) row_options.pack_start(vbox_kvm, False, True, 0) #row_options.pack_start(vbox_rkvm, False, True, 0) #Add the row with the install options (only iso, pendrive, kvm, ..) vbox.pack_start(row_options, False, True, 0)
def __init_ui(self): # label = Gtk.Label(_("Keyboard shortcuts:")) # label.set_justify(Gtk.Justification.LEFT) # label.set_alignment(0.0, 0.5) # self.pack_start(label, False, True, 4) # shortcuts view self.__shortcut_view = Gtk.TreeView( model = Gtk.ListStore(GObject.TYPE_STRING)) self.__shortcut_view.set_size_request(-1, 100) renderer = Gtk.CellRendererText() column = Gtk.TreeViewColumn(_("Keyboard shortcuts"), renderer, text = 0) self.__shortcut_view.append_column(column) self.__shortcut_view.connect("cursor-changed", self.__shortcut_view_cursor_changed_cb) scrolledwindow = Gtk.ScrolledWindow() scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolledwindow.add(self.__shortcut_view) scrolledwindow.set_shadow_type(Gtk.ShadowType.IN) self.pack_start(scrolledwindow, True, True, 4) # key code hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) label = Gtk.Label(label = _("Key code:")) label.set_justify(Gtk.Justification.LEFT) label.set_alignment(0.0, 0.5) hbox.pack_start(label, False, True, 4) self.__keycode_entry = Gtk.Entry() self.__keycode_entry.connect("notify::text", self.__keycode_entry_notify_cb) hbox.pack_start(self.__keycode_entry, True, True, 4) self.__keycode_button = Gtk.Button(label = "...") self.__keycode_button.connect("clicked", self.__keycode_button_clicked_cb) hbox.pack_start(self.__keycode_button, False, True, 4) self.pack_start(hbox, False, True, 4) # modifiers hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) label = Gtk.Label(label = _("Modifiers:")) label.set_justify(Gtk.Justification.LEFT) label.set_alignment(0.0, 0.5) hbox.pack_start(label, False, True, 4) table = Gtk.Table(n_rows = 4, n_columns = 2) self.__modifier_buttons = [] self.__modifier_buttons.append(("Control", Gtk.CheckButton.new_with_mnemonic("_Control"), Gdk.ModifierType.CONTROL_MASK)) self.__modifier_buttons.append(("Alt", Gtk.CheckButton.new_with_mnemonic("A_lt"), Gdk.ModifierType.MOD1_MASK)) self.__modifier_buttons.append(("Shift", Gtk.CheckButton.new_with_mnemonic("_Shift"), Gdk.ModifierType.SHIFT_MASK)) self.__modifier_buttons.append(("Meta", Gtk.CheckButton.new_with_mnemonic("_Meta"), Gdk.ModifierType.META_MASK)) self.__modifier_buttons.append(("Super", Gtk.CheckButton.new_with_mnemonic("S_uper"), Gdk.ModifierType.SUPER_MASK)) self.__modifier_buttons.append(("Hyper", Gtk.CheckButton.new_with_mnemonic("_Hyper"), Gdk.ModifierType.HYPER_MASK)) # <CapsLock> is not parsed by gtk_accelerator_parse() # FIXME: Need to check if ibus gtk panel can enable <Release>. self.__modifier_buttons.append(("Release", Gtk.CheckButton.new_with_mnemonic("_Release"), Gdk.ModifierType.RELEASE_MASK)) for name, button, mask in self.__modifier_buttons: button.connect("toggled", self.__modifier_button_toggled_cb, name) table.attach(self.__modifier_buttons[0][1], 0, 1, 0, 1) table.attach(self.__modifier_buttons[1][1], 1, 2, 0, 1) table.attach(self.__modifier_buttons[2][1], 2, 3, 0, 1) table.attach(self.__modifier_buttons[3][1], 3, 4, 0, 1) table.attach(self.__modifier_buttons[4][1], 0, 1, 1, 2) table.attach(self.__modifier_buttons[5][1], 1, 2, 1, 2) table.attach(self.__modifier_buttons[6][1], 2, 3, 1, 2) hbox.pack_start(table, True, True, 4) self.pack_start(hbox, False, True, 4) # buttons hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) # add button self.__add_button = Gtk.Button(label = _("_Add"), use_underline = True) self.__add_button.set_sensitive(False) self.__add_button.connect("clicked", self.__add_button_clicked_cb) hbox.pack_start(self.__add_button, False, True, 0) # apply button self.__apply_button = Gtk.Button(label = _("_Apply"), use_underline = True) self.__apply_button.set_sensitive(False) self.__apply_button.connect("clicked", self.__apply_button_clicked_cb) hbox.pack_start(self.__apply_button, False, True, 0) # delete button self.__delete_button = Gtk.Button(label = _("_Delete"), use_underline = True) self.__delete_button.set_sensitive(False) self.__delete_button.connect("clicked", self.__delete_button_clicked_cb) hbox.pack_start(self.__delete_button, False, True, 0) self.pack_start(hbox, False, True, 4)
def __init__(self, app): super().__init__(orientation=Gtk.Orientation.VERTICAL) self.app = app if Config.GTK_GE_312: self.headerbar = Gtk.HeaderBar() self.headerbar.props.show_close_button = True self.headerbar.props.has_subtitle = False self.headerbar.set_title(self.disname) restore_button = Gtk.Button() restore_img = Gtk.Image.new_from_icon_name('edit-undo-symbolic', Gtk.IconSize.SMALL_TOOLBAR) restore_button.set_image(restore_img) restore_button.set_tooltip_text(_('Restore')) restore_button.connect('clicked', self.on_restore_button_clicked) self.headerbar.pack_start(restore_button) # remove box right_box = Gtk.Box() right_box_context = right_box.get_style_context() right_box_context.add_class(Gtk.STYLE_CLASS_RAISED) right_box_context.add_class(Gtk.STYLE_CLASS_LINKED) self.headerbar.pack_end(right_box) delete_button = Gtk.Button() delete_img = Gtk.Image.new_from_icon_name('list-remove-symbolic', Gtk.IconSize.SMALL_TOOLBAR) delete_button.set_image(delete_img) delete_button.set_tooltip_text(_('Remove')) delete_button.set_tooltip_text( _('Delete selected files in trash permanently')) delete_button.connect('clicked', self.on_delete_button_clicked) right_box.pack_start(delete_button, False, False, 0) clear_button = Gtk.Button() clear_img = Gtk.Image.new_from_icon_name('list-remove-all-symbolic', Gtk.IconSize.SMALL_TOOLBAR) clear_button.set_image(clear_img) clear_button.set_tooltip_text(_('Clear trash')) clear_button.connect('clicked', self.on_clear_button_clicked) right_box.pack_start(clear_button, False, False, 0) reload_button = Gtk.Button() reload_img = Gtk.Image.new_from_icon_name('view-refresh-symbolic', Gtk.IconSize.SMALL_TOOLBAR) reload_button.set_image(reload_img) reload_button.set_tooltip_text(_('Reload')) reload_button.connect('clicked', self.on_reload_button_clicked) self.headerbar.pack_end(reload_button) # show loading process self.loading_spin = Gtk.Spinner() self.headerbar.pack_end(self.loading_spin) else: control_box = Gtk.Box(spacing=0) control_box.props.margin_bottom = 10 self.pack_start(control_box, False, False, 0) restore_button = Gtk.Button.new_with_label(_('Restore')) restore_button.connect('clicked', self.on_restore_button_clicked) control_box.pack_start(restore_button, False, False, 0) reload_button = Gtk.Button.new_with_label(_('Reload')) reload_button.connect('clicked', self.on_reload_button_clicked) control_box.pack_start(reload_button, False, False, 0) clear_button = Gtk.Button.new_with_label(_('Clear Trash')) clear_button.set_tooltip_text(_('Clear trash')) clear_button.connect('clicked', self.on_clear_button_clicked) control_box.pack_end(clear_button, False, False, 0) delete_button = Gtk.Button.new_with_label(_('Delete')) delete_button.set_tooltip_text( _('Delete selected files permanently')) delete_button.connect('clicked', self.on_delete_button_clicked) control_box.pack_end(delete_button, False, False, 0) # show loading process self.loading_spin = Gtk.Spinner() self.loading_spin.props.margin_right = 5 control_box.pack_end(self.loading_spin, False, False, 0) scrolled_win = Gtk.ScrolledWindow() self.pack_start(scrolled_win, True, True, 0) # icon name, disname, path, fs_id, tooltip, # size, humansize, deleting time, remaining days self.liststore = Gtk.ListStore(str, str, str, str, str, GObject.TYPE_INT64, str, str, str) self.treeview = Gtk.TreeView(model=self.liststore) selection = self.treeview.get_selection() selection.set_mode(Gtk.SelectionMode.MULTIPLE) self.treeview.set_rubber_banding(True) self.treeview.set_tooltip_column(PATH_COL) self.treeview.set_headers_clickable(True) self.treeview.set_reorderable(True) self.treeview.set_search_column(NAME_COL) scrolled_win.add(self.treeview) icon_cell = Gtk.CellRendererPixbuf() name_cell = Gtk.CellRendererText(ellipsize=Pango.EllipsizeMode.END, ellipsize_set=True) name_col = Gtk.TreeViewColumn() name_col.set_title(_('Name')) name_col.pack_start(icon_cell, False) name_col.pack_start(name_cell, True) if Config.GTK_LE_36: name_col.add_attribute(icon_cell, 'icon_name', ICON_COL) name_col.add_attribute(name_cell, 'text', NAME_COL) else: name_col.set_attributes(icon_cell, icon_name=ICON_COL) name_col.set_attributes(name_cell, text=NAME_COL) name_col.set_expand(True) self.treeview.append_column(name_col) name_col.set_sort_column_id(NAME_COL) self.liststore.set_sort_func(NAME_COL, gutil.tree_model_natsort) size_cell = Gtk.CellRendererText() size_col = Gtk.TreeViewColumn(_('Size'), size_cell, text=HUMANSIZE_COL) self.treeview.append_column(size_col) size_col.set_sort_column_id(SIZE_COL) time_cell = Gtk.CellRendererText() time_col = Gtk.TreeViewColumn(_('Time'), time_cell, text=DELETING_COL) self.treeview.append_column(time_col) time_col.set_sort_column_id(DELETING_COL) remaining_cell = Gtk.CellRendererText() remaining_col = Gtk.TreeViewColumn(_('Remaining'), remaining_cell, text=REMAINING_COL) self.treeview.append_column(remaining_col) remaining_col.set_sort_column_id(REMAINING_COL)
def __init__(self, parent, vmManageBox): super(ConnectionBox, self).__init__() self.connect('destroy', self.catchClosing) logging.debug("Creating ConnectionBox") self.parent = parent self.vmManageBox = vmManageBox self.set_selection_mode(Gtk.SelectionMode.NONE) self.set_border_width(10) self.row = Gtk.ListBoxRow() self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) self.row.add(self.hbox) self.connectionBoxDescLabel = Gtk.Label(xalign=0) self.connectionBoxDescLabel.set_markup("<b>CIT Connection</b>") self.hbox.pack_start(self.connectionBoxDescLabel, True, True, 0) self.add(self.row) self.row = Gtk.ListBoxRow() self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) self.row.add(self.hbox) self.connStatusDescLabel = Gtk.Label("Connection Status: ", xalign=0) self.hbox.pack_start(self.connStatusDescLabel, True, True, 0) self.connStatusLabel = Gtk.Label(" Disconnected ", xalign=0) self.connEventBox = Gtk.EventBox() self.connEventBox.add(self.connStatusLabel) self.connEventBox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(1, 0, 0, .5)) self.hbox.pack_start(self.connEventBox, False, True, 0) self.connectionButton = Gtk.Button("Connect") self.connectionButton.connect("clicked", self.changeConnState) self.connectionButton.props.valign = Gtk.Align.CENTER self.hbox.pack_start(self.connectionButton, False, True, 0) self.add(self.row) self.vmManageBox.set_sensitive(False) self.row = Gtk.ListBoxRow() self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) self.row.add(self.hbox) self.label = Gtk.Label("Automatic Reconnect", xalign=0) self.check = Gtk.CheckButton() # disable for now self.check.set_sensitive(False) self.hbox.pack_start(self.label, True, True, 0) self.hbox.pack_start(self.check, False, True, 0) self.add(self.row) self.row = Gtk.ListBoxRow() self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) self.row.add(self.hbox) self.citConnectionLabel = Gtk.Label(xalign=0) self.citConnectionLabel.set_markup("Choose Connection Type: ") self.hbox.pack_start(self.citConnectionLabel, True, True, 0) connection_store = Gtk.ListStore(str) connections = ["PPTP", "L2TP"] for connection in connections: connection_store.append([connection]) self.connection_combo = Gtk.ComboBox.new_with_model(connection_store) self.connection_combo.connect("changed", self.on_connection_combo_changed) self.renderer_text = Gtk.CellRendererText() self.connection_combo.pack_start(self.renderer_text, True) self.connection_combo.add_attribute(self.renderer_text, "text", 0) self.hbox.pack_start(self.connection_combo, False, False, 0) self.add(self.row) self.row = Gtk.ListBoxRow() self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) self.row.add(self.hbox) self.citLauchLabel = Gtk.Label(xalign=0) self.citLauchLabel.set_markup("Open CIT with default browser: ") self.hbox.pack_start(self.citLauchLabel, True, True, 0) self.citLaunchButton = Gtk.Button("Launch CIT") self.citLaunchButton.connect("clicked", self.openCITTab) self.citLaunchButton.props.valign = Gtk.Align.CENTER self.hbox.pack_start(self.citLaunchButton, False, True, 0) self.add(self.row) self.citLauchLabel.set_sensitive(False) self.citLaunchButton.set_sensitive(False) self.row = Gtk.ListBoxRow() self.hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=50) self.row.add(self.hbox) self.add(self.row) self.status = -1 # self.QUIT_SIGNAL = False self.QUIT_SIGNAL = threading.Event() self.t = threading.Thread(target=self.watchStatus, args=(self.QUIT_SIGNAL, )) self.t.start()
def add_settings_page(self, section_id): """Adds a page for the preferences in the specified section.""" options = self.prefs[section_id] grid = Gtk.Grid() grid.set_border_width(SPACING) grid.props.column_spacing = SPACING grid.props.row_spacing = SPACING / 2 prefs = [] for attrname in options: label, description, widget_class, args = options[attrname] widget = widget_class(**args) widget.setWidgetValue(getattr(self.settings, attrname)) widget.connectValueChanged(self._valueChangedCb, widget, attrname) widget.set_tooltip_text(description) self.widgets[attrname] = widget # Add a semicolon, except for checkbuttons. if isinstance(widget, widgets.ToggleWidget): widget.set_label(label) label_widget = None else: # Translators: This adds a semicolon to an already # translated name of a preference. label = _("%(preference_label)s:") % { "preference_label": label } label_widget = Gtk.Label(label=label) label_widget.set_tooltip_text(description) label_widget.set_alignment(1.0, 0.5) label_widget.show() icon = Gtk.Image() icon.set_from_icon_name("edit-clear-all-symbolic", Gtk.IconSize.MENU) revert = Gtk.Button() revert.add(icon) revert.set_tooltip_text(_("Reset to default value")) revert.set_relief(Gtk.ReliefStyle.NONE) revert.set_sensitive(not self.settings.isDefault(attrname)) revert.connect("clicked", self._resetOptionCb, attrname) revert.show_all() self.resets[attrname] = revert row_widgets = (label_widget, widget, revert) # Construct the prefs list so that it can be sorted. # Make sure the L{ToggleWidget}s appear at the end. prefs.append((label_widget is None, label, row_widgets)) # Sort widgets: I think we only want to sort by the non-localized # names, so options appear in the same place across locales ... # but then I may be wrong for y, (_1, _2, row_widgets) in enumerate(sorted(prefs)): label, widget, revert = row_widgets if not label: grid.attach(widget, 0, y, 2, 1) grid.attach(revert, 2, y, 1, 1) else: grid.attach(label, 0, y, 1, 1) grid.attach(widget, 1, y, 1, 1) grid.attach(revert, 2, y, 1, 1) widget.show() revert.show() grid.show() self._add_page(section_id, grid)
def __init__(self, cameraSource=None): Gtk.Window.__init__(self, title="Povray Viewer") self.connect("delete-event", Gtk.main_quit) self.show_all() # the camera and the image if cameraSource is None: camera = Camera() camera.quality = 9 Camera.showImage = False # When povray computes the image,does not pop-up camera.location = origin - 3 * Y + 2 * Z camera.imageHeight = 500 # in pixels #camera.imageWidth=500 #camera.zoom(1) tmpFile = "/tmp/viewer" camera.file = tmpFile + ".pov" camera.imageFile = tmpFile + ".png" camera.lookAt = origin else: camera = cameraSource (root, ext) = os.path.splitext(camera.file) camera.imageFile = root + ".png" self.camera = camera self.camera.pov_to_png() self.image = Gtk.Image() self.image.set_from_file(camera.imageFile) # The button containing the image grid = Gtk.Grid() self.add(grid) button1 = Gtk.Button() button1.add(self.image) grid.attach(button1, 0, 0, 1, 10) self.buttonInfo = Gtk.Label() self.buttonInfo.set_selectable(True) grid.attach(self.buttonInfo, 1, 9, 3, 1) # Radio buttons widgetList = [["buttonMenu1", "zoom", self.zoom_image], ["buttonMenu2", "HorizontalRotate", self.hrotate], ["buttonMenu3", "VerticalRotate", self.vrotate], ["buttonMenu4", "MoveEyeHorizontally", self.hlook_at], ["buttonMenu5", "MoveEyeVertically", self.vlook_at], ["buttonMenu6", "MoveForward", self.move_forward], ["buttonMenu7", "ParallelViews", self.view_from]] i = 0 for w in widgetList: if i == 0: reference = None else: reference = getattr(self, widgetList[0][0]) button = Gtk.RadioButton(group=reference, label=w[1]) button.connect("toggled", self.update_buttons, w[2], w[1]) grid.attach(button, 2, i, 1, 1) button.show() setattr(self, w[0], button) i = i + 1 # Buttons which perform action widgetList = [["buttonIntensity1", -4], ["buttonIntensity2", -3], ["buttonIntensity3", -2], ["buttonIntensity4", -1], ["buttonIntensity5", 1], ["buttonIntensity6", 2], ["buttonIntensity7", 3], ["buttonIntensity8", 4]] for w in widgetList: button = Gtk.Button(label=w[1]) setattr(self, w[0], button) grid.attach(button, 3, w[1] + 4, 1, 1) self.update_buttons(None, self.zoom_image, "zoom") grid.show() self.show_all() self.show_camera_info() Gtk.main()