Python GUI Development with GTK+ 3 - Tutorial 6 - ListBox

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Hey guys. Whoever is trying out this tutorial right now might be getting a message saying that calling the args directly in the init is deprecated. Here is the code with a bit more of the things I found that I had to add:

import gi

gi.require_version("Gtk", "3.0")


from gi.repository import Gtk


class MainWindow(Gtk.Window):


def __init__(self):

# Gtk.Window.__init__(self, title="Cheeseburger Machine")

Gtk.Window.__init__(self)

self.set_title("Cheeseburger Machine")

self.set_border_width(10)

listbox = Gtk.ListBox()



self.add(listbox)



# Checkbox

row_1 = Gtk.ListBoxRow()

# box_1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=100)

box_1 =

box_1.set_spacing(100)

row_1.add(box_1)

# label = Gtk.Label("Check if you love cheeseburgers:")

label = Gtk.Label()

label.set_text("Check if you love cheeseburgers:")

check = Gtk.CheckButton()

box_1.pack_start(label, True, True, 0)

box_1.pack_start(check, True, True, 0)

listbox.add(row_1)


# Toggle Switch

row_2 = Gtk.ListBoxRow()

# box_2 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, SPACING=100)

box_2 =

box_2.set_spacing(100)

row_2.add(box_2)

# label2 = Gtk.Label("Burger making machine:")

label2 = Gtk.Label()

label2.set_text("Burger making machine:")

switch = Gtk.Switch()

box_2.pack_start(label2, True, True, 0)

box_2.pack_start(switch, True, True, 0)

listbox.add(row_2)


window = MainWindow()

window.connect("delete-event", Gtk.main_quit)

window.show_all()

Gtk.main()



I just went around the source code and the docs to find what was the bug. Don't know that much about gtk

rumplstiltztinkerstein
Автор

What's the difference between the ListBox and the ordinary Box with vertical arrangement?

bonbonpony
Автор

4:27 " ... can't type a one letter " and goes with six keystrokes instead. That's the spirit. ;p

bibekgautam
Автор

What better and simpler for use - Grid Layout or ListBox?

acerlmt
Автор

what's that true true 0 means you did n't tell us

flow
Автор

Yeah it would probably be pretty ridiculous have a login on your cheeseburger machine.

nateedwards