Fix GTK deprecation warnings in tutorials
James Cameron
4 years ago
13 | 13 | def button_cb(widget): |
14 | 14 | print('click') |
15 | 15 | |
16 | button = Gtk.Button('Button') | |
16 | button = Gtk.Button(label='Button') | |
17 | 17 | fixed = Gtk.Fixed() |
18 | 18 | fixed.put(button, 20, 30) |
19 | 19 | button.connect('clicked', button_cb) |
14 | 14 | grid.set_column_homogeneous(True) |
15 | 15 | grid.set_row_homogeneous(True) |
16 | 16 | |
17 | button = Gtk.Button('Button 1') | |
17 | button = Gtk.Button(label='Button 1') | |
18 | 18 | grid.attach(button, 0, 0, 1, 1) |
19 | 19 | |
20 | button = Gtk.Button('Button 2') | |
20 | button = Gtk.Button(label='Button 2') | |
21 | 21 | grid.attach(button, 0, 2, 1, 2) |
22 | 22 | |
23 | button = Gtk.Button('Button 3') | |
23 | button = Gtk.Button(label='Button 3') | |
24 | 24 | grid.attach(button, 1, 1, 2, 2) |
25 | 25 | |
26 | button = Gtk.Button('Button 4') | |
26 | button = Gtk.Button(label='Button 4') | |
27 | 27 | grid.attach(button, 2, 0, 2, 1) |
28 | 28 | |
29 | button = Gtk.Button('Button 5') | |
29 | button = Gtk.Button(label='Button 5') | |
30 | 30 | grid.attach(button, 3, 3, 3, 3) |
31 | 31 | |
32 | 32 | self.add(grid) |
16 | 16 | scrolled.add(vbox) |
17 | 17 | |
18 | 18 | for x in range(1, 16): |
19 | boton = Gtk.Button('Button %d' % x) | |
19 | boton = Gtk.Button(label='Button %d' % x) | |
20 | 20 | vbox.pack_start(boton, False, False, 1) |
21 | 21 | |
22 | 22 | self.add(scrolled) |
23 | 23 | box = Gtk.HBox() |
24 | 24 | textview.add_child_at_anchor(box, anchor) |
25 | 25 | |
26 | button = Gtk.Button('Click me') | |
26 | button = Gtk.Button(label='Click me') | |
27 | 27 | button.connect('clicked', self._clicked_cb, textbuffer) |
28 | 28 | box.pack_start(button, False, False, 0) |
29 | 29 |
18 | 18 | menubar = Gtk.MenuBar() |
19 | 19 | vbox.pack_start(menubar, False, False, 0) |
20 | 20 | |
21 | self.label = Gtk.Label('Activate a menu item') | |
21 | self.label = Gtk.Label(label='Activate a menu item') | |
22 | 22 | vbox.pack_start(self.label, True, True, 0) |
23 | 23 | |
24 | 24 | menu_file = Gtk.Menu() |
102 | 102 | menu_edit.append(separator) |
103 | 103 | |
104 | 104 | label = 'Vertical page' |
105 | item_vertical = Gtk.RadioMenuItem(label) | |
105 | item_vertical = Gtk.RadioMenuItem(label=label) | |
106 | 106 | item_vertical.set_active(True) |
107 | 107 | item_vertical.connect('toggled', self._toggled_cb, label) |
108 | 108 | menu_edit.append(item_vertical) |
126 | 126 | |
127 | 127 | menu_help = Gtk.Menu() |
128 | 128 | |
129 | item_help = Gtk.MenuItem('Ayuda') | |
129 | item_help = Gtk.MenuItem(label='Ayuda') | |
130 | 130 | item_help.set_submenu(menu_help) |
131 | 131 | menubar.append(item_help) |
132 | 132 |
22 | 22 | self.bar1.set_vexpand(True) |
23 | 23 | grid.attach(self.bar1, 1, 0, 3, 1) |
24 | 24 | |
25 | label = Gtk.Label("Una barra de progreso simple") | |
25 | label = Gtk.Label(label="Una barra de progreso simple") | |
26 | 26 | label.set_hexpand(True) |
27 | 27 | grid.attach(label, 1, 1, 1, 1) |
28 | 28 | |
31 | 31 | self.bar2.set_vexpand(True) |
32 | 32 | grid.attach(self.bar2, 1, 2, 3, 1) |
33 | 33 | |
34 | label = Gtk.Label("Una barra de progreso con pulsos") | |
34 | label = Gtk.Label(label="Una barra de progreso con pulsos") | |
35 | 35 | grid.attach(label, 1, 3, 1, 1) |
36 | 36 | |
37 | 37 | GObject.timeout_add(200, self._update) |
34 | 34 | palette_box = Gtk.VBox() |
35 | 35 | palette.set_content(palette_box) |
36 | 36 | |
37 | checkbutton1 = Gtk.CheckButton('Option 1') | |
37 | checkbutton1 = Gtk.CheckButton(label='Option 1') | |
38 | 38 | palette_box.pack_start(checkbutton1, False, False, 0) |
39 | 39 | |
40 | checkbutton2 = Gtk.CheckButton('Option 2') | |
40 | checkbutton2 = Gtk.CheckButton(label='Option 2') | |
41 | 41 | palette_box.pack_start(checkbutton2, False, False, 0) |
42 | 42 | |
43 | checkbutton3 = Gtk.CheckButton('Option 3') | |
43 | checkbutton3 = Gtk.CheckButton(label='Option 3') | |
44 | 44 | palette_box.pack_start(checkbutton3, False, False, 0) |
45 | 45 | |
46 | 46 | separator = Gtk.VSeparator() |
47 | 47 | palette_box.pack_start(separator, False, False, 0) |
48 | 48 | |
49 | radio_button1 = Gtk.RadioButton('Option 1') | |
49 | radio_button1 = Gtk.RadioButton(label='Option 1') | |
50 | 50 | palette_box.pack_start(radio_button1, False, False, 0) |
51 | 51 | |
52 | radio_button2 = Gtk.RadioButton('Option 2', group=radio_button1) | |
52 | radio_button2 = Gtk.RadioButton(label='Option 2', group=radio_button1) | |
53 | 53 | palette_box.pack_start(radio_button2, False, False, 0) |
54 | 54 | |
55 | radio_button3 = Gtk.RadioButton('Option 3', group=radio_button1) | |
55 | radio_button3 = Gtk.RadioButton(label='Option 3', group=radio_button1) | |
56 | 56 | palette_box.pack_start(radio_button3, False, False, 0) |
57 | 57 | |
58 | 58 | palette_box.show_all() |
12 | 12 | def button_cb(widget): |
13 | 13 | print('click') |
14 | 14 | |
15 | button = Gtk.Button("Boton") | |
15 | button = Gtk.Button(label="Boton") | |
16 | 16 | fixed = Gtk.Fixed() |
17 | 17 | fixed.put(button, 20, 30) |
18 | 18 | button.connect('clicked', button_cb) |
14 | 14 | grid.set_column_homogeneous(True) |
15 | 15 | grid.set_row_homogeneous(True) |
16 | 16 | |
17 | button = Gtk.Button('Boton 1') | |
17 | button = Gtk.Button(label='Boton 1') | |
18 | 18 | grid.attach(button, 0, 0, 1, 1) |
19 | 19 | |
20 | button = Gtk.Button('Boton 2') | |
20 | button = Gtk.Button(label='Boton 2') | |
21 | 21 | grid.attach(button, 0, 2, 1, 2) |
22 | 22 | |
23 | button = Gtk.Button('Boton 3') | |
23 | button = Gtk.Button(label='Boton 3') | |
24 | 24 | grid.attach(button, 1, 1, 2, 2) |
25 | 25 | |
26 | button = Gtk.Button('Boton 4') | |
26 | button = Gtk.Button(label='Boton 4') | |
27 | 27 | grid.attach(button, 2, 0, 2, 1) |
28 | 28 | |
29 | button = Gtk.Button('Boton 5') | |
29 | button = Gtk.Button(label='Boton 5') | |
30 | 30 | grid.attach(button, 3, 3, 3, 3) |
31 | 31 | |
32 | 32 | self.add(grid) |
16 | 16 | scrolled.add(vbox) |
17 | 17 | |
18 | 18 | for x in range(1, 16): |
19 | boton = Gtk.Button('Boton %d' % x) | |
19 | boton = Gtk.Button(label='Boton %d' % x) | |
20 | 20 | vbox.pack_start(boton, False, False, 1) |
21 | 21 | |
22 | 22 | self.add(scrolled) |
23 | 23 | box = Gtk.HBox() |
24 | 24 | textview.add_child_at_anchor(box, anchor) |
25 | 25 | |
26 | button = Gtk.Button('Haz click en mi') | |
26 | button = Gtk.Button(label='Haz click en mi') | |
27 | 27 | button.connect('clicked', self._clicked_cb, textbuffer) |
28 | 28 | box.pack_start(button, False, False, 0) |
29 | 29 |
18 | 18 | menubar = Gtk.MenuBar() |
19 | 19 | vbox.pack_start(menubar, False, False, 0) |
20 | 20 | |
21 | self.label = Gtk.Label('Activa un item del menu') | |
21 | self.label = Gtk.Label(label='Activa un item del menu') | |
22 | 22 | vbox.pack_start(self.label, True, True, 0) |
23 | 23 | |
24 | 24 | menu_file = Gtk.Menu() |
102 | 102 | menu_edit.append(separator) |
103 | 103 | |
104 | 104 | label = 'Pagina vertical' |
105 | item_vertical = Gtk.RadioMenuItem(label) | |
105 | item_vertical = Gtk.RadioMenuItem(label=label) | |
106 | 106 | item_vertical.set_active(True) |
107 | 107 | item_vertical.connect('toggled', self._toggled_cb, label) |
108 | 108 | menu_edit.append(item_vertical) |
126 | 126 | |
127 | 127 | menu_help = Gtk.Menu() |
128 | 128 | |
129 | item_help = Gtk.MenuItem('Ayuda') | |
129 | item_help = Gtk.MenuItem(label='Ayuda') | |
130 | 130 | item_help.set_submenu(menu_help) |
131 | 131 | menubar.append(item_help) |
132 | 132 |
22 | 22 | self.bar1.set_vexpand(True) |
23 | 23 | grid.attach(self.bar1, 1, 0, 3, 1) |
24 | 24 | |
25 | label = Gtk.Label('Una barra de progreso simple') | |
25 | label = Gtk.Label(label='Una barra de progreso simple') | |
26 | 26 | label.set_hexpand(True) |
27 | 27 | grid.attach(label, 1, 1, 1, 1) |
28 | 28 | |
31 | 31 | self.bar2.set_vexpand(True) |
32 | 32 | grid.attach(self.bar2, 1, 2, 3, 1) |
33 | 33 | |
34 | label = Gtk.Label('Una barra de progreso con pulsos') | |
34 | label = Gtk.Label(label='Una barra de progreso con pulsos') | |
35 | 35 | grid.attach(label, 1, 3, 1, 1) |
36 | 36 | |
37 | 37 | GObject.timeout_add(200, self._update) |
34 | 34 | palette_box = Gtk.VBox() |
35 | 35 | palette.set_content(palette_box) |
36 | 36 | |
37 | checkbutton1 = Gtk.CheckButton('Opcion 1') | |
37 | checkbutton1 = Gtk.CheckButton(label='Opcion 1') | |
38 | 38 | palette_box.pack_start(checkbutton1, False, False, 0) |
39 | 39 | |
40 | checkbutton2 = Gtk.CheckButton('Opcion 2') | |
40 | checkbutton2 = Gtk.CheckButton(label='Opcion 2') | |
41 | 41 | palette_box.pack_start(checkbutton2, False, False, 0) |
42 | 42 | |
43 | checkbutton3 = Gtk.CheckButton('Opcion 3') | |
43 | checkbutton3 = Gtk.CheckButton(label='Opcion 3') | |
44 | 44 | palette_box.pack_start(checkbutton3, False, False, 0) |
45 | 45 | |
46 | 46 | separator = Gtk.VSeparator() |
47 | 47 | palette_box.pack_start(separator, False, False, 0) |
48 | 48 | |
49 | radio_button1 = Gtk.RadioButton("Opcion 1") | |
49 | radio_button1 = Gtk.RadioButton(label="Opcion 1") | |
50 | 50 | palette_box.pack_start(radio_button1, False, False, 0) |
51 | 51 | |
52 | radio_button2 = Gtk.RadioButton("Opcion 2", group=radio_button1) | |
52 | radio_button2 = Gtk.RadioButton(label="Opcion 2", group=radio_button1) | |
53 | 53 | palette_box.pack_start(radio_button2, False, False, 0) |
54 | 54 | |
55 | radio_button3 = Gtk.RadioButton("Opcion 3", group=radio_button1) | |
55 | radio_button3 = Gtk.RadioButton(label="Opcion 3", group=radio_button1) | |
56 | 56 | palette_box.pack_start(radio_button3, False, False, 0) |
57 | 57 | |
58 | 58 | palette_box.show_all() |
141 | 141 | entry = {"name": _(_file.capitalize()), |
142 | 142 | "path": os.path.join(path, _file)} |
143 | 143 | |
144 | button = Gtk.Button(entry['name']) | |
144 | button = Gtk.Button(label=entry['name']) | |
145 | 145 | button.set_tooltip_text(entry['path']) |
146 | 146 | button.set_has_tooltip(False) |
147 | 147 | button.connect('clicked', self._destroy, True) |